diff --git a/.gitignore b/.gitignore index ceaea36..030343a 100644 --- a/.gitignore +++ b/.gitignore @@ -130,3 +130,5 @@ dist .yarn/install-state.gz .pnp.* +#data +./data/ \ No newline at end of file diff --git a/bin/global-variables.js b/bin/global-variables.js index 43f89ec..96a2310 100644 --- a/bin/global-variables.js +++ b/bin/global-variables.js @@ -2,7 +2,9 @@ const path = require("path"); const root = path.resolve(__dirname, '../') const __glob = { - ROUTES: root + path.sep + "routes" + path.sep + ROUTES: root + path.sep + "routes" + path.sep, + ROOT: root, + LOGS: root + path.sep + "logs" }; diff --git a/bin/www b/bin/www index 8d4eea6..692c2a4 100644 --- a/bin/www +++ b/bin/www @@ -3,11 +3,19 @@ /** * Module dependencies. */ +var log = require("loguix") +var {LogType} = require("loguix") +var { __glob } = require("./global-variables") +log.setup(__glob.LOGS) +const wlog = new LogType("Web") +wlog.step.init("start_server", "Démarrage du serveur Express JS") var app = require('../main'); var debug = require('debug')('neutral:server'); var http = require('http'); + + /** * Get port from environment and store in Express. */ @@ -25,6 +33,7 @@ var server = http.createServer(app); * Listen on provided port, on all network interfaces. */ + server.listen(port); server.on('error', onError); server.on('listening', onListening); @@ -65,11 +74,11 @@ function onError(error) { // handle specific listen errors with friendly messages switch (error.code) { case 'EACCES': - console.error(bind + ' requires elevated privileges'); + wlog.step.error("start_server", bind + ' requires elevated privileges'); process.exit(1); break; case 'EADDRINUSE': - console.error(bind + ' is already in use'); + wlog.step.error("start_server" , bind + ' is already in use'); process.exit(1); break; default: @@ -86,5 +95,5 @@ function onListening() { var bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port; - debug('Listening on ' + bind); + wlog.step.end("start_server") } diff --git a/main.js b/main.js index 23b7af9..6c45712 100644 --- a/main.js +++ b/main.js @@ -5,11 +5,18 @@ const cookieParser = require('cookie-parser'); const app = express(); const fs = require("fs"); const { __glob } = require('./bin/global-variables'); +const log = require("loguix") + +var wlog = log.getInstance("Web") + + setup() + function getRouters() { + wlog.log("Récupération de " + fs.readdirSync(__glob.ROUTES).length + " routeurs") for(var route of fs.readdirSync(__glob.ROUTES)) { if(route == "index.js") { @@ -30,6 +37,7 @@ function setup() { app.set('view engine', 'ejs'); + app.use(express.json()); app.use(express.urlencoded({ extended: false })); app.use(cookieParser()); @@ -39,7 +47,15 @@ function setup() { // catch 404 and forward to error handler app.use(function(req, res, next) { - next(createError(404)); + res.locals.message = "Page non trouvé"; + res.locals.error = { + "status": "404", + "stack": "" + } + + // render the error page + res.status(404 || 404); + res.render('utils/error'); }); // error handler @@ -50,7 +66,7 @@ function setup() { // render the error page res.status(err.status || 500); - res.render('error'); + res.render('utils/error'); }); diff --git a/package-lock.json b/package-lock.json index 5ba4e5f..010a3d0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "ejs": "~2.6.1", "express": "~4.16.1", "http-errors": "~1.6.3", - "loguix": "^1.2.0", + "loguix": "1.4.1", "nodemon": "^3.0.1" } }, @@ -446,9 +446,9 @@ } }, "node_modules/loguix": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/loguix/-/loguix-1.2.0.tgz", - "integrity": "sha512-6ITC4SzqPG/R/uWr0HCGYybeciWk/GV7gZYOOxkES6DGVI5FcHK0UWOf8yczt2eXg+riLyT79HJQJwh10hVqFw==" + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/loguix/-/loguix-1.4.1.tgz", + "integrity": "sha512-lLBMc4ue37BLCIhtxBsp0PEbhOgf0DtHjYnJPoHkfUtO6T5sLy+kFwySKih0cEJgt1nmi1OMMoCEVYCqNnuODg==" }, "node_modules/lru-cache": { "version": "6.0.0", @@ -1179,9 +1179,9 @@ "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" }, "loguix": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/loguix/-/loguix-1.2.0.tgz", - "integrity": "sha512-6ITC4SzqPG/R/uWr0HCGYybeciWk/GV7gZYOOxkES6DGVI5FcHK0UWOf8yczt2eXg+riLyT79HJQJwh10hVqFw==" + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/loguix/-/loguix-1.4.1.tgz", + "integrity": "sha512-lLBMc4ue37BLCIhtxBsp0PEbhOgf0DtHjYnJPoHkfUtO6T5sLy+kFwySKih0cEJgt1nmi1OMMoCEVYCqNnuODg==" }, "lru-cache": { "version": "6.0.0", diff --git a/package.json b/package.json index 1150f7c..78d03ef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "neutral", - "version": "0.1.0", + "version": "0.1.1", "description": "Panel d'administration de Raphix", "main": "index.js", "scripts": { @@ -24,7 +24,7 @@ "ejs": "~2.6.1", "express": "~4.16.1", "http-errors": "~1.6.3", - "loguix": "^1.2.0", + "loguix": "1.4.1", "nodemon": "^3.0.1" }, "author": "Raphix", diff --git a/public/images/FontLogo.png b/public/images/FontLogo.png new file mode 100644 index 0000000..4a93ad1 Binary files /dev/null and b/public/images/FontLogo.png differ diff --git a/public/images/FormatLogo_BLACK.png b/public/images/FormatLogo_BLACK.png new file mode 100644 index 0000000..b78d4e2 Binary files /dev/null and b/public/images/FormatLogo_BLACK.png differ diff --git a/public/images/FormatLogo_BLACK.svg b/public/images/FormatLogo_BLACK.svg new file mode 100644 index 0000000..dada85b --- /dev/null +++ b/public/images/FormatLogo_BLACK.svg @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/images/FormatLogo_WHITE.png b/public/images/FormatLogo_WHITE.png new file mode 100644 index 0000000..7c8d0bf Binary files /dev/null and b/public/images/FormatLogo_WHITE.png differ diff --git a/public/images/FormatLogo_WHITE.svg b/public/images/FormatLogo_WHITE.svg new file mode 100644 index 0000000..fca4d89 --- /dev/null +++ b/public/images/FormatLogo_WHITE.svg @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/javascripts/basics.js b/public/javascripts/basics.js new file mode 100644 index 0000000..003ed88 --- /dev/null +++ b/public/javascripts/basics.js @@ -0,0 +1,35 @@ +// Get Document ID + +function getID(string) { + + return document.getElementById(string) +} + +class InfoPop { + constructor(name) { + this.name = name + this.element = getID(this.name) + this.element.style.fontSize = "14px" + + } + + clear() { + + this.element.innerHTML = "" + } + + err(text) { + + this.element.classList.add("yellow") + this.element.innerHTML = " " + text + + } + + info(text) { + + this.element.classList.remove("yellow") + + this.element.innerHTML = " " + text + } + +} \ No newline at end of file diff --git a/public/javascripts/loginscript.js b/public/javascripts/loginscript.js new file mode 100644 index 0000000..007f630 --- /dev/null +++ b/public/javascripts/loginscript.js @@ -0,0 +1,22 @@ +const username = getID("username") +const password = getID("password") +const submit = getID("submit") + +const loginInfo = new InfoPop("login-info") + +loginInfo.clear() + +submit.addEventListener("click", () => { + + if(!username.value) { + + loginInfo.err("Le nom d'utilisateur est nécéssaire pour se connecter !") + + } else if(!password.value) { + + loginInfo.err("Le mot de passe est nécéssaire pour se connecter !") + } else { + + loginInfo.clear() + } +}) \ No newline at end of file diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css index ec41653..df3ff9d 100644 --- a/public/stylesheets/style.css +++ b/public/stylesheets/style.css @@ -1,11 +1,17 @@ -@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap'); +@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300&display=swap'); body { padding: 2%; - background-color: #323031; + background: linear-gradient(120deg, #323031 40%, rgba(241,0,0,1) 100%); color: white; - font-size: 1vw; + font-size: 20px; font-family: 'Roboto', sans-serif !important; + +} + +html { + min-height: 100%; + margin: 0; } /*Button*/ @@ -19,7 +25,7 @@ body { color: currentColor; padding: 0.5vw; transition: 0.2s; - + cursor: pointer; } .btn span { @@ -48,20 +54,27 @@ body { } +.btn span a { + text-decoration: none; +} + /* Miniaturiez Button */ .min { - width: 2vw !important; - height: 2vw !important; + width: 40px !important; + height: 40px !important; border-radius: 100% !important; font-size: 1vw !important; - display: flex; - justify-content: center; - align-items: center; transition: 0.2s; + padding: 0 !important; } +.min span { + + font-size: 20px !important; + +} @@ -69,7 +82,7 @@ body { .red { - color: rgb(255, 63, 63) !important; + color: #f01000!important; } .blue { @@ -85,4 +98,185 @@ body { .green { color: rgb(64, 248, 64) !important; +} + +/*Balise Properties*/ + +code { + + background-color: #3D3B3C; + padding: 0.3vw; + border-radius: 0.5vw; +} + +p { + margin-block-start: 0.5em !important; + margin-block-end: 0.5em !important; +} + +a { + color: currentColor; +} + +/*Lists*/ + +.center { + + text-align: center !important; + + +} + +.col { + + display: flex; + flex-direction: column; + gap: 2vw; + +} + +@media (max-width: 500px) { + + .row { + + + display: flex; + flex-direction: column; + gap: 2vw; + + } + +} + +@media (min-width: 500px) { + +.row { + + + display: flex; + flex-direction: row; + gap: 2vw; + +} + +} + +/* Fields */ + +.field { + + width: fit-content; + border-radius: 5px; + padding-bottom: 0.3vw; + padding-top: 0.3vw; + padding-left: 0.5vw; + border: 1px solid white; + background-color: transparent; + transition: 0.2s; + color: white; +} + +.field:focus { + color: black; + outline: none; + background-color: white; + box-shadow: 0px 0px 8px #C1BDB3 ; +} + + + + +/* Logo */ + +@media (max-width: 640px) { + + .logo { + + font-family: 'Gunship', sans-serif; + text-shadow: 0px 0px 10px #ffffff; + font-size: 50px; + display: flex; + justify-content: center; + text-align: center; + flex-direction: column; + align-items: center; + } + + .logo-img { + + width: 70px; + margin-right: 10px; + } + + +} + +@media (min-width: 640px) { + + .logo { + + font-family: 'Gunship', sans-serif; + text-shadow: 0px 0px 10px #ffffff; + font-size: 50px; + display: flex; + + justify-content: center; + text-align: center; + align-items: center; + } + + .logo-img { + + width: 70px; + margin-right: 10px; + } + + +} + + + +/* Form Box */ + + +.form-box { + + width: 500px; + height: 400px; + border-radius: 0.5vw; + display: flex; + padding: 2%; + flex-direction: column; + justify-content: space-between; + background-color: #605e5863; +} + +.m-align { + + margin-right: auto !important; + margin-left: auto !important; +} + +.t-center { + + text-align: center; +} + + +/* LOGIN Specs */ + +.LOG_btn { + + margin-top: 2%; + margin-bottom: 2%; +} + +.LOG_body { + + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + padding: 0 !important; + margin: 0 !important; } \ No newline at end of file diff --git a/routes/login.js b/routes/login.js new file mode 100644 index 0000000..b44b1c5 --- /dev/null +++ b/routes/login.js @@ -0,0 +1,9 @@ +var express = require('express'); +var router = express.Router(); + +/* GET home page. */ +router.get('/', function(req, res, next) { + res.render('login'); +}); + +module.exports = router; diff --git a/routes/stylepage.js b/routes/stylepage.js index cc10add..6aaac1d 100644 --- a/routes/stylepage.js +++ b/routes/stylepage.js @@ -3,7 +3,7 @@ var router = express.Router(); /* GET home page. */ router.get('/', function(req, res, next) { - res.render('stylepage'); + res.render('utils/stylepage'); }); module.exports = router; diff --git a/views/login.ejs b/views/login.ejs new file mode 100644 index 0000000..a953ade --- /dev/null +++ b/views/login.ejs @@ -0,0 +1,28 @@ + + + + Neutral + + + +
+ + +
+

