From 4848a21c6b167c5d1ef10cd15003abe146995c38 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Thu, 21 Mar 2013 22:21:34 +0000 Subject: [PATCH] Add GettingStarted tiddler for empty TiddlyWikis --- core/messages/GettingStarted.tid | 11 +++++++++++ core/modules/startup.js | 14 +++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 core/messages/GettingStarted.tid diff --git a/core/messages/GettingStarted.tid b/core/messages/GettingStarted.tid new file mode 100644 index 000000000..201d7ed76 --- /dev/null +++ b/core/messages/GettingStarted.tid @@ -0,0 +1,11 @@ +title: $:/messages/GettingStarted +type: text/vnd.tiddlywiki +subtitle: Welcome to ~TiddlyWiki +footer: <$button message="tw-close-tiddler" class="btn btn-primary">Close +help: http://five.tiddlywiki.com/static/GettingStarted + +This ~TiddlyWiki is empty. + +You can create and edit tiddlers, but before you use ~TiddlyWiki in earnest it is strongly advised that you verify that you can save and retrieve your changes. + +~TiddlyWiki5 is currently a preliminary alpha release. Visit http://five.tiddlywiki.com/ for the latest information on how to use it. diff --git a/core/modules/startup.js b/core/modules/startup.js index 772d08839..f9ed4a111 100644 --- a/core/modules/startup.js +++ b/core/modules/startup.js @@ -104,11 +104,15 @@ exports.startup = function() { }); // If we're being viewed on a data: URI then give instructions for how to save if(document.location.protocol === "data:") { - var event = document.createEvent("Event"); - event.initEvent("tw-modal",true,true); - event.param = "$:/messages/SaveInstructions"; - document.dispatchEvent(event); - } + $tw.utils.dispatchCustomEvent(document,"tw-modal",{ + param: "$:/messages/SaveInstructions" + }); + } else if($tw.wiki.countTiddlers() === 0){ + // Otherwise, if give instructions if this is an empty TiddlyWiki + $tw.utils.dispatchCustomEvent(document,"tw-modal",{ + param: "$:/messages/GettingStarted" + }); + } // Display the PageTemplate var templateTitle = "$:/templates/PageTemplate", parser = $tw.wiki.parseTiddler(templateTitle),