From b6277049f36a71655a044844aadd8924f5a1dada Mon Sep 17 00:00:00 2001 From: azivner Date: Wed, 7 Mar 2018 23:24:23 -0500 Subject: [PATCH] added support for app_css attribute, which allows custom styling --- src/routes/index.js | 21 ++++++++++++++++++++- src/services/attributes.js | 3 ++- src/views/index.ejs | 4 ++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/routes/index.js b/src/routes/index.js index 84b5b9424..f32786ef8 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -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; diff --git a/src/services/attributes.js b/src/services/attributes.js index 8c8cc8e66..0d760d35c 100644 --- a/src/services/attributes.js +++ b/src/services/attributes.js @@ -13,7 +13,8 @@ const BUILTIN_ATTRIBUTES = [ 'exclude_from_export', 'run', 'manual_transaction_handling', - 'disable_inclusion' + 'disable_inclusion', + 'app_css' ]; async function getNoteAttributeMap(noteId) { diff --git a/src/views/index.ejs b/src/views/index.ejs index 7f390e66c..29f8f9fb4 100644 --- a/src/views/index.ejs +++ b/src/views/index.ejs @@ -529,5 +529,9 @@ // final form which is pretty ugly. $("#container").show(); + + \ No newline at end of file