mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 13:24:24 +00:00
add start page settings
This commit is contained in:
@@ -10,12 +10,12 @@
|
||||
const db = require( '../../backend/db/db.js' );
|
||||
const pm = require( '../../backend/plugins/manager.js' );
|
||||
const spm = require( '../startPageManager.js' );
|
||||
const startPageManager = new spm();
|
||||
|
||||
class GETHandler {
|
||||
constructor ( settings ) {
|
||||
this.pluginManager = new pm( settings );
|
||||
this.settings = settings;
|
||||
this.startPageManager = new spm( settings );
|
||||
}
|
||||
|
||||
handleCall ( call, query ) {
|
||||
@@ -115,9 +115,17 @@ class GETHandler {
|
||||
} else if ( call === 'getAllPlugins' ) {
|
||||
resolve( this.pluginManager.getPlugins() );
|
||||
} else if ( call === 'getStartPageSettings' ) {
|
||||
resolve( startPageManager.loadStartPagePreferences( query.name ) );
|
||||
resolve( this.startPageManager.loadStartPagePreferences( query.name ) );
|
||||
} else if ( call === 'getAllStartPages' ) {
|
||||
resolve( startPageManager.findAllStartPageTemplates() );
|
||||
resolve( this.startPageManager.findAllStartPageTemplates() );
|
||||
} else if ( call === 'buildStartPage' ) {
|
||||
( async() => {
|
||||
if ( await this.startPageManager.renderStartPage( query.page ) ) {
|
||||
resolve( 'ok' );
|
||||
} else {
|
||||
reject( { 'code': 412, 'error': 'Missing entries' } );
|
||||
}
|
||||
} )();
|
||||
} else {
|
||||
reject( { 'code': 404, 'error': 'Route not found' } );
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ const pwdmanager = require( '../pwdmanager.js' );
|
||||
const fs = require( 'fs' );
|
||||
const path = require( 'path' );
|
||||
const pm = require( '../../backend/plugins/manager.js' );
|
||||
const spm = require( '../startPageManager.js' );
|
||||
const startPageManager = new spm();
|
||||
|
||||
const letters = [ ',', '{' ];
|
||||
|
||||
@@ -178,6 +180,9 @@ class POSTHandler {
|
||||
} ).catch( err => {
|
||||
reject( { 'code': 500, 'message': err } );
|
||||
} );
|
||||
} else if ( call === 'savePageSettings' ) {
|
||||
startPageManager.saveStartPagePreferences( data.page, data.preferences );
|
||||
resolve( 'ok' );
|
||||
} else {
|
||||
reject( { 'code': 404, 'error': 'Route not found' } );
|
||||
}
|
||||
|
||||
@@ -18,7 +18,11 @@ class StartPageManager {
|
||||
}
|
||||
|
||||
saveStartPagePreferences( startPageName, preferences ) {
|
||||
fs.writeFileSync( path.join( __dirname + '/../ui/home/templates/' + startPageName + '/startPage.config.html' ), JSON.stringify( preferences ) );
|
||||
let conf = {};
|
||||
for ( let setting in preferences ) {
|
||||
conf[ setting ] = preferences[ setting ][ 'value' ];
|
||||
}
|
||||
fs.writeFileSync( path.join( __dirname + '/../ui/home/templates/' + startPageName + '/startPage.config.json' ), JSON.stringify( conf ) );
|
||||
}
|
||||
|
||||
loadStartPagePreferences( startPageName ) {
|
||||
@@ -43,14 +47,19 @@ class StartPageManager {
|
||||
|
||||
async renderStartPage( startPageName ) {
|
||||
this.setActiveStartPage( startPageName );
|
||||
let self = this;
|
||||
const app = createSSRApp( {
|
||||
data() {
|
||||
return this.loadStartPagePreferences( startPageName );
|
||||
return {
|
||||
'data': self.loadStartPagePreferences( startPageName ),
|
||||
'pageName': self.settings.pageName,
|
||||
};
|
||||
},
|
||||
template: '' + fs.readFileSync( path.join( __dirname + '/../ui/home/templates/' + startPageName + '/index.html' ) )
|
||||
} );
|
||||
|
||||
fs.writeFileSync( path.join( __dirname + '/../ui/home/active/en/index.html' ), await renderToString( app ) );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1 @@
|
||||
{
|
||||
"init":true,
|
||||
"twoFA":"enforce",
|
||||
"setupKey":"hello world",
|
||||
"twoFAMode":"enhanced",
|
||||
"db":"json",
|
||||
"payments":"stripe",
|
||||
"name":"libreevent",
|
||||
"yourDomain":"http://localhost:8080",
|
||||
"mailSender":"libreevent <info@libreevent.janishutz.com>",
|
||||
"maxTickets":10,
|
||||
"currency":"CHF",
|
||||
"gcInterval":300,
|
||||
"ticketTimeout":900,
|
||||
"startPage":"default",
|
||||
"version":"1.0.0"
|
||||
}
|
||||
{"init":true,"twoFA":"enforce","setupKey":"hello world","twoFAMode":"enhanced","db":"json","payments":"stripe","name":"libreevent","yourDomain":"http://localhost:8080","mailSender":"libreevent <info@libreevent.janishutz.com>","maxTickets":10,"currency":"CHF","gcInterval":300,"ticketTimeout":900,"startPage":"default","version":"1.0.0"}
|
||||
25
src/server/ui/home/index.html
Normal file
25
src/server/ui/home/index.html
Normal file
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<!-- <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200"> -->
|
||||
<script defer src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
|
||||
<link rel="stylesheet" href="/supportFiles/style.css">
|
||||
<link rel="stylesheet" href="/startPage/mainStyle">
|
||||
<script defer src="/startPage/helperFunction"></script>
|
||||
<title>libreevent</title>
|
||||
</head>
|
||||
<body>
|
||||
<nav>
|
||||
<a class="home">Home</a> |
|
||||
<a href="/tickets">Tickets</a> |
|
||||
<a href="/cart">Cart</a> |
|
||||
<a href="/account">Account</a> |
|
||||
<button onclick="changeTheme();" id="themeSelector">☽</button>
|
||||
</nav>
|
||||
<img src="/otherAssets/logo.png" alt="libreevent logo" class="logo">
|
||||
<h1>Welcome to libreevent!</h1>
|
||||
<p>No start page has been configured yet! Please configure one either by using the configurator in the settings or by uploading your own HTML page to the correct folder as detailed <a href="https://libreevent.janishutz.com/docs/admin-panel/pages">here</a></p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -20,6 +20,6 @@
|
||||
</nav>
|
||||
<img src="/otherAssets/logo.png" alt="libreevent logo" class="logo">
|
||||
<h1>Welcome to {{ pageName }}!</h1>
|
||||
<p>{{ description }}</p>
|
||||
<p>{{ data.description }}</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +1 @@
|
||||
{
|
||||
"subtitle": "this is a test",
|
||||
"description": "this is a test description",
|
||||
"banner": "homeBanner.jpg"
|
||||
}
|
||||
{"subtitle":"this is a test","description":"this is a test description"}
|
||||
@@ -10,8 +10,8 @@
|
||||
"type": "textarea",
|
||||
"display": "Description",
|
||||
"textarea-settings": {
|
||||
"resize-y": true,
|
||||
"resize-x": false,
|
||||
"cols": 50,
|
||||
"rows": 5,
|
||||
"max-length": 0,
|
||||
"min-length": 100
|
||||
},
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* libreevent - style.css
|
||||
*
|
||||
* Created by Janis Hutz 08/29/2023, Licensed under the GPL V3 License
|
||||
* https://janishutz.com, development@janishutz.com
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
.logo {
|
||||
height: 50vh;
|
||||
}
|
||||
25
src/server/ui/home/templates/default/supportFiles/index.html
Normal file
25
src/server/ui/home/templates/default/supportFiles/index.html
Normal file
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<!-- <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200"> -->
|
||||
<script defer src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
|
||||
<link rel="stylesheet" href="/supportFiles/style.css">
|
||||
<link rel="stylesheet" href="/startPage/mainStyle">
|
||||
<script defer src="/startPage/helperFunction"></script>
|
||||
<title>{{ pageName }} :: Home</title>
|
||||
</head>
|
||||
<body>
|
||||
<nav>
|
||||
<a class="home">Home</a> |
|
||||
<a href="/tickets">Tickets</a> |
|
||||
<a href="/cart">Cart</a> |
|
||||
<a href="/account">Account</a> |
|
||||
<button onclick="changeTheme();" id="themeSelector">☽</button>
|
||||
</nav>
|
||||
<img src="/otherAssets/logo.png" alt="libreevent logo" class="logo">
|
||||
<h1>Welcome to {{ pageName }}!</h1>
|
||||
<p>{{ data.description }}</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1 @@
|
||||
{"subtitle":"this is a test","description":"this is a test description"}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"subtitle": {
|
||||
"id": "subtitle",
|
||||
"type": "text",
|
||||
"display": "Subtitle",
|
||||
"can-be-empty": false
|
||||
},
|
||||
"description": {
|
||||
"id": "description",
|
||||
"type": "textarea",
|
||||
"display": "Description",
|
||||
"textarea-settings": {
|
||||
"cols": 50,
|
||||
"rows": 5,
|
||||
"max-length": 0,
|
||||
"min-length": 100
|
||||
},
|
||||
"can-be-empty": false
|
||||
},
|
||||
"banner": {
|
||||
"id": "banner",
|
||||
"type": "image",
|
||||
"display": "Banner",
|
||||
"image-settings": {
|
||||
"upload-name": "homeBanner",
|
||||
"accept-filetype": "image/jpeg",
|
||||
"height": 200,
|
||||
"width": 350
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,6 @@
|
||||
</nav>
|
||||
<img src="/otherAssets/logo.png" alt="libreevent logo" class="logo">
|
||||
<h1>Welcome to {{ pageName }}!</h1>
|
||||
<p>{{ description }}</p>
|
||||
<p>{{ data.description }}</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1 @@
|
||||
{"subtitle":"this is a test","description":"this is a test description"}
|
||||
31
src/server/ui/home/templates/modern/startPage.json
Normal file
31
src/server/ui/home/templates/modern/startPage.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"subtitle": {
|
||||
"id": "subtitle",
|
||||
"type": "text",
|
||||
"display": "Subtitle",
|
||||
"can-be-empty": false
|
||||
},
|
||||
"description": {
|
||||
"id": "description",
|
||||
"type": "textarea",
|
||||
"display": "Description",
|
||||
"textarea-settings": {
|
||||
"cols": 50,
|
||||
"rows": 5,
|
||||
"max-length": 0,
|
||||
"min-length": 100
|
||||
},
|
||||
"can-be-empty": false
|
||||
},
|
||||
"banner": {
|
||||
"id": "banner",
|
||||
"type": "image",
|
||||
"display": "Banner",
|
||||
"image-settings": {
|
||||
"upload-name": "homeBanner",
|
||||
"accept-filetype": "image/jpeg",
|
||||
"height": 200,
|
||||
"width": 350
|
||||
}
|
||||
}
|
||||
}
|
||||
25
src/server/ui/home/templates/modern/supportFiles/index.html
Normal file
25
src/server/ui/home/templates/modern/supportFiles/index.html
Normal file
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<!-- <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200"> -->
|
||||
<script defer src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
|
||||
<link rel="stylesheet" href="/supportFiles/style.css">
|
||||
<link rel="stylesheet" href="/startPage/mainStyle">
|
||||
<script defer src="/startPage/helperFunction"></script>
|
||||
<title>{{ pageName }} :: Home</title>
|
||||
</head>
|
||||
<body>
|
||||
<nav>
|
||||
<a class="home">Home</a> |
|
||||
<a href="/tickets">Tickets</a> |
|
||||
<a href="/cart">Cart</a> |
|
||||
<a href="/account">Account</a> |
|
||||
<button onclick="changeTheme();" id="themeSelector">☽</button>
|
||||
</nav>
|
||||
<img src="/otherAssets/logo.png" alt="libreevent logo" class="logo">
|
||||
<h1>Welcome to {{ pageName }}!</h1>
|
||||
<p>{{ data.description }}</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1 @@
|
||||
{"subtitle":"this is a test","description":"this is a test description"}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"subtitle": {
|
||||
"id": "subtitle",
|
||||
"type": "text",
|
||||
"display": "Subtitle",
|
||||
"can-be-empty": false
|
||||
},
|
||||
"description": {
|
||||
"id": "description",
|
||||
"type": "textarea",
|
||||
"display": "Description",
|
||||
"textarea-settings": {
|
||||
"cols": 50,
|
||||
"rows": 5,
|
||||
"max-length": 0,
|
||||
"min-length": 100
|
||||
},
|
||||
"can-be-empty": false
|
||||
},
|
||||
"banner": {
|
||||
"id": "banner",
|
||||
"type": "image",
|
||||
"display": "Banner",
|
||||
"image-settings": {
|
||||
"upload-name": "homeBanner",
|
||||
"accept-filetype": "image/jpeg",
|
||||
"height": 200,
|
||||
"width": 350
|
||||
}
|
||||
}
|
||||
}
|
||||
12
src/server/ui/home/templates/modern/supportFiles/style.css
Normal file
12
src/server/ui/home/templates/modern/supportFiles/style.css
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* libreevent - style.css
|
||||
*
|
||||
* Created by Janis Hutz 08/29/2023, Licensed under the GPL V3 License
|
||||
* https://janishutz.com, development@janishutz.com
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
.logo {
|
||||
height: 50vh;
|
||||
}
|
||||
Reference in New Issue
Block a user