diff --git a/plugins/tiddlypwa/filters.js b/plugins/tiddlypwa/filters.js new file mode 100644 index 0000000..e8384f4 --- /dev/null +++ b/plugins/tiddlypwa/filters.js @@ -0,0 +1,36 @@ +/*\ +title: $:/plugins/valpackett/tiddlypwa/filters.js +type: application/javascript +module-type: isfilteroperator + +Filter function for TiddlyPWA-managed tiddler identification + +Licensed under 0BSD, see license.tid. +Formatted with `deno fmt`. +\*/ + +'use strict'; + +exports.tiddlypwa = function (source, prefix, options) { + const results = []; + + const pwaStorage = $tw.syncer.syncadaptor; + if (!pwaStorage || !pwaStorage.tiddlersInFile) { + return ['Error: TiddlyPWA not available']; + } + + if (prefix === '!') { + source(function (tiddler, title) { + if (pwaStorage.tiddlersInFile.has(title)) { + results.push(title); + } + }); + } else { + source(function (tiddler, title) { + if (!pwaStorage.tiddlersInFile.has(title)) { + results.push(title); + } + }); + } + return results; +}; diff --git a/plugins/tiddlypwa/filters.tid b/plugins/tiddlypwa/filters.tid new file mode 100644 index 0000000..824f315 --- /dev/null +++ b/plugins/tiddlypwa/filters.tid @@ -0,0 +1,11 @@ +title: $:/plugins/valpackett/tiddlypwa/filters + +!!! Filter Operators + +TiddlyPWA provides filter operator to identify tiddlers it manages: + +* `[is[tiddlypwa]]` - tiddlers created/loaded by TiddlyPWA (from local DB or server) +* `[!is[tiddlypwa]]` - inversion of the above, i.e. tiddlers loaded from app wiki html file + +This may be useful to find system tiddlers created by you, or to check shadow tiddler origins +(app file vs DB/server) or when exporting (to e.g. backup everything stored on server including system tiddlers). \ No newline at end of file diff --git a/plugins/tiddlypwa/plugin.info b/plugins/tiddlypwa/plugin.info index f4ab32b..bdcc8e8 100644 --- a/plugins/tiddlypwa/plugin.info +++ b/plugins/tiddlypwa/plugin.info @@ -5,7 +5,7 @@ "author": "Val Packett", "version": "0.2.2", "core-version": ">=5.2.0", - "list": "readme license", + "list": "readme filters license", "source": "https://codeberg.org/valpackett/tiddlypwa", "demo": "https://tiddly.packett.cool/", "plugin-type": "plugin" diff --git a/plugins/tiddlypwa/readme.tid b/plugins/tiddlypwa/readme.tid index 4a77793..0aedf59 100644 --- a/plugins/tiddlypwa/readme.tid +++ b/plugins/tiddlypwa/readme.tid @@ -16,3 +16,5 @@ please do [[throw some monies her way|https://www.patreon.com/valpackett]] :3 <$action-navigate $to="$:/ControlPanel"/> Configure the plugin in the Control Panel + +See ''filters'' tab for filter operators. \ No newline at end of file