Feature: filter operator to identify tiddlers loaded by TiddlyPWA

This commit is contained in:
sunlaud 2025-07-06 21:41:45 +03:00 committed by Val Packett
parent 7ff63eb696
commit 9192a4d45a
4 changed files with 50 additions and 1 deletions

View file

@ -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;
};

View file

@ -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).

View file

@ -5,7 +5,7 @@
"author": "Val Packett", "author": "Val Packett",
"version": "0.2.2", "version": "0.2.2",
"core-version": ">=5.2.0", "core-version": ">=5.2.0",
"list": "readme license", "list": "readme filters license",
"source": "https://codeberg.org/valpackett/tiddlypwa", "source": "https://codeberg.org/valpackett/tiddlypwa",
"demo": "https://tiddly.packett.cool/", "demo": "https://tiddly.packett.cool/",
"plugin-type": "plugin" "plugin-type": "plugin"

View file

@ -16,3 +16,5 @@ please do [[throw some monies her way|https://www.patreon.com/valpackett]] :3
<$action-navigate $to="$:/ControlPanel"/> <$action-navigate $to="$:/ControlPanel"/>
Configure the plugin in the Control Panel Configure the plugin in the Control Panel
</$button> </$button>
See ''filters'' tab for filter operators.