QWiki can now be required as a module. If run directly, an instance of QWiki is created and started, as per before.
parent
2144e6d877
commit
7501ca4e41
44
index.js
44
index.js
|
|
@ -165,9 +165,26 @@ QWiki.prototype.savePage = function(wiki_page, content, cb) {
|
||||||
QWiki.prototype.deleteFile = function(file, cb) {
|
QWiki.prototype.deleteFile = function(file, cb) {
|
||||||
fs.unlink('wiki/'+file, cb);
|
fs.unlink('wiki/'+file, cb);
|
||||||
};
|
};
|
||||||
/*********************************
|
|
||||||
* qwiki instance *
|
if (require.main === module) {
|
||||||
*********************************/
|
var port = 8080;
|
||||||
|
process.argv.forEach(function (val, index, array) {
|
||||||
|
var parts = val.split('=');
|
||||||
|
var key = '';
|
||||||
|
var value = '';
|
||||||
|
if (parts[0].substr(0, 2) == '--') {
|
||||||
|
key = parts[0].substr(2);
|
||||||
|
value = parts[1];
|
||||||
|
}
|
||||||
|
if (key == 'port') {
|
||||||
|
if (value == '') {
|
||||||
|
console.log(key + ' needs a value');
|
||||||
|
} else {
|
||||||
|
port = Number(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var qwiki = new QWiki();
|
var qwiki = new QWiki();
|
||||||
|
|
||||||
qwiki.addMIMEtype('png', 'image/png');
|
qwiki.addMIMEtype('png', 'image/png');
|
||||||
|
|
@ -190,22 +207,7 @@ qwiki.addFormat('md', 'Markdown', function(source) {
|
||||||
|
|
||||||
qwiki.setDefault('format', 'md');
|
qwiki.setDefault('format', 'md');
|
||||||
|
|
||||||
var port = 8080;
|
|
||||||
process.argv.forEach(function (val, index, array) {
|
|
||||||
var parts = val.split('=');
|
|
||||||
var key = '';
|
|
||||||
var value = '';
|
|
||||||
if (parts[0].substr(0, 2) == '--') {
|
|
||||||
key = parts[0].substr(2);
|
|
||||||
value = parts[1];
|
|
||||||
}
|
|
||||||
if (key == 'port') {
|
|
||||||
if (value == '') {
|
|
||||||
console.log(key + ' needs a value');
|
|
||||||
} else {
|
|
||||||
port = Number(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
qwiki.listen(port, function() { qwiki.loadWikiIndex(); });
|
qwiki.listen(port, function() { qwiki.loadWikiIndex(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = QWiki;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue