1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +00:00

Improve support for bulk loading tiddlers under Node.js

Fixes #2610
This commit is contained in:
Jermolene 2016-10-15 16:21:51 +01:00
parent d7b6917638
commit 1b41b44684
10 changed files with 345 additions and 365 deletions

View File

@ -1456,17 +1456,26 @@ $tw.loadTiddlersFromFile = function(filepath,fields) {
typeInfo = type ? $tw.config.contentTypeInfo[type] : null, typeInfo = type ? $tw.config.contentTypeInfo[type] : null,
data = fs.readFileSync(filepath,typeInfo ? typeInfo.encoding : "utf8"), data = fs.readFileSync(filepath,typeInfo ? typeInfo.encoding : "utf8"),
tiddlers = $tw.wiki.deserializeTiddlers(ext,data,fields), tiddlers = $tw.wiki.deserializeTiddlers(ext,data,fields),
metafile = filepath + ".meta",
metadata; metadata;
if(ext !== ".json" && tiddlers.length === 1 && fs.existsSync(metafile)) { if(ext !== ".json" && tiddlers.length === 1) {
metadata = fs.readFileSync(metafile,"utf8"); metadata = $tw.loadMetadataForFile(filepath);
if(metadata) { tiddlers = [$tw.utils.extend({},metadata,tiddlers[0])];
tiddlers = [$tw.utils.parseFields(metadata,tiddlers[0])];
}
} }
return {filepath: filepath, type: type, tiddlers: tiddlers, hasMetaFile: !!metadata}; return {filepath: filepath, type: type, tiddlers: tiddlers, hasMetaFile: !!metadata};
}; };
/*
Load the metadata fields in the .meta file corresponding to a particular file
*/
$tw.loadMetadataForFile = function(filepath) {
var metafilename = filepath + ".meta";
if(fs.existsSync(metafilename)) {
return $tw.utils.parseFields(fs.readFileSync(metafilename,"utf8") || "");
} else {
return null;
}
};
/* /*
A default set of files for TiddlyWiki to ignore during load. A default set of files for TiddlyWiki to ignore during load.
This matches what NPM ignores, and adds "*.meta" to ignore tiddler This matches what NPM ignores, and adds "*.meta" to ignore tiddler
@ -1486,44 +1495,7 @@ $tw.loadTiddlersFromPath = function(filepath,excludeRegExp) {
var files = fs.readdirSync(filepath); var files = fs.readdirSync(filepath);
// Look for a tiddlywiki.files file // Look for a tiddlywiki.files file
if(files.indexOf("tiddlywiki.files") !== -1) { if(files.indexOf("tiddlywiki.files") !== -1) {
// If so, process the files it describes Array.prototype.push.apply(tiddlers,$tw.loadTiddlersFromSpecification(filepath));
var filesInfo = JSON.parse(fs.readFileSync(filepath + path.sep + "tiddlywiki.files","utf8"));
// First the tiddlers
$tw.utils.each(filesInfo.tiddlers,function(tidInfo) {
var type = tidInfo.fields.type || "text/plain",
typeInfo = $tw.config.contentTypeInfo[type],
pathname = path.resolve(filepath,tidInfo.file),
text = fs.readFileSync(pathname,typeInfo ? typeInfo.encoding : "utf8");
if(tidInfo.isTiddlerFile) {
var fileTiddlers = $tw.wiki.deserializeTiddlers(path.extname(pathname),text) || [];
$tw.utils.each(fileTiddlers,function(tiddler) {
$tw.utils.extend(tiddler,tidInfo.fields);
if(tidInfo.prefix) {
tiddler.text = tidInfo.prefix + tiddler.text;
}
if(tidInfo.suffix) {
tiddler.text = tiddler.text + tidInfo.suffix;
}
});
tiddlers.push({tiddlers: fileTiddlers});
} else {
if(tidInfo.prefix) {
text = tidInfo.prefix + text;
}
if(tidInfo.suffix) {
text = text + tidInfo.suffix;
}
tidInfo.fields.text = text;
tiddlers.push({tiddlers: [tidInfo.fields]});
}
});
// Then any recursive directories
$tw.utils.each(filesInfo.directories,function(dirPath) {
var pathname = path.resolve(filepath,dirPath);
if(fs.existsSync(pathname) && fs.statSync(pathname).isDirectory()) {
tiddlers.push.apply(tiddlers,$tw.loadTiddlersFromPath(pathname,excludeRegExp));
}
});
} else { } else {
// If not, read all the files in the directory // If not, read all the files in the directory
$tw.utils.each(files,function(file) { $tw.utils.each(files,function(file) {
@ -1539,6 +1511,98 @@ $tw.loadTiddlersFromPath = function(filepath,excludeRegExp) {
return tiddlers; return tiddlers;
}; };
/*
Load all the tiddlers defined by a `tiddlywiki.files` specification file
filepath: pathname of the directory containing the specification file
*/
$tw.loadTiddlersFromSpecification = function(filepath) {
var tiddlers = [];
// Read the specification
var filesInfo = JSON.parse(fs.readFileSync(filepath + path.sep + "tiddlywiki.files","utf8"));
// Helper to process a file
var processFile = function(filename,isTiddlerFile,fields) {
var extInfo = $tw.config.fileExtensionInfo[path.extname(filename)],
type = (extInfo || {}).type || fields.type || "text/plain",
typeInfo = $tw.config.contentTypeInfo[type] || {},
pathname = path.resolve(filepath,filename),
text = fs.readFileSync(pathname,typeInfo.encoding || "utf8"),
metadata = $tw.loadMetadataForFile(pathname) || {},
fileTiddlers;
if(isTiddlerFile) {
fileTiddlers = $tw.wiki.deserializeTiddlers(path.extname(pathname),text,metadata) || [];
} else {
fileTiddlers = [$tw.utils.extend({text: text},metadata)];
}
var combinedFields = $tw.utils.extend({},fields,metadata);
$tw.utils.each(fileTiddlers,function(tiddler) {
$tw.utils.each(combinedFields,function(fieldInfo,name) {
if(typeof fieldInfo === "string" || $tw.utils.isArray(fieldInfo)) {
tiddler[name] = fieldInfo;
} else {
var value = tiddler[name];
switch(fieldInfo.source) {
case "filename":
value = path.basename(filename);
break;
case "basename":
value = path.basename(filename,path.extname(filename));
break;
case "extname":
value = path.extname(filename);
break;
case "created":
value = new Date(fs.statSync(pathname).birthtime);
break;
case "modified":
value = new Date(fs.statSync(pathname).mtime);
break;
}
if(fieldInfo.prefix) {
value = fieldInfo.prefix + value;
}
if(fieldInfo.suffix) {
value = value + fieldInfo.suffix;
}
tiddler[name] = value;
}
});
});
tiddlers.push({tiddlers: fileTiddlers});
};
// Process the listed tiddlers
$tw.utils.each(filesInfo.tiddlers,function(tidInfo) {
if(tidInfo.prefix && tidInfo.suffix) {
tidInfo.fields.text = {prefix: tidInfo.prefix,suffix: tidInfo.suffix};
} else if(tidInfo.prefix) {
tidInfo.fields.text = {prefix: tidInfo.prefix};
} else if(tidInfo.suffix) {
tidInfo.fields.text = {suffix: tidInfo.suffix};
}
processFile(tidInfo.file,tidInfo.isTiddlerFile,tidInfo.fields);
});
// Process any listed directories
$tw.utils.each(filesInfo.directories,function(dirSpec) {
// Read literal directories directly
if(typeof dirSpec === "string") {
var pathname = path.resolve(filepath,dirSpec);
if(fs.existsSync(pathname) && fs.statSync(pathname).isDirectory()) {
tiddlers.push.apply(tiddlers,$tw.loadTiddlersFromPath(pathname,excludeRegExp));
}
} else {
// Process directory specifier
var dirPath = path.resolve(filepath,dirSpec.path),
files = fs.readdirSync(dirPath),
fileRegExp = new RegExp(dirSpec.filesRegExp || "^.*$");
for(var t=0; t<files.length; t++) {
if(files[t] !== "tiddlywiki.files" && fileRegExp.test(files[t])) {
processFile(dirPath + path.sep + files[t],dirSpec.isTiddlerFile,dirSpec.fields);
}
}
}
});
return tiddlers;
};
/* /*
Load the tiddlers from a plugin folder, and package them up into a proper JSON plugin tiddler Load the tiddlers from a plugin folder, and package them up into a proper JSON plugin tiddler
*/ */

