mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-13 16:06:21 +00:00
Added support for custom html files
There's a new folder that gets created upon running lolisafe for the first time. On said folder any html file with the same name as the default ones will be loaded instead, letting you place custom frontend files without messing with git.
This commit is contained in:
parent
8cddd06d7a
commit
18c66d27fb
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,8 +1,10 @@
|
||||
.DS_Store
|
||||
!.gitkeep
|
||||
node_modules/
|
||||
uploads/
|
||||
logs/
|
||||
database/db
|
||||
config.js
|
||||
start.json
|
||||
npm-debug.log
|
||||
npm-debug.log
|
||||
pages/custom/**
|
@ -31,6 +31,9 @@ module.exports = {
|
||||
// Port on which to run the server
|
||||
port: 9999,
|
||||
|
||||
// Pages to process for the frontend
|
||||
pages: ['home', 'auth', 'dashboard', 'faq'],
|
||||
|
||||
// Uploads config
|
||||
uploads: {
|
||||
|
||||
|
22
lolisafe.js
22
lolisafe.js
@ -9,6 +9,7 @@ const safe = express()
|
||||
|
||||
require('./database/db.js')(db)
|
||||
|
||||
fs.existsSync('./pages/custom' ) || fs.mkdirSync('./pages/custom')
|
||||
fs.existsSync('./' + config.logsFolder) || fs.mkdirSync('./' + config.logsFolder)
|
||||
fs.existsSync('./' + config.uploads.folder) || fs.mkdirSync('./' + config.uploads.folder)
|
||||
fs.existsSync('./' + config.uploads.folder + '/thumbs') || fs.mkdirSync('./' + config.uploads.folder + '/thumbs')
|
||||
@ -26,11 +27,22 @@ safe.use('/', express.static('./uploads'))
|
||||
safe.use('/', express.static('./public'))
|
||||
safe.use('/api', api)
|
||||
|
||||
safe.get('/', (req, res, next) => res.sendFile('home.html', { root: './pages/' }))
|
||||
safe.get('/faq', (req, res, next) => res.sendFile('faq.html', { root: './pages/' }))
|
||||
safe.get('/auth', (req, res, next) => res.sendFile('auth.html', { root: './pages/' }))
|
||||
safe.get('/dashboard', (req, res, next) => res.sendFile('dashboard.html', { root: './pages/' }))
|
||||
for(let page of config.pages){
|
||||
let root = './pages/'
|
||||
if(fs.existsSync(`./pages/custom/${page}.html`))
|
||||
root = './pages/custom/'
|
||||
|
||||
if(page === 'home') safe.get('/', (req, res, next) => res.sendFile(`${page}.html`, { root: root }))
|
||||
else safe.get(`/${page}`, (req, res, next) => res.sendFile(`${page}.html`, { root: root }))
|
||||
}
|
||||
|
||||
safe.use((req, res, next) => res.status(404).sendFile('404.html', { root: './pages/error/' }))
|
||||
safe.use((req, res, next) => res.status(500).sendFile('500.html', { root: './pages/error/' }))
|
||||
|
||||
safe.listen(config.port, () => console.log(`loli-safe started on port ${config.port}`))
|
||||
safe.listen(config.port, () => console.log(`loli-safe started on port ${config.port}`))
|
||||
|
||||
safe.prepareFrontendRoutes = function(){
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user