From 01ff50e06db2bef9300862f996d4b5f40c4d0afb Mon Sep 17 00:00:00 2001 From: Sting <loic.allegre@ensiie.fr> Date: Mon, 21 Sep 2020 17:58:08 +0200 Subject: [PATCH] MISC: Basic dummy kara list on public interface --- .gitignore | 2 +- client/main.js | 5 +++++ client/routes/public.js | 7 ++++++- client/views/public.ejs | 35 +++++++++++++++++++++++++++++++++++ package.json | 1 + 5 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 client/views/public.ejs diff --git a/.gitignore b/.gitignore index 32e0162..ae17659 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ node_modules/ yarn.lock - +dummyKaras\.json *.log diff --git a/client/main.js b/client/main.js index f3fc6a7..faf61ff 100644 --- a/client/main.js +++ b/client/main.js @@ -10,6 +10,11 @@ console.log('Express started'); var publicRouter = require('./routes/public.js'); +app.set('views', __dirname + '/views'); +app.set('view engine', 'ejs'); + +app.use(express.static(__dirname + '/../style')); + app.use('/', publicRouter); diff --git a/client/routes/public.js b/client/routes/public.js index ed2f5b7..a410380 100644 --- a/client/routes/public.js +++ b/client/routes/public.js @@ -1,9 +1,14 @@ var express = require('express'); var router = express.Router(); + +// Simulate karaoke data +dummyKaras = require('./../../dummyKaras.json'); + + /* GET on root. */ router.get('/', function(req, res, next) { - res.send('This is the public client interface !'); + res.render('public', { karas: dummyKaras }); }); module.exports = router; \ No newline at end of file diff --git a/client/views/public.ejs b/client/views/public.ejs new file mode 100644 index 0000000..ea706fe --- /dev/null +++ b/client/views/public.ejs @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="UTF-8"> + <title>Lektor App</title> + <link rel="stylesheet" href="/bootstrap-4.5.2-dist/css/bootstrap.min.css" type="text/css"> + </head> + <body> + <div class="container-fluid"> + <div class="card text-center"> + <h2> + Public interface + </h2> + <% karas.forEach(function(kara){ %> + <div class="card border border-primary rounded" style="border-width: 5px; margin-bottom: 10px; margin-top: 10px;"> + <div class="card-header"> + <h3> + <%- kara.source_name + " - " + kara.song_type + " - " + kara.song_name %> + </h3> + + </div> + <div class="card-body"> + <h3> + <%- kara.author_name %><br/> + <%- kara.language %><br/> + <%- kara.category %><br/> + </h3> + + </div> + </div> + <% }); %> + </div> + </div> + </body> +</html> \ No newline at end of file diff --git a/package.json b/package.json index ff13b29..1c878c2 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "start": "electron ." }, "dependencies": { + "ejs": "^3.1.5", "electron": "^10.1.1", "express": "^4.17.1" }, -- GitLab