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

Updating snippets that are inserted by templates #33

Closed kruff-a-lon closed 5 years ago

kruff-a-lon commented 7 years ago

Hi, I want to use this plugin to handle instructions to editors of my wiki.

My intention

To make things clear, what I want to accomplish is to:

Using the comment plugin to add comments to templates (using TemplatePageName). These comments should then be updated in the final pages when I update the snippet.

Current setup

I have the following files: snippets:comment_dont_edit_directly

/* !WARNING! **
** !WARNING! **  DON'T EDIT THIS PAGE DIRECTLY IN THIS TEXT-AREA
** !WARNING! **  USE THE FORM BELOW TO ENTER DATA. THANKS! <3 <3
** !WARNING! */

commander_skills:c_template

~~SNIPPET_O1509280532~~snippets:comment_dont_edit_directly~~
/* !WARNING! **
** !WARNING! **  DON'T EDIT THIS PAGE DIRECTLY IN THIS TEXT-AREA
** !WARNING! **  USE THE FORM BELOW TO ENTER DATA. THANKS! <3 <3
** !WARNING! */
~~SNIPPET_C~~:snippets:comment_dont_edit_directly~~

====== @!!PAGE@  ======

commander_skills:false_rally

~~SNIPPET_O1509280532~~snippets:comment_dont_edit_directly~~
/* !WARNING! **
** !WARNING! **  DON'T EDIT THIS PAGE DIRECTLY IN THIS TEXT-AREA
** !WARNING! **  USE THE FORM BELOW TO ENTER DATA. THANKS! <3 <3
** !WARNING! */
~~SNIPPET_C~~:snippets:comment_dont_edit_directly~~

====== False Rally  ======

Problem

When I make changes to the file snippets:comment_dont_edit_directly it doesn't propagate the way I expect it to the actual file: commander_skills:false_rally.

What I think happens

I haven't looked into the code, and I'm very new to dokuwiki in general, so this probably doesn't make any sense, still...

When a snippet is inserted into a page with the toolbar button a script is invoked to update the database that keeps track of what pages has snippets in them and what snippets they are.

So, when a snippet is inserted by other means, from a template or by copy/paste the plugin doesn't really know about it.

Help I hope to get

I hope that we can find a way to update snippets that where inserted by other means, hopefully it could be something 'simple' like attaching an action to the standard save-page and preview-page actions present in the editor.

turnermm commented 7 years ago

A bit Byzantine. First, the snippets plugin does not know about the c_type plugin templates, in case you are thinking about using them as snippets instead of the standard namespace templates. Secondly, the contents of templates are a one-time only insertion, when the file is accessed in the editor. Once the file is saved the contents don't update. But perhaps I don't understand this.

kruff-a-lon commented 7 years ago

Hm, well, unfortunately I had to wipe this particular instance of dokuwiki for unrelated problems...

But I don't think it's a problem with using the TemplatePageName plugin, since those get updated.

The problem for me is that for pages where I haven't used the Toolbar-button to insert the snippets the snippet-contents aren't getting updated when I edit the snippet.

This makes me think that the database for keeping records on what snippets are inserted in what pages is handled by the GUI accessible by the ToolBar-button.

If this is correct I wonder if there is anyway to force your plugin to check if a certain page (or collection of pages) have snippets in them and update the database with that information. Alternatively if there is a way to force your plugin to do it's thing on all 'save's and 'preview's.

I understand that my usecase is different from the one you intended so not a big deal if it is not possible.

turnermm commented 7 years ago

But I don't think it's a problem with using the TemplatePageName plugin, since those get updated.

That's not my understanding, though I have never used it. Presumably it's a namespace template that is editable from the dw editor, otherwise functions the same as dw's, in which case it does not update the contents on the page where its contents have been inserted.

To insert an updatable snippet you have to use the toolbar and make sure that the updatable box is checked. If a snippet has been updated, you will get a chance to update all of the pages in which it is embedded. When a page with a snippet is loaded the plugin checks to see if a new version is available.
"Force", therefore is not applicable.

See the documentation.

turnermm commented 7 years ago

The problem for me is that for pages where I haven't used the Toolbar-button to insert the snippets the snippet-contents aren't getting updated when I edit the snippet

Also, I'm not sure in what way that is a 'snippet'. Or do you simply mean that you copy and paste--in which case there's no way that the snippet plugin can track it.