View File

@ -1,124 +1,40 @@
created: 20130825214200000 created: 20130825214200000
modified: 20150728104424501 modified: 20161015134454785
tags: [[TiddlyWiki on Node.js]] tags: [[TiddlyWiki on Node.js]]
title: TiddlyWikiFolders title: TiddlyWikiFolders
type: text/vnd.tiddlywiki 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. 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 Folder Structure
Wiki folders can contain the following files and folders: Wiki folders can contain the following files and folders:
* ''tiddlywiki.info'' - JSON file containing metadata for the wiki * ''tiddlywiki.info'' - JSON file containing metadata for the wiki -- see [[tiddlywiki.info Files]]
* ''\tiddlers'' - folder containing tiddler files comprising the wiki * ''\tiddlers'' - folder containing tiddler files comprising the wiki
* ''\plugins'' - folder containing [[plugin folders|PluginMechanism]] to be included in the wiki * ''\plugins'' - folder containing [[plugin folders|PluginFolders]] to be included in the wiki
* ''\languages'' - folder containing [[plugin folders|PluginFolders]] for language plugins to be included in the wiki
* ''\themes'' - folder containing [[plugin folders|PluginFolders]] for theme plugins 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. Only the ''tiddlywiki.info'' file is required; everything else is optional. Any files and folders not listed above are ignored.
!! Content of `tiddlywiki.info` file !! Plugin processing
The `tiddlywiki.info` file in a wiki folder contains a JSON object comprising the following fields: To be usable in the browser, plugins just need to be included in the wiki. For wikis that are generated on the server, TiddlyWikiFolders can contain a [[tiddlywiki.info file|tiddlywiki.info Files]] that identifies the plugins to be included in this wiki:
* ''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": [ "plugins": [
"tiddlywiki/tiddlyweb", "tiddlywiki/slider",
"tiddlywiki/filesystem" "tiddlytools/chooser"
],
"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. Newly created tiddlers are stored in TiddlerFiles directly beneath the `tiddlers` folder, unless [[configured otherwise|Customising Tiddler File Naming]].
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:
```
{
"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"
}
},
{
"file": "local/mytiddler.tid",
"isTiddlerFile": true,
"fields": {
"title": "A different title"
}
}
],
"directories": [
"../../mytiddlers/store"
] ]
} }
``` ```
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: Plugins names refer to plugin folders listed in TiddlyWiki5's root `plugins` folder. Plugins can also be included manually by copying them into the `plugins` subfolder of the wiki.
* The relative or absolute path to the file to include as either: !! Processing of `tiddlers` folder
** `file`: the file containing the tiddler
** `isTiddlerFile`: if `true`, the file will be deserialised to extract the tiddlers. Otherwise, the raw content of the file is assigned to the `text` field without any parsing
* `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
The ''directories'' property allows a list of directories to be specified. All tiddlers will be recursively loaded from each directory listed. All the TiddlerFiles in the `tiddlers` folder are read into the wiki at startup. Sub-folders are scanned recursively for TiddlerFiles. Newly created tiddlers are stored in TiddlerFiles directly beneath the `tiddlers` folder, unless [[configured otherwise|Customising Tiddler File Naming]].
The default processing for sub-folders within the `tiddlers` folder can be overridden by providing a JSON file called `tiddlywiki.files` -- see [[tiddlywiki.files Files]].

