1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-09 03:19:56 +00:00
TiddlyWiki5/editions/tw5.com/tiddlers/concepts/TiddlyWikiFolders.tid

125 lines
4.6 KiB
Plaintext
Raw Normal View History

2013-11-29 12:26:48 +00:00
created: 20130825214200000
modified: 20150728104424501
2014-09-12 15:05:37 +00:00
tags: [[TiddlyWiki on Node.js]]
2013-04-17 15:38:32 +00:00
title: TiddlyWikiFolders
2013-11-29 12:26:48 +00:00
type: text/vnd.tiddlywiki
2013-04-17 15:38:32 +00:00
2013-12-12 09:48:08 +00:00
As well as traditional single file wikis, [[TiddlyWiki on Node.js]] supports wikis that are stored as a folder of individual tiddler files.
2013-04-17 15:38:32 +00:00
! Wiki folder files and folders
Wiki folders can contain the following files and folders:
2013-08-30 19:06:23 +00:00
* ''tiddlywiki.info'' - JSON file containing metadata for the wiki
2013-04-17 15:38:32 +00:00
* ''\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.
2013-08-30 19:06:23 +00:00
!! Content of `tiddlywiki.info` file
2013-04-17 15:38:32 +00:00
The `tiddlywiki.info` file in a wiki folder contains a JSON object comprising the following fields:
2013-08-28 19:14:27 +00:00
* ''plugins'' - an array of plugin names to be included in the wiki
2014-02-27 16:30:05 +00:00
* ''themes'' - an array of theme names to be included in the wiki
* ''languages'' - an array of language names to be included in the wiki
2014-11-26 11:22:20 +00:00
* ''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)
2014-02-27 16:30:05 +00:00
* ''config'' - an optional hashmap of configuration options (see below)
2014-11-26 11:22:20 +00:00
!!! ''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.
2014-11-26 11:22:20 +00:00
!!! ''config''
2014-02-27 16:30:05 +00:00
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)
2014-02-27 16:30:05 +00:00
* ''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
2013-04-17 15:38:32 +00:00
2014-11-26 11:22:20 +00:00
!!! Example
2013-04-17 15:38:32 +00:00
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
}
2013-04-17 15:38:32 +00:00
}
```
2013-08-30 19:06:23 +00:00
!! Content of `tiddlers` folder
Make tiddler file paths configurable (#2379) When saving new tiddlers on node.js, allow the user to override the path of the generated .tid file. This is done by creating a tiddler $:/config/FileSystemPaths which contains one or more filter expressions, one per line. These filters are applied in turn to the tiddler to be saved, and the first output produced is taken as a logical path relative to the wiki's tiddlers directory. Any occurences of "/" in the logical path are replaced with the platform's path separator, the extension ".tid" is appended, illegal characters are replaced by "_" and the path is disambiguated (if necessary) in order to arrive at the final tiddler file path. If none of the filters matches, or the configuration tiddler does not exist, fall back to the previous file naming scheme (i.e. replacing "/" by "_"). This implies we will now, for tiddlers matching the user-specified filters, create directory trees below the tiddlers directory. In order to avoid cluttering it with empty directory trees when renaming or removing tiddlers, any directories that become empty by deleting a tiddler file are removed (recursively). Benefits of this configuration option include the ability to organize git repositories of TiddlyWikis running on node.js, ability to replace characters that cause trouble with particular operating systems or workflows (e.g. '$' on unix) and the ability to replicate tiddler "paths" in the filesystem (by including a filter like "[!has[draft.of]]") without forcing such a (potentially problematic) change on all users.
2016-04-25 07:36:32 +00:00
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|Customizing Tiddler File Naming]].
2013-08-30 19:06:23 +00:00
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:
2013-08-30 19:06:23 +00:00
```
{
"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"
]
2013-08-30 19:06:23 +00:00
}
```
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:
* The relative or absolute path to the file to include as either:
** `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
2013-08-30 19:06:23 +00:00
* `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.