Conditional action

I’m using the TimerActions plugin to do a periodic save of the wiki. It works by accepting an actions string and invoking it periodically. The problem is that it also invokes it on startup which messes up my saver (the native html saver, it requires an interactive action to be able to save, so the non interactive save on startup causes it to have errors).

So what I want is an action string (that is, something that invokeActionString will execute) that will call save only if an initial save was already done. I don’t know if an initial save can be identified, so if not, I want something that waits x minutes (so up until then, it will be called, but do nothing).

(as for the initial save, if there’s a hook to listen to saves, then that can set a tiddle field, or some other variable that the conditional action checks).

You might want to try TiddlyTools/Time/AutoSaver, which does periodic saves, using TiddlyTools/Time/CountDown

It has a sidebar interface that lets you set the amount of time between saves, with buttons to start/pause/stop the countdown or immediately trigger save action(s), as well as optional settings to:

  • automatically begin countdown at startup
  • ask before saving/exporting
  • save the file (using whatever saver you have configured)
  • export all changed tiddlers to a JSON, CSV, or static HTML file
  • export a selected set of tiddlers (using filters to get the set of tiddlers plus multiselect to choose desired tiddlers from that set)

To install, copy these 4 tiddlers into your TiddlyWiki, then save-and-reload:
TiddlyTools/Time/AutoSaver
TiddlyTools/Time/CountDown
TiddlyTools/Time/Ticker
TiddlyTools/Time/action-timeout.js

see TiddlyTools/Time/Info for more documentation.
(note: you can also install all 4 tiddlers by dragging and dropping the “required” button from the “TiddlyTools/Time/AutoSaver” section of the Info tiddler)

2 Likes

Thank you. If I don’t want the save to happen at startup, then I need to manually save through the tiddler the first time, right? Is there a way for it to start after the first save of the wiki (since I might forget to start autosave every time I load the wiki)?

And also, is there a problem moving these tiddlers to something like $:/TiddlyTools… (I want to make sure I export them if I ever start a fresh wiki and making them a system tiddler will make sure of that without me needing to remember them explicitly)

TiddlyTools/Time/AutoSaver doesn’t save at startup. The option is to start the countdown at startup. Thus, if your countdown is set for 30 minute intervals (the default), then the first save will occur automatically 30 minutes after startup. Manual saving has no effect on the current countdown. It just triggers the selected save action(s), but doesn’t automatically start (or stop) the current countdown.

Currently, many of the TiddlyTools/Time/* tiddlers include hard-coded references to other TiddlyTools/Time/* tiddlers that they depend on. Thus, renaming them will cause things to not work properly (or at all!). Let me give some thought to the best way to make these paths easily configurable. I’ll let you know when I post an update available for installation.

-e

Without any renaming or modifications on my part, here’s a quick way to turn the four AutoSaver-related tiddlers into a plugin so that it’s easier to install when you create a fresh TiddlyWiki:

Part 1: Creating a plugin from individual tiddlers

  1. open TiddlyTools/Time/Info and, in a separate tab, open https://tiddlywiki.com/empty

  2. From the “TiddlyTools/Time/AutoSaver” section of the TiddlyTools/Time/Info tiddler, drag the “required” button and drop it onto the open https://tiddlywiki.com/empty to show the usual TWCore $:/Import tiddler

  3. DO NOT PRESS THE IMPORT BUTTON! Instead, EDIT the $:/Import tiddler.

  4. Change the title from “$:/Import” to “$:/plugins/TiddlyTools/Time/AutoSaver”

  5. Scroll down to the bottom of the tiddler (where the “extra” fields are shown). Change the value of the plugin-type field from “import” to “plugin” and delete the status field.

  6. Save the tiddler. It will now appear as a plugin, containing the TiddlyTools/Time/AutoSaver and related tiddlers.

Part 2: Installing the plugin in your TiddlyWiki files

  1. Drag the plugin “heading” and drop it into your own TiddlyWiki. The usual TWCore $:/Import tiddler will be displayed, showing ONE tiddler, with a title of “$:/plugins/TiddlyTools/Time/AutoSaver” and a status that says “(requires reload)”.

  2. This time, DO PRESS THE IMPORT BUTTON. This installs the plugin into your TiddlyWiki file. Save-and-reload for the installed plugin to take effect. Note that the four AutoSaver-related tiddlers will now exist as SHADOW tiddlers, so they won’t appear in your normal sidebar lists, but can still be accessed as usual.

Part 3: Creating a new TiddlyWiki file

  1. From then on, you can easily add the plugin to any new TiddlyWiki file you create just by repeating PART TWO above… or, if you create your new TiddlyWiki file by copying your existing TiddlyWiki file and deleting the non-system tiddlers, the AutoSaver plugin will already be installed.

DONE.

4 Likes