mirror of
https://github.com/janishutz/libreevent.git
synced 2026-04-28 13:59:23 +02: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' );
|
||||
}
|
||||
} );
|
||||
};
|
||||
@@ -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>
|
||||
+32
-7
@@ -17,10 +17,12 @@ const cookieParser = require( 'cookie-parser' );
|
||||
const favicon = require( 'serve-favicon' );
|
||||
const http = require( 'http' );
|
||||
|
||||
const env = process.env.PROD || false;
|
||||
// const env = process.env.PROD || false;
|
||||
|
||||
const root = process.env.ROOT || '/order';
|
||||
|
||||
const settings = fs.readFileSync( path.join( __dirname + '/config.json' ) );
|
||||
|
||||
// initialise express with middlewares
|
||||
app.use( expressSession( {
|
||||
secret: 'gaoevgoawefgo083tq2rfvöfaf0p8',
|
||||
@@ -33,18 +35,41 @@ app.use( bodyParser.json() );
|
||||
app.use( cookieParser() );
|
||||
app.use( favicon( path.join( __dirname + '/ui/assets/logo.png' ) ) );
|
||||
|
||||
// create 404 handler
|
||||
app.use( ( request, response ) => {
|
||||
response.sendFile( path.join( __dirname + '' ) );
|
||||
} );
|
||||
|
||||
require( './admin/routes.js' )( app, settings ); // admin route
|
||||
|
||||
if ( settings[ 'init' ] ) {
|
||||
if ( root !== '/' ) {
|
||||
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;
|
||||
http.createServer( app ).listen( PORT );
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"init":false
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
@@ -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,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,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