Loading tiddlers into tiddlywikis with bookmarklets - include timestamp

Folks,

I am using bookmarklets more and more. I package a set of tiddlers into a bookmarklet and on a click they are installed silently. This is very helpful to add settings and configurations you like on any tiddlywiki in the wild.

I wanted to ask if there are any javascript bookmarklet experts or otherwise out there if there would be a way to add to the bookmarklet a “function” that could set a filed on a targeted tiddler to now (TW date format) at the time the bookmarklet is clicked?

That is while Loading tiddlers into tiddlywikis with bookmarklets,
apply a time stamp that indicates when the bookmarklet is used.

This would allow us to keep track of when such a bookmarklet was applied allowing us to do a little more automation through bookmarklets.

I hope you get an exact reply to the OP as it is a very interesting approach!

Without going too much off-thread … I think your use of Bookmarklets very interesting!

TBH, I think a “Repository Of Bookmarklets” could be both interesting and useful to many!

But how would we better collectively share such bookmarklets?

A comment, TT

I have worked out how to do this with a tiddler so we can use the same methods we use to share tiddlers, json or drag and drop. Of you could visit my site and drag a bookmarklet to your bookmarks.

However we can also share the method to create the bookmarklet, thus making it relative to the wiki it is installed in, so rather than the content in the bookmarklet we share, being frozen in time it will use the content in the current wiki as its dragged to your bookmarks.

Once a bookmark is saved it is frozen in time, what this topic asks is can part of the bookmark change when it is used like get a " now tinestamp " and save it in the current wiki?

I have a proof of concept for bookmarks that toggles, reoccuring or are one shot use but this needs supporting macros.

If I could get some funding I would build a full solution

“Everyone needs money, that is why it is called ‘money’.” – HEIST, David Mamet.

I feel for your commitment to TW!
HOW to get money to support your activity properly I don’t know, yet, what to say.

TT

1 Like

I think one of the easiest ways to create “custom content bookmarks” is to drag & drop a tag-pill to the bookmarks bar as shown in my video

So if you have tagged it, it’s easy to be bookmarked.

2 Likes

I never noticed that. Great stuff

I that works we Should be able to do it with any filter on a button and draggable payload.

Yes. The “dragFilter” parameter of the button widget defines the filter.

Just thinking about it. It should be easy to add a drag to bookmarks button to bundler plugin.

3 Likes

So you want to change the modified timestamp of the imported tiddler? …

I think that’s not a good idea, since it modifies the tiddler, without modifying the text field.
So for a user it may look like a different tiddler but in reality it is not.

On the other hand, if the modified field is changed, it will show up on top of the Recent tab. … If that’s the intention, I could see a reason.

But imo it should be done by the import mechanism, where the user is in control and the bookmark wouldn’t need any javascript

1 Like

The bookmarklets I install use javascript and install tiddlers silently, rather than the data format, No import necessary. Clicking date downloads it, you can only drag and drop it.

Thy this in a bookmarklet to install a favicon
javascript:(function() %7B%0A%24tw.wiki.addTiddlers(%5B%7B"created"%3A"20220603060306576"%2C"text"%3A"<svg xmlns%3D%5C"http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%5C" width%3D%5C"22pt%5C" height%3D%5C"22pt%5C" viewBox%3D%5C"0 0 128 128%5C"><path fill%3D%5C"orange%5C" d%3D%5C"M64 0l54.56 32v64L64 128 9.44 96V32L64 0zm21.127 95.408c-3.578-.103-5.15-.094-6.974-3.152l-1.42.042c-1.653-.075-.964-.04-2.067-.097-1.844-.07-1.548-1.86-1.873-2.8-.52-3.202.687-6.43.65-9.632-.014-1.14-1.593-5.17-2.157-6.61-1.768.34-3.546.406-5.34.497-4.134-.01-8.24-.527-12.317-1.183-.8 3.35-3.16 8.036-1.21 11.44 2.37 3.52 4.03 4.495 6.61 4.707 2.572.212 3.16 3.18 2.53 4.242-.55.73-1.52.864-2.346 1.04l-1.65.08c-1.296-.046-2.455-.404-3.61-.955-1.93-1.097-3.925-3.383-5.406-5.024.345.658.55 1.938.24 2.53-.878 1.27-4.665 1.26-6.4.47-1.97-.89-6.73-7.162-7.468-11.86 1.96-3.78 4.812-7.07 6.255-11.186-3.146-2.05-4.83-5.384-4.61-9.16l.08-.44c-3.097.59-1.49.37-4.82.628-10.608-.032-19.935-7.37-14.68-18.774.34-.673.664-1.287 1.243-.994.466.237.4 1.18.166 2.227-3.005 13.627 11.67 13.732 20.69 11.21.89-.25 2.67-1.936 3.905-2.495 2.016-.91 4.205-1.282 6.376-1.55 5.4-.63 11.893 2.276 15.19 2.37 3.3.096 7.99-.805 10.87-.615 2.09.098 4.143.483 6.16 1.03 1.306-6.49 1.4-11.27 4.492-12.38 1.814.293 3.213 2.818 4.25 4.167 2.112-.086 4.12.46 6.115 1.066 3.61-.522 6.642-2.593 9.833-4.203-3.234 2.69-3.673 7.075-3.303 11.127.138 2.103-.444 4.386-1.164 6.54-1.348 3.507-3.95 7.204-6.97 7.014-1.14-.036-1.805-.695-2.653-1.4-.164 1.427-.81 2.7-1.434 3.96-1.44 2.797-5.203 4.03-8.687 7.016-3.484 2.985 1.114 13.65 2.23 15.594 1.114 1.94 4.226 2.652 3.02 4.406-.37.58-.936.785-1.54 1.01l-.82.11zm-40.097-8.85l.553.14c.694-.27 2.09.15 2.83.353-1.363-1.31-3.417-3.24-4.897-4.46-.485-1.47-.278-2.96-.174-4.46l.02-.123c-.582 1.205-1.322 2.376-1.72 3.645-.465 1.71 2.07 3.557 3.052 4.615l.336.3z%5C" fill-rule%3D%5C"evenodd%5C"%2F><%2Fsvg>"%2C"title"%3A"%24%3A%2Ffavicon.ico"%2C"tags"%3A""%2C"modified"%3A"20220713021354667"%2C"type"%3A"image%2Fsvg%2Bxml"%2C"modifier"%3A"visitor"%7D%5D)%3B%0A%7D)()

