A procedure to create Wikipedia links to currentTiddler, a field or something else

I tinkered with procedures and transclusion and created my first procedure. :partying_face:
It makes a link to:

  • Wikipedia about the Tiddler: <<wikipedialink>>,
  • Wiki about something else: <<wikipedialink "Tiddlywiki">>
  • Wikipedia about a field-value: <$transclude $variable=wikipedialink entry={{!!foo}}/>
\procedure wikipedialink(entry)
  <$set name="target" filter={{{ [<entry>] }}}  emptyValue=<<currentTiddler>>>
    <$let hash={{{ [<target>encodeuricomponent[]] }}}>
    <a href=`https://en.wikipedia.org/wiki/$(hash)$`  target="_blank" rel="noopener noreferrer">Wikipedia</a>
    </$let>
  </$set>
\end

Procedure WikipediaLink.json (650 Bytes)

6 Likes

Nice little tool to add to my default wiki definition !

I just modify two things :

  1. a wikipedia logo (W) as prefix to the link

  2. replace the ‘wikipedia’ term by <<target>> to show the term used in the link.

Capture d’écran 2023-07-06 à 11.57.39
$__img_Wikipedia-W.svg.json (1021 Bytes)
$__Procedure_WikipediaLink.json (726 Bytes)

2 Likes

Another little trick is to use target=“wikipedia” so all links open in the same tab unless you use r-click.

2 Likes

That are good ideas.
Did you upload the correct json? There are 224 Tiddlers in it but not the modified procedure


oups I edited my post to correct this.

1 Like

If I just choose

<<target>> as shown link there are some realy ugly cases like https://en.wikipedia.org/wiki/Phrases_from_The_Hitchhiker%27s_Guide_to_the_Galaxy#The_Answer_to_the_Ultimate_Question_of_Life,_the_Universe,_and_Everything_is_42.

I changed it and now got these possibilities.

grafik

I did not figure out how to show currentTiddler. I bet, I am missing triple brackets or somebackticks.

How do I pass <<currentTiddler>> to the procedure without the long macrocall?

If I use {{!!title}} in those cases, it looks and works fine in some wikis BUT
the 4th row each (“show currenTiddler”) is somehow corrupt
. On tiddlywiki.com and tiddlyhost it mixes the links, depending on how many / are in the title. On empty.html it works fine.

wikilink bug

I don’t understand that behavior.

The

does not work.

\procedure wikipedialink(input, topic)

<$set name="target" filter={{{ [<input>] }}}  emptyValue=<<currentTiddler>>>
    <$let hash={{{ [<target>encodeuricomponent[]] }}}>
        <a href=`https://en.wikipedia.org/wiki/$(hash)$`  target=“wikipedia” style="text-decoration:none;" rel="noopener noreferrer">{{$:/img/Wikipedia}}<<topic>></a>
    </$let>
</$set>

\end

---
;about the currentTiddler:
:show only icon: <<wikipedialink>>
:show custom text: <<wikipedialink "" "custom">> <br>
:show field-value: <$transclude $variable=wikipedialink topic={{!!foo}}}/>
:show currenTiddler: <<wikipedialink "" "{{!!title}}" >>


;about a field-value
:show only icon <$transclude $variable=wikipedialink input={{!!foo}}/>
:show custom: <$transclude $variable=wikipedialink input={{!!foo}}} topic=custom/>
:show other field:-valu<$transclude $variable=wikipedialink input={{!!foo}} topic="{{!!other-field}}"/>
:show currenTiddler: <$transclude $variable=wikipedialink input={{!!foo}} topic=<<currentTiddler>>}/>

;about something else 
:show only icon: <<wikipedialink "Tiddlywiki">>
:show custom text: <<wikipedialink "Tiddlywiki" "custom">>
:show field-valu: <<wikipedialink "Tiddlywiki" "{{!!foo}}">>
:show currenTiddler:  <<wikipedialink "Tiddlywiki" "{{!!title}}" >>

WikipediaLink_v0.6.json (1.5 KB)
$__img_Wikipedia.json (1.0 KB)

Thats Odd, look closely at the quotes, they are not the same as elsewhere, try "wikipedia", if you dont have any luck I will review / test the code.

This seams to be a problem with CamelCase that I to stumbled upon by chance. CamelCase is activated on tiddlywiki.com and it overrules my link. Without CamelCase it works fine.

My procedure doesn’t set a “wikipedia browser tab”. If have another link with target="wikipedia" and use this first to create a browser tab “wikipedia” than my procedure will use this tab. But if the browser tab with the wikipedia site is created by my procedure than it will create a new tab for each link.

@TW_Tones Thanks for the offer! Could you have a look at the code?

  1. How can I set the target tab?
  2. How can I call the procedure to show the tidderl title? Is my use of {{!!title}} the elgetante was or could one use currentTiddler?