1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-17 23:34:50 +00:00

Merge branch 'master' into demo-alternate-store

This commit is contained in:
jeremy@jermolene.com 2023-06-29 15:49:04 +01:00
commit 6ded5e68bf
3 changed files with 45 additions and 7 deletions

View File

@ -4,7 +4,7 @@ description: Saves a wiki to a new wiki folder
<<.from-version "5.1.20">> Saves the current wiki as a wiki folder, including tiddlers, plugins and configuration:
```
--savewikifolder <wikifolderpath> [<filter>]
--savewikifolder <wikifolderpath> [<filter>] [ [<name>=<value>] ]*
```
* The target wiki folder must be empty or non-existent
@ -12,8 +12,19 @@ description: Saves a wiki to a new wiki folder
* Plugins from the official plugin library are replaced with references to those plugins in the `tiddlywiki.info` file
* Custom plugins are unpacked into their own folder
The following options are supported:
* ''filter'': a filter expression that defines the tiddlers to include in the output.
* ''explodePlugins'': set to "no" to save plugins to the tiddlers directory of the target wiki folder, to suppress breaking plugins into their constituent shadow tiddlers (default is "yes").
A common usage is to convert a TiddlyWiki HTML file into a wiki folder:
```
tiddlywiki --load ./mywiki.html --savewikifolder ./mywikifolder
```
Save the plugin to the tiddlers directory of the target wiki folder:
```
tiddlywiki --load ./mywiki.html --savewikifolder ./mywikifolder explodePlugins=no
```

View File

@ -5,7 +5,14 @@ module-type: command
Command to save the current wiki as a wiki folder
--savewikifolder <wikifolderpath> [<filter>]
--savewikifolder <wikifolderpath> [ [<name>=<value>] ]*
The following options are supported:
* ''filter'': a filter expression defining the tiddlers to be included in the output
* ''explodePlugins'': set to "no" to suppress exploding plugins into their constituent shadow tiddlers (defaults to "yes")
Supports backward compatibility with --savewikifolder <wikifolderpath> [<filter>] [ [<name>=<value>] ]*
\*/
(function(){
@ -35,14 +42,28 @@ Command.prototype.execute = function() {
if(this.params.length < 1) {
return "Missing wiki folder path";
}
var wikifoldermaker = new WikiFolderMaker(this.params[0],this.params[1],this.commander);
var regFilter = /^[a-zA-Z0-9\.\-_]+=/g, // dynamic parameters
namedParames,
tiddlerFilter,
options = {};
if (regFilter.test(this.params[1])) {
namedParames = this.commander.extractNamedParameters(this.params.slice(1));
tiddlerFilter = namedParames.filter || "[all[tiddlers]]";
} else {
namedParames = this.commander.extractNamedParameters(this.params.slice(2));
tiddlerFilter = this.params[1];
}
tiddlerFilter = tiddlerFilter || "[all[tiddlers]]";
options.explodePlugins = namedParames.explodePlugins || "yes";
var wikifoldermaker = new WikiFolderMaker(this.params[0],tiddlerFilter,this.commander,options);
return wikifoldermaker.save();
};
function WikiFolderMaker(wikiFolderPath,wikiFilter,commander) {
function WikiFolderMaker(wikiFolderPath,wikiFilter,commander,options) {
this.wikiFolderPath = wikiFolderPath;
this.wikiFilter = wikiFilter || "[all[tiddlers]]";
this.wikiFilter = wikiFilter;
this.commander = commander;
this.explodePlugins = options.explodePlugins;
this.wiki = commander.wiki;
this.savedPaths = []; // So that we can detect filename clashes
}
@ -93,10 +114,13 @@ WikiFolderMaker.prototype.save = function() {
self.log("Adding built-in plugin: " + libraryDetails.name);
newWikiInfo[libraryDetails.type] = newWikiInfo[libraryDetails.type] || [];
$tw.utils.pushTop(newWikiInfo[libraryDetails.type],libraryDetails.name);
} else {
} else if(self.explodePlugins !== "no") {
// A custom plugin
self.log("Processing custom plugin: " + title);
self.saveCustomPlugin(tiddler);
} else if(self.explodePlugins === "no") {
self.log("Processing custom plugin to tiddlders folder: " + title);
self.saveTiddler("tiddlers", tiddler);
}
} else {
// Ordinary tiddler

View File

@ -67,6 +67,7 @@ Secondly, the new [[substitute operator|substitute Operator]] allows the same te
Improvements to the following translations:
* French
* German
* Polish
* Chinese
@ -113,6 +114,7 @@ Improvements to the following translations:
* <<.link-badge-extended "https://github.com/Jermolene/TiddlyWiki5/pull/7471">> [[WebServer Parameter: authenticated-user-header]] to require URI encoding of authenticated username header, permitting non-ASCII characters in usernames
* <<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/pull/7253">> support for `filepath` source attribute to [[tiddlywiki.files Files]]
* <<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/commit/48b22abdaab62c281c207127c66883b50898f9dd">> a warning message for JSON errors in [[tiddlywiki.info Files]] or [[plugin.info Files|PluginFolders]]
* <<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/pull/7490">> new "explodePlugins" option to SaveWikiFolderCommand
! Performance Improvements
@ -128,7 +130,7 @@ Arlen22
BramChen
btheado
buggyj
carlo-carlombo
carlo-colombo
cdruan
donmor
EvidentlyCube
@ -146,6 +148,7 @@ rmunn
saqimtiaz
tavin
twMat
xcazin
yaisog
Zacharia2
""">>