2012-05-11 16:36:04 +00:00
|
|
|
/*\
|
|
|
|
title: $:/core/modules/commands/server.js
|
|
|
|
type: application/javascript
|
|
|
|
module-type: command
|
|
|
|
|
2018-07-18 15:54:43 +00:00
|
|
|
Deprecated legacy command for serving tiddlers
|
2012-05-11 16:36:04 +00:00
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
2018-07-18 15:54:43 +00:00
|
|
|
var Server = require("$:/core/modules/server/server.js").Server;
|
2013-03-17 17:57:46 +00:00
|
|
|
|
2012-05-11 16:36:04 +00:00
|
|
|
exports.info = {
|
|
|
|
name: "server",
|
|
|
|
synchronous: true
|
|
|
|
};
|
|
|
|
|
2013-03-17 17:57:46 +00:00
|
|
|
var Command = function(params,commander,callback) {
|
2018-07-18 15:54:43 +00:00
|
|
|
var self = this;
|
2013-03-17 17:57:46 +00:00
|
|
|
this.params = params;
|
|
|
|
this.commander = commander;
|
|
|
|
this.callback = callback;
|
|
|
|
};
|
|
|
|
|
|
|
|
Command.prototype.execute = function() {
|
2014-10-21 18:31:29 +00:00
|
|
|
if(!$tw.boot.wikiTiddlersPath) {
|
2014-10-22 15:47:20 +00:00
|
|
|
$tw.utils.warning("Warning: Wiki folder '" + $tw.boot.wikiPath + "' does not exist or is missing a tiddlywiki.info file");
|
2014-10-21 18:31:29 +00:00
|
|
|
}
|
2018-07-18 15:54:43 +00:00
|
|
|
// Set up server
|
|
|
|
this.server = new Server({
|
|
|
|
wiki: this.commander.wiki,
|
|
|
|
variables: {
|
|
|
|
port: this.params[0],
|
|
|
|
host: this.params[6],
|
|
|
|
"root-tiddler": this.params[1],
|
|
|
|
"root-render-type": this.params[2],
|
|
|
|
"root-serve-type": this.params[3],
|
|
|
|
username: this.params[4],
|
|
|
|
password: this.params[5],
|
|
|
|
"path-prefix": this.params[7],
|
|
|
|
"debug-level": this.params[8]
|
|
|
|
}
|
|
|
|
});
|
|
|
|
var nodeServer = this.server.listen();
|
2018-11-29 09:51:11 +00:00
|
|
|
$tw.hooks.invokeHook("th-server-command-post-start",this.server,nodeServer,"tiddlywiki");
|
2012-05-11 16:36:04 +00:00
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.Command = Command;
|
|
|
|
|
|
|
|
})();
|