Store and display links with each tiddler

Hello,

Almost all of my tiddlers have a list of external links at the bottom that relate to the tiddler. So, every time I create a tiddler, I write “See also:” followed by a list of external links.

My questions are:

  • I’d like to devise a method for conveniently entering those links if appropriate
  • I would like a consistent way of displaying them

What’s the best practice for something like that?

Thanks!
S

Welcome @Surge to TiddlyWiki forum.

Have a look at Mehregan and TZK editions of TiddlyWiki.
Also Stroll, TiddlyStudy and TiddlyResearch!

All Show nodes!

One other solution is Node Explorer in Shiraz.

Yes, Welcome @Surge

One approach is to save links in fields, then create a view template to scan the current tiddlers fields and when finding fields who’s content begins http:// or https:// generate the external link. Using the field name as the link name.

  • I started work on a method to drop links on a tiddler, to create “link-n” fields you can then rename eg discussion. It looked great but had a little unpredictable behaviour, thus I have not published it.

Sorry for the late reply, I’d be interested in having even that partially usable code.

@Surge to whom are you replying?

  • Use the reply on another reply, to link back to it
  • Rather than the reply at the bottom, which replies only to the whole thread.

[Edited] Talk.tiddlywiki no longer shows this if you reply to the last one?

Here I reply to my own previous reply, see top right of this text.

I clicked on “View Topic” in the email and went from there. How is this?

I don’t use the email, only the interactive environment, but how did you reply?, from inside the email, or on the forum?. You may have done the correct thing and there is a change in talk.tiddlywiki

  • To get around this try an @ mention - like I do here @Surge

Were you replying to me?

@TW_Tones , sorry for the confusion. I was using the email (didn’t know about the issue). And yes, I was replying to you :slight_smile:

1 Like

@Surge I looked around for a “complete” solution for this and I have a few in different states of development, each using one or more personal innovations.

However it seems they are all incomplete in one way or another.

  • Hopefully I can return with a finished package soon but here is a code snipit you can start with. Place in a tiddler tagged $:/tags/ViewTemplate
<$list filter="[all[current]fields[]sort[]]" variable=currentField>
   <$list filter="[all[current]get<currentField>prefix[http]]" variable=http-address counter=item>
       <$list filter="[<item>match[1]]"><$link to="$:/PSaT/auto-protocol/viewTemplate">{{$:/core/images/globe}}</$link></$list>
       <a href=<<http-address>> target="_blank"><$text text={{{ [<currentField>sentencecase[]] }}}/></a> 
   </$list>
   <$list filter="[all[current]get<currentField>prefix[file://]]" variable=file-address counter=item>
       <$list filter="[<item>match[1]]"><$link to="$:/PSaT/auto-protocol/viewTemplate">{{$:/core/images/folder}}</$link></$list>
       <a href=<<file-address>> target="_blank"><$text text={{{ [<currentField>sentencecase[]] }}}/></a> 
   </$list>
</$list>
  • It will generate a link for any fieldname containing a value prefixed http/https and file
1 Like

@TW_Tones Thank you much. It will give me a good start. There’s a lot there to grok.

1 Like

If you put your links in a field called “links” just put this in a tiddler tagged $:/tags/ViewTemplate

<$list filter="[all[current]has:field[links]]">

See Also : {{!!links}}

</$list>

So I’ve settled on this:

<$list filter="[<currentTiddler>has[links]]">
References:
<ul>
<$list filter="[enlist{!!links}]" variable="link">
<li><<link>></li>
</$list>
</ul>
</$list>

This will output each link as a bulleted item. There’s only one problem, if the link is of the format [[title|actual link]], the result is not rendered correctly (the [[) are eaten somewhere in the process as described in the docs on the enslist operator:

Literal filter operands cannot contain square brackets but you can work around the issue by using a variable. Learn more at: SetWidget documentation under the heading “Filtered List Variable Assignment”

However I can’t understand how to modify my code to fix that.

@TW_Tones , do you by chance know?

Try replacing this:

<li><<link>></li>

with this:

<$let text={{{ [<link>split[|]nth[1]] }}} tid={{{ [<link>split[|]nth[2]else<text>] }}}>
<li><$link to=<<tid>>><$text text=<<text>>/></$link></li>
</$let>

-e

damn that’s cool!

The links are all external so I changed your recipe to:

<$list filter="[<currentTiddler>has[links]]">
References:
<ul>
<$list filter="[enlist{!!links}]" variable="link">
<$let text={{{ [<link>split[|]nth[1]] }}} href={{{ [<link>split[|]nth[2]else<text>] }}}>
<li>
  <a href=<<href>>><$text text=<<text>>/></a>
</li>
</$let>
</$list>
</ul>
</$list>

Otherwise it’s working! So I thought enlist eats up the [[]]] but apparently not since the let statement has access to them still. Can you shed some light on what the warning on the enlist operator exactly means?

Otherwise thank you!

The enlist[...] DOES “eat up” the square brackets surrounding items with spaces ([[ and ]]), but NOT the vertical bars (|) WITHIN items.

To see what the $list widget is doing, try putting this debugging line immediately after the $list line:

LINK = <$text text=<<link>>/><br>

Oh i see, very clever to split on the pipe. But what do the docs mean by:

you can work around the issue by using a variable

Literal filter operands are text constant operand values surrounded by square brackets ([ and ]). In your code, has[links], split[|], nth[1], and nth[2] all use literal filter operands (“links”, “|”, “1”, and “2”, respectively). Note also that in your code, none of these literal filter operands contains any square brackets.

If we imagine that, in some other use-case, you wanted to split an item that contains an open square bracket ([), then you might be inclined to write something like split[[]… but that won’t work because, as the documentation says, “Literal filter operands cannot contain square brackets”. To avoid this limitation, you can first define a variable: <$let squarebracket="[">, and then use split<squarebracket> within the filter syntax.

In addition, there isn’t actually a need to use variable="link" in your $list widget. Instead, you could write just:

<$list filter="[enlist{!!links}]">
<$let text={{{ [<currentTiddler>split[|]nth[1]] }}} href={{{ [<currentTiddler>split[|]nth[2]else<text>] }}}>

However, for code readability, it can be helpful to use variable="link" to make it clear exactly what is being referred to.

However, suppose that within the body of the $list widget you wanted to refer to the containing tiddler’s title. Then, using variable="link" is important, as it preserves the existing value of <<currentTiddler>>, while using <<link>> to refer to each enlisted item being processed by the $list widget.

Makes sense, thanks again.

Thank you @Mohammad , what’s the right way to install Mehregan or TZK on NodeJS?