1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-26 19:47:20 +00:00

Make default location for new tiddlers configurable

This commit is contained in:
Jermolene 2014-07-20 20:19:09 +01:00
parent 67faf3fe5d
commit ef67cc3fd9
3 changed files with 10 additions and 4 deletions

View File

@ -1588,7 +1588,8 @@ $tw.loadWikiTiddlers = function(wikiPath,parentPaths) {
$tw.wiki.addTiddlers(tiddlerFile.tiddlers); $tw.wiki.addTiddlers(tiddlerFile.tiddlers);
}); });
// Save the original tiddler file locations if requested // 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 = []; var output = [];
for(var title in $tw.boot.files) { for(var title in $tw.boot.files) {
output.push(title + ": " + path.relative(resolvedWikiPath,$tw.boot.files[title].filepath) + "\n"); 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("")}); $tw.wiki.addTiddler({title: "$:/config/OriginalTiddlerPaths", type: "application/x-tiddler-dictionary", text: output.join("")});
} }
// Save the path to the tiddlers folder for the filesystemadaptor // 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 // Load any plugins within the wiki folder
var wikiPluginsPath = path.resolve(wikiPath,$tw.config.wikiPluginsSubDir); var wikiPluginsPath = path.resolve(wikiPath,$tw.config.wikiPluginsSubDir);
if(fs.existsSync(wikiPluginsPath)) { if(fs.existsSync(wikiPluginsPath)) {

View File

@ -11,5 +11,8 @@
], ],
"includeWikis": [ "includeWikis": [
"../tw5.com" "../tw5.com"
] ],
"config": {
"default-tiddler-location": "../tw5.com/tiddlers"
}
} }

View File

@ -1,5 +1,5 @@
created: 20130825214200000 created: 20130825214200000
modified: 20140427210453175 modified: 20140720210453175
tags: dev tags: dev
title: TiddlyWikiFolders title: TiddlyWikiFolders
type: text/vnd.tiddlywiki 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: 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 * ''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: For example: