Is it possible to trigger a macro with a filter search?

Now that TW 5.2.0 support literal macro parameters, I wonder if it’s possible to execute a macro via a filter search.

This would be useful to trigger actions by accessing a specific url, e.g :

<a href="#:[<disable-read-only>]">url to this wiki in edit mode</a>

2 Likes

I don’t know if I understand you.

I think that you need the linkcatcher but I don’t help you because I don’t know much about it.

You can get more info here → https://tiddlywiki.com/#TriggeringWidgets:TriggeringWidgets%20LinkCatcherWidget%20ActionWidgets%20[[WidgetMessage%3A%20tm-edit-tiddler]]

I think the terminology in this question can be rephrased as macros are never triggered, they are kind of “just” replacement content.

However i think i can answer your question in two ways however could you please ask again with what you want to achive without the partial solution?

Do you mean an auto-trigger on a specific URL?

Just a question
TT

Hum so from what I understand to make such a thing works it would require to somehow modify the way tiddlywiki navigate to an url and use a linkcatcher to be able to trigger an action widget…

I found more info on this feature :

When TiddlyWiki starts up it processes permalinks according to the following steps; the same steps are repeated if the permalink changes dynamically (this happens in response to the user editing the address bar, for example).

  1. If the permalink contains a colon, treat the string before as the target and the string after it as the story filter
  2. If the permalink doesn’t contain a colon, treat the entire string as the target and mark the story filter as unspecified
  3. If the story filter was unspecified and we’re in the process of starting up, then set the story filter to the empty string if the target is specified, or to the default tiddlers if the target is unspecified
  4. If the story filter was unspecified and we’re not starting up, then set the story filter to the current story list
  5. Evaluate the story filter as the story list
  6. If the target is specified and not present in the story list then add it at the top
  7. If the target is specified then navigate to it, otherwise navigate to the first tiddler in the story list

So it seems like this is the story filter that needs to be tweaked ?
I guess this would be done in $:/core/ui/PageTemplate…

@TW_Tones Yes sorry about that, I will reformulate :

If we add a colon in the url of a wiki, navigating to that url make tiddlywiki treat the string after it as the story filter.

We can define an ActionWidgets in a macro, and provided it is used in a triggering widget, the action widget will be executed.

TW 5.2.0 now support literal macro parameters.

My question then is : is it possible to catch and trigger the action widget generated by a macro in the story filter ?

@TiddlyTweeter yes that’s what I meant ! :slight_smile: That way we could use bookmarks to interact with a wiki - a bit like what the safe mode does but with far more possibilities.

Maybe that’s not possible without modifying $:/core/modules/parsers/wikiparser/wikiparser.js

If not possible, maybe with a javascript bookmarklet?

1 Like

To navigate to and edit any tiddler you can use linkcatcher widget wrapped around your link:

<$linkcatcher message="tm-edit-tiddler" >
<<list-links "[tag[HelloThere]]">>
</$linkcatcher>

This will work with HTML links also, as long as they are internal:

<$linkcatcher message="tm-edit-tiddler" >
<a href="#HelloThere">HelloThere</a>
</$linkcatcher>

It does not work with the href attribute similar to your first post

<$vars mytid="HelloThere">
<$linkcatcher message="tm-edit-tiddler" >
<a href="#<<mytid>>"><$text text=<<mytid>>/></a>
</$linkcatcher>
</$vars>

This is because we weren’t promised that "something <<macro>> something" would work everywhere – but only inside wikitext macro parameters.

Finally, if you just want a link that opens it’s target for editing, you can use a button disguised as a link using classes tc-btn-invisible tc-tiddlylink:

<$list filter="[tag[HelloThere]]">
<$button class="tc-btn-invisible tc-tiddlylink" message="tm-edit-tiddler" param=<<currentTiddler>> >
<$text text=<<currentTiddler>>/>
</$button><br/>
</$list>
2 Likes

@telumire I am sorry, but I still don’t understand the outcome or purpose it. My Bad I am sure, and you don’t need to keep explaining to me, others seem to be answering your question.

I have used in depth the following methods

  • Respond to content on the URL in the start up actions
    ** permitting a trigger in a wiki to reload the same with a message in the URL an respond to the message.
  • Make use of the clicking of links to trigger other actions

In this case also you are talking about URL’s which are in fact places inside the current wiki so the need to treat them as external urls is curious. Although I have done this for a Check in and Out Mechaisium, on reloading in “edit” mode I immediately save the wiki with details it is checked out for “edit”.

Best of luck

@Mark_S The href was to demonstrate the filter-in-url feature that we can use in tiddlywiki. The <<now>> macro seems to work everywhere (even in the url !) so I tough that maybe something could be done … looks like I was wrong! The button idea is great (I use it a lot), but the benefit of an “in-url startup action” is that we could share it to other and bookmark it.

@TW_Tones I was talking about URL placed inside the current wiki because tiddlywiki can navigate to the specified filter inside the url without reloading the whole wiki, so I thought that an external url would work the same as an internal url.

The specific use case I had in mind is to have a special link that open the wiki in “edit mode”, that we can then share to other or bookmark for ease of access.

I didnt know we could do that, looks like this could be a nice alternative. This would require to reload the whole wiki but it’s fine for the purpose of “starting the wiki with a specific setting”. For “in-wiki” action I could use the solutions mentioned by @Mark_S.

Do you have examples I could take inspiration from ? Are you using a list or reveal widget + a regex to check if a specific string is in the url ?

1 Like

@telumire to cut a long story short,

  • I have a tiddler tagged $:/tags/StartupAction/PostRender that interrogates the contents of [prefix[$:/info/]] and or tiddlers in Local storage but not saved to the wiki. All Actions that are inside listWidgets are executed in the tiddler if the conditions are correct.
  • I disable save to host unless the wiki is available for checkout,
  • On receiving a request update the wiki and save immediately to ensure another visitor arrives they see its checked out.
  • When in read only mode a request to edit is sent from a button for example;
:Checkout? {{{ [[$:/config/cio-session-id]has[text]get[text]] }}}={{$:/local/session-id}}?
<$list filter="[[$:/config/cio-session-id]!has[text]]">
    <$button>
        <$action-setfield $tiddler="$:/local/cio-message" $field="text" $value="request"/>
       <$action-sendmessage $message="tm-notify" $param="$:/PSaT/CIO/messages/request-access"/>
       <$action-sendmessage $message="tm-browser-refresh"/>
        Check out
    </$button>
</$list>

The above sets a tiddler only saved in local storage and refreshes. The wiki startup then interrogates the $:/local/cio-message tiddler if it sees a request and the just loaded wiki is not already in edit mode triggers all the edit mode settings and saves.

You could use Erics cookies plugins rather than local storage however if using file:// addresses you can tell between sessions.

This is quite sophisticated and complex and so far I have being working on my own, I have the proof of concept just need to polish some solutions.

1 Like

This sounds complicated indeed but it’s very interesting, I’m going to experiment with it tonight. Thanks a lot! :slight_smile:

1 Like

This seems not work! Can you check with non CamelCase title?

You’re right! The camelcase of the rendered HTML was constricting an internal <$link>, so that’s why it worked.