2024-01-02 14:39:14 +00:00
|
|
|
/*\
|
|
|
|
title: $:/plugins/tiddlywiki/multiwikiserver/init.js
|
|
|
|
type: application/javascript
|
|
|
|
module-type: startup
|
|
|
|
|
|
|
|
Multi wiki server initialisation
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
// Export name and synchronous status
|
|
|
|
exports.name = "multiwikiserver";
|
|
|
|
exports.platforms = ["node"];
|
|
|
|
exports.before = ["story"];
|
|
|
|
exports.synchronous = true;
|
|
|
|
|
|
|
|
exports.startup = function() {
|
2024-01-05 10:58:07 +00:00
|
|
|
var path = require("path");
|
2024-02-16 16:02:40 +00:00
|
|
|
// Create and initialise the tiddler store and upload manager
|
|
|
|
var SqlTiddlerStore = require("$:/plugins/tiddlywiki/multiwikiserver/sql-tiddler-store.js").SqlTiddlerStore,
|
|
|
|
store = new SqlTiddlerStore({
|
2024-02-22 17:58:30 +00:00
|
|
|
databasePath: path.resolve($tw.boot.wikiPath,"store/database.sqlite"),
|
|
|
|
engine: $tw.wiki.getTiddlerText("$:/config/MultiWikiServer/Engine","better") // better || wasm
|
2024-02-16 16:02:40 +00:00
|
|
|
}),
|
|
|
|
UploadManager = require("$:/plugins/tiddlywiki/multiwikiserver/upload-manager.js").UploadManager,
|
|
|
|
uploadManager = new UploadManager({
|
|
|
|
inboxPath: path.resolve($tw.boot.wikiPath,"store/inbox"),
|
|
|
|
store: store
|
|
|
|
});
|
2024-02-05 14:49:08 +00:00
|
|
|
$tw.mws = {
|
2024-02-16 16:02:40 +00:00
|
|
|
store: store,
|
|
|
|
uploadManager: uploadManager
|
2024-02-05 14:49:08 +00:00
|
|
|
};
|
2024-02-20 09:33:39 +00:00
|
|
|
// Performance timing
|
|
|
|
console.time("mws-initial-load");
|
2024-02-22 11:57:41 +00:00
|
|
|
// Copy TiddlyWiki core editions
|
|
|
|
function copyEdition(options) {
|
|
|
|
console.log(`Copying edition ${options.tiddlersPath}`);
|
|
|
|
$tw.mws.store.createBag(options.bagName,options.bagDescription);
|
|
|
|
$tw.mws.store.createRecipe(options.recipeName,[options.bagName],options.recipeDescription);
|
|
|
|
$tw.mws.store.saveTiddlersFromPath(path.resolve($tw.boot.corePath,$tw.config.editionsPath,options.tiddlersPath),options.bagName);
|
|
|
|
}
|
2024-02-25 18:04:54 +00:00
|
|
|
copyEdition({
|
|
|
|
bagName: "docs",
|
|
|
|
bagDescription: "TiddlyWiki Documentation from https://tiddlywiki.com",
|
|
|
|
recipeName: "docs",
|
|
|
|
recipeDescription: "TiddlyWiki Documentation from https://tiddlywiki.com",
|
|
|
|
tiddlersPath: "tw5.com/tiddlers"
|
|
|
|
});
|
2024-02-22 11:57:41 +00:00
|
|
|
copyEdition({
|
|
|
|
bagName: "dev-docs",
|
|
|
|
bagDescription: "TiddlyWiki Developer Documentation from https://tiddlywiki.com/dev",
|
|
|
|
recipeName: "dev-docs",
|
|
|
|
recipeDescription: "TiddlyWiki Developer Documentation from https://tiddlywiki.com/dev",
|
|
|
|
tiddlersPath: "dev/tiddlers"
|
|
|
|
});
|
2024-01-02 14:39:14 +00:00
|
|
|
// Create bags and recipes
|
2024-02-05 14:49:08 +00:00
|
|
|
$tw.mws.store.createBag("bag-alpha","A test bag");
|
|
|
|
$tw.mws.store.createBag("bag-beta","Another test bag");
|
|
|
|
$tw.mws.store.createBag("bag-gamma","A further test bag");
|
|
|
|
$tw.mws.store.createRecipe("recipe-rho",["bag-alpha","bag-beta"],"First wiki");
|
|
|
|
$tw.mws.store.createRecipe("recipe-sigma",["bag-alpha","bag-gamma"],"Second Wiki");
|
|
|
|
$tw.mws.store.createRecipe("recipe-tau",["bag-alpha"],"Third Wiki");
|
|
|
|
$tw.mws.store.createRecipe("recipe-upsilon",["bag-alpha","bag-gamma","bag-beta"],"Fourth Wiki");
|
2024-01-02 14:39:14 +00:00
|
|
|
// Save tiddlers
|
2024-02-24 09:30:20 +00:00
|
|
|
$tw.mws.store.saveBagTiddler({title: "😀😃😄😁😆🥹😅😂",text: "Bag Alpha"},"bag-alpha");
|
2024-02-05 14:49:08 +00:00
|
|
|
$tw.mws.store.saveBagTiddler({title: "$:/SiteTitle",text: "Bag Alpha"},"bag-alpha");
|
|
|
|
$tw.mws.store.saveBagTiddler({title: "$:/SiteTitle",text: "Bag Beta"},"bag-beta");
|
|
|
|
$tw.mws.store.saveBagTiddler({title: "$:/SiteTitle",text: "Bag Gamma"},"bag-gamma");
|
2024-02-20 09:33:39 +00:00
|
|
|
console.timeEnd("mws-initial-load");
|
2024-01-02 14:39:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
})();
|