From 3e999d9d462c377fdc53edcb6ac481a7b9e62841 Mon Sep 17 00:00:00 2001 From: nightly Date: Tue, 18 Oct 2022 12:30:12 +0200 Subject: [PATCH] *Yoink* --- Source/Webserver/index.ts | 16 ++++++++--- Source/Webserver/partials/layout.liquid | 14 ++++++++++ Source/Webserver/partials/todo.liquid | 1 + Source/Webserver/views/todolist.liquid | 11 ++++++++ package-lock.json | 35 +++++++++++++++++++++++++ package.json | 2 ++ 6 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 Source/Webserver/partials/layout.liquid create mode 100644 Source/Webserver/partials/todo.liquid create mode 100644 Source/Webserver/views/todolist.liquid diff --git a/Source/Webserver/index.ts b/Source/Webserver/index.ts index 25247b9..a51a025 100644 --- a/Source/Webserver/index.ts +++ b/Source/Webserver/index.ts @@ -1,10 +1,20 @@ import express from "express"; +import { Liquid } from "liquidjs"; +const engine = new Liquid(); const app = express(); const port = 3430; -app.get('/', (req, res) => { - res.send("Hello wold!"); -}); +app.engine('liquid', engine.express()); +app.set('views', ['./partials', './views']); +app.set('view engine', 'liquid'); + +app.get('/', function (req, res) { + const todos = ['fork and clone', 'make it better', 'make a pull request'] + res.render('todolist', { + todos: todos, + title: 'Welcome to liquidjs!' + }) +}) app.listen(port, () => { console.log('✅ Webserver started on port ', port) diff --git a/Source/Webserver/partials/layout.liquid b/Source/Webserver/partials/layout.liquid new file mode 100644 index 0000000..fa3273e --- /dev/null +++ b/Source/Webserver/partials/layout.liquid @@ -0,0 +1,14 @@ + + + + + {{title}} + + +

{{title}}

+ + {% block %}{% endblock %} + + + + \ No newline at end of file diff --git a/Source/Webserver/partials/todo.liquid b/Source/Webserver/partials/todo.liquid new file mode 100644 index 0000000..0b58851 --- /dev/null +++ b/Source/Webserver/partials/todo.liquid @@ -0,0 +1 @@ +{{id}} - {{todo}} \ No newline at end of file diff --git a/Source/Webserver/views/todolist.liquid b/Source/Webserver/views/todolist.liquid new file mode 100644 index 0000000..7216576 --- /dev/null +++ b/Source/Webserver/views/todolist.liquid @@ -0,0 +1,11 @@ +{% layout 'layout' %} + + + +{% block 'footer' %} + Copyright @ 2016, Harttle +{% endblock %} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 932fc88..0a4107a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,10 +11,12 @@ "dependencies": { "express": "^4.18.2", "express-session": "^1.17.3", + "liquidjs": "^9.42.0", "path": "^0.12.7", "terser": "^5.15.1" }, "devDependencies": { + "@types/ejs": "^3.1.1", "@types/express": "^4.17.14", "eslint": "8.25.0", "eslint-config-next": "12.3.1", @@ -223,6 +225,12 @@ "@types/node": "*" } }, + "node_modules/@types/ejs": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@types/ejs/-/ejs-3.1.1.tgz", + "integrity": "sha512-RQul5wEfY7BjWm0sYY86cmUN/pcXWGyVxWX93DFFJvcrxax5zKlieLwA3T77xJGwNcZW0YW6CYG70p1m8xPFmA==", + "dev": true + }, "node_modules/@types/express": { "version": "4.17.14", "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.14.tgz", @@ -2250,6 +2258,22 @@ "node": ">= 0.8.0" } }, + "node_modules/liquidjs": { + "version": "9.42.0", + "resolved": "https://registry.npmjs.org/liquidjs/-/liquidjs-9.42.0.tgz", + "integrity": "sha512-krvhwGFrMCMGhybGkxJIvlWVVnoCSpYCn7NhEN43+uvlg2vOkYWpq8be+L3NMlOfwe4ZrKQ7hCh1EmS4yhLKow==", + "bin": { + "liquid": "bin/liquid.js", + "liquidjs": "bin/liquid.js" + }, + "engines": { + "node": ">=4.8.7" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/liquidjs" + } + }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -3615,6 +3639,12 @@ "@types/node": "*" } }, + "@types/ejs": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@types/ejs/-/ejs-3.1.1.tgz", + "integrity": "sha512-RQul5wEfY7BjWm0sYY86cmUN/pcXWGyVxWX93DFFJvcrxax5zKlieLwA3T77xJGwNcZW0YW6CYG70p1m8xPFmA==", + "dev": true + }, "@types/express": { "version": "4.17.14", "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.14.tgz", @@ -5151,6 +5181,11 @@ "type-check": "~0.4.0" } }, + "liquidjs": { + "version": "9.42.0", + "resolved": "https://registry.npmjs.org/liquidjs/-/liquidjs-9.42.0.tgz", + "integrity": "sha512-krvhwGFrMCMGhybGkxJIvlWVVnoCSpYCn7NhEN43+uvlg2vOkYWpq8be+L3NMlOfwe4ZrKQ7hCh1EmS4yhLKow==" + }, "locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", diff --git a/package.json b/package.json index 2e5fd3f..33f59e4 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "author": "nightlymania", "license": "GPL-2.0-or-later", "devDependencies": { + "@types/ejs": "^3.1.1", "@types/express": "^4.17.14", "eslint": "8.25.0", "eslint-config-next": "12.3.1", @@ -27,6 +28,7 @@ "dependencies": { "express": "^4.18.2", "express-session": "^1.17.3", + "liquidjs": "^9.42.0", "path": "^0.12.7", "terser": "^5.15.1" }