[TW5] Date stamp - any method to do this in mid text?

141 views
Skip to first unread message

Mat

unread,
Jan 28, 2016, 3:58:44 AM1/28/16
to TiddlyWiki
In jotting quick notes into a single tiddler I'd like to insert date stamps, something like so

  • adsff  asfd sda gas g
  • dasgsag gsga
2016-01-28
  • adfsad dsf gagg
2016-01-27
  • adjköj

Once set, the date becomes a fixed string. So it might read todays date on creation but it should not re-render or re-parse when I later edit the tiddler.

Ideally - but this is less important - the date string is thereafter also what is seen in edit mode instead of e.g the original macro call.

Any idea how this can be made?


<:-)

Tobias Beer

unread,
Jan 28, 2016, 5:37:44 AM1/28/16
to TiddlyWiki
Hi Mat,

I tried this, but it throws a js error. No idea why:

title: $:/_my/ui/button/datestamp
tags: $:/tags/EditToolbar

\define button()
<$button>
<$action-setfield $field="text" $value="""$(currentText)$

$(dateStamp)$"""/>
{{$:/core/images/new-journal-button}}
</$button>
\end

<$vars currentText={{!!text}} dateStamp=<<now "YYYY-0MM-0DD">>>
<<button>>
</$vars>

Also, I am thinking the action-setfield method should support:

— prepend the specified value to the existing value of the target field / index
— append the specified value to the existing value of the target field / index
— replace the specified text with the defined value in the target field / index

Best wishes,

Tobias.

Mat

unread,
Jan 28, 2016, 6:46:53 AM1/28/16
to TiddlyWiki
Tobias, thanks for looking at this!

I get your code to work if I specify a(nother) tiddler (..but, see below), so my guess is that the problem lies in that the tiddler is attempting to apply the stamp to itself...?

But - it is also the matter that stamp is applied not to the editing draft, but to the actual tiddler. Thus, when I save, the original is overwritten with the content of the draft where the stamp does not appear, resulting in no stamp... (I found this by using your code in the SideEditor).

Hmmm...

<:-)

Tobias Beer

unread,
Jan 28, 2016, 7:05:02 AM1/28/16
to TiddlyWiki
Hi Mat,

so my guess is that the problem lies in that the tiddler is attempting to apply the stamp to itself...?

Sure, that was the idea. And I was thinking that the action widget would only ever do something when I actually click the button. It appears that is not the case, which makes me think that this smells of a bug.

But - it is also the matter that stamp is applied not to the editing draft, but to the actual tiddler. Thus, when I save, the original is overwritten with the content of the draft where the stamp does not appear, resulting in no stamp... (I found this by using your code in the SideEditor).

The idea was to set the text of the draft, not of the original, though. ;-)
At least, I imagined the "currentTiddler" in edit mode to be the title of the draft,
not of the original tiddler.

Best wishes,

Tobias.

Mat

unread,
Jan 28, 2016, 7:22:17 AM1/28/16
to TiddlyWiki
which makes me think that this smells of a bug.

Interesting. I'd be happy to post an issue... but basically just how to reproduce the problem without any qualified additional info. Could you post a better issue?
 

The idea was to set the text of the draft, not of the original, though. ;-)
 
Ah, of course, that is what I ask for. I confused myself.

Thanks 

<:-)

Tobias Beer

unread,
Jan 28, 2016, 7:57:23 AM1/28/16
to TiddlyWiki
Hi Mat,
 
Interesting. I'd be happy to post an issue... but basically just how to reproduce the problem without any qualified additional info. Could you post a better issue?

Kept it somewhat simple:

#2258 edit button for appending a datestamp throws js error

Best wishes,

Tobias.

Mat

unread,
Jan 31, 2016, 2:05:09 PM1/31/16
to TiddlyWiki
Tobias, both of your codes in #2258 cause problems when the text has a quotation mark at end, i.e when typing e.g:

anything like this "

(disregard the coloration)

I'm guessing the quotation mark in the text is interpreted as some end or start of something in the code.

Is there any way to prevent this?

Thanks!

BTW, if anyone is curious, I'm using Tobias' little creation in this tiddler.

<:-)
Reply all
Reply to author
Forward
0 new messages