Set indent size
This commit is contained in:
parent
33c87b434c
commit
3ebdc9c06a
9 changed files with 143 additions and 155 deletions
|
@ -46,6 +46,7 @@
|
||||||
"connect-flash": "^0.1.1",
|
"connect-flash": "^0.1.1",
|
||||||
"connect-mongo": "^4.6.0",
|
"connect-mongo": "^4.6.0",
|
||||||
"cookie-parser": "^1.4.6",
|
"cookie-parser": "^1.4.6",
|
||||||
|
"debug": "^4.3.3",
|
||||||
"ejs": "^3.1.6",
|
"ejs": "^3.1.6",
|
||||||
"express": "^4.17.2",
|
"express": "^4.17.2",
|
||||||
"express-session": "^1.17.2",
|
"express-session": "^1.17.2",
|
||||||
|
|
|
@ -50,10 +50,8 @@ if (["production"].indexOf(env) !== -1) {
|
||||||
/* eslint-disable func-names */
|
/* eslint-disable func-names */
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
if (req.secure) {
|
if (req.secure) {
|
||||||
// request was via https, so do no special handling
|
|
||||||
next();
|
next();
|
||||||
} else {
|
} else {
|
||||||
// request was via http, so redirect to https
|
|
||||||
res.redirect(`https://${req.headers.host}${req.url}`);
|
res.redirect(`https://${req.headers.host}${req.url}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,54 +4,49 @@
|
||||||
* Module dependencies.
|
* Module dependencies.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import app from '../app';
|
import debugLib from "debug";
|
||||||
import debugLib from 'debug';
|
import http from "http";
|
||||||
import http from 'http';
|
import app from "../app";
|
||||||
import {port} from '../config';
|
import { port } from "../config";
|
||||||
|
|
||||||
const debug = debugLib('nodecdtheque:server');
|
const debug = debugLib("nodecdtheque:server");
|
||||||
const server = http.createServer(app);
|
const server = http.createServer(app);
|
||||||
|
|
||||||
server.listen(port);
|
|
||||||
server.on('error', onError);
|
|
||||||
server.on('listening', onListening);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event listener for HTTP server "error" event.
|
* Event listener for HTTP server "error" event.
|
||||||
* @param {*} error
|
* @param {*} error
|
||||||
*/
|
*/
|
||||||
function onError(error) {
|
function onError(error) {
|
||||||
if (error.syscall !== 'listen') {
|
if (error.syscall !== "listen") {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bind = typeof port === 'string' ?
|
const bind = typeof port === "string" ? `Pipe ${port}` : `Port ${port}`;
|
||||||
'Pipe ' + port :
|
|
||||||
'Port ' + port;
|
|
||||||
|
|
||||||
// handle specific listen errors with friendly messages
|
switch (error.code) {
|
||||||
switch (error.code) {
|
case "EACCES":
|
||||||
case 'EACCES':
|
console.error(`${bind} requires elevated privileges`);
|
||||||
console.error(bind + ' requires elevated privileges');
|
process.exit(1);
|
||||||
process.exit(1);
|
break;
|
||||||
break;
|
case "EADDRINUSE":
|
||||||
case 'EADDRINUSE':
|
console.error(`${bind} is already in use`);
|
||||||
console.error(bind + ' is already in use');
|
process.exit(1);
|
||||||
process.exit(1);
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
throw error;
|
||||||
throw error;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event listener for HTTP server "listening" event.
|
* Event listener for HTTP server "listening" event.
|
||||||
*/
|
*/
|
||||||
function onListening() {
|
function onListening() {
|
||||||
const addr = server.address();
|
const addr = server.address();
|
||||||
const bind = typeof addr === 'string' ?
|
const bind =
|
||||||
'pipe ' + addr :
|
typeof addr === "string" ? `pipe ${addr}` : `port ${addr.port}`;
|
||||||
'port ' + addr.port;
|
debug(`Listening on ${bind}`);
|
||||||
debug('Listening on ' + bind);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
server.listen(port);
|
||||||
|
server.on("error", onError);
|
||||||
|
server.on("listening", onListening);
|
||||||
|
|
|
@ -1,23 +1,22 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
<%- include('partials/head', {page: page, user: user}); %>
|
<%- include('partials/head', {page: page, user: user}); %>
|
||||||
|
|
||||||
<body class="error">
|
|
||||||
<%- include('partials/header'); %>
|
|
||||||
<main class="mt-4">
|
|
||||||
<div class="container">
|
|
||||||
<section class="px-md-5 mx-md-5 dark-grey-text mb-4">
|
|
||||||
<h1><%= page.title %></h1>
|
|
||||||
<% if ( errorCode && errorCode === 404 ) { %>
|
|
||||||
<img src="/img/404.svg" alt="Erreur 404" style="max-height: 400px;" />
|
|
||||||
<% } %>
|
|
||||||
<p class="lead">
|
|
||||||
<%= page.error %>
|
|
||||||
</p>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
<%- include('partials/footer', {page: page, user: user, blog: null}); %>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
|
<body class="error">
|
||||||
|
<%- include('partials/header'); %>
|
||||||
|
<main class="mt-4">
|
||||||
|
<div class="container">
|
||||||
|
<section class="px-md-5 mx-md-5 dark-grey-text mb-4">
|
||||||
|
<h1><%= page.title %></h1>
|
||||||
|
<% if ( errorCode && errorCode === 404 ) { %>
|
||||||
|
<img src="/img/404.svg" alt="Erreur 404" style="max-height: 400px;" />
|
||||||
|
<% } %>
|
||||||
|
<p class="lead">
|
||||||
|
<%= page.error %>
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
<%- include('partials/footer', {page: page, user: user, blog: null}); %>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -1,26 +1,27 @@
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
<%- include('partials/head'); %>
|
<%- include('partials/head'); %>
|
||||||
<body>
|
<body>
|
||||||
<%- include('partials/header'); %>
|
<%- include('partials/header'); %>
|
||||||
|
|
||||||
<% if ( page.failureFlash ) {%>
|
<% if ( page.failureFlash ) {%>
|
||||||
<div class="alert alert-danger" role="alert">
|
<div class="alert alert-danger" role="alert">
|
||||||
<%= page.failureFlash %>
|
<%= page.failureFlash %>
|
||||||
</div>
|
</div>
|
||||||
<% } %>
|
<% } %>
|
||||||
<%
|
|
||||||
if (error && error.length > 0) {
|
<%
|
||||||
for( let i = 0 ; i < error.length ; i += 1 ) {
|
if (error && error.length > 0) {
|
||||||
%>
|
for( let i = 0 ; i < error.length ; i += 1 ) {
|
||||||
<div class="alert alert-danger" role="alert">
|
%>
|
||||||
<%= error %>
|
<div class="alert alert-danger" role="alert">
|
||||||
</div>
|
<%= error %>
|
||||||
<%
|
</div>
|
||||||
}
|
<%
|
||||||
}
|
}
|
||||||
%>
|
}
|
||||||
<%- include(viewname) %>
|
%>
|
||||||
<%- include('partials/footer'); %>
|
<%- include(viewname) %>
|
||||||
</body>
|
<%- include('partials/footer'); %>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,26 +1,24 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="d-flex justify-content-center">
|
<div class="d-flex justify-content-center">
|
||||||
<div class="p-2">
|
<div class="p-2">
|
||||||
<form class="text-center border border-light p-5" method="POST">
|
<form class="text-center border border-light p-5" method="POST">
|
||||||
<img class="mb-4" src="/img/logo.png" alt="DarKou">
|
<img class="mb-4" src="/img/logo.png" alt="DarKou">
|
||||||
<p class="h4 mb-4">Connexion</p>
|
<p class="h4 mb-4">Connexion</p>
|
||||||
|
|
||||||
<div class="md-form">
|
<div class="md-form">
|
||||||
<input type="email" id="email" name="email" class="form-control" required>
|
<input type="email" id="email" name="email" class="form-control" required>
|
||||||
<label for="email">Adresse e-mail</label>
|
<label for="email">Adresse e-mail</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-form">
|
||||||
|
<input type="password" id="password" name="password" class="form-control" required>
|
||||||
|
<label for="password">Mot de passe</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button class="btn btn-primary btn-block my-4" type="submit">Connexion</button>
|
||||||
|
|
||||||
|
<p>Pas encore inscrit ? <a href="/inscription">Inscrivez-vous</a></p>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="md-form">
|
|
||||||
<input type="password" id="password" name="password" class="form-control" required>
|
|
||||||
<label for="password">Mot de passe</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button class="btn btn-primary btn-block my-4" type="submit">Connexion</button>
|
|
||||||
|
|
||||||
<p>Pas encore inscrit ?
|
|
||||||
<a href="/inscription">Inscrivez-vous</a>
|
|
||||||
</p>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
|
@ -1,31 +1,29 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="d-flex justify-content-center">
|
<div class="d-flex justify-content-center">
|
||||||
<div class="p-2">
|
<div class="p-2">
|
||||||
<form class="text-center border border-light p-5" method="POST">
|
<form class="text-center border border-light p-5" method="POST">
|
||||||
<img class="mb-4" src="/img/logo.png" alt="DarKou">
|
<img class="mb-4" src="/img/logo.png" alt="DarKou">
|
||||||
<p class="h4 mb-4">Inscription</p>
|
<p class="h4 mb-4">Inscription</p>
|
||||||
|
|
||||||
<div class="md-form">
|
<div class="md-form">
|
||||||
<input type="text" id="username" name="username" class="form-control" required>
|
<input type="text" id="username" name="username" class="form-control" required>
|
||||||
<label for="username">Nom d'utilisateur</label>
|
<label for="username">Nom d'utilisateur</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-form">
|
||||||
|
<input type="email" id="email" name="email" class="form-control" required>
|
||||||
|
<label for="email">Adresse e-mail</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md-form">
|
||||||
|
<input type="password" id="password" name="password" class="form-control" required>
|
||||||
|
<label for="password">Mot de passe</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button class="btn btn-primary btn-block my-4" type="submit">Inscription</button>
|
||||||
|
|
||||||
|
<p>Déjà inscrit ? <a href="/connexion">Connectez-vous</a></p>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="md-form">
|
|
||||||
<input type="email" id="email" name="email" class="form-control" required>
|
|
||||||
<label for="email">Adresse e-mail</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="md-form">
|
|
||||||
<input type="password" id="password" name="password" class="form-control" required>
|
|
||||||
<label for="password">Mot de passe</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button class="btn btn-primary btn-block my-4" type="submit">Inscription</button>
|
|
||||||
|
|
||||||
<p>Déjà inscrit ?
|
|
||||||
<a href="/connexion">Connectez-vous</a>
|
|
||||||
</p>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
|
@ -1,18 +1,17 @@
|
||||||
<head>
|
<head>
|
||||||
<!-- Required meta tags -->
|
<meta charset="utf-8">
|
||||||
<meta charset="utf-8">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
|
|
||||||
<title><% if (page.title) { %><%= page.title %> <% } else { %> DarKou - Ma CDThèque <% } %></title>
|
<title><% if (page.title) { %><%= page.title %> <% } else { %> DarKou - Ma CDThèque <% } %></title>
|
||||||
<link rel="icon" type="image/png" href="/favicon.png" />
|
<link rel="icon" type="image/png" href="/favicon.png" />
|
||||||
|
|
||||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.11.2/css/all.css">
|
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.11.2/css/all.css">
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap">
|
||||||
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="/libs/mdbootstrap/css/bootstrap.min.css">
|
<link rel="stylesheet" href="/libs/mdbootstrap/css/bootstrap.min.css">
|
||||||
<link rel="stylesheet" href="/libs/mdbootstrap/css/mdb.min.css">
|
<link rel="stylesheet" href="/libs/mdbootstrap/css/mdb.min.css">
|
||||||
<link rel="stylesheet" href="/libs/mdbootstrap/css/style.css">
|
<link rel="stylesheet" href="/libs/mdbootstrap/css/style.css">
|
||||||
|
|
||||||
<link rel="stylesheet" href="/css/main.css" />
|
<link rel="stylesheet" href="/css/main.css" />
|
||||||
</head>
|
</head>
|
|
@ -1,25 +1,24 @@
|
||||||
<nav class="navbar navbar-expand-md navbar-dark primary-color sticky-top">
|
<nav class="navbar navbar-expand-md navbar-dark primary-color sticky-top">
|
||||||
<a class="navbar-brand" href="/">CDThèque</a>
|
<a class="navbar-brand" href="/">CDThèque</a>
|
||||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<% if ( user ) { %>
|
<% if ( user ) { %>
|
||||||
<div class="navbar-collapse collapse w-100 order-1 dual-collapse2">
|
<div class="navbar-collapse collapse w-100 order-1 dual-collapse2">
|
||||||
<ul class="navbar-nav ml-auto">
|
<ul class="navbar-nav ml-auto">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="/upload">Ajouter une image</a>
|
<a class="nav-link" href="/upload">Ajouter une image</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true"
|
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Mon compte</a>
|
||||||
aria-expanded="false">Mon compte</a>
|
<div class="dropdown-menu">
|
||||||
<div class="dropdown-menu">
|
<a class="dropdown-item" href="/gallery">Mes images</a>
|
||||||
<a class="dropdown-item" href="/gallery">Mes images</a>
|
<div class="dropdown-divider"></div>
|
||||||
<div class="dropdown-divider"></div>
|
<a class="dropdown-item" href="/se-deconnecter">Déconnexion</a>
|
||||||
<a class="dropdown-item" href="/se-deconnecter">Déconnexion</a>
|
</div>
|
||||||
</div>
|
</li>
|
||||||
</li>
|
</ul>
|
||||||
</ul>
|
</div>
|
||||||
</div>
|
<% } %>
|
||||||
<% } %>
|
|
||||||
</nav>
|
</nav>
|
Loading…
Reference in a new issue