2017-10-22 09:10:33 +08:00
|
|
|
"use strict";
|
|
|
|
|
2018-04-02 09:27:46 +08:00
|
|
|
const sourceIdService = require('../services/source_id');
|
2017-12-20 12:22:21 +08:00
|
|
|
const sql = require('../services/sql');
|
2018-08-07 19:33:10 +08:00
|
|
|
const attributeService = require('../services/attributes');
|
2018-04-03 09:34:28 +08:00
|
|
|
const config = require('../services/config');
|
2018-06-09 11:18:53 +08:00
|
|
|
const optionService = require('../services/options');
|
2017-10-15 11:31:44 +08:00
|
|
|
|
2018-03-31 07:31:22 +08:00
|
|
|
async function index(req, res) {
|
2018-09-06 17:54:04 +08:00
|
|
|
const options = await optionService.getOptionsMap();
|
|
|
|
|
2017-12-17 09:48:34 +08:00
|
|
|
res.render('index', {
|
2018-09-06 17:54:04 +08:00
|
|
|
theme: options.theme,
|
|
|
|
leftPaneMinWidth: parseInt(options.leftPaneMinWidth),
|
|
|
|
leftPaneWidthPercent: parseInt(options.leftPaneWidthPercent),
|
|
|
|
rightPaneWidthPercent: 100 - parseInt(options.leftPaneWidthPercent),
|
2018-04-02 09:27:46 +08:00
|
|
|
sourceId: await sourceIdService.generateSourceId(),
|
2018-03-08 12:24:23 +08:00
|
|
|
maxSyncIdAtLoad: await sql.getValue("SELECT MAX(id) FROM sync"),
|
2018-04-03 09:34:28 +08:00
|
|
|
instanceName: config.General ? config.General.instanceName : null,
|
2018-03-31 21:07:58 +08:00
|
|
|
appCss: await getAppCss()
|
2017-12-17 09:48:34 +08:00
|
|
|
});
|
2018-03-31 07:31:22 +08:00
|
|
|
}
|
2017-10-15 11:31:44 +08:00
|
|
|
|
2018-03-31 21:07:58 +08:00
|
|
|
async function getAppCss() {
|
2018-03-08 12:24:23 +08:00
|
|
|
let css = '';
|
2018-08-07 19:33:10 +08:00
|
|
|
const notes = attributeService.getNotesWithLabel('appCss');
|
2018-03-08 12:24:23 +08:00
|
|
|
|
|
|
|
for (const note of await notes) {
|
|
|
|
css += `/* ${note.noteId} */
|
|
|
|
${note.content}
|
|
|
|
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
|
|
|
|
return css;
|
|
|
|
}
|
|
|
|
|
2018-03-31 07:31:22 +08:00
|
|
|
module.exports = {
|
|
|
|
index
|
|
|
|
};
|