Skip to content

Commit fadc599

Browse files
committed
Merge branch 'develop'
2 parents 8947c89 + ec2b040 commit fadc599

File tree

19 files changed

+544
-55
lines changed

19 files changed

+544
-55
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,22 @@ CodiMD
99
CodiMD lets you collaborate in real-time with markdown.
1010
Built on [HackMD](https://hackmd.io) source code, CodiMD lets you host and control your team's content with speed and ease.
1111

12+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
13+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
14+
# Table of Contents
15+
16+
- [CodiMD - The Open Source HackMD](#codimd---the-open-source-hackmd)
17+
- [Documentation](#documentation)
18+
- [Deployment](#deployment)
19+
- [Configuration](#configuration)
20+
- [Upgrading and Migration](#upgrading-and-migration)
21+
- [Developer](#developer)
22+
- [Contribution and Discussion](#contribution-and-discussion)
23+
- [Browser Support](#browser-support)
24+
- [License](#license)
25+
26+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
27+
1228
## CodiMD - The Open Source HackMD
1329
[HackMD](https://hackmd.io) helps developers write better documents and build active communities with open collaboration.
1430
HackMD is built with one promise - **You own and control all your content**:

lib/config/default.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ module.exports = {
5656
// socket.io
5757
heartbeatInterval: 5000,
5858
heartbeatTimeout: 10000,
59+
// toobusy-js
60+
responseMaxLag: 70,
5961
// document
6062
documentMaxLength: 100000,
6163
// image upload setting, available options are imgur/s3/filesystem/azure
@@ -66,7 +68,8 @@ module.exports = {
6668
s3: {
6769
accessKeyId: undefined,
6870
secretAccessKey: undefined,
69-
region: undefined
71+
region: undefined,
72+
endpoint: undefined
7073
},
7174
minio: {
7275
accessKey: undefined,

lib/config/environment.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ module.exports = {
3333
dbURL: process.env.CMD_DB_URL,
3434
sessionSecret: process.env.CMD_SESSION_SECRET,
3535
sessionLife: toIntegerConfig(process.env.CMD_SESSION_LIFE),
36+
responseMaxLag: toIntegerConfig(process.env.CMD_RESPONSE_MAX_LAG),
3637
imageUploadType: process.env.CMD_IMAGE_UPLOAD_TYPE,
3738
imgur: {
3839
clientID: process.env.CMD_IMGUR_CLIENTID
3940
},
4041
s3: {
4142
accessKeyId: process.env.CMD_S3_ACCESS_KEY_ID,
4243
secretAccessKey: process.env.CMD_S3_SECRET_ACCESS_KEY,
43-
region: process.env.CMD_S3_REGION
44+
region: process.env.CMD_S3_REGION,
45+
endpoint: process.env.CMD_S3_ENDPOINT
4446
},
4547
minio: {
4648
accessKey: process.env.CMD_MINIO_ACCESS_KEY,

lib/config/hackmdEnvironment.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ module.exports = {
2828
dbURL: process.env.HMD_DB_URL,
2929
sessionSecret: process.env.HMD_SESSION_SECRET,
3030
sessionLife: toIntegerConfig(process.env.HMD_SESSION_LIFE),
31+
responseMaxLag: toIntegerConfig(process.env.HMD_RESPONSE_MAX_LAG),
3132
imageUploadType: process.env.HMD_IMAGE_UPLOAD_TYPE,
3233
imgur: {
3334
clientID: process.env.HMD_IMGUR_CLIENTID
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
'use strict'
22
module.exports = {
3-
up: function (queryInterface, Sequelize) {
4-
queryInterface.changeColumn('Notes', 'content', { type: Sequelize.TEXT('long') })
5-
queryInterface.changeColumn('Revisions', 'patch', { type: Sequelize.TEXT('long') })
6-
queryInterface.changeColumn('Revisions', 'content', { type: Sequelize.TEXT('long') })
7-
queryInterface.changeColumn('Revisions', 'lastContent', { type: Sequelize.TEXT('long') })
3+
up: async function (queryInterface, Sequelize) {
4+
await queryInterface.changeColumn('Notes', 'content', { type: Sequelize.TEXT('long') })
5+
await queryInterface.changeColumn('Revisions', 'patch', { type: Sequelize.TEXT('long') })
6+
await queryInterface.changeColumn('Revisions', 'content', { type: Sequelize.TEXT('long') })
7+
await queryInterface.changeColumn('Revisions', 'lastContent', { type: Sequelize.TEXT('long') })
88
},
99

10-
down: function (queryInterface, Sequelize) {
11-
queryInterface.changeColumn('Notes', 'content', { type: Sequelize.TEXT })
12-
queryInterface.changeColumn('Revisions', 'patch', { type: Sequelize.TEXT })
13-
queryInterface.changeColumn('Revisions', 'content', { type: Sequelize.TEXT })
14-
queryInterface.changeColumn('Revisions', 'lastContent', { type: Sequelize.TEXT })
10+
down: async function (queryInterface, Sequelize) {
11+
await queryInterface.changeColumn('Notes', 'content', { type: Sequelize.TEXT })
12+
await queryInterface.changeColumn('Revisions', 'patch', { type: Sequelize.TEXT })
13+
await queryInterface.changeColumn('Revisions', 'content', { type: Sequelize.TEXT })
14+
await queryInterface.changeColumn('Revisions', 'lastContent', { type: Sequelize.TEXT })
1515
}
1616
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
'use strict'
22

33
module.exports = {
4-
up: function (queryInterface, Sequelize) {
5-
queryInterface.changeColumn('Notes', 'authorship', { type: Sequelize.TEXT('long') })
6-
queryInterface.changeColumn('Revisions', 'authorship', { type: Sequelize.TEXT('long') })
4+
up: async function (queryInterface, Sequelize) {
5+
await queryInterface.changeColumn('Notes', 'authorship', { type: Sequelize.TEXT('long') })
6+
await queryInterface.changeColumn('Revisions', 'authorship', { type: Sequelize.TEXT('long') })
77
},
88

9-
down: function (queryInterface, Sequelize) {
10-
queryInterface.changeColumn('Notes', 'authorship', { type: Sequelize.TEXT })
11-
queryInterface.changeColumn('Revisions', 'authorship', { type: Sequelize.TEXT })
9+
down: async function (queryInterface, Sequelize) {
10+
await queryInterface.changeColumn('Notes', 'authorship', { type: Sequelize.TEXT })
11+
await queryInterface.changeColumn('Revisions', 'authorship', { type: Sequelize.TEXT })
1212
}
1313
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
'use strict'
22

33
module.exports = {
4-
up: function (queryInterface, Sequelize) {
5-
queryInterface.changeColumn('Notes', 'permission', { type: Sequelize.ENUM('freely', 'editable', 'limited', 'locked', 'protected', 'private') })
4+
up: async function (queryInterface, Sequelize) {
5+
await queryInterface.changeColumn('Notes', 'permission', { type: Sequelize.ENUM('freely', 'editable', 'limited', 'locked', 'protected', 'private') })
66
},
77

8-
down: function (queryInterface, Sequelize) {
9-
queryInterface.changeColumn('Notes', 'permission', { type: Sequelize.ENUM('freely', 'editable', 'locked', 'private') })
8+
down: async function (queryInterface, Sequelize) {
9+
await queryInterface.changeColumn('Notes', 'permission', { type: Sequelize.ENUM('freely', 'editable', 'locked', 'private') })
1010
}
1111
}

lib/response.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var config = require('./config')
1414
var logger = require('./logger')
1515
var models = require('./models')
1616
var utils = require('./utils')
17+
var history = require('./history')
1718

1819
// public
1920
var response = {
@@ -106,6 +107,12 @@ function responseCodiMD (res, note) {
106107
})
107108
}
108109

110+
function updateHistory (userId, note, document, time) {
111+
var noteId = note.alias ? note.alias : models.Note.encodeNoteId(note.id)
112+
history.updateHistory(userId, noteId, document, time)
113+
logger.info('history updated')
114+
}
115+
109116
function newNote (req, res, next) {
110117
var owner = null
111118
var body = ''
@@ -125,6 +132,10 @@ function newNote (req, res, next) {
125132
alias: req.alias ? req.alias : null,
126133
content: body
127134
}).then(function (note) {
135+
if (req.isAuthenticated()) {
136+
updateHistory(owner, note, body)
137+
}
138+
128139
return res.redirect(config.serverURL + '/' + models.Note.encodeNoteId(note.id))
129140
}).catch(function (err) {
130141
logger.error(err)

lib/web/auth/mattermost/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22
require('babel-polyfill')
3-
require('isomorphic-fetch');
3+
require('isomorphic-fetch')
44
const Router = require('express').Router
55
const passport = require('passport')
66
const MattermostClient = require('mattermost-redux/client/client4').default

lib/web/imageRouter/filesystem.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,12 @@ exports.uploadImage = function (imagePath, callback) {
1616
return
1717
}
1818

19-
callback(null, (new URL(path.basename(imagePath), config.serverURL + '/uploads/')).href)
19+
let url
20+
try {
21+
url = (new URL(path.basename(imagePath), config.serverURL + '/uploads/')).href
22+
} catch (e) {
23+
url = config.serverURL + '/uploads/' + path.basename(imagePath)
24+
}
25+
26+
callback(null, url)
2027
}

0 commit comments

Comments
 (0)