lintry

绑定端口参数化

...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
6 const customize = require('kml-customize'); 6 const customize = require('kml-customize');
7 7
8 const configure = customize({ 8 const configure = customize({
9 + "system": {
10 + "bind_port": 8200,
11 + },
9 "md": { 12 "md": {
10 "base_path": "md", 13 "base_path": "md",
11 "default_md": "readme.md", 14 "default_md": "readme.md",
......
1 const express = require('express'); 1 const express = require('express');
2 const app = express(); 2 const app = express();
3 3
4 -const config = require('./init/config').md; 4 +const config = require('./init/config');
5 5
6 const mdview = new (require('./lib/mdview')), 6 const mdview = new (require('./lib/mdview')),
7 path = require('path'); 7 path = require('path');
8 8
9 -const MARKDOWN_FILE_BASE = path.resolve(process.cwd(), config.base_path); 9 +const MARKDOWN_FILE_BASE = path.resolve(process.cwd(), config.md.base_path);
10 10
11 app.use(express.static(__dirname + '/themes')); 11 app.use(express.static(__dirname + '/themes'));
12 app.use(express.static(MARKDOWN_FILE_BASE)); 12 app.use(express.static(MARKDOWN_FILE_BASE));
...@@ -14,7 +14,7 @@ app.use(express.static(MARKDOWN_FILE_BASE)); ...@@ -14,7 +14,7 @@ app.use(express.static(MARKDOWN_FILE_BASE));
14 function sendTemplate (filename, theme) { 14 function sendTemplate (filename, theme) {
15 //默认md 15 //默认md
16 if (!filename || filename.match(/.+\/$/)) { 16 if (!filename || filename.match(/.+\/$/)) {
17 - filename = (filename || '') + config.default_md 17 + filename = (filename || '') + config.md.default_md
18 } 18 }
19 let file = path.resolve(MARKDOWN_FILE_BASE, filename); 19 let file = path.resolve(MARKDOWN_FILE_BASE, filename);
20 if (!path.parse(file).ext) { 20 if (!path.parse(file).ext) {
...@@ -22,7 +22,7 @@ function sendTemplate (filename, theme) { ...@@ -22,7 +22,7 @@ function sendTemplate (filename, theme) {
22 file += '.md' 22 file += '.md'
23 } 23 }
24 let result = mdview.renderFile(file); 24 let result = mdview.renderFile(file);
25 - theme = theme || config.theme; 25 + theme = theme || config.md.theme;
26 return ` 26 return `
27 <!DOCTYPE html> 27 <!DOCTYPE html>
28 <html> 28 <html>
...@@ -47,6 +47,6 @@ app.get('/**', function (req, res) { ...@@ -47,6 +47,6 @@ app.get('/**', function (req, res) {
47 res.send(sendTemplate(urls[1], query.t)); 47 res.send(sendTemplate(urls[1], query.t));
48 }) 48 })
49 49
50 -const PORT = 3000; 50 +const PORT = config.system.bind_port;
51 app.listen(PORT); 51 app.listen(PORT);
52 console.info(`Server is started up by binding ${PORT}. Visit http://localhost:${PORT}`); 52 console.info(`Server is started up by binding ${PORT}. Visit http://localhost:${PORT}`);
......