Skip to content

Build your personal knowledge base with Trilium Notes

added support for app_css attribute, which allows custom styling

azivnerb6277049f36a
diff --git a/src/routes/index.js b/src/routes/index.js
index 84b5b94246..f32786ef85 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 8c8cc8e66c..0d760d35c9 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 7f390e66cf..29f8f9fb47 100644
--- a/src/views/index.ejs
+++ b/src/views/index.ejs
@@ -529,5 +529,9 @@
// final form which is pretty ugly.
$("#container").show();
</script>
+
+ <style type="text/css">
+ <%= appCss %>
+ </style>
</body>
</html>
\ No newline at end of file