Allow includeWikis to be read-only

Hopefully this will help resolve issues that @xcazin and @pmario have
been having with using the client-server configuration to prepare
translations of the TW5 docs.
This commit is contained in:
Jermolene
2014-11-13 12:28:51 +00:00
parent d1bbe7253c
commit 8e685e5150
3 changed files with 130 additions and 8 deletions
+17 -8
View File
@@ -1550,11 +1550,14 @@ $tw.loadPlugins = function(plugins,libraryPath,envVar) {
/*
path: path of wiki directory
parentPaths: array of parent paths that we mustn't recurse into
options:
parentPaths: array of parent paths that we mustn't recurse into
readOnly: true if the tiddler file paths should not be retained
*/
$tw.loadWikiTiddlers = function(wikiPath,parentPaths) {
parentPaths = parentPaths || [];
var wikiInfoPath = path.resolve(wikiPath,$tw.config.wikiInfo),
$tw.loadWikiTiddlers = function(wikiPath,options) {
options = options || {};
var parentPaths = options.parentPaths || [],
wikiInfoPath = path.resolve(wikiPath,$tw.config.wikiInfo),
wikiInfo,
pluginFields;
// Bail if we don't have a wiki info file
@@ -1567,10 +1570,16 @@ $tw.loadWikiTiddlers = function(wikiPath,parentPaths) {
if(wikiInfo.includeWikis) {
parentPaths = parentPaths.slice(0);
parentPaths.push(wikiPath);
$tw.utils.each(wikiInfo.includeWikis,function(includedWikiPath) {
var resolvedIncludedWikiPath = path.resolve(wikiPath,includedWikiPath);
$tw.utils.each(wikiInfo.includeWikis,function(info) {
if(typeof info === "string") {
info = {path: info};
}
var resolvedIncludedWikiPath = path.resolve(wikiPath,info.path);
if(parentPaths.indexOf(resolvedIncludedWikiPath) === -1) {
var subWikiInfo = $tw.loadWikiTiddlers(resolvedIncludedWikiPath,parentPaths);
var subWikiInfo = $tw.loadWikiTiddlers(resolvedIncludedWikiPath,{
parentPaths: parentPaths,
readOnly: info["read-only"]
});
// Merge the build targets
wikiInfo.build = $tw.utils.extend([],subWikiInfo.build,wikiInfo.build);
} else {
@@ -1585,7 +1594,7 @@ $tw.loadWikiTiddlers = function(wikiPath,parentPaths) {
// Load the wiki files, registering them as writable
var resolvedWikiPath = path.resolve(wikiPath,$tw.config.wikiTiddlersSubDir);
$tw.utils.each($tw.loadTiddlersFromPath(resolvedWikiPath),function(tiddlerFile) {
if(tiddlerFile.filepath) {
if(!options.readOnly && tiddlerFile.filepath) {
$tw.utils.each(tiddlerFile.tiddlers,function(tiddler) {
$tw.boot.files[tiddler.title] = {
filepath: tiddlerFile.filepath,