From ef67cc3fd9b267a522598abccdfbb93fbfca240c Mon Sep 17 00:00:00 2001 From: Jermolene Date: Sun, 20 Jul 2014 20:19:09 +0100 Subject: [PATCH] Make default location for new tiddlers configurable --- boot/boot.js | 5 +++-- editions/tw5.com-server/tiddlywiki.info | 5 ++++- editions/tw5.com/tiddlers/concepts/TiddlyWikiFolders.tid | 4 +++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/boot/boot.js b/boot/boot.js index 39f929609..3abe993a4 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -1588,7 +1588,8 @@ $tw.loadWikiTiddlers = function(wikiPath,parentPaths) { $tw.wiki.addTiddlers(tiddlerFile.tiddlers); }); // Save the original tiddler file locations if requested - if(wikiInfo.config && wikiInfo.config["retain-original-tiddler-path"]) { + var config = wikiInfo.config || {}; + if(config["retain-original-tiddler-path"]) { var output = []; for(var title in $tw.boot.files) { output.push(title + ": " + path.relative(resolvedWikiPath,$tw.boot.files[title].filepath) + "\n"); @@ -1596,7 +1597,7 @@ $tw.loadWikiTiddlers = function(wikiPath,parentPaths) { $tw.wiki.addTiddler({title: "$:/config/OriginalTiddlerPaths", type: "application/x-tiddler-dictionary", text: output.join("")}); } // Save the path to the tiddlers folder for the filesystemadaptor - $tw.boot.wikiTiddlersPath = path.resolve($tw.boot.wikiPath,$tw.config.wikiTiddlersSubDir); + $tw.boot.wikiTiddlersPath = path.resolve($tw.boot.wikiPath,config["default-tiddler-location"] || $tw.config.wikiTiddlersSubDir); // Load any plugins within the wiki folder var wikiPluginsPath = path.resolve(wikiPath,$tw.config.wikiPluginsSubDir); if(fs.existsSync(wikiPluginsPath)) { diff --git a/editions/tw5.com-server/tiddlywiki.info b/editions/tw5.com-server/tiddlywiki.info index fc6bb51b3..fc60e20d7 100644 --- a/editions/tw5.com-server/tiddlywiki.info +++ b/editions/tw5.com-server/tiddlywiki.info @@ -11,5 +11,8 @@ ], "includeWikis": [ "../tw5.com" - ] + ], + "config": { + "default-tiddler-location": "../tw5.com/tiddlers" + } } diff --git a/editions/tw5.com/tiddlers/concepts/TiddlyWikiFolders.tid b/editions/tw5.com/tiddlers/concepts/TiddlyWikiFolders.tid index 6b127b307..3ef478926 100644 --- a/editions/tw5.com/tiddlers/concepts/TiddlyWikiFolders.tid +++ b/editions/tw5.com/tiddlers/concepts/TiddlyWikiFolders.tid @@ -1,5 +1,5 @@ created: 20130825214200000 -modified: 20140427210453175 +modified: 20140720210453175 tags: dev title: TiddlyWikiFolders type: text/vnd.tiddlywiki @@ -29,6 +29,8 @@ The `tiddlywiki.info` file in a wiki folder contains a JSON object comprising th Configuration options include: +* ''default-tiddler-location'' - a string path to the default location for the filesystem adaptor to save new tiddlers (resolved relative to the wiki folder) + * ''retain-original-tiddler-path'' - If true, the server will generate a tiddler [[$:/config/OriginalTiddlerPaths]] containing the original file paths of each tiddler in the wiki For example: