turnermm / Updatable-Snippets-for-Dokuwiki

Inserts updatable snippets into Dokuwiki pages
https://dokuwiki.org/plugin:snippets
GNU General Public License v2.0
6 stars 4 forks source link

add option to autoload new snippet versions #24

Open lisps opened 7 years ago

lisps commented 7 years ago

old revisions are ignored now

turnermm commented 7 years ago

Could you give a brief description of what the changes do? Thanks.

lisps commented 7 years ago

sure I added Doku_Event to the event function callbacks as described in https://www.dokuwiki.org/devel:action_plugins#event_handler_method

I added the config flag autoload_updated_snippets and set it per default to 1
I changed handle_wiki_read event callback function which is called when wiki reads the raw wiki file. There I checked if they read an revision page and exit the function. If the config flag autoload_updated_snippets is set to 0 then the function will also exit without doing anything.

turnermm commented 7 years ago

I had a chance to look this over. Here are the mechanics. If the snippet is already embedded in the datafile, the plugin checks to see if the snippet is the current version and if so, it replaces the old version with the new version. If you load a revision into the browser before an updated version of the datafile is saved to disk, the current version of the snippet is inserted into the revision.

In your update to the plugin, the current snippet is never inserted into revisions. That does make sense. On the other hand, you could argue that one of the drawbacks of the current implementation is that the user never gets a chance to auto-insert an updated snippet once the datafile has been updated. But I can imagine situations where a user wants to edit a revision and use the current version of the snippet. So, ideally, we should have a way that the user can make a choice between using or not using the current snippet when editing a revision. I can imagine this being done by displaying both the new version and the old in the browser and adding either a set of radio buttons or check boxes to submission form.

lisps commented 7 years ago

ok maybe we can solve it this way. If the user wants to revert to an old revision he can still do this, save and then the plugin will load the new version if autoload_updated_snippets is set.

This wont work now because the plugin is checking the page filemtime instead of the real snippet version used. This should nevertheless be the case, right?

turnermm commented 7 years ago

This is definitely a possibility and would be easy enough to change. I'll take a look at it.

turnermm commented 7 years ago

See my revisions at https://github.com/turnermm/Updatable-Snippets-for-Dokuwiki/pull/26