It is this Javascript I would like to include a now stamp when activated.

1 Like

Do you have a version, which is not URL encoded?

Its just a copy of one of tiddlywikis favicons as an example.

  • I believe it needs to be url encoded.

I am still looking to do this;

  • It needs someone who knows how to write a JavaScript function that I can include in the bookmarklet generation.

To reiterate when building a bookmarklet with the “add tiddlers” function. It need only be clicked and the tiddlers are silently installed. No need for the additional import step. What I want to do is load my bookmarklet making tool with an additional javascript function that does one of the following;

  • Sets the modified field of one of the payload tiddlers to now
  • Creates a tiddler not existing in the bookmarklet payload with a current created or modified date.
  • Add a record to a data tiddler (not in the payload) such as timestamp + bookmarklet name or primary tiddler.

The idea is that this simple action will allow a list to detect the installation of one of these one touch bookmarklets, when installed and the order in which they were installed/reinstalled.

  • This is needed so as to track if you succeeded installing a particular bookmarklet.

I find the additional import step to be an advantage, not a disadvantage

Here is some javascript to accomplish it:

$tw.wiki.addTiddler(
  new $tw.Tiddler({title: "my test tiddler", text: "hello there"},
  $tw.wiki.getModificationFields()));

Thanks @btheado

  • Me too but not always
  • I have over a dozen regular settings and additions I install and I don’t need any confirmation or intermediate steps. I do design them so they will not have unwanted side effects.

Thanks this looks promising. I am not so sure how to integrate it.

  • I have not being able to test it yet.

Here is a simple bookmarklet that installs a single Home tiddler;

javascript:(function()%20%7B%0A%24tw.wiki.addTiddlers(%5B%7B%22created%22%3A%2220200309235231388%22%2C%22creator%22%3A%22Designer%22%2C%22text%22%3A%22%3Cstrong%3EWelcome%20%5C%22%7B%7B%24%3A%2Fstatus%2FUserName%7D%7D%5C%22%20to%20%5C%22%7B%7B%24%3A%2FSiteTitle%7D%7D%5C%22%3C%2Fstrong%3E%20%7B%7B%24%3A%2FSiteSubtitle%7D%7D%5Cn%5Cn%7B%7B%24%3A%2FPSaT%2Fwiki-info%2Fpackages-list%7D%7D%22%2C%22title%22%3A%22Home%22%2C%22tags%22%3A%22TableOfContents%22%2C%22modified%22%3A%2220230131113238954%22%2C%22modifier%22%3A%22!build%22%7D%5D)%3B%0A%7D)()

Home.json (289 Bytes)

  • If this helps with integrating your example.

Ultimately I would like to investigate options to apply this in a few ways;

  • Add an additional tiddler with the date set along with an existing package as above
  • Apply the date/time to all tiddlers
  • Set the date/time on a nominated tiddler outside the package.

Any further help appreciated, but I expect with some effort on my part, you have given the critical info I need. Thanks again Brian.

I don’t understand what you mean for the last bullet point, but here is a share site demo for the first two requests.

The first one involved just adding the code I previously shared after your call to addTiddlers. The 2nd one involved assigning the tiddler array json to a variable and then looping through the array elements adding each one while updating the timestamp.

1 Like

Thanks Heaps :nerd_face:

This was about how; Normally a bookmarklet adds tiddlers, I am wondering if a bookmarklet could on its own set the last modified date of a nominated tiddler already in the wiki. eg; $:/config/last-bookmarklet-installed ie the target tiddler is not in the package.

However looking at your examples I can see the answer to this and the method of appending multiple “functions”.

  • It will take a little while to incorporate this into my bookmarklet tool but it will make it very powerful and more self documenting.

You are very skilled @btheado

1 Like

In TW5 tiddlers are immutable. So if you want to change the modified state of a tiddler you’ll need to read the tiddler and call .getModificationFields() again. Like so:

$tw.wiki.addTiddler(
  new $tw.Tiddler($tw.wiki.getTiddler("HelloThere"),
  $tw.wiki.getModificationFields()));

If you call this code snippet in the browser dev-console you’ll see that the HelloThere tiddler will be at the top of the Recent Tab.

-m