mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 13:24:24 +00:00
add version + start page builder
This commit is contained in:
46
src/server/admin/startPageManager.js
Normal file
46
src/server/admin/startPageManager.js
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* libreevent - startPageManager.js
|
||||||
|
*
|
||||||
|
* Created by Janis Hutz 09/04/2023, Licensed under the GPL V3 License
|
||||||
|
* https://janishutz.com, development@janishutz.com
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
let createSSRApp = require( 'vue' ).createSSRApp;
|
||||||
|
let renderToString = require( 'vue/server-renderer' ).renderToString;
|
||||||
|
const fs = require( 'fs' );
|
||||||
|
const path = require( 'path' );
|
||||||
|
|
||||||
|
class StartPageManager {
|
||||||
|
constructor ( settings ) {
|
||||||
|
this.settings = settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
saveStartPagePreferences( startPageName, preferences ) {
|
||||||
|
fs.writeFileSync( path.join( __dirname + '/../ui/home/templates/' + startPageName + '/startPage.config.html' ), JSON.stringify( preferences ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
loadStartPagePreferences( startPageName ) {
|
||||||
|
return JSON.parse( fs.readFileSync( path.join( __dirname + '/../ui/home/templates/' + startPageName + '/startPage.config.html' ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
setActiveStartPage( startPageName ) {
|
||||||
|
this.settings[ 'startPage' ] = startPageName;
|
||||||
|
fs.writeFileSync( path.join( __dirname + '/../config/settings.config.json' ), JSON.stringify( this.settings ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
async renderStartPage( startPageName ) {
|
||||||
|
this.setActiveStartPage( startPageName );
|
||||||
|
const app = createSSRApp( {
|
||||||
|
data() {
|
||||||
|
return this.loadStartPagePreferences( startPageName );
|
||||||
|
},
|
||||||
|
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 ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = StartPageManager;
|
||||||
@@ -12,5 +12,6 @@
|
|||||||
"currency":"CHF",
|
"currency":"CHF",
|
||||||
"gcInterval":300,
|
"gcInterval":300,
|
||||||
"ticketTimeout":900,
|
"ticketTimeout":900,
|
||||||
"startPage":"default"
|
"startPage":"default",
|
||||||
|
"version":"1.0.0"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user