How to use Stamp to insert literals - e.g. a time-stamped Signature

Hello,

Apologies for noob questions; only a few days TW experience, moving from Doku…

I call the detail that appears below the Tiddler title a Signature - for example mine says:
[[jeff]] 30th December 2021 at 11:26am

  1. Can I change the date-format (or other details of the Signature)
  2. Can I create a Stamp i.e. tiddler tagged $:/tags/TextEditor/Snippet
    that returns the literal result of <<now "DD-MMM-YY 0HH:0MM ddd">> rather than the expression?

For more advanced alternative, Doku supports save-interpolation where markers in the wiki-text are replaced with literal values when the tiddler is posted.

For example I can define

%%sig%% as  --- [[ {{username}} ]] <<now>>

and %%sig%% is then replaced with a one-time interpolation / evaluation that is literal and unchanging when the tiddler is posted.

P.S. I know [[ {{}} ]] is not valid TW syntax - haven’t yet got my head around why [[]] don’t act as interpolating delimiters.

Many thanks for any pointers.

Jeff

You may need to wikify the value first, so the result you get in the final rendering is available mid way.

<$wikify name=timestamp text="""<<now "DD-MMM-YY 0HH:0MM ddd">>""">
   in your code <<timestamp>>
</$wikify>

Personally I tend to use this “just in time” as above to keep things simple.

The following is an example how I reuse the same macro/variable name

\define timestamp() <<now "DD-MMM-YY 0HH:0MM ddd">>
...
<$wikify name=timestamp text="""<<timestamp>>""">
   in your code <<timestamp>>
</$wikify>
...

Thank you for the clue - I’m part-way there…

  1. I found Scripts in Tiddlywiki — codes, macros, and solutions in TW
  2. I created a tiddler called $:/core/ui/EditorToolbar/Time with the fields and content as per the example - that inserts a timestamp only. (The name feels wrong - haven’t tried to see if I can put it somewhere non-core)
  3. I wrapped the tiddler content so that it ended up as:
<$wikify name=signature text="""{{ $:/status/UserName }} <<now "DD-MMM-YY 0hh:0mm">>"""  >
<$action-sendmessage
	$message="tm-edit-text-operation"
	$param="replace-selection"
	text=<<signature>>
/>
<$wikify>

Which works to insert the literal wikitext that I want - but without the link-square-brackets around the username. Almost there?

But now I am stymied on how to get link-square-bracket literals into the signature. I’ve looked at:

It seems to me that getting a fragment of literal wikitext that contains a link to the current user should not be so hard. It makes me feel that I am fighting TW rather than groking it.

Any further pointers appreciated.

Jeff

This should not have the spaces in it, use {{$:/status/UserName}}

Any particular reason why? It seems to work ok - there are no spurious spaces in the output, and it reads better in the code?

I thought that was your problem.

Actually in $:/core/ui/EditorToolbar/linkify the editor toolbars does this with

<$action-sendmessage
	$message="tm-edit-text-operation"
	$param="wrap-selection"
	prefix="[["
	suffix="]]"
/>

However now with 5.2.0+ you can use the operator format, perhaps try this ;

text={{{ [<signature>format:titlelist[]] }}}

Hmmm - the format:titlelist operator just creates a title-list string from a list - it only adds [[ and ]] around entries if they contain spaces.

My username standard does not allow spaces, and forcing usernames to contain spaces is not really an option.

I’ve looked through all 387 matches for /operator/ on www.tiddlywiki.com without finding anything that looks appropriate.

I’ve also looked through WidgetMessage: tm-edit-text-operation and reviewed the various combination of operations and params.

I’m going to give up on TW having Signatures for a while - THDC.

Sorry i have not helped this time. Normaly i am much more helpful :sunglasses:

Try this:

<$vars prefix="[[" suffix="]]">
<$wikify name=signature text="""{{{ [{$:/status/UserName}addprefix<prefix>addsuffix<suffix>] }}} <<now "DD-MMM-YY 0hh:0mm">>"""  >
<$action-sendmessage
	$message="tm-edit-text-operation"
	$param="replace-selection"
	text=<<signature>>
/>
</$wikify>
</$vars>

For the username link creation I’m using a transclude-filter shorcut instead of the transclusion see: {{{ [{$:/status/UserName}addprefix<prefix>addsuffix<suffix>] }}} and I’m using <prefix> and <suffix> variables, since [[ andd ]] can’t be used because it would create an invalid filter syntax.

In your example you wrote <$wikify> instead of /$wikify for your wikify closing tag.

1 Like

Thank you very much for that - much appreciated.

I’ve learnt that '''{{{ [...]}}}''' is a kind of string-expression that gets interpolated. Slowly starting to make more sense :slight_smile:

I wanted to wrap the entire sig in italics so that it looks like the Doku ones that have been imported. The final content of my $:/plugins/jeff/EditorToolbar/Signature ended up being:

<$vars linkon="[[" linkoff="]]" sigstart="--- //" sigend="//">
<$wikify name=sigval text="""{{{ [{$:/status/UserName}addprefix<linkon>addsuffix<linkoff>] }}} - <<now "ddd DD-mmm-YY 0hh:0mm">>"""  >
<$wikify name=signature text="""{{{ [<sigval>addprefix<sigstart>addsuffix<sigend>] }}}"""  >
<$action-sendmessage
	$message="tm-edit-text-operation"
	$param="insert-text"
	text=<<signature>>
/>
</$wikify>
</$wikify>
</$vars>

Hi Jeff,
See an alternative full solution in An Editor Toolbar Button to Insert User Signature with Timestamp

I will update TW-Script with the new solution!

As user name is given as a link, I intentionally removed the italic style, as italic links in Tiddlywiki has special meaning, italic links are used for missing links

3 Likes