mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 13:24:24 +00:00
add routes, error & config
This commit is contained in:
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* myevent - routes.js (admin)
|
||||||
|
*
|
||||||
|
* Created by Janis Hutz 03/11/2023, Licensed under the GPL V3 License
|
||||||
|
* https://janishutz.com, development@janishutz.com
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
const path = require( 'path' );
|
||||||
|
|
||||||
|
module.exports = ( app, settings ) => {
|
||||||
|
app.get( '/admin/login', ( request, response ) => {
|
||||||
|
response.sendFile( path.join( __dirname + '/ui/login.html' ) );
|
||||||
|
} );
|
||||||
|
|
||||||
|
|
||||||
|
app.get( '/admin', ( request, response ) => {
|
||||||
|
if ( request.session.loggedIn ) {
|
||||||
|
if ( settings[ 'init' ] ) {
|
||||||
|
response.sendFile( path.join( __dirname + '/ui/panel.html' ) );
|
||||||
|
} else {
|
||||||
|
response.sendFile( path.join( __dirname + '/ui/setup.html' ) );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
response.redirect( '/admin/login' );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
};
|
||||||
19
src/server/admin/ui/login.html
Normal file
19
src/server/admin/ui/login.html
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>login :: myevent - admin panel</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="content">
|
||||||
|
<img src="/assets/logo.png" alt="myevent-logo" class="logo">
|
||||||
|
<div class="lang" id="en">
|
||||||
|
<h1>Welcome to myevent!</h1>
|
||||||
|
<p>Thank you for installing and using myevent! Let's get started by setting it up! First plan of action is to log in to the admin panel where you can replace this page here with your own landing page!</p>
|
||||||
|
<a href="/admin/login" class="button">To the admin panel</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -17,10 +17,12 @@ const cookieParser = require( 'cookie-parser' );
|
|||||||
const favicon = require( 'serve-favicon' );
|
const favicon = require( 'serve-favicon' );
|
||||||
const http = require( 'http' );
|
const http = require( 'http' );
|
||||||
|
|
||||||
const env = process.env.PROD || false;
|
// const env = process.env.PROD || false;
|
||||||
|
|
||||||
const root = process.env.ROOT || '/order';
|
const root = process.env.ROOT || '/order';
|
||||||
|
|
||||||
|
const settings = fs.readFileSync( path.join( __dirname + '/config.json' ) );
|
||||||
|
|
||||||
// initialise express with middlewares
|
// initialise express with middlewares
|
||||||
app.use( expressSession( {
|
app.use( expressSession( {
|
||||||
secret: 'gaoevgoawefgo083tq2rfvöfaf0p8',
|
secret: 'gaoevgoawefgo083tq2rfvöfaf0p8',
|
||||||
@@ -33,18 +35,41 @@ app.use( bodyParser.json() );
|
|||||||
app.use( cookieParser() );
|
app.use( cookieParser() );
|
||||||
app.use( favicon( path.join( __dirname + '/ui/assets/logo.png' ) ) );
|
app.use( favicon( path.join( __dirname + '/ui/assets/logo.png' ) ) );
|
||||||
|
|
||||||
// create 404 handler
|
require( './admin/routes.js' )( app, settings ); // admin route
|
||||||
app.use( ( request, response ) => {
|
|
||||||
response.sendFile( path.join( __dirname + '' ) );
|
|
||||||
} );
|
|
||||||
|
|
||||||
|
|
||||||
|
if ( settings[ 'init' ] ) {
|
||||||
if ( root !== '/' ) {
|
if ( root !== '/' ) {
|
||||||
app.get( '/', ( request, response ) => {
|
app.get( '/', ( request, response ) => {
|
||||||
|
let lang = request.query.lang || 'en';
|
||||||
|
response.sendFile( path.join( __dirname + '/ui/html/' + lang + '/index.html' ) );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
app.get( '/', ( request, response ) => {
|
||||||
|
response.sendFile( path.join( __dirname + '/ui/html/index.html' ) );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Assets route for logo, etc
|
||||||
|
app.get( '/assets/:file', ( request, response ) => {
|
||||||
|
response.sendFile( path.join( __dirname + '/ui/assets/' + request.params.file ) );
|
||||||
|
} );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// CSS route for all user-facing CSS files
|
||||||
|
app.get( '/css/:file', ( request, response ) => {
|
||||||
|
response.sendFile( path.join( __dirname + '/ui/css/' + request.params.file ) );
|
||||||
|
} );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// create 404 handler
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
app.use( ( request, response, next ) => {
|
||||||
|
response.sendFile( path.join( __dirname + '/ui/html/en/errorResponses/404.html' ) );
|
||||||
|
} );
|
||||||
|
|
||||||
const PORT = process.env.PORT || 8080;
|
const PORT = process.env.PORT || 8080;
|
||||||
http.createServer( app ).listen( PORT );
|
http.createServer( app ).listen( PORT );
|
||||||
0
src/server/backend/db/dbhandler.js
Normal file
0
src/server/backend/db/dbhandler.js
Normal file
3
src/server/config.json
Normal file
3
src/server/config.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"init":false
|
||||||
|
}
|
||||||
BIN
src/server/ui/assets/logo.png
Normal file
BIN
src/server/ui/assets/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
54
src/server/ui/css/errorstyle.css
Normal file
54
src/server/ui/css/errorstyle.css
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* myevent - errorstyle.css
|
||||||
|
*
|
||||||
|
* Created by Janis Hutz 03/11/2023, Licensed under the GPL V3 License
|
||||||
|
* https://janishutz.com, development@janishutz.com
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
html {
|
||||||
|
height: 98%;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-color: lightgray;
|
||||||
|
font-family: monospace;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.code {
|
||||||
|
font-size: 20vw;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message {
|
||||||
|
font-size: 1.5vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
|
text-decoration: none;
|
||||||
|
background-color: gray;
|
||||||
|
font-style: italic;
|
||||||
|
font-size: 1vw;
|
||||||
|
color: white;
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 30px;
|
||||||
|
transition: 1s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button:hover {
|
||||||
|
transition: ease-in-out 0.2s;
|
||||||
|
background-color: black;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
0
src/server/ui/html/de/index.html
Normal file
0
src/server/ui/html/de/index.html
Normal file
17
src/server/ui/html/en/errorResponses/404.html
Normal file
17
src/server/ui/html/en/errorResponses/404.html
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>404 - Not found</title>
|
||||||
|
<link rel="stylesheet" href="/css/errorstyle.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="content">
|
||||||
|
<h1 class="code">404</h1>
|
||||||
|
<h2 class="message">The page you are looking for was not found on the server!</h2>
|
||||||
|
<a href="/" class="button">Back to the homepage</a>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
0
src/server/ui/html/en/index.html
Normal file
0
src/server/ui/html/en/index.html
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>myevent</title>
|
||||||
|
<!-- We are using inline styling to simplify the removal of this page -->
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background-color: rgb(202, 223, 255);
|
||||||
|
font-family: sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content, .lang {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo {
|
||||||
|
margin: 2%;
|
||||||
|
height: 50vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lang {
|
||||||
|
background-color: white;
|
||||||
|
padding: 2%;
|
||||||
|
margin: 3%;
|
||||||
|
margin-bottom: 0;
|
||||||
|
border-radius: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
|
text-decoration: none;
|
||||||
|
color: white;
|
||||||
|
background-color: blue;
|
||||||
|
padding: 30px;
|
||||||
|
border-radius: 30px;
|
||||||
|
transition: 0.4s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button:hover {
|
||||||
|
transition: ease-in-out 0.2s;
|
||||||
|
background-color: darkblue;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="content">
|
||||||
|
<img src="/assets/logo.png" alt="myevent-logo" class="logo">
|
||||||
|
<div class="lang" id="en">
|
||||||
|
<h1>Welcome to myevent!</h1>
|
||||||
|
<p>Thank you for installing and using myevent! Let's get started by setting it up! First plan of action is to log in to the admin panel where you can replace this page here with your own landing page!</p>
|
||||||
|
<a href="/admin/login" class="button">To the admin panel</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user