add info about SystemTag: $:/tags/InjectCustomTiddlers to the dev edition

This commit is contained in:
pmario 2024-03-11 16:59:18 +01:00
parent e67eaca030
commit 6971f256a3
2 changed files with 88 additions and 2 deletions

View File

@ -1,10 +1,19 @@
created: 20140708085814626
modified: 20210525165526997
modified: 20240311154305433
tags: doc
title: Data Storage
type: text/vnd.tiddlywiki
~TiddlyWiki has two approaches to saving the user data (tiddlers) depending on whether you are using the single file version, or are using the node.js server.
~TiddlyWiki on node.js saves each tiddler in a separate text file. For details on the file formats supported for tiddlers on node.js, see [[Tiddler Files|https://tiddlywiki.com/#TiddlerFiles]].
!! Client Server Configuration
~TiddlyWiki on node.js saves each tiddler in a separate text file. For details on the file formats supported for tiddlers on node.js.
Also see: [[Tiddler Files|https://tiddlywiki.com/#TiddlerFiles]]
!! Single File Wiki
The single file version of ~TiddlyWiki saves the tiddlers within the HTML file. See [[Data Storage in Single File TiddlyWiki]]
Also see: [[SystemTag: $:/tags/InjectCustomTiddlers]]

View File

@ -0,0 +1,77 @@
created: 20240311152329217
modified: 20240311154116728
tags: [[Data Storage]]
title: SystemTag: $:/tags/InjectCustomTiddlers
type: text/vnd.tiddlywiki
The [[system tag|http://localhost:8080/#SystemTags]] `$:/tags/InjectCustomTiddlers` marks JSON serialized tiddlers to be injected [[into a custom store section|$:/core/templates/store.injected.template.html]] in the [[generated HTML|$:/core/templates/tiddlywiki5.html]] file.
Note that the wiki must be saved and reloaded in order for the tiddlers to be seen.
!! Example Template Code
This example template injects 4 tiddlers into the custom store.
```
title: $:/core/templates/store.injected.timestamps.template
caption: Inject last-saved and server-created timestamps
tags: $:/tags/InjectCustomTiddlers
<!-- This template will be injected into the html file when the wiki is saved. It is activated by $:/core/templates/store.injected.template.html -->
\whitespace trim
\procedure readableFormat() [UTC]YYYY-0MM-0DD 0hh:0mm:0ss.0XXX UTC TZD
<!-- It's needed to use variables, to have the absolute same timestamp for all tiddlers -->
<$let
timestamp={{{ [<now format:[UTC]YYYY0MM0DD0hh0mm0ss0XXX>] }}}
timeReadable={{{ [<timestamp>format:date<readableFormat>] }}}
>
<% if [{$:/info/browser}match[yes]] %>
`{"title": "$:/info/last-saved/timestamp", "created":"`<<timestamp>>`", "modified":"`<<timestamp>>`", "text":"`<<timestamp>>`"}`
<$text text=<<join>>/>
`{"title": "$:/info/last-saved/date", "created":"`<<timestamp>>`", "modified":"`<<timestamp>>`", "text":"`<<timeReadable>>`"}`
<% elseif [{$:/info/node}match[yes]] %>
`{"title": "$:/info/server-created-wiki/timestamp", "created":"`<<timestamp>>`", "modified":"`<<timestamp>>`", "text":"`<<timestamp>>`"}`
<$text text=<<join>>/>
`{"title": "$:/info/server-created-wiki/date", "created":"`<<timestamp>>`", "modified":"`<<timestamp>>`", "text":"`<<timeReadable>>`"}`
<% endif %>
</$let>
```
!! Last Saved -- Single File Wiki
With the template above, the following tiddlers will be "injected" into the HTML file when the wiki is saved. Tagged template tiddlers are used to create the info tiddlers. Those tiddlers will be overwritten with the next automatic or manual save action.
`$:/info/last-saved/*` will not be created on a server if used with a client-server configuration. They will be created, if a "snapshot" is saved to the disk.
|! Title |! Description |
|$:/info/last-saved/timestamp |<<.from-version "5.3.4">> This tiddler will be created when a single file wiki is saved. It uses ~TiddlyWiki DateFormat |
|$:/info/last-saved/date |<<.from-version "5.3.4">> Shows the same last-saved timestamp in human readable form. Eg: "2024-01-30 15:36:04.430 UTC +01:00"<br>using the following format: `[UTC]YYYY-0MM-0DD 0hh:0mm:0ss.0XXX UTC TZD` |
!! Client Server Configuration
<<.warning """If a client server configuration is used, the TW template is used to create the wiki file on the server. So the timestamps saved to the "server-created" info tiddlers are generated by the server. Depending on the server "local time" this timestamp ''can be different'' to the current "user time". Whenever the wiki file is created, the values will be set. `server-created-*` tiddlers will ''not'' be deleted if saved as a single file. The information may have some value""">>
|! Title |! Description |
|$:/info/server-created-wiki/timestamp |<<.from-version "5.3.4">> This tiddler will be created when the server creates a wiki to be transferred to the client, ''ore'' if as single-file wiki is created by the server using the `--build index` command. It uses ~TiddlyWiki DateFormat |
|$:/info/server-created-wiki/date |<<.from-version "5.3.4">> Shows the same timestamp in human readable form |
!! Additional information
By default ~TiddlyWiki does not save the full URL information to the file, due to privacy concerns. Eg: `$:/info/last-saved/full/url` can contain private information. Users are free to include the following code into their wiki, if they decide to do so.
<details><summary>Show code to add the full path to an info tiddler</summary>
<$codeblock code="""title: inject-full-path
tags: $:/tags/InjectCustomTiddlers
<!-- This template will be injected into the html file when the wiki is saved. It is activated by $:/core/templates/store.info.template.html -->
\whitespace trim
\function timestamp() [<now format:[UTC]YYYY0MM0DD0hh0mm0ss0XXX>]
<% if [{$:/info/browser}match[yes]] %>
<$text text=<<join>>/>
`{"title": "$:/info/last-saved/full/url", "created":"`<<timestamp>>`", "modified":"`<<timestamp>>`", "text":"`{{$:/info/url/full}}`"}`
<% endif %>
"""/>
</details>