diff --git a/bld.cmd b/bld.cmd index 01f71807f..9d803d2b0 100644 --- a/bld.cmd +++ b/bld.cmd @@ -40,6 +40,15 @@ node .\tiddlywiki.js ^ --build favicon empty static index ^ || exit 1 +rem upgrade.html: custom edition for handling upgrades + +node .\tiddlywiki.js ^ + .\editions\upgrade ^ + --verbose ^ + --output %TW5_BUILD_OUTPUT% ^ + --build upgrade ^ + || exit 1 + rem encrypted.html: a version of the main file encrypted with the password "password" node .\tiddlywiki.js ^ diff --git a/bld.sh b/bld.sh index f77eb6345..ad707acd9 100755 --- a/bld.sh +++ b/bld.sh @@ -41,6 +41,15 @@ node ./tiddlywiki.js \ --build favicon empty static index \ || exit 1 +# upgrade.html: custom edition for handling upgrades + +node ./tiddlywiki.js \ + ./editions/upgrade \ + --verbose \ + --output $TW5_BUILD_OUTPUT \ + --build upgrade \ + || exit 1 + # encrypted.html: a version of the main file encrypted with the password "password" node ./tiddlywiki.js \ diff --git a/core/modules/widgets/navigator.js b/core/modules/widgets/navigator.js index 6bd678687..bbff1b261 100755 --- a/core/modules/widgets/navigator.js +++ b/core/modules/widgets/navigator.js @@ -420,7 +420,8 @@ NavigatorWidget.prototype.handleImportTiddlersEvent = function(event) { newFields = new Object({ title: IMPORT_TITLE, type: "application/json", - "plugin-type": "import" + "plugin-type": "import", + "status": "pending" }), incomingTiddlers = []; // Process each tiddler @@ -446,18 +447,21 @@ NavigatorWidget.prototype.handleImportTiddlersEvent = function(event) { // Save the $:/Import tiddler newFields.text = JSON.stringify(importData,null,$tw.config.preferences.jsonSpaces); this.wiki.addTiddler(new $tw.Tiddler(importTiddler,newFields)); - // Get the story and history details - var storyList = this.getStoryList(), - history = []; - // Add it to the story - if(storyList.indexOf(IMPORT_TITLE) === -1) { - storyList.unshift(IMPORT_TITLE); + // Update the story and history details + debugger; + if(this.getVariable("tw-auto-open-on-import") !== "no") { + var storyList = this.getStoryList(), + history = []; + // Add it to the story + if(storyList.indexOf(IMPORT_TITLE) === -1) { + storyList.unshift(IMPORT_TITLE); + } + // And to history + history.push(IMPORT_TITLE); + // Save the updated story and history + this.saveStoryList(storyList); + this.addToHistory(history); } - // And to history - history.push(IMPORT_TITLE); - // Save the updated story and history - this.saveStoryList(storyList); - this.addToHistory(history); return false; }; @@ -477,7 +481,11 @@ NavigatorWidget.prototype.handlePerformImportEvent = function(event) { } }); // Replace the $:/Import tiddler with an import report - this.wiki.addTiddler(new $tw.Tiddler({title: IMPORT_TITLE, text: importReport.join("\n")})); + this.wiki.addTiddler(new $tw.Tiddler({ + title: IMPORT_TITLE, + text: importReport.join("\n"), + "status": "complete" + })); // Navigate to the $:/Import tiddler this.addToHistory([IMPORT_TITLE]); }; diff --git a/editions/empty/tiddlywiki.info b/editions/empty/tiddlywiki.info index 0a0341bb5..6a97b5666 100644 --- a/editions/empty/tiddlywiki.info +++ b/editions/empty/tiddlywiki.info @@ -9,9 +9,6 @@ "build": { "index": [ "--rendertiddler","$:/core/save/all","index.html","text/plain"], - "upgrade": [ - "--makelibrary", - "--rendertiddler","$:/core/save/all","upgrade.html","text/plain"], "externalimages": [ "--savetiddlers","[is[image]]","images", "--setfield","[is[image]]","_canonical_uri","$:/core/templates/canonical-uri-external-image","text/plain", diff --git a/editions/upgrade/tiddlywiki.info b/editions/upgrade/tiddlywiki.info new file mode 100644 index 000000000..34e2987de --- /dev/null +++ b/editions/upgrade/tiddlywiki.info @@ -0,0 +1,14 @@ +{ + "plugins": [ + "tiddlywiki/upgrade" + ], + "themes": [ + "tiddlywiki/vanilla", + "tiddlywiki/snowwhite" + ], + "build": { + "upgrade": [ + "--makelibrary", + "--rendertiddler","$:/core/save/all","upgrade.html","text/plain"] + } +} \ No newline at end of file diff --git a/plugins/tiddlywiki/upgrade/DefaultTiddlers.tid b/plugins/tiddlywiki/upgrade/DefaultTiddlers.tid new file mode 100644 index 000000000..4faa3e07c --- /dev/null +++ b/plugins/tiddlywiki/upgrade/DefaultTiddlers.tid @@ -0,0 +1 @@ +title: $:/DefaultTiddlers diff --git a/plugins/tiddlywiki/upgrade/UpgradeWizard.tid b/plugins/tiddlywiki/upgrade/UpgradeWizard.tid new file mode 100644 index 000000000..69e9dc275 --- /dev/null +++ b/plugins/tiddlywiki/upgrade/UpgradeWizard.tid @@ -0,0 +1,34 @@ +title: $:/UpgradeWizard +tags: $:/tags/StoryBackdrop + +<$list filter="[[$:/Import]is[missing]]"> + +Drag a TiddlyWiki file here to upgrade it + +<$browse/> + + + +<$reveal state="$:/Import!!status" type="match" text="pending"> + +And now there's a pending import + +<$set name="storyTiddler" value="$:/Import"> + +<$tiddler tiddler="$:/Import"> + +<$transclude tiddler="$:/core/ui/ViewTemplate/import"/> + + + + + + + +<$reveal state="$:/Import!!status" type="match" text="complete"> + +All done + +{{$:/plugins/tiddlywiki/upgrade/save}} + + diff --git a/plugins/tiddlywiki/upgrade/plugin.info b/plugins/tiddlywiki/upgrade/plugin.info new file mode 100644 index 000000000..c72d242da --- /dev/null +++ b/plugins/tiddlywiki/upgrade/plugin.info @@ -0,0 +1,6 @@ +{ + "title": "$:/plugins/tiddlywiki/upgrade", + "description": "User interface for upgrading TiddlyWiki documents", + "author": "JeremyRuston", + "core-version": ">=5.0.0" +} diff --git a/plugins/tiddlywiki/upgrade/save-tiddler-filter.tid b/plugins/tiddlywiki/upgrade/save-tiddler-filter.tid new file mode 100644 index 000000000..988cdae54 --- /dev/null +++ b/plugins/tiddlywiki/upgrade/save-tiddler-filter.tid @@ -0,0 +1,6 @@ +title: $:/plugins/tiddlywiki/upgrade/save-tiddler-filter + +\define saveTiddlerFilter() +[is[tiddler]] -[[$:/UpgradeLibrary]] -[[$:/plugins/tiddlywiki/upgrade]] -[prefix[$:/state/popup/]] -[[$:/HistoryList]] -[[$:/boot/boot.css]] -[type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] +[sort[title]] +\end +{{$:/core/templates/tiddlywiki5.html}} diff --git a/plugins/tiddlywiki/upgrade/save.tid b/plugins/tiddlywiki/upgrade/save.tid new file mode 100644 index 000000000..a61af1f4e --- /dev/null +++ b/plugins/tiddlywiki/upgrade/save.tid @@ -0,0 +1,3 @@ +title: $:/plugins/tiddlywiki/upgrade/save + +<$button message="tw-download-file" param="$:/plugins/tiddlywiki/upgrade/save-tiddler-filter" class="btn-big-green">Save upgraded ~TiddlyWiki file {{$:/core/images/save-button}} diff --git a/plugins/tiddlywiki/upgrade/set-auto-open-on-import.tid b/plugins/tiddlywiki/upgrade/set-auto-open-on-import.tid new file mode 100644 index 000000000..5c1e43543 --- /dev/null +++ b/plugins/tiddlywiki/upgrade/set-auto-open-on-import.tid @@ -0,0 +1,6 @@ +title: $:/plugins/tiddlywiki/upgrade/set-auto-open-on-import +tags: $:/tags/Macro + +\define tw-auto-open-on-import() +no +\end