In-Wiki Incremental Revisions -- Now Even Better!

Success! Thanks so much :smiling_face_with_three_hearts:

To be honest, I cannot count the number of times that I had to go back to a previous version of a tiddler because I messed up something. Programming in WikiText is often trial-and-error for me, and with this “plugin” the error part of that is quickly undone.

For this reason, I use the whitelist filter [is[tiddler]is[system]] to only backup “code” tiddlers. I rarely feel the need for backups of “prose” tiddlers.

2 Likes

this worked for me as well. thanks for all your work @Yaisog !

Hi @Yaisog,

I am having the same problem again that I first mentioned here, in which the column showing the list of revisions is not showing up.

This is after I installed your plugin from https://yaisog-patches.tiddlyhost.com/ into a new single-file wiki.

I confirmed that my wiki does include $:/plugins/yaisog/modules/filters/userfriendlydate.js, and it is tagged with $:/plugins/yaisog/patches.

Thanks,

Dahlia

1 Like

Hi @Dahlia, did you save the wiki and reload? Since userfriendlydate.js is a JavaScript module, it only gets loaded when TW is initialized.
I can confirm that the problem exists after importing but before reloading, but in my tests disappears thereafter.

Hmmm, I saved it several times, but I’m not sure I reloaded it.

However, I did reload it today, and it’s still not working, but it looks a little different:

I’m having the same problem as Dahlia. I’m using your demo directly. It shows “yesterday” in the left hand column, but no entries. It shows “yesterday” even though all changes were/are today.

image

1 Like

Hi @Dahlia & @Mark_S, thank you for the feedback. What time zones are you in? Revisions currently uses the modified field data as is, which is saved in UTC, so maybe that’s why a comparison to the local today fails, at least during part of your day. I live in UTC+1, so this would affect me only for an hour around midnight, which is why I may never have stumbled upon it.
I will take a look at how that could be fixed.

PS: In userfriendlydate.js I left this todo for myself:

TODO: add an option to interpret the input as a UTC time string and translate to local time for comparison

So, clearly I was aware of the problem potential at some point


Update:
I fixed a bug in the Viewer where it derived the date headings (e.g. “yesterday”) from the timestamps interpreted as local time instead of them actually being UTC. So it did generate the wrong name string and then found nothing when comparing the actual UTC timestamps of the patches to that name string to populate the list. It should work now (fingers crossed).

1 Like

Also: Save the cheerleader, save the world!

1 Like

Hi @Yaisog, yes, working again! Thanks so much! :smiling_face_with_three_hearts::+1:

Now I have a request, if you’re willing:

I would like to turn off “Globally enabled backups” and just use the plugin manually. Would it be possible for you to add a button to the Edit toolbar that will perform a manual save?

(Idea: You could use an icon similar to the current one, but add a “+” to it.)

I would be especially grateful if a keyboard shortcut could be assigned to it.

(I tried to create a button and keyboard shortcut myself, but I’m pretty new to TiddlyWiki - I learned some things by attempting it, but I’ve got a long way to go :wink:đŸ€·)

I made the button you requested, since it seemed like a pretty good idea to me. Note that the button will only appear if automatic backups are disabled in the control panel (I renamed the global option), which is not the case when the demo site is loaded.

I did not create the keyboard shortcut. I am not sure how the script would know which tiddler to revision when you press the shortcut. It would probably be possible to check all open tiddlers if they have a current revision and make one if they don’t, but this would have to wait for when I have more time.

Sorry, I didn’t see your post until now. Thank you so much for adding that function! :heart_eyes:

As can be seen in the following screenshot, I tagged both of your buttons with $:/tags/EditToolbar so that the buttons will appear on the Edit toolbar, allowing me to do manual saves and check revisions while I’m editing tiddlers:

Here’s an example that shows the buttons appearing in the Edit toolbar while editing a tiddler:

I looked at your code for the button, and yeah, most of that is still way over my head. :sweat_smile:

As for a keyboard shortcut, is there some way to tie it to the button on the current tiddler?

Hi @moosh, I’m also interested in being able to add comments to my snapshots. Would you be willing to share how you added that?

Hi @Dahlia, I’m not sure if putting the manual revision button in the Edit Toolbar will work as expected. Edit Mode creates a draft copy of the tiddler titled “Draft of 
” and the revision button might create a revision of that draft tiddler. This may or may not associate correctly with the other revisions of that tiddler, since the tiddler creation date is used as the tiddler ID for revisioning purposes. This way, we can also track if the tiddler has been renamed.
Please test if it works in your setup before you rely on its functionality.

Concerning shortcuts, I think you could customize the EditTemplate to insert a $keyboard widget that reacts to your shortcut as long as the cursor is in an input or textarea element that is part of the widget’s content. This $keyboard widget would have knowledge of which tiddler the focused input/textarea element belongs to and could set the â€čcurrentTiddlerâ€ș variable accordingly for the revisions macro.
Alternatively, you could create an Editor (not Edit) Toolbar button and assign it a shortcut key. I think these are triggered by $keyboard widgets that are in place already. You could take a look at e.g. $:/core/ui/EditorToolbar/bold and try to figure out how that works via the various fields (not really trivial).
But like I said, creating a revision in Edit Mode might not work as expected.

I think you’re right. It actually partially works — the Viewer shows revisions for both the original tiddler and the drafts. But it gets mixed up when you try to restore a previous revision.