Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Server.prototype.start = function(prefix) {
var socketPath = path.join(this.socketDir, prefix);
var wikiPath = path.join(this.wikiDir, prefix);
console.log("Starting server at " + prefix + " for " + wikiPath);
// Create the server on a unix socket path
var $tw = require("tiddlywiki/boot/bootprefix.js").bootprefix();
delete $tw.browser;
var server = require("tiddlywiki/boot/boot.js").TiddlyWiki($tw);
server.boot.argv = [wikiPath, '--unixserver', socketPath]
server.boot.boot();
// Save the server to the object, so we can shut it down later if needed.
this.servers[prefix] = server;
// Setup the proxy rules to route to the correct location.
this.proxyRules.rules["/" + prefix] = {socketPath: socketPath};
};
Server.prototype.start = function(prefix) {
var socketPath = path.join(this.socketDir, prefix);
var wikiPath = path.join(this.wikiDir, prefix);
console.log("Starting server at " + prefix + " for " + wikiPath);
// Create the server on a unix socket path
var $tw = require("tiddlywiki/boot/bootprefix.js").bootprefix();
delete $tw.browser;
var server = require("tiddlywiki/boot/boot.js").TiddlyWiki($tw);
server.boot.argv = [wikiPath, '--unixserver', socketPath]
server.boot.boot();
// Save the server to the object, so we can shut it down later if needed.
this.servers[prefix] = server;
// Setup the proxy rules to route to the correct location.
this.proxyRules.rules["/" + prefix] = {socketPath: socketPath};
};
gulp.task('bundle the plugin', (cb) => {
// init the tw environment
const $tw = TiddlyWiki.TiddlyWiki();
// set the output to verbose;
// Attention: argv always needs to contain at least one element,
// otherwise the wiki instance will issue a help output.
// @see https://github.com/Jermolene/TiddlyWiki5/issues/2238
$tw.boot.argv = [
'--verbose'
];
// trigger the startup; since we are not in a browser environment,
// we need to call boot() explicitly.
$tw.boot.boot();
// bundle from the plugin files as json
const plugin = $tw.loadPluginFolder(path.resolve(outPath.dist, pluginNamespace));
function loadTiddlyWiki(wikiPath) {
// ref $TiddlyWikiRepoRoot/boot/boot.js at _boot top
var $tw0 = require(path.join(tiddlywiki_root,
"boot", "bootprefix.js")).bootprefix({
browser: null
});
// ref $TiddlyWikiRepoRoot/boot/boot.js:startup()
var $tw = tiddlywiki.TiddlyWiki($tw0);
$tw.boot.argv = [];
$tw.boot.wikiPath = expandUserHome(wikiPath);
// Get the URL hash and check for safe mode
$tw.locationHash = "#";
if($tw.browser && !$tw.node) {
if(location.hash === "#:safe") {
$tw.safeMode = true;
} else {
$tw.locationHash = $tw.utils.getLocationHash();
}
}
// Initialise some more $tw properties
$tw.utils.deepDefaults($tw,{
modules: { // Information about each module
titles: Object.create(null), // hashmap by module title of {fn:, exports:, moduleType:}
/*
Run the TW5FontAwesome development TiddlyWiki server by simply running
this Nodejs module. This module is wired up as the "main" module in the
package metadata "package.json".
*/
var $tw = require("tiddlywiki").TiddlyWiki();
if (process.argv.length > 2) {
$tw.boot.argv = process.argv.slice(2);
} else {
$tw.boot.argv = "editions/develop --verbose --server 8080 $:/core/save/all text/plain text/html".split(" ");
}
console.log("Booting TW:", $tw.boot.argv.join(" "));
$tw.boot.boot();
function loadTiddlyWiki(prefix: string, folder: string) {
console.time('twboot');
const $tw = require("tiddlywiki").TiddlyWiki();
$tw.boot.argv = [folder];
const execute = $tw.boot.executeNextStartupTask;
$tw.boot.executeNextStartupTask = function () {
const res = execute();
if (!res) complete();
return true;
}
function complete() {
console.log('complete');
console.timeEnd('twboot');
//we use $tw.modules.execute so that the module has its respective $tw variable.
var serverCommand = $tw.modules.execute('$:/core/modules/commands/server.js').Command;
var command = new serverCommand([], { wiki: $tw.wiki });
var server = command.server;
server.set({