1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-24 17:10:29 +00:00

Adds support for autosave with the download saver

Also does some reorganisation of control panel to move “saving” related
settings together, and expose a UI for savers to plug into.

Fixes #2741
This commit is contained in:
Jermolene 2017-01-30 18:19:28 +00:00
parent 56b6781715
commit b5059c612a
8 changed files with 90 additions and 46 deletions

View File

@ -80,10 +80,17 @@ Plugins/Reinstall/Caption: reinstall
Plugins/Themes/Caption: Themes Plugins/Themes/Caption: Themes
Plugins/Themes/Hint: Theme plugins Plugins/Themes/Hint: Theme plugins
Saving/Caption: Saving Saving/Caption: Saving
Saving/Heading: Saving Saving/DownloadSaver/AutoSave/Description: Permit automatic saving for the download saver
Saving/DownloadSaver/AutoSave/Hint: Enable Autosave for Download Saver
Saving/DownloadSaver/Caption: Download Saver
Saving/DownloadSaver/Hint: These settings apply to the HTML5-compatible download saver
Saving/General/Caption: General
Saving/General/Hint: These settings apply to all the loaded savers
Saving/Hint: Settings used for saving the entire TiddlyWiki as a single file via a saver module
Saving/TiddlySpot/Advanced/Heading: Advanced Settings Saving/TiddlySpot/Advanced/Heading: Advanced Settings
Saving/TiddlySpot/BackupDir: Backup Directory Saving/TiddlySpot/BackupDir: Backup Directory
Saving/TiddlySpot/Backups: Backups Saving/TiddlySpot/Backups: Backups
Saving/TiddlySpot/Caption: ~TiddlySpot Saver
Saving/TiddlySpot/Description: These settings are only used when saving to http://tiddlyspot.com or a compatible remote server Saving/TiddlySpot/Description: These settings are only used when saving to http://tiddlyspot.com or a compatible remote server
Saving/TiddlySpot/Filename: Upload Filename Saving/TiddlySpot/Filename: Upload Filename
Saving/TiddlySpot/Heading: ~TiddlySpot Saving/TiddlySpot/Heading: ~TiddlySpot
@ -95,7 +102,7 @@ Saving/TiddlySpot/UserName: Wiki Name
Settings/AutoSave/Caption: Autosave Settings/AutoSave/Caption: Autosave
Settings/AutoSave/Disabled/Description: Do not save changes automatically Settings/AutoSave/Disabled/Description: Do not save changes automatically
Settings/AutoSave/Enabled/Description: Save changes automatically Settings/AutoSave/Enabled/Description: Save changes automatically
Settings/AutoSave/Hint: Automatically save changes during editing Settings/AutoSave/Hint: Attempt to automatically save changes during editing when using a supporting saver
Settings/CamelCase/Caption: Camel Case Wiki Links Settings/CamelCase/Caption: Camel Case Wiki Links
Settings/CamelCase/Hint: You can globally disable automatic linking of ~CamelCase phrases. Requires reload to take effect Settings/CamelCase/Hint: You can globally disable automatic linking of ~CamelCase phrases. Requires reload to take effect
Settings/CamelCase/Description: Enable automatic ~CamelCase linking Settings/CamelCase/Description: Enable automatic ~CamelCase linking

View File

@ -55,10 +55,19 @@ Information about this saver
*/ */
DownloadSaver.prototype.info = { DownloadSaver.prototype.info = {
name: "download", name: "download",
priority: 100, priority: 100
capabilities: ["save", "download"]
}; };
Object.defineProperty(DownloadSaver.prototype.info, "capabilities", {
get: function() {
var capabilities = ["save", "download"];
if(($tw.wiki.getTextReference("$:/config/DownloadSaver/AutoSave") || "").toLowerCase() === "yes") {
capabilities.push("autosave");
}
return capabilities;
}
});
/* /*
Static method that returns true if this saver is capable of working Static method that returns true if this saver is capable of working
*/ */

View File

