Skip to content

Commit 71ea581

Browse files
committed
Merge branch 'develop' into feature/support-vega-lite
# Conflicts: # package.json # public/views/slide.ejs
2 parents 2613b63 + 3038f5c commit 71ea581

Some content is hidden

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

49 files changed

+1510
-1358
lines changed

app.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ var csp = require('./lib/csp')
2828
function createHttpServer () {
2929
if (config.useSSL) {
3030
const ca = (function () {
31-
let i, len, results
32-
results = []
31+
let i, len
32+
const results = []
3333
for (i = 0, len = config.sslCAPath.length; i < len; i++) {
3434
results.push(fs.readFileSync(config.sslCAPath[i], 'utf8'))
3535
}
@@ -55,7 +55,7 @@ var server = createHttpServer()
5555

5656
// logger
5757
app.use(morgan('combined', {
58-
'stream': logger.stream
58+
stream: logger.stream
5959
}))
6060

6161
// socket io

lib/config/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ if (['debug', 'verbose', 'info', 'warn', 'error'].includes(config.loglevel)) {
5353

5454
// load LDAP CA
5555
if (config.ldap.tlsca) {
56-
let ca = config.ldap.tlsca.split(',')
57-
let caContent = []
58-
for (let i of ca) {
59-
if (fs.existsSync(i)) {
60-
caContent.push(fs.readFileSync(i, 'utf8'))
56+
const certificateAuthorities = config.ldap.tlsca.split(',')
57+
const caContent = []
58+
for (const ca of certificateAuthorities) {
59+
if (fs.existsSync(ca)) {
60+
caContent.push(fs.readFileSync(ca, 'utf8'))
6161
}
6262
}
63-
let tlsOptions = {
63+
const tlsOptions = {
6464
ca: caContent
6565
}
6666
config.ldap.tlsOptions = config.ldap.tlsOptions ? Object.assign(config.ldap.tlsOptions, tlsOptions) : tlsOptions
@@ -134,10 +134,10 @@ config.isGitlabSnippetsEnable = (!config.gitlab.scope || config.gitlab.scope ===
134134
config.updateI18nFiles = (env === Environment.development)
135135

136136
// merge legacy values
137-
let keys = Object.keys(config)
137+
const keys = Object.keys(config)
138138
const uppercase = /[A-Z]/
139139
for (let i = keys.length; i--;) {
140-
let lowercaseKey = keys[i].toLowerCase()
140+
const lowercaseKey = keys[i].toLowerCase()
141141
// if the config contains uppercase letters
142142
// and a lowercase version of this setting exists
143143
// and the config with uppercase is not set

lib/history.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@ var logger = require('./logger')
99
var response = require('./response')
1010
var models = require('./models')
1111

12-
// public
13-
var History = {
14-
historyGet: historyGet,
15-
historyPost: historyPost,
16-
historyDelete: historyDelete,
17-
updateHistory: updateHistory
18-
}
19-
2012
function getHistory (userid, callback) {
2113
models.User.findOne({
2214
where: {
@@ -41,7 +33,7 @@ function getHistory (userid, callback) {
4133
continue
4234
}
4335
try {
44-
let id = LZString.decompressFromBase64(history[i].id)
36+
const id = LZString.decompressFromBase64(history[i].id)
4537
if (id && models.Note.checkNoteIdValid(id)) {
4638
history[i].id = models.Note.encodeNoteId(id)
4739
}
@@ -200,4 +192,8 @@ function historyDelete (req, res) {
200192
}
201193
}
202194

203-
module.exports = History
195+
// public
196+
exports.historyGet = historyGet
197+
exports.historyPost = historyPost
198+
exports.historyDelete = historyDelete
199+
exports.updateHistory = updateHistory

lib/letter-avatars.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ exports.generateAvatarURL = function (name, email = '', big = true) {
3232
}
3333
name = encodeURIComponent(name)
3434

35-
let hash = crypto.createHash('md5')
35+
const hash = crypto.createHash('md5')
3636
hash.update(email.toLowerCase())
37-
let hexDigest = hash.digest('hex')
37+
const hexDigest = hash.digest('hex')
3838

3939
if (email !== '' && config.allowGravatar) {
4040
photo = 'https://www.gravatar.com/avatar/' + hexDigest

lib/models/note.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,15 @@ module.exports = function (sequelize, DataTypes) {
165165
}
166166
Note.encodeNoteId = function (id) {
167167
// remove dashes in UUID and encode in url-safe base64
168-
let str = id.replace(/-/g, '')
169-
let hexStr = Buffer.from(str, 'hex')
168+
const str = id.replace(/-/g, '')
169+
const hexStr = Buffer.from(str, 'hex')
170170
return base64url.encode(hexStr)
171171
}
172172
Note.decodeNoteId = function (encodedId) {
173173
// decode from url-safe base64
174-
let id = base64url.toBuffer(encodedId).toString('hex')
174+
const id = base64url.toBuffer(encodedId).toString('hex')
175175
// add dashes between the UUID string parts
176-
let idParts = []
176+
const idParts = []
177177
idParts.push(id.substr(0, 8))
178178
idParts.push(id.substr(8, 4))
179179
idParts.push(id.substr(12, 4))
@@ -196,7 +196,7 @@ module.exports = function (sequelize, DataTypes) {
196196
}
197197
}).then(function (note) {
198198
if (note) {
199-
let filePath = path.join(config.docsPath, noteId + '.md')
199+
const filePath = path.join(config.docsPath, noteId + '.md')
200200
if (Note.checkFileExist(filePath)) {
201201
// if doc in filesystem have newer modified time than last change time
202202
// then will update the doc in db
@@ -421,20 +421,20 @@ module.exports = function (sequelize, DataTypes) {
421421
if (ot.TextOperation.isRetain(op)) {
422422
index += op
423423
} else if (ot.TextOperation.isInsert(op)) {
424-
let opStart = index
425-
let opEnd = index + op.length
426-
var inserted = false
424+
const opStart = index
425+
const opEnd = index + op.length
426+
let inserted = false
427427
// authorship format: [userId, startPos, endPos, createdAt, updatedAt]
428428
if (authorships.length <= 0) authorships.push([userId, opStart, opEnd, timestamp, timestamp])
429429
else {
430430
for (let j = 0; j < authorships.length; j++) {
431-
let authorship = authorships[j]
431+
const authorship = authorships[j]
432432
if (!inserted) {
433-
let nextAuthorship = authorships[j + 1] || -1
433+
const nextAuthorship = authorships[j + 1] || -1
434434
if ((nextAuthorship !== -1 && nextAuthorship[1] >= opEnd) || j >= authorships.length - 1) {
435435
if (authorship[1] < opStart && authorship[2] > opStart) {
436436
// divide
437-
let postLength = authorship[2] - opStart
437+
const postLength = authorship[2] - opStart
438438
authorship[2] = opStart
439439
authorship[4] = timestamp
440440
authorships.splice(j + 1, 0, [userId, opStart, opEnd, timestamp, timestamp])
@@ -460,13 +460,13 @@ module.exports = function (sequelize, DataTypes) {
460460
}
461461
index += op.length
462462
} else if (ot.TextOperation.isDelete(op)) {
463-
let opStart = index
464-
let opEnd = index - op
463+
const opStart = index
464+
const opEnd = index - op
465465
if (operation.length === 1) {
466466
authorships = []
467467
} else if (authorships.length > 0) {
468468
for (let j = 0; j < authorships.length; j++) {
469-
let authorship = authorships[j]
469+
const authorship = authorships[j]
470470
if (authorship[1] >= opStart && authorship[1] <= opEnd && authorship[2] >= opStart && authorship[2] <= opEnd) {
471471
authorships.splice(j, 1)
472472
j -= 1
@@ -491,12 +491,12 @@ module.exports = function (sequelize, DataTypes) {
491491
}
492492
// merge
493493
for (let j = 0; j < authorships.length; j++) {
494-
let authorship = authorships[j]
494+
const authorship = authorships[j]
495495
for (let k = j + 1; k < authorships.length; k++) {
496-
let nextAuthorship = authorships[k]
496+
const nextAuthorship = authorships[k]
497497
if (nextAuthorship && authorship[0] === nextAuthorship[0] && authorship[2] === nextAuthorship[1]) {
498-
let minTimestamp = Math.min(authorship[3], nextAuthorship[3])
499-
let maxTimestamp = Math.max(authorship[3], nextAuthorship[3])
498+
const minTimestamp = Math.min(authorship[3], nextAuthorship[3])
499+
const maxTimestamp = Math.max(authorship[3], nextAuthorship[3])
500500
authorships.splice(j, 1, [authorship[0], authorship[1], nextAuthorship[2], minTimestamp, maxTimestamp])
501501
authorships.splice(k, 1)
502502
j -= 1
@@ -506,7 +506,7 @@ module.exports = function (sequelize, DataTypes) {
506506
}
507507
// clear
508508
for (let j = 0; j < authorships.length; j++) {
509-
let authorship = authorships[j]
509+
const authorship = authorships[j]
510510
if (!authorship[0]) {
511511
authorships.splice(j, 1)
512512
j -= 1
@@ -537,11 +537,11 @@ module.exports = function (sequelize, DataTypes) {
537537
var lengthBias = 0
538538
for (let j = 0; j < patch.length; j++) {
539539
var operation = []
540-
let p = patch[j]
540+
const p = patch[j]
541541
var currIndex = p.start1
542542
var currLength = contentLength - bias
543543
for (let i = 0; i < p.diffs.length; i++) {
544-
let diff = p.diffs[i]
544+
const diff = p.diffs[i]
545545
switch (diff[0]) {
546546
case 0: // retain
547547
if (i === 0) {

lib/realtime.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -744,8 +744,8 @@ function queueForConnect (socket) {
744744
})
745745
return socket.disconnect(true)
746746
}
747-
let note = notes[noteId]
748-
let user = users[socket.id]
747+
const note = notes[noteId]
748+
const user = users[socket.id]
749749
// update user color to author color
750750
if (note.authors[user.userid]) {
751751
user.color = users[socket.id].color = note.authors[user.userid].color
@@ -766,7 +766,7 @@ function queueForConnect (socket) {
766766
socketClient.registerEventHandler()
767767

768768
if (config.debug) {
769-
let noteId = socket.noteId
769+
const noteId = socket.noteId
770770
logger.info('SERVER connected a client to [' + noteId + ']:')
771771
logger.info(JSON.stringify(user))
772772
// logger.info(notes);

0 commit comments

Comments
 (0)