|
|
@ -28,13 +28,68 @@ module.exports = { |
|
|
|
const label = `/${options.board._id}/banners.html`; |
|
|
|
const label = `/${options.board._id}/banners.html`; |
|
|
|
const start = process.hrtime(); |
|
|
|
const start = process.hrtime(); |
|
|
|
options.managePage = 'assets.html'; |
|
|
|
options.managePage = 'assets.html'; |
|
|
|
const { html } = await render(label, 'banners.pug', options, { |
|
|
|
const { html, json } = await render(label, 'banners.pug', options, { |
|
|
|
'name': `/${options.board._id}/banners.json`, |
|
|
|
'name': `/${options.board._id}/banners.json`, |
|
|
|
'data': options.board.banners |
|
|
|
'data': options.board.banners |
|
|
|
}); |
|
|
|
}); |
|
|
|
const end = process.hrtime(start); |
|
|
|
const end = process.hrtime(start); |
|
|
|
debugLogs && console.log(timeDiffString(label, end)); |
|
|
|
debugLogs && console.log(timeDiffString(label, end)); |
|
|
|
return html; |
|
|
|
return { html, json }; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buildBoardSettings: async (options) => { |
|
|
|
|
|
|
|
const label = `/${options.board._id}/settings.json`; |
|
|
|
|
|
|
|
const start = process.hrtime(); |
|
|
|
|
|
|
|
const customPages = await CustomPages.find(options.board._id); |
|
|
|
|
|
|
|
const bs = options.board.settings; |
|
|
|
|
|
|
|
const projectedSettings = { |
|
|
|
|
|
|
|
customPages: customPages.map(p => p.page), //list of custompage names
|
|
|
|
|
|
|
|
announcement: bs.announcement, |
|
|
|
|
|
|
|
allowedFileTypes: bs.allowedFileTypes, |
|
|
|
|
|
|
|
maxFiles: bs.maxFiles, |
|
|
|
|
|
|
|
captchaMode: bs.captchaMode, |
|
|
|
|
|
|
|
forceAnon: bs.forceAnon, |
|
|
|
|
|
|
|
sageOnlyEmail: bs.sageOnlyEmail, |
|
|
|
|
|
|
|
customFlags: bs.customFlags, |
|
|
|
|
|
|
|
forceThreadMessage: bs.forceThreadMessage, |
|
|
|
|
|
|
|
forceThreadFile: bs.forceThreadFile, |
|
|
|
|
|
|
|
forceThreadSubject: bs.forceThreadSubject, |
|
|
|
|
|
|
|
disableReplySubject: bs.disableReplySubject, |
|
|
|
|
|
|
|
minThreadMessageLength: bs.minThreadMessageLength, |
|
|
|
|
|
|
|
minReplyMessageLength: bs.minReplyMessageLength, |
|
|
|
|
|
|
|
maxThreadMessageLength: bs.maxThreadMessageLength, |
|
|
|
|
|
|
|
maxReplyMessageLength: bs.maxReplyMessageLength, |
|
|
|
|
|
|
|
defaultName: bs.defaultName, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
const { json } = await render(null, null, null, { |
|
|
|
|
|
|
|
'name': `/${options.board._id}/settings.json`, |
|
|
|
|
|
|
|
'data': projectedSettings |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
const end = process.hrtime(start); |
|
|
|
|
|
|
|
debugLogs && console.log(timeDiffString(label, end)); |
|
|
|
|
|
|
|
return json; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buildGlobalSettings: async () => { |
|
|
|
|
|
|
|
const label = '/settings.json'; |
|
|
|
|
|
|
|
const start = process.hrtime(); |
|
|
|
|
|
|
|
const { captchaOptions: co } = config.get; |
|
|
|
|
|
|
|
const projectedSettings = { |
|
|
|
|
|
|
|
captchaOptions: { |
|
|
|
|
|
|
|
type: co.type, |
|
|
|
|
|
|
|
grid: { |
|
|
|
|
|
|
|
size: co.grid.size, |
|
|
|
|
|
|
|
question: co.grid.question, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
const { json } = await render(null, null, null, { |
|
|
|
|
|
|
|
name: '/settings.json', |
|
|
|
|
|
|
|
data: projectedSettings |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
const end = process.hrtime(start); |
|
|
|
|
|
|
|
debugLogs && console.log(timeDiffString(label, end)); |
|
|
|
|
|
|
|
return json; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
buildCatalog: async (options) => { |
|
|
|
buildCatalog: async (options) => { |
|
|
@ -162,7 +217,7 @@ module.exports = { |
|
|
|
if (!options.customPage) { |
|
|
|
if (!options.customPage) { |
|
|
|
const customPage = await CustomPages.findOne(options.board._id || options.board, options.page); |
|
|
|
const customPage = await CustomPages.findOne(options.board._id || options.board, options.page); |
|
|
|
if (!customPage) { |
|
|
|
if (!customPage) { |
|
|
|
return; |
|
|
|
return {}; |
|
|
|
} |
|
|
|
} |
|
|
|
options.customPage = customPage; |
|
|
|
options.customPage = customPage; |
|
|
|
} |
|
|
|
} |
|
|
@ -170,12 +225,15 @@ module.exports = { |
|
|
|
options.board = await Boards.findOne(options.board); |
|
|
|
options.board = await Boards.findOne(options.board); |
|
|
|
} |
|
|
|
} |
|
|
|
options.managePage = 'custompages.html'; |
|
|
|
options.managePage = 'custompages.html'; |
|
|
|
const { html } = await render(label, 'custompage.pug', { |
|
|
|
const { html, json } = await render(label, 'custompage.pug', { |
|
|
|
...options, |
|
|
|
...options, |
|
|
|
|
|
|
|
}, { |
|
|
|
|
|
|
|
name: `/${options.board._id}/custompage/${options.page}.json`, |
|
|
|
|
|
|
|
data: options.customPage |
|
|
|
}); |
|
|
|
}); |
|
|
|
const end = process.hrtime(start); |
|
|
|
const end = process.hrtime(start); |
|
|
|
debugLogs && console.log(timeDiffString(label, end)); |
|
|
|
debugLogs && console.log(timeDiffString(label, end)); |
|
|
|
return html; |
|
|
|
return { html, json }; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
buildModLog: async (options) => { |
|
|
|
buildModLog: async (options) => { |
|
|
@ -196,12 +254,22 @@ module.exports = { |
|
|
|
options.logs = await Modlogs.findBetweenDate(options.board, options.startDate, options.endDate); |
|
|
|
options.logs = await Modlogs.findBetweenDate(options.board, options.startDate, options.endDate); |
|
|
|
} |
|
|
|
} |
|
|
|
options.managePage = 'logs.html'; |
|
|
|
options.managePage = 'logs.html'; |
|
|
|
const { html } = await render(label, 'modlog.pug', { |
|
|
|
const projectedLogs = options.logs.map(l => { |
|
|
|
|
|
|
|
const pl = l; |
|
|
|
|
|
|
|
if (pl.showUser === false) { |
|
|
|
|
|
|
|
pl.user = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return pl; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
const { html, json } = await render(label, 'modlog.pug', { |
|
|
|
...options |
|
|
|
...options |
|
|
|
|
|
|
|
}, { |
|
|
|
|
|
|
|
'name': `/${options.board._id}/logs/${month}-${day}-${year}.json`, |
|
|
|
|
|
|
|
'data': projectedLogs, |
|
|
|
}); |
|
|
|
}); |
|
|
|
const end = process.hrtime(start); |
|
|
|
const end = process.hrtime(start); |
|
|
|
debugLogs && console.log(timeDiffString(label, end)); |
|
|
|
debugLogs && console.log(timeDiffString(label, end)); |
|
|
|
return html; |
|
|
|
return { html, json }; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
buildModLogList: async (options) => { |
|
|
|
buildModLogList: async (options) => { |
|
|
@ -224,19 +292,25 @@ module.exports = { |
|
|
|
}); |
|
|
|
}); |
|
|
|
if (pruneLogs.length > 0) { |
|
|
|
if (pruneLogs.length > 0) { |
|
|
|
await Promise.all(pruneLogs.map(log => { |
|
|
|
await Promise.all(pruneLogs.map(log => { |
|
|
|
remove(`${uploadDirectory}/html/${options.board._id}/logs/${log}.html`); |
|
|
|
return Promise.all([ |
|
|
|
|
|
|
|
remove(`${uploadDirectory}/html/${options.board._id}/logs/${log}.html`), |
|
|
|
|
|
|
|
remove(`${uploadDirectory}/json/${options.board._id}/logs/${log}.json`), |
|
|
|
|
|
|
|
]); |
|
|
|
})); |
|
|
|
})); |
|
|
|
await Modlogs.deleteOld(options.board._id, pruneAfter); |
|
|
|
await Modlogs.deleteOld(options.board._id, pruneAfter); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
const { html } = await render(label, 'modloglist.pug', { |
|
|
|
const { html, json } = await render(label, 'modloglist.pug', { |
|
|
|
board: options.board, |
|
|
|
board: options.board, |
|
|
|
dates, |
|
|
|
dates, |
|
|
|
managePage: 'logs.html', |
|
|
|
managePage: 'logs.html', |
|
|
|
|
|
|
|
}, { |
|
|
|
|
|
|
|
'name': `/${options.board._id}/logs.json`, |
|
|
|
|
|
|
|
'data': dates, |
|
|
|
}); |
|
|
|
}); |
|
|
|
const end = process.hrtime(start); |
|
|
|
const end = process.hrtime(start); |
|
|
|
debugLogs && console.log(timeDiffString(label, end)); |
|
|
|
debugLogs && console.log(timeDiffString(label, end)); |
|
|
|
return html; |
|
|
|
return { html, json }; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
buildHomepage: async () => { |
|
|
|
buildHomepage: async () => { |
|
|
|