Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Shenlin
/
markdown-view
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
lintry
2018-01-09 14:10:11 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b0bb3067bc9826054ff1577efb75a366f3d6204f
b0bb3067
1 parent
c7f78971
绑定端口参数化
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
5 deletions
init/config.js
server.js
init/config.js
View file @
b0bb306
...
...
@@ -6,6 +6,9 @@
const
customize
=
require
(
'kml-customize'
);
const
configure
=
customize
({
"system"
:
{
"bind_port"
:
8200
,
},
"md"
:
{
"base_path"
:
"md"
,
"default_md"
:
"readme.md"
,
...
...
server.js
View file @
b0bb306
const
express
=
require
(
'express'
);
const
app
=
express
();
const
config
=
require
(
'./init/config'
)
.
md
;
const
config
=
require
(
'./init/config'
);
const
mdview
=
new
(
require
(
'./lib/mdview'
)),
path
=
require
(
'path'
);
const
MARKDOWN_FILE_BASE
=
path
.
resolve
(
process
.
cwd
(),
config
.
base_path
);
const
MARKDOWN_FILE_BASE
=
path
.
resolve
(
process
.
cwd
(),
config
.
md
.
base_path
);
app
.
use
(
express
.
static
(
__dirname
+
'/themes'
));
app
.
use
(
express
.
static
(
MARKDOWN_FILE_BASE
));
...
...
@@ -14,7 +14,7 @@ app.use(express.static(MARKDOWN_FILE_BASE));
function
sendTemplate
(
filename
,
theme
)
{
//默认md
if
(
!
filename
||
filename
.
match
(
/.+
\/
$/
))
{
filename
=
(
filename
||
''
)
+
config
.
default_md
filename
=
(
filename
||
''
)
+
config
.
md
.
default_md
}
let
file
=
path
.
resolve
(
MARKDOWN_FILE_BASE
,
filename
);
if
(
!
path
.
parse
(
file
).
ext
)
{
...
...
@@ -22,7 +22,7 @@ function sendTemplate (filename, theme) {
file
+=
'.md'
}
let
result
=
mdview
.
renderFile
(
file
);
theme
=
theme
||
config
.
theme
;
theme
=
theme
||
config
.
md
.
theme
;
return
`
<!DOCTYPE html>
<html>
...
...
@@ -47,6 +47,6 @@ app.get('/**', function (req, res) {
res
.
send
(
sendTemplate
(
urls
[
1
],
query
.
t
));
})
const
PORT
=
3000
;
const
PORT
=
config
.
system
.
bind_port
;
app
.
listen
(
PORT
);
console
.
info
(
`Server is started up by binding
${
PORT
}
. Visit http://localhost:
${
PORT
}
`
);
...
...
Please
register
or
login
to post a comment