Save to local & upload to host in one button?

So for context, I typically work from a tiddlywiki hosted on tiddlyhost but I’m worried one day I will be in a rush and get called to travel out to a remote post and be left without internet or a copy of my main TW (there is read/write restrictions placed on my work devices that I don’t like to bypass unless for very urgent reasons.)

Is there a way to modify the save button to trigger a local download, as well as save the TW to your hosting platform(s) of choice? (Tiddlyhost, Github, etc.)

You can modify the current save button to include additional actions that allow an interactive local download but you can get into difficulty with the savers if you try to make it do both in the background.

There wouldnt happen to be a way to trigger one after another, or have a check for if one worked and the other didnt (ie couldnt save to server, so downloaded localy twice) would there?

I don’t know if it is of use, but the InfoMechanism can tell if the wikis is on http vs C: etc. But not sure if that means the mechanism can tell if you’re onilne or not but that would certainly be useful.

…but even if that doesn’t work, I’m wondering if TW can tell if a saving was successful or not? I think it should be able to do so because I don’t think the yellow “saved” slides in if it was not saved, right? Maybe some timer mechanism and if it didn’t show within a few seconds, then trigger a local save…?

Maybe @EricShulman here: Startup behaviour using $:/status/UserName? gives some relevant clues, especially bout timers.

1 Like

I am not expert on this, but I believe the savers and download use different mechanisms and you may not be able to get them to communicate.

However it should be easy to get the save button to also trigger a download.

There have being discussions about setting a last saved timestamp that may help.

That would be pretty helpful, if not for this reason then just in general for version control.

a timestamp ckuld be used for comparing tiddlywiki anx preventing accidental overwriting, and a revision counter could also give a way to destingish between mutliple saves during the same period of time.

and thus has given me an idea of having a revision counter for each time a save is made. I imagine it shouldnt be too difficult to do :thinking:

If you use autosave you need a message catcher to trap the save action and add your own. We have had some discussions but I don’t recall the last state of that.

You could abandon the autosave and look to Erics timer trigger, than trigger save and download Startup behaviour using $:/status/UserName? - #2 by EricShulman

One simple thing that might get you closer to what you want is this Download Button.

If you install that, with the tag and the list-after field, then click the “Tools” tab and enable the “download a copy” option, you get a button right next to the save button that always downloads, even when you’re on Tiddlyhost.

So you’ll still need two clicks to save to Tiddlyhost and also download, but with the download button there it should be a little more convenient.

(Creating another button that simulates clicking both of those seems like something that might be possible, but I don’t know how.)

1 Like

Oh! I have a very similar button I named my export button. I used it whenever I bricked my wiki. not too proud of how Often i used it but, lessons were learned lol

I’d forgotten about it honestly, but your right. if there was a way to combine the two into one button, it would be a lot closer to what i was looking for.

You need to use revision field to check loca&cloud which were newer and trigger 1 to 2 times of saves to override the older one.

The only problem with combining the two buttons is jus that. Save wiki (upload) can just start and finish and occur for autosave, if however it also downloads the wiki you will have to use the save as dialogue every time.

If you are happy with this then clone and open $:/core/ui/Buttons/save-wiki then following the line;

<$action-sendmessage $message="tm-save-wiki" $param={{$:/config/SaveWikiButton/Template}} filename=<<site-title>>/>

add the line

<$action-sendmessage $message="tm-download-file" $param={{$:/config/SaveWikiButton/Template}} filename=<<site-title>> filename="mywiki"/>

Clicking the cloned save button will save the wiki then open the save as dialogue, with a filename set. Automatic saves will continue.