An Editor Toolbar Button to Insert User Signature with Timestamp

Description

Add a button to editor toolbar to insert the user signature as below

  • --- //[[UserName]] - ddd DD-mmm-YY 0hh:0mm
  • for example : — Jeff - Fri 31-Dec-21 07:43

If the Username for signing edits is not set, then use Anonymouse

Solution

i. Create the action tiddler

  1. Create a new tiddler with below fields
    1.1. caption: Signature
    1.2. condition: [<targetTiddler>!has[type]] [<targetTiddler>type[text/vnd.tiddlywiki]]
    1.3 description Insert user signature
    1.4. icon: $:/core/images/timestamp-on
    1.5. list-before: $:/core/ui/EditorToolbar/stamp
    1.6. shortcuts: ((signature))

The below action shall be written in the text field

\define signature() --- [[$(username)$]] - //$(datetime)$//
<$vars datetime=<<now "ddd DD-mmm-YY 0hh:0mm">>
       username={{{ [[$:/status/UserName]get[text]else[Anonymouse]] }}}
>
<$action-sendmessage
	$message="tm-edit-text-operation"
	$param="insert-text"
	text=<<signature>>
/>			
			
</$vars>			
  1. Tag it with $:/tags/EditorToolbar and save the above tiddler: use any title you like, but here I use $:/kookma/ui/EditorToolbar/signature as the tiddler title.

ii. Create the keyboard shortcuts

Now, we create keyboard shortcuts, these shortcuts can be customized through $:/ControlPanel > Keyboard Shortcuts tab.

  1. create a tiddler titled $:/config/shortcuts/signature
    1.1 in the text field enter ctrl+g as shortcut key (use your own if do not like)

  2. create a tiddler titled $:/config/ShortcutInfo/signature
    2.1 in the text field enter Inser user signature

Code and demo

  1. to give a try download the attached solution Insert-User-Signature-EditorToolbar-Button.json (1.1 KB)
  2. drag and drop the downloaded JSON from step 1 into https://tiddlywiki.com/
  3. create a new tiddler and see it in action
    3.1 click on the signature button appears before stamp
    3.2 or use shortcut keys (press ctrl+g)

img_763_%pn

Ref

[1]. [ How to use Stamp to insert literals - e.g. a time-stamped Signature](How to use Stamp to insert literals - e.g. a time-stamped Signature)
[2]. Scripts in Tiddlywiki — codes, macros, and solutions in TW
[3]. https://tiddlywiki.com/#How%20to%20create%20keyboard%20shortcuts

3 Likes

Side note: In How to use Stamp to insert literals - e.g. a time-stamped Signature it was asked to insert usrname as a link in italic style!

The above solution does not use italic style for link as in Tiddlywiki they are reserved for missing links!

1 Like

Here is a tip inspired by the recent discussions on Journals that made me decide to revive this old thread after looking to see if anyone else does what I find to be a more convenient way of “journaling” in tiddlers.

Rather than add a signature and complete time-stamp, the alternative I use is simply:

<$action-sendmessage
	$message="tm-edit-text-operation"
	$param="insert-text"
	text=<<now __YYYY/0MM/0DD__>>
/>

with field values comparable to above except I use ((date-stamp) for the shortcut.

That implements an underlined year/month/day style date stamp. $:/config/shortcuts/date-stamp then defines ctrl-D for my preferred, hands on the keyboard, shortcut to insert this “date stamp”

As I start editing a tiddler to record a change log entry for a topic/task, ctrl-D inserts today’s date stamp as I begin. Back dating an entry, if I forgot to make a note yesterday, is just a few keystrokes away. What I end up with is a reverse chronological history, latest bit of knowledge first, for the topic/task, demarcated by their dates.

I gave up making Journal tiddlers and switched to this scheme almost a decade ago when I realized that bits and pieces of knowledge were getting buried by date and task information intermixed in Journal entries. Keeping a history of lessons observed / changes associated with each topic/task tiddler seemed more useful.

A bonus for this approach: finding other topics/tasks updated on or after the same date – because of the YYYY/MM/DD date format of these date stamps – is accomplished by a simple search for the leading characters of some date, e.g., 2022/09/2 results in tiddlers modified and date stamped in a 10 day window; and they end up close to each other in search results and also in reverse chronological order. The latter happens because I also create a shadow $:/core/ui/DefaultSearchResultList, changing the default sort[title] to !sort[modified] because in general I want to find more recent information first.