From bcef8579ce8579eeaae282be7bf6dd9311e64b9a Mon Sep 17 00:00:00 2001 From: zadam Date: Wed, 22 Dec 2021 09:36:38 +0100 Subject: [PATCH] added shareCss relation and shareHiddenFromTree label --- src/services/attributes.js | 4 +++- src/share/routes.js | 8 ++++---- src/views/share/page.ejs | 3 +++ src/views/share/tree_item.ejs | 2 ++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/services/attributes.js b/src/services/attributes.js index 302cab1ec..6ace1af13 100644 --- a/src/services/attributes.js +++ b/src/services/attributes.js @@ -52,6 +52,7 @@ const BUILTIN_ATTRIBUTES = [ { type: 'label', name: 'sorted' }, { type: 'label', name: 'top' }, { type: 'label', name: 'fullContentWidth' }, + { type: 'label', name: 'shareHiddenFromTree' }, // relation names { type: 'relation', name: 'runOnNoteCreation', isDangerous: true }, @@ -62,7 +63,8 @@ const BUILTIN_ATTRIBUTES = [ { type: 'relation', name: 'runOnAttributeChange', isDangerous: true }, { type: 'relation', name: 'template' }, { type: 'relation', name: 'widget', isDangerous: true }, - { type: 'relation', name: 'renderNote', isDangerous: true } + { type: 'relation', name: 'renderNote', isDangerous: true }, + { type: 'relation', name: 'shareCss', isDangerous: false }, ]; /** @returns {Note[]} */ diff --git a/src/share/routes.js b/src/share/routes.js index d91aed1cd..1dcaa4c6c 100644 --- a/src/share/routes.js +++ b/src/share/routes.js @@ -45,10 +45,10 @@ function register(router) { const image = shaca.getNote(req.params.noteId); if (!image) { - return res.sendStatus(404); + return res.status(404).send("Not found"); } else if (image.type !== 'image') { - return res.sendStatus(400); + return res.status(400).send("Requested note is not an image"); } res.set('Content-Type', image.mime); @@ -56,12 +56,12 @@ function register(router) { res.send(image.getContent()); }); - router.get('/share/api/notes/:noteId/:download', (req, res, next) => { + router.get('/share/api/notes/:noteId/download', (req, res, next) => { const {noteId} = req.params; const note = shaca.getNote(noteId); if (!note) { - return res.status(404).send(`Note ${noteId} doesn't exist.`); + return res.status(404).send(`Not found`); } const utils = require("../services/utils"); diff --git a/src/views/share/page.ejs b/src/views/share/page.ejs index bc9d48426..19c8e3029 100644 --- a/src/views/share/page.ejs +++ b/src/views/share/page.ejs @@ -8,6 +8,9 @@ <% if (note.type === 'text' || note.type === 'book') { %> <% } %> + <% for (const cssRelation of note.getRelations("shareCss")) { %> + + <% } %> <%= note.title %> diff --git a/src/views/share/tree_item.ejs b/src/views/share/tree_item.ejs index 8d7bc5a73..b01e0efa5 100644 --- a/src/views/share/tree_item.ejs +++ b/src/views/share/tree_item.ejs @@ -9,9 +9,11 @@ <% if (note.hasChildren()) { %> <% } %>