From 71bf9554707d096dd367cd0227853106b2a5fad7 Mon Sep 17 00:00:00 2001 From: Mhykol Date: Mon, 10 Jun 2024 04:34:51 -0400 Subject: Added user generated titles --- app.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'app.js') diff --git a/app.js b/app.js index 433d0b1..bb8e066 100644 --- a/app.js +++ b/app.js @@ -36,7 +36,12 @@ require('dotenv').config() // Handles the routes class App { constructor() { - this.readfile = new readfile({baseUrl: process.env.baseUrl, mime: mime}) + this.readfile = new readfile({ + baseUrl: process.env.baseUrl, + mime: mime, + header: 'header.html', + footer: 'footer.html' + }) this.controller = new Controller() } @@ -76,7 +81,10 @@ class App { if (this.path.string.endsWith('/') && this.path.string.length > 1) this.path.string = this.path.string.substring(0, this.path.string.length - 1) if (output.has(this.path.string)) { try { - output.get(this.path.string).then(output => res.send(this.readfile.GetMain(output.meta))) + output.get(this.path.string).then(output => { + console.log(output.meta) + res.send(this.readfile.GetMain(output.meta)) + }) } catch { res.send(this.readfile.GetMain(output.get(this.path.string))) } @@ -107,9 +115,9 @@ class App { this.readfile.Create(output.html).then(output => { const DOMPurify = createDOMPurify(new JSDOM('').window) const clean = DOMPurify.sanitize(output.layouts.header + output.layouts.data + output.layouts.footer, { - ADD_TAGS: ["iframe"], ADD_ATTR: ['allow', 'allowfullscreen', 'frameborder', 'scrolling'] + ADD_TAGS: ['iframe'], ADD_ATTR: ['allow', 'allowfullscreen', 'frameborder', 'scrolling'] }) - res.send(JSON.stringify({html: clean, css: object.css, js: object.js})) + res.send(JSON.stringify({title: object.title, html: clean, css: object.css, js: object.js})) }) }) } catch { -- cgit v1.2.3-70-g09d2