diff --git a/core/modules/saver-handler.js b/core/modules/saver-handler.js index 98ff08bdb..2c7fc968e 100644 --- a/core/modules/saver-handler.js +++ b/core/modules/saver-handler.js @@ -28,7 +28,7 @@ function SaverHandler(options) { this.initSavers(); } // Only do dirty tracking if required - if(this.dirtyTracking) { + if($tw.browser && this.dirtyTracking) { // Compile the dirty tiddler filter this.filterFn = this.wiki.compileFilter(this.wiki.getTiddlerText(this.titleSyncFilter)); // Count of tiddlers that have been changed but not yet saved @@ -43,6 +43,9 @@ function SaverHandler(options) { }); self.numTasksInQueue += filteredChanges.length; self.updateDirtyStatus(); + if(self.numTasksInQueue > 0) { + self.saveWiki({method: "autosave"}); + } }); // Browser event handlers if($tw.browser) { @@ -65,13 +68,6 @@ function SaverHandler(options) { downloadType: "text/plain" }); }); - $tw.rootWidget.addEventListener("tw-auto-save-wiki",function(event) { - self.saveWiki({ - method: "autosave", - template: event.param, - downloadType: "text/plain" - }); - }); $tw.rootWidget.addEventListener("tw-download-file",function(event) { self.saveWiki({ method: "download", @@ -82,7 +78,7 @@ function SaverHandler(options) { } } -SaverHandler.prototype.titleSyncFilter = "$:/config/SyncFilter"; +SaverHandler.prototype.titleSyncFilter = "$:/config/SaverFilter"; SaverHandler.prototype.titleAutoSave = "$:/config/AutoSave"; SaverHandler.prototype.titleSavedNotification = "$:/language/Notifications/Save/Done"; @@ -115,7 +111,7 @@ SaverHandler.prototype.initSavers = function(moduleType) { /* Save the wiki contents. Options are: - method: "save" or "download" + method: "save", "autosave" or "download" template: the tiddler containing the template to save downloadType: the content type for the saved file */ @@ -130,6 +126,11 @@ SaverHandler.prototype.saveWiki = function(options) { if(err) { alert("Error while saving:\n\n" + err); } else { + // Clear the task queue if we're saving (rather than downloading) + if(method !== "download") { + self.numTasksInQueue = 0; + self.updateDirtyStatus(); + } $tw.notifier.display(self.titleSavedNotification); if(options.callback) { options.callback(); @@ -145,11 +146,6 @@ SaverHandler.prototype.saveWiki = function(options) { var saver = this.savers[t]; if(saver.info.capabilities.indexOf(method) !== -1 && saver.save(text,method,callback)) { this.logger.log("Saving wiki with method",method,"through saver",saver.info.name); - // Clear the task queue if we're saving (rather than downloading) - if(method !== "download") { - this.numTasksInQueue = 0; - this.updateDirtyStatus(); - } return true; } } diff --git a/core/modules/utils/pluginmaker.js b/core/modules/utils/pluginmaker.js index eadef8e43..5cce747a0 100644 --- a/core/modules/utils/pluginmaker.js +++ b/core/modules/utils/pluginmaker.js @@ -71,8 +71,6 @@ exports.repackPlugin = function(title,additionalTiddlers,excludeTiddlers) { $tw.wiki.deleteTiddler(title); } }); - // Trigger an autosave - $tw.rootWidget.dispatchEvent({type: "tw-auto-save-wiki"}); // Return a heartwarming confirmation return "Plugin " + title + " successfully saved"; } diff --git a/core/modules/widgets/navigator.js b/core/modules/widgets/navigator.js index 71a49ff2f..8b06289ad 100755 --- a/core/modules/widgets/navigator.js +++ b/core/modules/widgets/navigator.js @@ -243,8 +243,6 @@ NavigatorWidget.prototype.handleDeleteTiddlerEvent = function(event) { // Remove the closed tiddler from the story this.removeTitleFromStory(storyList,title); this.saveStoryList(storyList); - // Send a notification event - this.dispatchEvent({type: "tw-auto-save-wiki"}); return false; }; @@ -333,8 +331,6 @@ NavigatorWidget.prototype.handleSaveTiddlerEvent = function(event) { if(draftTitle !== this.storyTitle) { this.saveStoryList(storyList); } - // Send a notification event - this.dispatchEvent({type: "tw-auto-save-wiki"}); } } } @@ -376,13 +372,8 @@ NavigatorWidget.prototype.handleNewTiddlerEvent = function(event) { var storyList = this.getStoryList(); // Get the template tiddler if there is one var templateTiddler = this.wiki.getTiddler(event.param); - // Create the new tiddler + // Title the new tiddler var title = this.wiki.generateNewTitle((templateTiddler && templateTiddler.fields.title) || "New Tiddler"); - var tiddler = new $tw.Tiddler(this.wiki.getCreationFields(),{ - text: "Newly created tiddler", - title: title - },this.wiki.getModificationFields()); - this.wiki.addTiddler(tiddler); // Create the draft tiddler var draftTitle = this.generateDraftTitle(title), draftTiddler = new $tw.Tiddler({ @@ -487,8 +478,6 @@ NavigatorWidget.prototype.handlePerformImportEvent = function(event) { })); // Navigate to the $:/Import tiddler this.addToHistory([IMPORT_TITLE]); - // Send a notification event - this.dispatchEvent({type: "tw-auto-save-wiki"}); }; exports.navigator = NavigatorWidget; diff --git a/core/wiki/config/SaverFilter.tid b/core/wiki/config/SaverFilter.tid new file mode 100644 index 000000000..872fc8744 --- /dev/null +++ b/core/wiki/config/SaverFilter.tid @@ -0,0 +1,3 @@ +title: $:/config/SaverFilter + +[!is[shadow]] -[[$:/HistoryList]] -[[$:/StoryList]] -[[$:/Import]] -[[$:/isEncrypted]] -[prefix[$:/status]] -[prefix[$:/state]] -[prefix[$:/temp]] -[has[draft.of]] \ No newline at end of file diff --git a/editions/tw5.com/tiddlers/TableOfContents.tid b/editions/tw5.com/tiddlers/TableOfContents.tid index c30ab83a9..52161d843 100644 --- a/editions/tw5.com/tiddlers/TableOfContents.tid +++ b/editions/tw5.com/tiddlers/TableOfContents.tid @@ -183,7 +183,6 @@ $body$ ">> ## <