added support for app_css attribute, which allows custom styling

This commit is contained in:
azivner
2018-03-07 23:24:23 -05:00
parent c831221cc4
commit b6277049f3
3 changed files with 26 additions and 2 deletions

View File

@@ -5,13 +5,32 @@ const router = express.Router();
const auth = require('../services/auth');
const source_id = require('../services/source_id');
const sql = require('../services/sql');
const Repository = require('../services/repository');
const attributes = require('../services/attributes');
const wrap = require('express-promise-wrap').wrap;
router.get('', auth.checkAuth, wrap(async (req, res, next) => {
const repository = new Repository(req);
res.render('index', {
sourceId: await source_id.generateSourceId(),
maxSyncIdAtLoad: await sql.getValue("SELECT MAX(id) FROM sync")
maxSyncIdAtLoad: await sql.getValue("SELECT MAX(id) FROM sync"),
appCss: await getAppCss(repository)
});
}));
async function getAppCss(repository) {
let css = '';
const notes = attributes.getNotesWithAttribute(repository, 'app_css');
for (const note of await notes) {
css += `/* ${note.noteId} */
${note.content}
`;
}
return css;
}
module.exports = router;