Plugin: make save dialog friendly and tabbed

This commit is contained in:
Val Packett 2023-06-25 02:34:42 -03:00
parent b7abd70d90
commit 6fba1691c9
5 changed files with 106 additions and 61 deletions

View file

@ -70,6 +70,14 @@ Formatted with `deno fmt`.
return url === `${location.origin}${location.pathname}${location.search}`;
}
function saveToApp(title) {
return title.startsWith('$:/themes/') ||
title.startsWith('$:/plugins/') ||
title.startsWith('$:/languages/');
}
$tw.wiki.doesPluginInfoRequireReload = (x) => x && x.tiddlers && Object.keys(x.tiddlers).find(saveToApp);
class PWAStorage {
constructor(options) {
this.wiki = options.wiki;
@ -699,12 +707,7 @@ Formatted with `deno fmt`.
// For some reason this is not in the default $:/config/SyncFilter but no one would want this actually stored.
return cb(null, '', 1);
}
if (
tiddler.fields.title.startsWith('$:/themes/') ||
tiddler.fields.title.startsWith('$:/plugins/') ||
tiddler.fields.title.startsWith('$:/languages/')
) {
// Those should go into the saved wiki file.
if (saveToApp(tiddler.fields.title)) {
// Attempting to only direct the `doesPluginRequireReload` ones into the file does not seem worth it.
// By ignoring the callback we make TW think there's something unsaved now, which there is!
return;

View file

@ -0,0 +1,43 @@
title: $:/plugins/valpackett/tiddlypwa/save-dialog-app
tags: $:/tags/TiddlyPWA/SaveDialog
caption: Advanced App Management
\define tv-wikilinks() no
<$reveal type="match" state="$:/isEncrypted" text="yes">
TiddlyWiki single-file password must not be used when doing this, please disable it: {{$:/core/ui/Buttons/encryption}}
</$reveal>
<$reveal type="nomatch" state="$:/isEncrypted" text="yes">
To update the wiki file that is used as the TiddlyPWA application (''this is the kind of save you want to install plugins/themes''), you can
<$button>
<$action-sendmessage $message="tm-download-file" publishFilter={{$:/plugins/valpackett/tiddlypwa/app-filter}} />
save this wiki without content
</$button>
<$reveal type="nomatch" state="$:/status/TiddlyPWAUploading" text="yes">
or directly
<$button>
<$action-sendmessage $message="tiddlypwa-upload-app-wiki" publishFilter={{$:/plugins/valpackett/tiddlypwa/app-filter}} />
upload it to sync servers
</$button>
</$reveal>!
<details>
<summary>Or even upload to a sync server you are not currently syncing with…</summary>
{{$:/plugins/valpackett/tiddlypwa/upload-app-form}}
</details>
{{$:/status/TiddlyPWAUploadResult}}
Note that some basic configuration like the title, subtitle, favicon, theme and palette will be saved unencrypted.
<details>
<summary>Specifically, these tiddlers will be saved…</summary>
<ul>
<$list filter={{$:/plugins/valpackett/tiddlypwa/app-filter}}>
<li><<currentTiddler>></li>
</$list>
</ul>
</details>
</$reveal>

View file

@ -0,0 +1,14 @@
title: $:/plugins/valpackett/tiddlypwa/save-dialog-export
tags: $:/tags/TiddlyPWA/SaveDialog
caption: Export Single-File
\define tv-wikilinks() no
To make a single-file export/backup of the wiki, you can {{$:/core/ui/Buttons/encryption}} if you want and
<$button>
<$action-sendmessage $message="tm-download-file" publishFilter="-[[$:/HistoryList]] -[[$:/StoryList]] -[[$:/isEncrypted]] -[[$:/UploadName]] -[prefix[$:/state/]] -[prefix[$:/status/]] -[prefix[$:/temp/]] -[prefix[$:/plugins/valpackett/tiddlypwa]]"/>
save this wiki without TiddlyPWA
</$button>.
Note that the password configured via the button above will ''only'' apply to wiki files exported via this save button.
It is completely independent of the TiddlyPWA storage password.

View file

@ -0,0 +1,22 @@
title: $:/plugins/valpackett/tiddlypwa/save-dialog-sync
tags: $:/tags/TiddlyPWA/SaveDialog
caption: Sync Status
\define tv-wikilinks() no
<table style="width:100%">
<thead>
<tr>
<td>Server</td>
<td>Last synced change</td>
</tr>
</thead>
<$list filter="[tag[$:/temp/TiddlyPWAServer]]">
<tr>
<td>{{!!url}}</td>
<td style="width:35%">{{!!lastSync}}</td>
</tr>
</$list>
</table>
{{$:/plugins/valpackett/tiddlypwa/sync-status}}

View file

@ -1,75 +1,38 @@
title: $:/plugins/valpackett/tiddlypwa/save-dialog
subtitle: Saving and Exporting
!! Sync status
<table style="width:100%">
<thead>
<tr>
<td>Server</td>
<td>Last synced change</td>
</tr>
</thead>
<$list filter="[tag[$:/temp/TiddlyPWAServer]]">
<tr>
<td>{{!!url}}</td>
<td style="width:35%">{{!!lastSync}}</td>
</tr>
</$list>
</table>
{{$:/plugins/valpackett/tiddlypwa/sync-status}}
!! Export as ordinary single-file ~TiddlyWiki
\define tv-wikilinks() no
<$set name="tv-config-toolbar-icons" value="yes">
<$set name="tv-config-toolbar-text" value="yes">
<$set name="tv-config-toolbar-class" value="">
To make a single-file backup of the wiki, you can {{$:/core/ui/Buttons/encryption}} &
<$button>
<$action-sendmessage $message="tm-download-file" publishFilter="-[[$:/HistoryList]] -[[$:/StoryList]] -[[$:/isEncrypted]] -[[$:/UploadName]] -[prefix[$:/state/]] -[prefix[$:/status/]] -[prefix[$:/temp/]] -[prefix[$:/plugins/valpackett/tiddlypwa]]"/>
save this wiki without ~TiddlyPWA
</$button>.
<$reveal type="match" state="$:/status/RequireReloadDueToPluginChange" text="yes">
Note that the native ~TiddlyWiki password that is configured via the button above will ''only''
apply to files saved via this save button — it is completely independent of the ~TiddlyPWA storage password.
!! Export as ~TiddlyPWA app wiki
To finish the installation of plugins/themes/languages, you need to save and reload the app:
<$reveal type="match" state="$:/isEncrypted" text="yes">
~TiddlyWiki single-file password must not be used when doing this, please unset it using the "clear password" button above.
But first, disable single-file encryption: {{$:/core/ui/Buttons/encryption}}!
</$reveal>
<$reveal type="nomatch" state="$:/isEncrypted" text="yes">
To update the wiki file that is used as the ~TiddlyPWA application (''this is the kind of save you want to install plugins/themes''), you can
<$button>
<$action-sendmessage $message="tm-download-file" publishFilter={{$:/plugins/valpackett/tiddlypwa/app-filter}} />
save this wiki without content
</$button>
<$reveal type="nomatch" state="$:/status/TiddlyPWAUploading" text="yes">
or directly
<$button>
<$action-sendmessage $message="tiddlypwa-upload-app-wiki" publishFilter={{$:/plugins/valpackett/tiddlypwa/app-filter}} />
upload it to sync servers
</$button>
</$reveal>!
<details>
<summary>Or even upload to a sync server you are not currently syncing with…</summary>
{{$:/plugins/valpackett/tiddlypwa/upload-app-form}}
</details>
Upload it to sync servers
</$button>!
</$reveal>
</$reveal>
{{$:/status/TiddlyPWAUploadResult}}
Note that some basic configuration like the title, subtitle, favicon, theme and palette will be saved unencrypted.
<details>
<summary>Specifically, these tiddlers will be saved…</summary>
<ul>
<$list filter={{$:/plugins/valpackett/tiddlypwa/app-filter}}>
<li><<currentTiddler>></li>
</$list>
</ul>
</details>
You can also use the "Advanced App Management" tab below to upload the app with these modifications to any other server or save it locally.
</$reveal>
<$reveal type="nomatch" state="$:/status/RequireReloadDueToPluginChange" text="yes">
TiddlyPWA saves and syncs your content automatically! However, here you can find options to export your content
and manually manage the app files.
</$reveal>
<$macrocall $name="tabs" tabsList="[all[tiddlers+shadows]tag[$:/tags/TiddlyPWA/SaveDialog]!has[draft.of]]"
default="$:/plugins/valpackett/tiddlypwa/save-dialog-sync" explicitState="$:/state/tab--28743853"/>