[tw5] [TW5] Save Changes button, Action before saving changes

I am sucessfully using a tiddler to restrict access to parts of the wiki with selective tagging, reveal and some style sheets but have run into a problem, when I want to type in the “key” its getting saved to a tiddler ($:/state/GMKey).

Onto my problem… I would like to try and hook into the start of the save process so I can clear the contents of that tiddler before the save actually happens, if I can do that then I might be able to save temporarily using a set and then put it back afterwards…

The only other solution I can think of is to save it somewhere other than $:/state/GMKey like, I know the PAT key for Github saving isn’t saved as part of the wiki, but I don’t have the first clue where to start digging to find that, or how I could save to a similar location, and how I could then READ from that location in the to control stuff…

A slightly older version of what I am playing with can be found here http://gmsandbox.eaglesroost.org/ Select “Ross” and then put in 98631635 and edit mode should then work, what I am looking to do is clear that 98631635 before saving (and restore it after if possible)

Thanks in Advance!

You can prevent a tiddler from being saved in the file by creating a global macro named publishFilter() that removes the specific tiddler title, like this:

Create a tiddler (e.g., “MyPublishFilter”), tagged with $:/tags/Macro, containing:

\define publishFilter()
-[[$:/state/GMKey]]
\end

The contents of the publishFilter() macro are automatically appended to the saveTiddlerFilter() filter definition contained in $:/core/save/all which is then used by $:/core/templates/tiddlywiki5.html to determine which tiddlers will be saved to the TiddlyWiki file.

Notes:

  • Each listed tiddler title should be preceded by a minus sign, so that those titles are excluded from the file.
  • The publishFilter() macro can use any valid filter syntax. Thus, in addition to automatically excluding specific tiddler titles, you can exclude an entire set of matching titles. For example, if you were to specify -[prefix[$:/state]], then ALL $:/state tiddler would be excluded from the file when it is saved.
  • The publishFilter() definition doesn’t remove the tiddlers from the currently loaded TiddlyWiki… it just prevents those tiddler from being saved to the file so they won’t be there the next time you re-load.

enjoy,
-e

3 Likes

Thankyou! I think thats going to work!

(Thankyou again as In the mean time I had actually found the tiddler for the save button, but, trying to write to $:/state/GMKey BEFORE saving wasn’t working, well, that or I was doing something wrong… I was probably doing something wrong!)