shaca now loads attributes, added favicon and shareJs

This commit is contained in:
zadam
2022-01-01 13:23:09 +01:00
parent dad82ea4e8
commit 1fed71a92e
8 changed files with 86 additions and 34 deletions

View File

@@ -46,19 +46,15 @@ function register(router) {
}
});
router.get('/share/api/images/:noteId/:filename', (req, res, next) => {
const image = shaca.getNote(req.params.noteId);
router.get('/share/api/notes/:noteId', (req, res, next) => {
const {noteId} = req.params;
const note = shaca.getNote(noteId);
if (!image) {
return res.status(404).send("Not found");
}
else if (image.type !== 'image') {
return res.status(400).send("Requested note is not an image");
if (!note) {
return res.status(404).send(`Note ${noteId} not found`);
}
res.set('Content-Type', image.mime);
res.send(image.getContent());
res.json(note.getPojoWithAttributes());
});
router.get('/share/api/notes/:noteId/download', (req, res, next) => {
@@ -66,7 +62,7 @@ function register(router) {
const note = shaca.getNote(noteId);
if (!note) {
return res.status(404).send(`Not found`);
return res.status(404).send(`Note ${noteId} not found`);
}
const utils = require("../services/utils");
@@ -81,20 +77,30 @@ function register(router) {
res.send(note.getContent());
});
router.get('/share/api/images/:noteId/:filename', (req, res, next) => {
const image = shaca.getNote(req.params.noteId);
if (!image) {
return res.status(404).send(`Note ${noteId} not found`);
}
else if (image.type !== 'image') {
return res.status(400).send("Requested note is not an image");
}
res.set('Content-Type', image.mime);
res.send(image.getContent());
});
// used for PDF viewing
router.get('/share/api/notes/:noteId/view', (req, res, next) => {
const {noteId} = req.params;
const note = shaca.getNote(noteId);
if (!note) {
return res.status(404).send(`Not found`);
return res.status(404).send(`Note ${noteId} not found`);
}
const utils = require("../services/utils");
const filename = utils.formatDownloadTitle(note.title, note.type, note.mime);
// res.setHeader('Content-Disposition', utils.getContentDisposition(filename));
res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
res.setHeader('Content-Type', note.mime);