View File

@ -1,14 +1,16 @@
created: 20130826122000000 created: 20130826122000000
modified: 20141029221758239 modified: 20161015122959346
tags: Mechanisms tags: Mechanisms
title: PluginMechanism title: PluginMechanism
type: text/vnd.tiddlywiki type: text/vnd.tiddlywiki
[[Plugins]] are bundles of tiddlers that are distributed and managed as a single unit by being packed into a single JSON tiddler. If a tiddler isn't found in the main store, then the registered plugins are searched for it instead. ! Introduction
Tiddlers within plugins behave something like shadow tiddlers in classic TiddlyWiki: they can be freely overwritten by creating a tiddler with the same title, but deleting that tiddler restores the underlying tiddler value from the plugin. [[Plugins]] are bundles of tiddlers that are distributed and managed as a single unit by being packed into a single JSON tiddler. Users can install them with drag and drop, or using the [[plugin library|Installing a plugin from the plugin library]].
Plugins have a `plugin-type` field that may be (see the table below): The tiddlers within registered plugins behave as ShadowTiddlers: they can be freely overwritten by creating a tiddler with the same title, but deleting that tiddler restores the underlying tiddler value from the plugin.
Plugins have a `plugin-type` field that may take the following values:
* `plugin` //(default)// - a plain plugin * `plugin` //(default)// - a plain plugin
* `theme` - a theme plugin (see ThemeMechanism) * `theme` - a theme plugin (see ThemeMechanism)
@ -18,103 +20,9 @@ Plugins can be used to package ordinary content, or can include JavaScript [[mod
Plugins conventionally have a title of the form `$:/plugins/publisher/name`. Plugins that are part of the core TiddlyWiki distribution have titles of the form `$:/plugins/tiddlywiki/name`. Plugins conventionally have a title of the form `$:/plugins/publisher/name`. Plugins that are part of the core TiddlyWiki distribution have titles of the form `$:/plugins/tiddlywiki/name`.
Plugins that define macros, views or other named entities are expected to prefix the name with their publisher identifier, for example: `tiddlytools.slider`. When [[running TiddlyWiki under Node.js|TiddlyWiki on Node.js]], plugins can also be stored as individual tiddler files in [[PluginFolders]].
! Plugin fields ! More information
Plugins are stored as tiddlers with the following fields: <<list-links "[tag[PluginMechanism]]">>
|!Field |!Description |
|title |Title of plugin |
|description |Description of plugin |
|author |Author of plugin |
|version |Version string (must conform to [ext[SemanticVersioning|http://semver.org/]] convention) |
|source |Source URL of plugin |
|type |Must be ''application/json'' |
|plugin-type |Can be ''plugin'' (default), ''language'' or ''theme'' |
|text |JSON encoding of the list of tiddlers comprising the plugin |
|list |Names of exposed plugin information tiddlers (see below) |
|name |Name of the theme (only for themes) |
|dependents |List of dependent plugins (currently only implemented for themes) |
! Plugin folders
On the server, plugins can be stored as ordinary JSON tiddlers but it is often more convenient to store them as separate tiddler files within folders. Plugin folders must contain a `plugin.info` file that contains the metadata for the plugin. It can also optionally identify files external to the plugin folder that should be loaded as tiddlers.
The `plugin.info` file should contain the following JSON structure:
The JSON structure for plugin tiddlers is as follows:
```
{
"title": "$:/plugins/publisher/name",
"description": "An exemplary plugin for demonstration purposes",
"author": "JeremyRuston",
"version": "1.2.3-alpha3",
"core-version": ">=5.0.0",
"source": "http://tiddlywiki.com/MyPlugin",
"plugin-type": "plugin",
"list": "readme license history"
}
```
By convention, the titles of the individual tiddlers are prefixed with the title of the containing plugin, but they are not restricted to do so.
Note that if the `version` field is omitted from a `plugin.info` file when the plugin folder is packed then it is automatically filled in by the core to the current core version number. This is to ensure that all the core plugins carry the correct version number. Generally plugin authors will want to ensure that they do explicitly specify a version number.
! Plugin library
The standard distribution of TiddlyWiki includes a number of standard plugins in the `plugins` directory.
! Including plugins in a wiki
To be usable in the browser, plugins just need to be included in the wiki. For wikis that are generated on the server, TiddlyWikiFolders can contain a `tiddlywiki.info` file that identifies the plugins to be included in this wiki:
```
{
"plugins": [
"tiddlywiki/slider",
"tiddlytools/chooser"
]
}
```
Plugins names refer to plugin folders listed in TiddlyWiki5's root `plugins` folder.
Plugins can also be included manually by copying them into the `plugins` subfolder of the wiki.
! Plugin processing
The wiki object keeps track of all of the currently loaded plugins. If a request for a tiddler isn't in the store then the wiki looks through the cascade of plugins to find the requested tiddler. It is a similar idea to the way that shadow tiddlers are implemented in classic TiddlyWiki.
In the browser, any constituent tiddlers that are JavaScript modules (ie shadow tiddlers of content type `application/javascript` and possessing the field `module-type`) are executed during startup processing.
!! Disabling Plugins
Plugins can be disabled by creating a tiddler titled `$:/config/Plugins/Disabled/` concatenated with the plugin title, and setting its text to `yes`.
For example, to disable the plugin `$:/plugins/tiddlywiki/highlight`, the title would be:
```
$:/config/Plugins/Disabled/$:/plugins/tiddlywiki/highlight
```
! Information Tiddlers for Plugins
Plugin authors are encouraged to provide special information and documentation tiddlers that TiddlyWiki can include as plugin information tabs in the [[control panel|$:/ControlPanel]].
Plugins should provide an icon contained in a tiddler with the title formed of `<plugin-name>/icon` (for example, [[$:/core/icon]]).
Plugins expose the names of the individual information tabs that they wish to display in the `list` field of the plugin tiddler. By convention, some or all of the following should be provided:
* ''readme'': basic information about the plugin
* ''license'': the license under which the plugin is published
The title of the associated information tiddler must be formed as follows:
# `$:/<plugin-name>/<current-language>/<tab-name>` (for example, ''$:/core/en-GB/readme'')
# `$:/<plugin-name>/<tab-name>` (for example, ''$:/core/readme'')
Thus, plugins can provide language-specific versions of each information tiddler.
Note that information tiddlers should not reference other tiddlers within the plugin. This is because plugins containing themes or languages are dynamically switched in and out as they are selected, and so their information tiddlers may not be available for viewing. The control panel uses the 'subtiddler' attribute of the TranscludeWidget to access these tiddlers, which works independently of the plugin switching mechanism.

View File

@ -0,0 +1,52 @@
created: 20161015114118243
modified: 20161015151555834
tags: TiddlyWikiFolders
title: tiddlywiki.files Files
type: text/vnd.tiddlywiki
! Introduction
A `tiddlywiki.files` JSON file in a sub-folder within [[a TiddlyWiki folder|TiddlyWikiFolders]] overrides the usual logic for recursively scanning the folder for tiddler files. Instead, the `tiddlywiki.files` file specifies instructions for loading tiddlers from specific files and folders.
The format of the file is an object with two optional properties:
* ''tiddlers'' - an array of objects describing external files with the ability to override or modify any of the fields read from the file
* ''directories'' - an array of objects describing external directories, a filter determining which files within those directories should be processed, and the ability to override or modify any of the fields read from the file
Note that significant enhancements to `tiddlywiki.files` processing were introduced in [[Release 5.1.14]].
!! Field overrides
Both the ''tiddlers'' and ''directories'' sections of `tiddlywiki.files` files include the ability to override or customise the values of fields with a `fields` object.
Each field can be specified as either a ''string'' or ''array'' value to be assigned directly to the field, or <<.from-version "5.1.14">> an ''object'' describing how to generate the value for the field. The object contains the following properties:
* ''source'' - (optional) a string specifying the source value for the field. If not specified, the existing value is used
** //filename// the filename of the file containing the tiddler
** //basename// the filename of the file containing the tiddler without any extension
** //extname// the extension of the filename of the file containing the tiddler
** //created// the creation date/time of the file containing the tiddler
** //modified// the modification date/time of the file containing the tiddler
* ''prefix'' - (optional) a string to be prepended to the value of the field
* ''suffix'' - (optional) a string to be appended to the value of the field
! Tiddlers section
The file specifications in the `tiddlers` array support the following properties:
* ''file'': (required) the absolute or relative path to the file containing the tiddler data (relative paths are interpreted relative to the path of the `tiddlywiki.files` file)
* ''isTiddlerFile'': (optional) if `true`, the file will be treated as a [[tiddler file|TiddlerFiles]] and deserialised to extract the tiddlers. Otherwise, the raw content of the file is assigned to the `text` field without any parsing
* ''fields'': (optional) an object containing values that override or customise the fields provided in the tiddler file (see above)
* ''prefix'' & ''suffix'': (optional) strings to be prefixed and suffixed to the tiddler `text` field
*> Note that providing a ''prefix'' here is equivalent to setting the `text` field of the ''fields'' object to `{"prefix":"<prefixvalue>"}`.
! Directories section
Directory specifications in the `directories` array may take the following forms:
* a ''string'' literal, specifying the absolute or relative path to the directory containing the tiddler files (relative paths are interpreted relative to the path of the `tiddlywiki.files` file). The directory is recursively searched for tiddler files
* <<.from-version "5.1.14">> an ''object'' with the following properties:
** ''path'' - (required) the absolute or relative path to the directory containing the tiddler files (relative paths are interpreted relative to the path of the `tiddlywiki.files` file). Note that the directory is not recursively searched; sub-directories are ignored
** ''filesRegExp'' - (optional) a [[regular expression]] that matches the filenames of the files that should be processed within the directory
** ''isTiddlerFile'' - (required) if `true`, the file will be treated as a [[tiddler file|TiddlerFiles]] and deserialised to extract the tiddlers. Otherwise, the raw content of the file is assigned to the `text` field without any parsing
** ''fields'' - (required) an object containing values that override or customise the fields provided in the tiddler file (see above)

View File

@ -0,0 +1,59 @@
created: 20161015114042793
modified: 20161015121622327
tags: TiddlyWikiFolders
title: tiddlywiki.info Files
type: text/vnd.tiddlywiki
[[TiddlyWikiFolders]] are configured with a single `tiddlywiki.info` file in the root of the wiki folder. It should contain a JSON object comprising the following properties:
* ''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
}
}
```

View File

@ -0,0 +1,15 @@
created: 20161015121727194
modified: 20161015121728291
tags: PluginMechanism
title: Disabling Plugins
type: text/vnd.tiddlywiki
!! Disabling Plugins
Plugins can be disabled by creating a tiddler titled `$:/config/Plugins/Disabled/` concatenated with the plugin title, and setting its text to `yes`.
For example, to disable the plugin `$:/plugins/tiddlywiki/highlight`, the title would be:
```
$:/config/Plugins/Disabled/$:/plugins/tiddlywiki/highlight
```

View File

@ -0,0 +1,28 @@
created: 20161015113519246
modified: 20161015113833256
tags: PluginMechanism
title: PluginFolders
type: text/vnd.tiddlywiki
On the server, plugins can be stored as ordinary JSON tiddlers but it is often more convenient to store them as separate tiddler files within folders. Plugin folders must contain a `plugin.info` file that contains the metadata for the plugin. It can also optionally identify files external to the plugin folder that should be loaded as tiddlers.
The `plugin.info` file should contain the following JSON structure:
The JSON structure for plugin tiddlers is as follows:
```
{
"title": "$:/plugins/publisher/name",
"description": "An exemplary plugin for demonstration purposes",
"author": "JeremyRuston",
"version": "1.2.3-alpha3",
"core-version": ">=5.0.0",
"source": "http://tiddlywiki.com/MyPlugin",
"plugin-type": "plugin",
"list": "readme license history"
}
```
By convention, the titles of the individual tiddlers are prefixed with the title of the containing plugin, but they are not restricted to do so.
Note that if the `version` field is omitted from a `plugin.info` file when the plugin folder is packed then it is automatically filled in by the core to the current core version number. This is to ensure that all the core plugins carry the correct version number. Generally plugin authors will want to ensure that they do explicitly specify a version number.

View File

@ -0,0 +1,22 @@
created: 20161015122718559
modified: 20161015122719647
tags: PluginMechanism
title: Plugin Fields
type: text/vnd.tiddlywiki
! Plugin fields
Plugins are stored as tiddlers with the following fields:
|!Field |!Description |
|title |Title of plugin |
|description |Description of plugin |
|author |Author of plugin |
|version |Version string (must conform to [ext[SemanticVersioning|http://semver.org/]] convention) |
|source |Source URL of plugin |
|type |Must be ''application/json'' |
|plugin-type |Can be ''plugin'' (default), ''language'' or ''theme'' |
|text |JSON encoding of the list of tiddlers comprising the plugin |
|list |Names of exposed plugin information tiddlers (see below) |
|name |Name of the theme (only for themes) |
|dependents |List of dependent plugins (currently only implemented for themes) |

View File

@ -0,0 +1,25 @@
created: 20161015121708376
modified: 20161015121709477
tags: PluginMechanism
title: Plugin Information Tiddlers
type: text/vnd.tiddlywiki
! Information Tiddlers for Plugins
Plugin authors are encouraged to provide special information and documentation tiddlers that TiddlyWiki can include as plugin information tabs in the [[control panel|$:/ControlPanel]].
Plugins should provide an icon contained in a tiddler with the title formed of `<plugin-name>/icon` (for example, [[$:/core/icon]]).
Plugins expose the names of the individual information tabs that they wish to display in the `list` field of the plugin tiddler. By convention, some or all of the following should be provided:
* ''readme'': basic information about the plugin
* ''license'': the license under which the plugin is published
The title of the associated information tiddler must be formed as follows:
# `$:/<plugin-name>/<current-language>/<tab-name>` (for example, ''$:/core/en-GB/readme'')
# `$:/<plugin-name>/<tab-name>` (for example, ''$:/core/readme'')
Thus, plugins can provide language-specific versions of each information tiddler.
Note that information tiddlers should not reference other tiddlers within the plugin. This is because plugins containing themes or languages are dynamically switched in and out as they are selected, and so their information tiddlers may not be available for viewing. The control panel uses the 'subtiddler' attribute of the TranscludeWidget to access these tiddlers, which works independently of the plugin switching mechanism.

View File

@ -1,126 +1,17 @@
{ {
"directories": [
{
"path": "./fonts/",
"filesRegExp": "^.*\\.woff$",
"isTiddlerFile": false,
"fields": {
"title": {"source": "filename", "prefix": "$:/plugins/tiddlywiki/katex/fonts/"},
"type": "application/font-woff"
}
}
],
"tiddlers": [ "tiddlers": [
{ {
"file": "fonts/KaTeX_AMS-Regular.woff",
"fields": {
"type": "application/font-woff",
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_AMS-Regular.woff"
}
},{
"file": "fonts/KaTeX_Caligraphic-Bold.woff",
"fields": {
"type": "application/font-woff",
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Caligraphic-Bold.woff"
}
},{
"file": "fonts/KaTeX_Caligraphic-Regular.woff",
"fields": {
"type": "application/font-woff",
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Caligraphic-Regular.woff"
}
},{
"file": "fonts/KaTeX_Fraktur-Bold.woff",
"fields": {
"type": "application/font-woff",
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Fraktur-Bold.woff"
}
},{
"file": "fonts/KaTeX_Fraktur-Regular.woff",
"fields": {
"type": "application/font-woff",
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Fraktur-Regular.woff"
}
},{
"file": "fonts/KaTeX_Main-Bold.woff",
"fields": {
"type": "application/font-woff",
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Main-Bold.woff"
}
},{
"file": "fonts/KaTeX_Main-Italic.woff",
"fields": {
"type": "application/font-woff",
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Main-Italic.woff"
}
},{
"file": "fonts/KaTeX_Main-Regular.woff",
"fields": {
"type": "application/font-woff",
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Main-Regular.woff"
}
},{
"file": "fonts/KaTeX_Math-BoldItalic.woff",
"fields": {
"type": "application/font-woff",
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Math-BoldItalic.woff"
}
},{
"file": "fonts/KaTeX_Math-Italic.woff",
"fields": {
"type": "application/font-woff",
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Math-Italic.woff"
}
},{
"file": "fonts/KaTeX_Math-Regular.woff",
"fields": {
"type": "application/font-woff",
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Math-Regular.woff"
}
},{
"file": "fonts/KaTeX_SansSerif-Bold.woff",
"fields": {
"type": "application/font-woff",
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_SansSerif-Bold.woff"
}
},{
"file": "fonts/KaTeX_SansSerif-Italic.woff",
"fields": {
"type": "application/font-woff",
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_SansSerif-Italic.woff"
}
},{
"file": "fonts/KaTeX_SansSerif-Regular.woff",
"fields": {
"type": "application/font-woff",
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_SansSerif-Regular.woff"
}
},{
"file": "fonts/KaTeX_Script-Regular.woff",
"fields": {
"type": "application/font-woff",
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Script-Regular.woff"
}
},{
"file": "fonts/KaTeX_Size1-Regular.woff",
"fields": {
"type": "application/font-woff",
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Size1-Regular.woff"
}
},{
"file": "fonts/KaTeX_Size2-Regular.woff",
"fields": {
"type": "application/font-woff",
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Size2-Regular.woff"
}
},{
"file": "fonts/KaTeX_Size3-Regular.woff",
"fields": {
"type": "application/font-woff",
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Size3-Regular.woff"
}
},{
"file": "fonts/KaTeX_Size4-Regular.woff",
"fields": {
"type": "application/font-woff",
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Size4-Regular.woff"
}
},{
"file": "fonts/KaTeX_Typewriter-Regular.woff",
"fields": {
"type": "application/font-woff",
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Typewriter-Regular.woff"
}
},{
"file": "katex.without-font-face.min.css", "file": "katex.without-font-face.min.css",
"fields": { "fields": {
"type": "text/plain", "type": "text/plain",