Richlinks revisited

Some time ago @twMat made the vvery smart Richlinks-macro to display medialinks and links to websites like youtube and twitter in a direct and elegant way.

Since it still needed an Tobi Beer’s split operator which can now be replace by the on-board split filter, I thought it might be time for a relaunch. So let us start by uploading a first replacement of the macro that does not need additional filters (1.3 KB)

But I see further potential I would like to implement:

  • I would like to replace the dictionary tiddler by a listfield in each template in which the mediatypes and websites to apply it to listed.
  • I would like to have a viewtemplate, that applies the macro if a tiddler has a url in a “richlinks” filed.
    .
4 Likes

That would be awesome!

I never could get the iframe rich link to work!

I would be happy to contribute to this effort, I would like to combine it with a method I use called protocol links, when any field containing a value beginning with a protocol such as http:// or https:// … is presented as a link, add a richlinks view, fantastic.

  • I recently recalled fieldnames are much less restricted now, so we can use the fieldname to store the window.name/target and/or pretty name the link will open in, since it is the value that is used to detect its a link.
  • I am working on a method so such fieldnames do not “pollute the fieldname space”, with the “new field” dropdown.

Yeah, you’re probably right. It’s just that I constantly have sooo many ideas. I’m currently working on one I’ve polished for weeks that I think many people will appreciate (but which was sidetracked by DragTag the other day). But I like RichLinks, including the way I constructed it, so I’ll try to take a look at it over the coming weeks. (But before I’ve already promised someone I should fix a bug in NewTids and then there’s @Siniy-Kit 's project that must not be dropped… why don’t more people see that that is a super important project?)

I didn’t yet check out your file but I’m very happy to see contributions to it! :smiley:

3 Likes

I made richlinks-realaunch which chooses the templates without dictionary just by searching a keyword in the title: Like in $:/richlink/img:jpg:jpeg:png:gif the keywords have to be preceded by a colon ( : )

http://szen.io/richlinks/

P.S. For Wikipedia (because of the prefix en. wikipedia) this does not work yet. I still will have to think of a smart tweaks for prefixes…

Submissions welcome!

I guess we need a template for the case where no template is defined… I have to think of this because like the original macro the new version digests the link in two parallel ways which makes it a little tricky for an emptyMessage solution.

\define abevregexp() ([a-zA-Z0-9_]{5}).*
\define applytemplate(signum)
<$set name=template filter="[prefix[$:/richlink]search:title:[$signum$]]">
<$tiddler tiddler=<<template>> >
     <$transclude/>
</$tiddler>
</$set>
\end

\define richlink(link, 1, 2, 3)
<$vars link="$link$" 1="$1$" 2="$2$" 3="$3$">
<$set name="domain" filter="""[[$link$]split[://]last[]] +[search-replace::regexp[www.],[]]
+[search-replace::regexp<abevregexp>,[:$1]]""">
 <$macrocall $name=applytemplate signum=<<domain>> />
</$set>
<$set name="filetype" filter="""[[$link$]split[.]last[]addprefix[:]]""" >
 <$macrocall $name=applytemplate signum=<<filetype>> />
</$set>
</$vars>
\end
1 Like

I replaced the colon ( : ) by an @-symbol to preceed each keywords to trigger a template. So now templates look like $:/plugins/richlink/img@jpg@jpeg@png@gif@webp@svg

My setup is singlefile…Please tell me whether this works in node

I added an instant display feature, to use the richlinks with an inputfield in the sidebar to show temporary content.

http://szen.io/richlinks

There still is some work to do on some of the existing templates and of course it would be good to add templates for more sites so submissions uploaded here are very welcome

1 Like

Looking really good.

This is fantastic! I never saw the original, but this seems extremely useful. Off to go examine the code…

On RichLinks in the install section, it says Tobias’s split is still required. Is this the case? I thought you were removing it!

I got to change this in the docs. Split should not be necessary anymore.

1 Like

Speaking of richlink additions…

I stumbled across the 3d paint in windows this morning and .glb files.
Oooh. Shiny! I thought.

One small rabbit hole later I have found this Model Editor to embed them in web pages but now it’s the end of my lunch break!

I just updated my version of richlinks
most tmeplate work fine, but I have difficulties to apply the simple IFrame for all Links where no template is identified. This macro:

\define applytemplate(signum)
<$set name=template filter="[prefix[$:/plugins/richlink]search:title:[$signum$]]">
<$tiddler tiddler=<<template>> >
     <$transclude/>
</$tiddler>
</$set>
\end

Should apply
$:/plugins/richlink/iframe

if no template is found.

1 Like

Add an “else” filter run as a fallback, like this:

<$let template="[prefix[$:/plugins/richlink]search:title:[$signum$]] ~[[$:/plugins/richlink/iframe]]">

Note use of simpler $let widget since the template value should always be a single tiddler title.

-e

1 Like

Hi Eric, is this what you meant? I seem to have made a mistake, because the existing templates no longer work…

\define abevregexp() ([a-zA-Z0-9_]{5}).*
\define applytemplate(signum)
<$let template="[prefix[$:/plugins/richlink]search:title:[$signum$]] ~[[$:/plugins/richlink/iframe]]">
<$tiddler tiddler=<<template>> >
     <$transclude/>
</$tiddler>
</$let>
\end

\define richlink(link, 1, 2, 3)
<$vars link="$link$" 1="$1$" 2="$2$" 3="$3$">
<$set name="domain" filter="""[[$link$]split[://]last[]] +[search-replace::regexp[www.],[]]
+[search-replace::regexp<abevregexp>,[@$1]]""">
 <$macrocall $name=applytemplate signum=<<domain>> />
</$set>
<$set name="filetype" filter="""[[$link$]split[.]last[]addprefix[@]]""" >
 <$macrocall $name=applytemplate signum=<<filetype>> />
</$set>
</$vars>
\end

<$list filter="[all[current]has[richlink]get[richlink]]" 
         variable="link">
{{$:/core/images/import-button}}<$macrocall $name=richlink link=<<link>>/>
</$list>

Let seems to be a problem, because the templates wont work without ~[[$:/plugins/richlink/iframe]]

APOLOGIES! The code I provided should have used filtered transclusion (tripled curly braces) rather than quoted text.

This:

<$let template="[prefix[$:/plugins/richlink]search:title:[$signum$]] ~[[$:/plugins/richlink/iframe]]">

should be this:

<$let template={{{ [prefix[$:/plugins/richlink]search:title:[$signum$]] ~[[$:/plugins/richlink/iframe]] }}}>

-e

2 Likes

Again, thank you,
but now I get double results with the timebased elements immediately starting to play.
I really cannot figure out what is happening.

Looking really good. Good work.

Thank you @Ste_W I tried to implement the model viewer… but I could not find a public model to implement.
So please check…and send me a link