mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-01-06 15:39:04 +00:00
Allow setting boot, wiki, and pathPrefix for each request (#4649)
* Add pathPrefix to state, and options to request handler * use ternary operator instead of default empty object * Fix styling issues * Update server.js * Add boot to server and filesystem adapter
This commit is contained in:
@@ -19,9 +19,10 @@ var fs = $tw.node ? require("fs") : null,
|
||||
function FileSystemAdaptor(options) {
|
||||
var self = this;
|
||||
this.wiki = options.wiki;
|
||||
this.boot = options.boot || $tw.boot;
|
||||
this.logger = new $tw.utils.Logger("filesystem",{colour: "blue"});
|
||||
// Create the <wiki>/tiddlers folder if it doesn't exist
|
||||
$tw.utils.createDirectory($tw.boot.wikiTiddlersPath);
|
||||
$tw.utils.createDirectory(this.boot.wikiTiddlersPath);
|
||||
}
|
||||
|
||||
FileSystemAdaptor.prototype.name = "filesystem";
|
||||
@@ -43,22 +44,22 @@ Return a fileInfo object for a tiddler, creating it if necessary:
|
||||
type: the type of the tiddler file (NOT the type of the tiddler -- see below)
|
||||
hasMetaFile: true if the file also has a companion .meta file
|
||||
|
||||
The boot process populates $tw.boot.files for each of the tiddler files that it loads. The type is found by looking up the extension in $tw.config.fileExtensionInfo (eg "application/x-tiddler" for ".tid" files).
|
||||
The boot process populates this.boot.files for each of the tiddler files that it loads. The type is found by looking up the extension in $tw.config.fileExtensionInfo (eg "application/x-tiddler" for ".tid" files).
|
||||
|
||||
It is the responsibility of the filesystem adaptor to update $tw.boot.files for new files that are created.
|
||||
It is the responsibility of the filesystem adaptor to update this.boot.files for new files that are created.
|
||||
*/
|
||||
FileSystemAdaptor.prototype.getTiddlerFileInfo = function(tiddler,callback) {
|
||||
// See if we've already got information about this file
|
||||
var title = tiddler.fields.title,
|
||||
fileInfo = $tw.boot.files[title];
|
||||
fileInfo = this.boot.files[title];
|
||||
if(!fileInfo) {
|
||||
// Otherwise, we'll need to generate it
|
||||
fileInfo = $tw.utils.generateTiddlerFileInfo(tiddler,{
|
||||
directory: $tw.boot.wikiTiddlersPath,
|
||||
directory: this.boot.wikiTiddlersPath,
|
||||
pathFilters: this.wiki.getTiddlerText("$:/config/FileSystemPaths","").split("\n"),
|
||||
wiki: this.wiki
|
||||
});
|
||||
$tw.boot.files[title] = fileInfo;
|
||||
this.boot.files[title] = fileInfo;
|
||||
}
|
||||
callback(null,fileInfo);
|
||||
};
|
||||
@@ -91,7 +92,7 @@ Delete a tiddler and invoke the callback with (err)
|
||||
*/
|
||||
FileSystemAdaptor.prototype.deleteTiddler = function(title,callback,options) {
|
||||
var self = this,
|
||||
fileInfo = $tw.boot.files[title];
|
||||
fileInfo = this.boot.files[title];
|
||||
// Only delete the tiddler if we have writable information for the file
|
||||
if(fileInfo) {
|
||||
// Delete the file
|
||||
|
||||
Reference in New Issue
Block a user