Skip to content

Commit 6291813

Browse files
authored
Merge branch 'develop' into feature/lutim
2 parents 82ac870 + 9f16f32 commit 6291813

File tree

117 files changed

+8775
-6308
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+8775
-6308
lines changed

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.git/
2+
node_modules/
3+
docs/
4+
test/
5+
.sequelizerc.example
6+
config.json.example
7+
public/build
8+

.eslintignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ public/views/build
2727

2828
public/uploads/*
2929
!public/uploads/.gitkeep
30+
/.nyc_output
31+
/coverage/

.travis.yml

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,34 @@
11
language: node_js
2-
dist: trusty
2+
3+
node_js:
4+
- "lts/carbon"
5+
- "lts/dubnium"
6+
- "11"
7+
- "12"
8+
9+
dist: xenial
310
cache: yarn
4-
env:
5-
global:
6-
- CXX=g++-4.8
7-
- YARN_VERSION=1.3.2
11+
12+
matrix:
13+
fast_finish: true
14+
include:
15+
- node_js: lts/carbon
16+
- node_js: lts/dubnium
17+
allow_failures:
18+
- node_js: "11"
19+
- node_js: "12"
20+
21+
script:
22+
- yarn test:ci
23+
- yarn build
824

925
jobs:
1026
include:
11-
- env: task=npm-test
12-
node_js:
13-
- 6
14-
before_install:
15-
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version "$YARN_VERSION"
16-
- export PATH="$HOME/.yarn/bin:$PATH"
17-
- env: task=npm-test
18-
node_js:
19-
- 8
20-
before_install:
21-
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version "$YARN_VERSION"
22-
- export PATH="$HOME/.yarn/bin:$PATH"
23-
- env: task=npm-test
24-
node_js:
25-
- 10
26-
before_install:
27-
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version "$YARN_VERSION"
28-
- export PATH="$HOME/.yarn/bin:$PATH"
29-
- env: task=ShellCheck
30-
script:
31-
- shellcheck bin/heroku bin/setup
32-
language: generic
33-
- env: task=doctoc
34-
install: npm install doctoc
27+
- stage: doctoc-check
28+
install: npm install -g doctoc
29+
if: type = pull_request OR branch = master
3530
script:
3631
- cp README.md README.md.orig
3732
- npm run doctoc
3833
- diff -q README.md README.md.orig
39-
language: generic
40-
- env: task=json-lint
41-
addons:
42-
apt:
43-
packages:
44-
- jq
45-
script:
46-
- npm run jsonlint
47-
language: generic
34+
node_js: lts/carbon

README.md

Lines changed: 79 additions & 356 deletions
Large diffs are not rendered by default.

app.js

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ var ejs = require('ejs')
77
var passport = require('passport')
88
var methodOverride = require('method-override')
99
var cookieParser = require('cookie-parser')
10-
var compression = require('compression')
1110
var session = require('express-session')
1211
var SequelizeStore = require('connect-session-sequelize')(session.Store)
1312
var fs = require('fs')
@@ -26,31 +25,34 @@ var response = require('./lib/response')
2625
var models = require('./lib/models')
2726
var csp = require('./lib/csp')
2827

29-
// server setup
30-
var app = express()
31-
var server = null
32-
if (config.useSSL) {
33-
var ca = (function () {
34-
var i, len, results
35-
results = []
36-
for (i = 0, len = config.sslCAPath.length; i < len; i++) {
37-
results.push(fs.readFileSync(config.sslCAPath[i], 'utf8'))
28+
function createHttpServer () {
29+
if (config.useSSL) {
30+
const ca = (function () {
31+
let i, len, results
32+
results = []
33+
for (i = 0, len = config.sslCAPath.length; i < len; i++) {
34+
results.push(fs.readFileSync(config.sslCAPath[i], 'utf8'))
35+
}
36+
return results
37+
})()
38+
const options = {
39+
key: fs.readFileSync(config.sslKeyPath, 'utf8'),
40+
cert: fs.readFileSync(config.sslCertPath, 'utf8'),
41+
ca: ca,
42+
dhparam: fs.readFileSync(config.dhParamPath, 'utf8'),
43+
requestCert: false,
44+
rejectUnauthorized: false
3845
}
39-
return results
40-
})()
41-
var options = {
42-
key: fs.readFileSync(config.sslKeyPath, 'utf8'),
43-
cert: fs.readFileSync(config.sslCertPath, 'utf8'),
44-
ca: ca,
45-
dhparam: fs.readFileSync(config.dhParamPath, 'utf8'),
46-
requestCert: false,
47-
rejectUnauthorized: false
46+
return require('https').createServer(options, app)
47+
} else {
48+
return require('http').createServer(app)
4849
}
49-
server = require('https').createServer(options, app)
50-
} else {
51-
server = require('http').createServer(app)
5250
}
5351

52+
// server setup
53+
var app = express()
54+
var server = createHttpServer()
55+
5456
// logger
5557
app.use(morgan('combined', {
5658
'stream': logger.stream
@@ -77,9 +79,6 @@ var sessionStore = new SequelizeStore({
7779
db: models.sequelize
7880
})
7981

80-
// compression
81-
app.use(compression())
82-
8382
// use hsts to tell https users stick to this
8483
if (config.hsts.enable) {
8584
app.use(helmet.hsts({
@@ -113,7 +112,7 @@ if (config.csp.enable) {
113112
}
114113

115114
i18n.configure({
116-
locales: ['en', 'zh-CN', 'zh-TW', 'fr', 'de', 'ja', 'es', 'ca', 'el', 'pt', 'it', 'tr', 'ru', 'nl', 'hr', 'pl', 'uk', 'hi', 'sv', 'eo', 'da', 'ko', 'id'],
115+
locales: ['en', 'zh-CN', 'zh-TW', 'fr', 'de', 'ja', 'es', 'ca', 'el', 'pt', 'it', 'tr', 'ru', 'nl', 'hr', 'pl', 'uk', 'hi', 'sv', 'eo', 'da', 'ko', 'id', 'sr'],
117116
cookie: 'locale',
118117
directory: path.join(__dirname, '/locales'),
119118
updateFiles: config.updateI18nFiles
@@ -279,6 +278,7 @@ process.on('uncaughtException', function (err) {
279278
function handleTermSignals () {
280279
logger.info('CodiMD has been killed by signal, try to exit gracefully...')
281280
realtime.maintenance = true
281+
realtime.terminate()
282282
// disconnect all socket.io clients
283283
Object.keys(io.sockets.sockets).forEach(function (key) {
284284
var socket = io.sockets.sockets[key]
@@ -299,6 +299,9 @@ function handleTermSignals () {
299299
})
300300
}
301301
}, 100)
302+
setTimeout(() => {
303+
process.exit(1)
304+
}, 5000)
302305
}
303306
process.on('SIGINT', handleTermSignals)
304307
process.on('SIGTERM', handleTermSignals)

app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"Markdown",
77
"Notes"
88
],
9-
"website": "https://hackmd.io",
9+
"website": "https://github.com/hackmdio/codimd",
1010
"repository": "https://github.com/hackmdio/codimd",
1111
"logo": "https://github.com/hackmdio/codimd/raw/master/public/codimd-icon-1024.png",
1212
"success_url": "/",

0 commit comments

Comments
 (0)