From 1783713e0dd573c84e53dae91d4e3daf59754f58 Mon Sep 17 00:00:00 2001 From: Gerald Date: Wed, 15 Jan 2025 16:56:14 +0100 Subject: [PATCH] fix page titles add print buttons for presentations and flow-text to settings dropdown --- app.js | 22 ++++++++++++++------ obsidian-page.js | 8 +++++++- obsidian.js | 53 +++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 73 insertions(+), 10 deletions(-) diff --git a/app.js b/app.js index a9e6693..0b1dd06 100644 --- a/app.js +++ b/app.js @@ -95,7 +95,7 @@ const DOMPurify = createDOMPurify(window); const app = express(); app.set("trust proxy", true); -import { scanFiles, scanFonts, preParse, manipulateHtml, wrapInPage, wrapInReveal, splitForReveal, parseFirstLineForPermissions } from "./obsidian.js"; +import { scanFiles, scanFonts, preParse, manipulateHtml, wrapInPage, wrapInReveal, splitForReveal, parseFirstLineForPermissions, wrapAsDocument } from "./obsidian.js"; import { hasSomeRoles } from "./utils.js"; async function sanitizeAndParseMarkdown(data, req) { @@ -199,12 +199,22 @@ initKeycloak(app).then(() => { }); }); } else { - sanitizeAndParseMarkdown(data, req).then((html) => { - setUserAttribute(req, "lastVisitedUrl", req.originalUrl); - wrapInPage(html, getStartPage(), req).then((r) => { - res.send(r); + const doc = req.query.document; + if (doc) { + sanitizeAndParseMarkdown(data, req).then((html) => { + setUserAttribute(req, "lastVisitedUrl", req.originalUrl); + wrapAsDocument(html, req).then((r) => { + res.send(r); + }); }); - }); + } else { + sanitizeAndParseMarkdown(data, req).then((html) => { + setUserAttribute(req, "lastVisitedUrl", req.originalUrl); + wrapInPage(html, getStartPage(), req).then((r) => { + res.send(r); + }); + }); + } } }); } else { diff --git a/obsidian-page.js b/obsidian-page.js index 644be2c..1ab8de9 100644 --- a/obsidian-page.js +++ b/obsidian-page.js @@ -165,7 +165,7 @@ function toggleTopdownMenu() { } } -function openAsPresentation() { +function openAsPresentation(print) { let url = new URL(window.location.href); if (print) { url.searchParams.set("print-pdf", "true") @@ -174,6 +174,12 @@ function openAsPresentation() { window.open(url, "_blank"); } +function openAsDocument() { + const url = new URL(window.location.href); + url.searchParams.set("document", "true"); + window.open(url, "_blank"); +} + let mainFontsArray = []; let navFontsArray = []; diff --git a/obsidian.js b/obsidian.js index bbc573a..701e6de 100644 --- a/obsidian.js +++ b/obsidian.js @@ -988,6 +988,22 @@ async function getTopdownMenu(req) { ` : "" } +
+ + +
`; } @@ -1021,9 +1037,6 @@ async function getTopBar(startPage, req) { - @@ -1062,6 +1075,7 @@ export async function wrapInPage(html, startPage, req) { + ${req.file.name}
${await getTopBar(startPage, req)}
@@ -1091,6 +1105,39 @@ export async function wrapInPage(html, startPage, req) { return pre + html + post; } +export async function wrapAsDocument(html, req) { + const pre = ` + + + + + + + + ${req.file.name} + + +
+
+ `; + const post = ` +
+
+ + + + + `; + return pre + html + post; +} + export async function wrapInReveal(reveal, req) { const pre = `