Nom d'utilisateur

+ +
+
+

Mot de passe

+ +
+

+ +
+ + + + + + + diff --git a/views/stylepage.ejs b/views/stylepage.ejs deleted file mode 100644 index b9cbc50..0000000 --- a/views/stylepage.ejs +++ /dev/null @@ -1,70 +0,0 @@ - - - - Neutral - - - -

Neutral - Style Page

-

Welcome to Neutral

- -

Police : 'Roboto', sans-serif

- - -
- - - - - - - - -

#323031

-

#3D3B3C

-

#7F7979

-

#C1BDB3

-

#5F5B6B

-
- - - - - diff --git a/views/error.ejs b/views/utils/error.ejs similarity index 51% rename from views/error.ejs rename to views/utils/error.ejs index 8e3cb4b..dffc8b0 100644 --- a/views/error.ejs +++ b/views/utils/error.ejs @@ -16,34 +16,17 @@ border-radius: 1vw; padding: 2%; } - - button { - color: red; - background-color: transparent; - border-radius: 1vw; - border-color: red; - border-style: solid; - padding: 10px; - transition: all 0.2s ease 0s; - } - - button:hover { - - color: white; - background-color: red; - cursor: pointer; - }
-

Erreur

+

Erreur <%= error.status %>

<%= message %> - <%= error.status %>

<%= error.stack %>

- + diff --git a/views/utils/stylepage.ejs b/views/utils/stylepage.ejs new file mode 100644 index 0000000..6795125 --- /dev/null +++ b/views/utils/stylepage.ejs @@ -0,0 +1,75 @@ + + + + Neutral + + + +

Neutral - Page de style

+

Cette page est dédiée au développement et n'est pas en relation avec le Panel Neutral.

+ +
+

Police : 'Roboto', sans-serif

+

Liens : https://neutral.raphix.fr/stylepage

+
+
+ + +
+

Classe : btn

+
+ + + + + +
+

Classe : btn min

+
+ + + +
+
+

#323031

+

#f10000

+

#605e5863

+
+

Classe : field

+ + + + + +