diff --git a/src/server/admin/routes.js b/src/server/admin/routes.js index e69de29..f16b802 100644 --- a/src/server/admin/routes.js +++ b/src/server/admin/routes.js @@ -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' ); + } + } ); +}; \ No newline at end of file diff --git a/src/server/admin/ui/login.html b/src/server/admin/ui/login.html new file mode 100644 index 0000000..ad8ef4e --- /dev/null +++ b/src/server/admin/ui/login.html @@ -0,0 +1,19 @@ + + + + + + + login :: myevent - admin panel + + +
+ +
+

Welcome to myevent!

+

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!

+ To the admin panel +
+
+ + \ No newline at end of file diff --git a/src/server/app.js b/src/server/app.js index f97aa5c..b5eab37 100644 --- a/src/server/app.js +++ b/src/server/app.js @@ -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 ( root !== '/' ) { +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 ); \ No newline at end of file diff --git a/src/server/backend/db/dbhandler.js b/src/server/backend/db/dbhandler.js new file mode 100644 index 0000000..e69de29 diff --git a/src/server/config.json b/src/server/config.json new file mode 100644 index 0000000..baf095c --- /dev/null +++ b/src/server/config.json @@ -0,0 +1,3 @@ +{ + "init":false +} \ No newline at end of file diff --git a/src/server/ui/assets/logo.png b/src/server/ui/assets/logo.png new file mode 100644 index 0000000..b9a3da3 Binary files /dev/null and b/src/server/ui/assets/logo.png differ diff --git a/src/server/ui/css/errorstyle.css b/src/server/ui/css/errorstyle.css new file mode 100644 index 0000000..12e0f45 --- /dev/null +++ b/src/server/ui/css/errorstyle.css @@ -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; +} diff --git a/src/server/ui/html/de/index.html b/src/server/ui/html/de/index.html new file mode 100644 index 0000000..e69de29 diff --git a/src/server/ui/html/en/errorResponses/404.html b/src/server/ui/html/en/errorResponses/404.html new file mode 100644 index 0000000..b264312 --- /dev/null +++ b/src/server/ui/html/en/errorResponses/404.html @@ -0,0 +1,17 @@ + + + + + + + 404 - Not found + + + +
+

404

+

The page you are looking for was not found on the server!

+ Back to the homepage +
+ + \ No newline at end of file diff --git a/src/server/ui/html/en/index.html b/src/server/ui/html/en/index.html new file mode 100644 index 0000000..e69de29 diff --git a/src/server/ui/html/index.html b/src/server/ui/html/index.html index e69de29..4560cfd 100644 --- a/src/server/ui/html/index.html +++ b/src/server/ui/html/index.html @@ -0,0 +1,61 @@ + + + + + + + myevent + + + + +
+ +
+

Welcome to myevent!

+

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!

+ To the admin panel +
+
+ + \ No newline at end of file