@ -2,35 +2,8 @@ title: $:/core/ui/ControlPanel/Saving
tags: $:/tags/ControlPanel tags: $:/tags/ControlPanel
caption: {{$:/language/ControlPanel/Saving/Caption}} caption: {{$:/language/ControlPanel/Saving/Caption}}
\define lingo-base() $:/language/ControlPanel/Saving/ {{$:/language/ControlPanel/Saving/Hint}}
\define backupURL()
http://$(userName)$.tiddlyspot.com/backup/
\end
\define backupLink()
<$reveal type="nomatch" state="$:/UploadName" text="">
<$set name="userName" value={{$:/UploadName}}>
<$reveal type="match" state="$:/UploadURL" text="">
<<backupURL>>
</$reveal>
<$reveal type="nomatch" state="$:/UploadURL" text="">
<$macrocall $name=resolvePath source={{$:/UploadBackupDir}} root={{$:/UploadURL}}>>
</$reveal>
</$set>
</$reveal>
\end
! <<lingo TiddlySpot/Heading>>
<<lingo TiddlySpot/Description>> <div class="tc-control-panel">
<<tabs "[all[shadows+tiddlers]tag[$:/tags/ControlPanel/Saving]!has[draft.of]]" "$:/core/ui/ControlPanel/Saving/General">>
|<<lingo TiddlySpot/UserName>> |<$edit-text tiddler="$:/UploadName" default="" tag="input"/> | </div>
|<<lingo TiddlySpot/Password>> |<$password name="upload"/> |
|<<lingo TiddlySpot/Backups>> |<<backupLink>> |
''<<lingo TiddlySpot/Advanced/Heading>>''
|<<lingo TiddlySpot/ServerURL>> |<$edit-text tiddler="$:/UploadURL" default="" tag="input"/> |
|<<lingo TiddlySpot/Filename>> |<$edit-text tiddler="$:/UploadFilename" default="index.html" tag="input"/> |
|<<lingo TiddlySpot/UploadDir>> |<$edit-text tiddler="$:/UploadDir" default="." tag="input"/> |
|<<lingo TiddlySpot/BackupDir>> |<$edit-text tiddler="$:/UploadBackupDir" default="." tag="input"/> |
<<lingo TiddlySpot/Hint>>

View File

@ -0,0 +1,11 @@
title: $:/core/ui/ControlPanel/Saving/DownloadSaver
tags: $:/tags/ControlPanel/Saving
caption: {{$:/language/ControlPanel/Saving/DownloadSaver/Caption}}
\define lingo-base() $:/language/ControlPanel/Saving/DownloadSaver/
<<lingo Hint>>
!! <$link to="$:/config/DownloadSaver/AutoSave"><<lingo AutoSave/Hint>></$link>
<$checkbox tiddler="$:/config/DownloadSaver/AutoSave" field="text" checked="yes" unchecked="no" default="no"> <<lingo AutoSave/Description>> </$checkbox>

View File

@ -0,0 +1,16 @@
title: $:/core/ui/ControlPanel/Saving/General
tags: $:/tags/ControlPanel/Saving
caption: {{$:/language/ControlPanel/Saving/General/Caption}}
list-before:
\define lingo-base() $:/language/ControlPanel/Settings/
{{$:/language/ControlPanel/Saving/General/Hint}}
!! <$link to="$:/config/AutoSave"><<lingo AutoSave/Caption>></$link>
<<lingo AutoSave/Hint>>
<$radio tiddler="$:/config/AutoSave" value="yes"> <<lingo AutoSave/Enabled/Description>> </$radio>
<$radio tiddler="$:/config/AutoSave" value="no"> <<lingo AutoSave/Disabled/Description>> </$radio>

View File

@ -0,0 +1,36 @@
title: $:/core/ui/ControlPanel/Saving/TiddlySpot
tags: $:/tags/ControlPanel/Saving
caption: {{$:/language/ControlPanel/Saving/TiddlySpot/Caption}}
\define lingo-base() $:/language/ControlPanel/Saving/TiddlySpot/
\define backupURL()
http://$(userName)$.tiddlyspot.com/backup/
\end
\define backupLink()
<$reveal type="nomatch" state="$:/UploadName" text="">
<$set name="userName" value={{$:/UploadName}}>
<$reveal type="match" state="$:/UploadURL" text="">
<<backupURL>>
</$reveal>
<$reveal type="nomatch" state="$:/UploadURL" text="">
<$macrocall $name=resolvePath source={{$:/UploadBackupDir}} root={{$:/UploadURL}}>>
</$reveal>
</$set>
</$reveal>
\end
<<lingo Description>>
|<<lingo UserName>> |<$edit-text tiddler="$:/UploadName" default="" tag="input"/> |
|<<lingo Password>> |<$password name="upload"/> |
|<<lingo Backups>> |<<backupLink>> |
''<<lingo Advanced/Heading>>''
|<<lingo ServerURL>> |<$edit-text tiddler="$:/UploadURL" default="" tag="input"/> |
|<<lingo Filename>> |<$edit-text tiddler="$:/UploadFilename" default="index.html" tag="input"/> |
|<<lingo UploadDir>> |<$edit-text tiddler="$:/UploadDir" default="." tag="input"/> |
|<<lingo BackupDir>> |<$edit-text tiddler="$:/UploadBackupDir" default="." tag="input"/> |
<<lingo TiddlySpot/Hint>>

View File

@ -1,11 +0,0 @@
title: $:/core/ui/ControlPanel/Settings/AutoSave
tags: $:/tags/ControlPanel/Settings
caption: {{$:/language/ControlPanel/Settings/AutoSave/Caption}}
\define lingo-base() $:/language/ControlPanel/Settings/AutoSave/
<$link to="$:/config/AutoSave"><<lingo Hint>></$link>
<$radio tiddler="$:/config/AutoSave" value="yes"> <<lingo Enabled/Description>> </$radio>
<$radio tiddler="$:/config/AutoSave" value="no"> <<lingo Disabled/Description>> </$radio>

View File

@ -0,0 +1,3 @@
title: $:/config/DownloadSaver/AutoSave
no