mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-08-07 22:33:50 +00:00
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:
parent
d1bbe7253c
commit
8e685e5150
25
boot/boot.js
25
boot/boot.js
@ -1550,11 +1550,14 @@ $tw.loadPlugins = function(plugins,libraryPath,envVar) {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
path: path of wiki directory
|
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) {
|
$tw.loadWikiTiddlers = function(wikiPath,options) {
|
||||||
parentPaths = parentPaths || [];
|
options = options || {};
|
||||||
var wikiInfoPath = path.resolve(wikiPath,$tw.config.wikiInfo),
|
var parentPaths = options.parentPaths || [],
|
||||||
|
wikiInfoPath = path.resolve(wikiPath,$tw.config.wikiInfo),
|
||||||
wikiInfo,
|
wikiInfo,
|
||||||
pluginFields;
|
pluginFields;
|
||||||
// Bail if we don't have a wiki info file
|
// Bail if we don't have a wiki info file
|
||||||
@ -1567,10 +1570,16 @@ $tw.loadWikiTiddlers = function(wikiPath,parentPaths) {
|
|||||||
if(wikiInfo.includeWikis) {
|
if(wikiInfo.includeWikis) {
|
||||||
parentPaths = parentPaths.slice(0);
|
parentPaths = parentPaths.slice(0);
|
||||||
parentPaths.push(wikiPath);
|
parentPaths.push(wikiPath);
|
||||||
$tw.utils.each(wikiInfo.includeWikis,function(includedWikiPath) {
|
$tw.utils.each(wikiInfo.includeWikis,function(info) {
|
||||||
var resolvedIncludedWikiPath = path.resolve(wikiPath,includedWikiPath);
|
if(typeof info === "string") {
|
||||||
|
info = {path: info};
|
||||||
|
}
|
||||||
|
var resolvedIncludedWikiPath = path.resolve(wikiPath,info.path);
|
||||||
if(parentPaths.indexOf(resolvedIncludedWikiPath) === -1) {
|
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
|
// Merge the build targets
|
||||||
wikiInfo.build = $tw.utils.extend([],subWikiInfo.build,wikiInfo.build);
|
wikiInfo.build = $tw.utils.extend([],subWikiInfo.build,wikiInfo.build);
|
||||||
} else {
|
} else {
|
||||||
@ -1585,7 +1594,7 @@ $tw.loadWikiTiddlers = function(wikiPath,parentPaths) {
|
|||||||
// Load the wiki files, registering them as writable
|
// Load the wiki files, registering them as writable
|
||||||
var resolvedWikiPath = path.resolve(wikiPath,$tw.config.wikiTiddlersSubDir);
|
var resolvedWikiPath = path.resolve(wikiPath,$tw.config.wikiTiddlersSubDir);
|
||||||
$tw.utils.each($tw.loadTiddlersFromPath(resolvedWikiPath),function(tiddlerFile) {
|
$tw.utils.each($tw.loadTiddlersFromPath(resolvedWikiPath),function(tiddlerFile) {
|
||||||
if(tiddlerFile.filepath) {
|
if(!options.readOnly && tiddlerFile.filepath) {
|
||||||
$tw.utils.each(tiddlerFile.tiddlers,function(tiddler) {
|
$tw.utils.each(tiddlerFile.tiddlers,function(tiddler) {
|
||||||
$tw.boot.files[tiddler.title] = {
|
$tw.boot.files[tiddler.title] = {
|
||||||
filepath: tiddlerFile.filepath,
|
filepath: tiddlerFile.filepath,
|
||||||
|
@ -14,6 +14,9 @@
|
|||||||
"languages": [
|
"languages": [
|
||||||
"fr-FR"
|
"fr-FR"
|
||||||
],
|
],
|
||||||
|
"includeWikis": [
|
||||||
|
{"path": "../tw5.com", "read-only": true}
|
||||||
|
],
|
||||||
"build": {
|
"build": {
|
||||||
"index": [
|
"index": [
|
||||||
"--rendertiddler","$:/core/save/all","fr-fr-demo.html","text/plain"]
|
"--rendertiddler","$:/core/save/all","fr-fr-demo.html","text/plain"]
|
||||||
|
110
editions/prerelease/tiddlers/TiddlyWikiFolders.tid
Normal file
110
editions/prerelease/tiddlers/TiddlyWikiFolders.tid
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
created: 20130825214200000
|
||||||
|
modified: 20141113122142639
|
||||||
|
tags: [[TiddlyWiki on Node.js]]
|
||||||
|
title: TiddlyWikiFolders
|
||||||
|
type: text/vnd.tiddlywiki
|
||||||
|
|
||||||
|
As well as traditional single file wikis, [[TiddlyWiki on Node.js]] supports wikis that are stored as a folder of individual tiddler files.
|
||||||
|
|
||||||
|
! Wiki folder files and folders
|
||||||
|
|
||||||
|
Wiki folders can contain the following files and folders:
|
||||||
|
|
||||||
|
* ''tiddlywiki.info'' - JSON file containing metadata for the wiki
|
||||||
|
* ''\tiddlers'' - folder containing tiddler files comprising the wiki
|
||||||
|
* ''\plugins'' - folder containing [[plugin folders|PluginMechanism]] to be included in the wiki
|
||||||
|
|
||||||
|
Only the ''tiddlywiki.info'' file is required, the ''tiddlers'' and ''plugins'' folders are optional. Any files and folders not listed above are ignored.
|
||||||
|
|
||||||
|
!! Content of `tiddlywiki.info` file
|
||||||
|
|
||||||
|
The `tiddlywiki.info` file in a wiki folder contains a JSON object comprising the following fields:
|
||||||
|
|
||||||
|
* ''plugins'' - an array of plugin names to be included in the wiki
|
||||||
|
* ''themes'' - an array of theme names to be included in the wiki
|
||||||
|
* ''languages'' - an array of language names to be included in the wiki
|
||||||
|
* ''includeWikis'' - an array of references to external wiki folders to be included in the wiki
|
||||||
|
* ''build'' - a hashmap of named build targets, each defined by an array of command tokens (see BuildCommand)
|
||||||
|
* ''config'' - an optional hashmap of configuration options (see below)
|
||||||
|
|
||||||
|
!!! ''includeWikis''
|
||||||
|
|
||||||
|
The entries in the ''includeWikis'' array can be either a string specifying the relative path to the wiki, or an object with the following fields:
|
||||||
|
|
||||||
|
* ''path'' - relative path to wiki folder
|
||||||
|
* ''read-only'' - set //true// to prevent the tiddlers in the included wiki from being modified. The modifications will be written to the directory specified in ''default-tiddler-location'', described below
|
||||||
|
|
||||||
|
!!! ''build''
|
||||||
|
|
||||||
|
Note that the build targets of included wikis are merged if a target of that name isn't defined in the current `tiddlywiki.info` file.
|
||||||
|
|
||||||
|
!!! ''config''
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
!!! Example
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
"tiddlywiki/tiddlyweb",
|
||||||
|
"tiddlywiki/filesystem"
|
||||||
|
],
|
||||||
|
"includeWikis": [
|
||||||
|
"../tw5.com"
|
||||||
|
],
|
||||||
|
"build": {
|
||||||
|
"index": [
|
||||||
|
"--rendertiddler","$:/core/save/all","index.html","text/plain"],
|
||||||
|
"favicon": [
|
||||||
|
"--savetiddler","$:/favicon.ico","favicon.ico",
|
||||||
|
"--savetiddler","$:/green_favicon.ico","static/favicon.ico"]
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"retain-original-tiddler-path": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
!! Content of `tiddlers` folder
|
||||||
|
|
||||||
|
All the TiddlerFiles in the `tiddlers` folder are read into the wiki at startup. Sub-folders are scanned recursively for TiddlerFiles.
|
||||||
|
|
||||||
|
Sub-folders within the `tiddlers` folder can also be given a `tiddlywiki.files` JSON file that overrides the default processing for that folder. The file format is illustrated with this example from the D3 plugin:
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"tiddlers": [
|
||||||
|
{
|
||||||
|
"file": "d3.min.js",
|
||||||
|
"fields": {
|
||||||
|
"type": "application/javascript",
|
||||||
|
"title": "$:/plugins/tiddlywiki/d3/d3.js",
|
||||||
|
"module-type": "library"
|
||||||
|
},
|
||||||
|
"prefix": "var d3;if($tw.browser){\n",
|
||||||
|
"suffix": "}\nexports.d3 = d3;\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"file": "cloud/d3.layout.cloud.js",
|
||||||
|
"fields": {
|
||||||
|
"type": "application/javascript",
|
||||||
|
"title": "$:/plugins/tiddlywiki/d3/d3.layout.cloud.js",
|
||||||
|
"module-type": "library"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The JSON data consists of an object with a `tiddlers` property that contains an array of information about each tiddler to be loaded into the wiki. That information consists of:
|
||||||
|
|
||||||
|
* `file`: the relative or absolute path to the file to include
|
||||||
|
* `fields`: an object containing fields that override any provided in the tiddler file
|
||||||
|
* `prefix` & `suffix`: (optional) specify strings to be prefixed and suffixed to the tiddler file text content
|
Loading…
x
Reference in New Issue
Block a user