summaryrefslogtreecommitdiff
path: root/app.js
diff options
context:
space:
mode:
authorMhykol <mchaeldonald62@pm.me>2024-06-10 04:34:51 -0400
committerMhykol <mchaeldonald62@pm.me>2024-06-10 04:34:51 -0400
commit71bf9554707d096dd367cd0227853106b2a5fad7 (patch)
tree49bed80b513c1e4a02135f8f1520c996e6e7d9b9 /app.js
parentacad4247d93e7a61b781924e5175664811bcf3e2 (diff)
Added user generated titles
Diffstat (limited to 'app.js')
-rw-r--r--app.js16
1 files changed, 12 insertions, 4 deletions
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 {