Learn about DokuWiki
Learn about DokuWiki
The user decides when inserting the snippet whether or not to track revisions. In addition to the checkbox for
keeping the window open, there is now a checkbox to check for updates to the snippet:
By default the box is checked. This can be changed in the Configuration Settings. When the
updateable box is checked, the plugin is wrapped in a header and a footer which indicate that this instance of the snippet should be tracked and updated in the current page whenever the snippet is updated.
The header markup looks like this:
~~SNIPPET_O1423002180~~snippet_1~~, where the embedded number is the timestamp for when the snippet was embedded in the page. This changes every time the snippet is updated. The footer looks llike this:
If a snippet is not marked for updating, then it will not change when the snippet is revised but will be a permanent part of the page. This means that the same snippet can be used for both a permanent part of one page and a mutating part of another.
Namespace templates can be used as snippets. There are two ways to do this:
templ_must be included in the directory. When creating the listing of snippets, this empty page must be listed as a snippet. When this empty page is selected, the template data will be inserted in its place.
templ. Then a namespace template and an empty file can be placed in this directory which will be used as described in (1) above. This directory can also be hidden using the
hidepagesoption by excluding files with this
These snippets cannot be updatable. The
hidepages option can be used to exclude both pages beginning with
templ_ and the
templ directory with the following expression
templ:|templ_ in the
The plugin keeps track of its updatable snippets in a meta file consisting of a serialized multi-dimensional array and in the meta files created by Dokluwiki for each of its pages. The plugin's meta file is found in the meta directory:
data/meta/snippets_upd.ser. Its structure is as follows:
$snip:an array of page ids of updatable snippets which have been inserted into pages. Each snippet id is an array of the pages into which it has been inserted:
$page_id. . .
$doc: an array of ids of the pages into which updatable snippets have been inserted. Each id is in turn an array of the snippet names which have been inserted into that page:
$snippet_id. . .
This scheme is illustrated diagramatically below.
The page metafiles keep lists of inserted snippets and their timestamps. Before inserting a snippet into a page, the timestamp of the snippet is checked against the snippet's timestamp held in the metafile. If they are the same, then the snippet has already been inserted and the plugin knows not to re-insert it.
On the admin page, under “Additional Plugins”, there is a tool for reconciling any differences between what might be on your pages and what might be listed in the database.