trilium/src/routes/index.js

41 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-10-22 09:10:33 +08:00
"use strict";
const sourceIdService = require('../services/source_id');
const sql = require('../services/sql');
const attributeService = require('../services/attributes');
2018-04-03 09:34:28 +08:00
const config = require('../services/config');
const optionService = require('../services/options');
async function index(req, res) {
2018-09-06 17:54:04 +08:00
const options = await optionService.getOptionsMap();
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),
sourceId: await sourceIdService.generateSourceId(),
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()
});
}
2018-03-31 21:07:58 +08:00
async function getAppCss() {
let css = '';
const notes = attributeService.getNotesWithLabel('appCss');
for (const note of await notes) {
css += `/* ${note.noteId} */
${note.content}
`;
}
return css;
}
module.exports = {
index
};