mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-12 23:46:22 +00:00
WIP admin, probably not smart to clone repo now
This commit is contained in:
parent
e5af2bd04c
commit
91a7ec7286
@ -1,4 +1,5 @@
|
||||
const config = require('./config.js')
|
||||
const api = require('./routes/api.js')
|
||||
const routes = require('./routes/routes.js')
|
||||
const express = require('express')
|
||||
const db = require('knex')(config.database)
|
||||
@ -18,7 +19,8 @@ if( prefix !== '' )
|
||||
|
||||
safe.use('/' + prefix, express.static('./uploads'))
|
||||
safe.use('/', express.static('./public'))
|
||||
safe.use('/api' , routes)
|
||||
safe.use('/', routes)
|
||||
safe.use('/api', api)
|
||||
|
||||
safe.use(function (req, res, next) {
|
||||
res.status(404).sendFile('404.html', {
|
||||
|
56
pages/admin/index.html
Normal file
56
pages/admin/index.html
Normal file
@ -0,0 +1,56 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>loli-safe - A self hosted upload service</title>
|
||||
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.3.0/css/bulma.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="/css/style.css">
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.3.0/min/dropzone.min.js"></script>
|
||||
<script type="text/javascript" src="/js/upload.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
<h1 class="title">Dashboard</h1>
|
||||
<h2 class="subtitle">A simple <strong>dashboard</strong>, to sort your uploaded stuff</h2>
|
||||
<hr>
|
||||
<div class="columns">
|
||||
<div class="column is-3">
|
||||
<aside class="menu">
|
||||
<p class="menu-label">
|
||||
General
|
||||
</p>
|
||||
<ul class="menu-list">
|
||||
<li><a>Frontpage</a></li>
|
||||
<li><a>Uploads</a></li>
|
||||
</ul>
|
||||
<p class="menu-label">
|
||||
Galleries
|
||||
</p>
|
||||
<ul class="menu-list">
|
||||
<li><a>Manage your galleries</a></li>
|
||||
<li>
|
||||
<a class="is-active">Galleries</a>
|
||||
<ul>
|
||||
<li><a>Gallery 1</a></li>
|
||||
<li><a>Gallery 2</a></li>
|
||||
<li><a>Gallery 3</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="menu-label">
|
||||
Administration
|
||||
</p>
|
||||
<ul class="menu-list">
|
||||
<li><a>Change your token</a></li>
|
||||
<li><a>Some other fancy stuff</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
</div>
|
||||
<div class="column has-text-centered">
|
||||
<img src="/images/logo.png">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
63
pages/home.html
Normal file
63
pages/home.html
Normal file
@ -0,0 +1,63 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>loli-safe - A self hosted upload service</title>
|
||||
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.3.0/css/bulma.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="/css/style.css">
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.3.0/min/dropzone.min.js"></script>
|
||||
<script type="text/javascript" src="/js/upload.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<section class="hero is-fullheight has-text-centered">
|
||||
<div class="hero-body">
|
||||
<div class="container">
|
||||
<p id="b">
|
||||
<img class='logo' src="/images/logo.png">
|
||||
</p>
|
||||
<h1 id="bulma" class="title">loli-safe</h1>
|
||||
<h2 id="modern-framework" class="subtitle">A <strong>modern</strong> self-hosted file upload service</h2>
|
||||
|
||||
<div class="columns">
|
||||
<div class="column"></div>
|
||||
<div class="column" id='uploadContainer'>
|
||||
|
||||
<p id='tokenContainer' class="control has-addons has-addons-centered">
|
||||
<input id='token' class="input is-danger" type="text" placeholder="Your upload token">
|
||||
<a id='tokenSubmit' class="button is-danger">Check</a>
|
||||
</p>
|
||||
|
||||
<a id='btnGithub' class="button is-danger is-outlined" href='https://github.com/kanadeko/loli-safe' target='_blank'>View on Github</a>
|
||||
|
||||
</div>
|
||||
<div class="column"></div>
|
||||
</div>
|
||||
|
||||
<div class="columns">
|
||||
<div class="column"></div>
|
||||
<div class="column"><a href="/dashboard" class="is-danger">Dashboard</a></div>
|
||||
<div class="column"></div>
|
||||
</div>
|
||||
|
||||
<div id="uploads">
|
||||
<div id="template" class="columns">
|
||||
<div class="column">
|
||||
<p data-dz-size></p>
|
||||
</div>
|
||||
<div class="column">
|
||||
<p data-dz-name></p>
|
||||
</div>
|
||||
<div class="column">
|
||||
<progress class="progress is-danger" value="100" max="100" data-dz-uploadprogress></progress>
|
||||
<p data-dz-errormessage></p>
|
||||
<p class="link"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,61 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>loli-safe - A self hosted upload service</title>
|
||||
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.3.0/css/bulma.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="/css/style.css">
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.3.0/min/dropzone.min.js"></script>
|
||||
<script type="text/javascript" src="/js/upload.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<section class="hero is-fullheight has-text-centered">
|
||||
<div class="hero-body">
|
||||
<div class="container">
|
||||
<p id="b">
|
||||
<img class='logo' src="/images/logo.png">
|
||||
</p>
|
||||
<h1 id="bulma" class="title">
|
||||
loli-safe
|
||||
</h1>
|
||||
<h2 id="modern-framework" class="subtitle">
|
||||
A <strong>modern</strong> self-hosted file upload service
|
||||
</h2>
|
||||
|
||||
<div class="columns">
|
||||
<div class="column"></div>
|
||||
<div class="column" id='uploadContainer'>
|
||||
|
||||
<p id='tokenContainer' class="control has-addons has-addons-centered">
|
||||
<input id='token' class="input is-danger" type="text" placeholder="Your upload token">
|
||||
<a id='tokenSubmit' class="button is-danger">Check</a>
|
||||
</p>
|
||||
|
||||
<a id='btnGithub' class="button is-danger is-outlined" href='https://github.com/kanadeko/loli-safe' target='_blank'>View on Github</a>
|
||||
|
||||
</div>
|
||||
<div class="column"></div>
|
||||
</div>
|
||||
|
||||
<div id="uploads">
|
||||
<div id="template" class="columns">
|
||||
<div class="column">
|
||||
<p data-dz-size></p>
|
||||
</div>
|
||||
<div class="column">
|
||||
<p data-dz-name></p>
|
||||
</div>
|
||||
<div class="column">
|
||||
<progress class="progress is-danger" value="100" max="100" data-dz-uploadprogress></progress>
|
||||
<p data-dz-errormessage></p>
|
||||
<p class="link"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</body>
|
||||
</html>
|
21
routes/api.js
Normal file
21
routes/api.js
Normal file
@ -0,0 +1,21 @@
|
||||
const config = require('../config.js')
|
||||
const routes = require('express').Router()
|
||||
const uploadController = require('../controllers/uploadController')
|
||||
const galleryController = require('../controllers/galleryController')
|
||||
|
||||
routes.get ('/info', (req, res, next) => {
|
||||
|
||||
if(config.TOKEN !== '')
|
||||
if(req.headers.auth !== config.TOKEN)
|
||||
return res.status(401).send('not-authorized')
|
||||
|
||||
return res.json({
|
||||
maxFileSize: config.uploads.maxsize.slice(0, -2)
|
||||
})
|
||||
})
|
||||
|
||||
routes.post ('/upload', (req, res, next) => uploadController.upload(req, res, next))
|
||||
routes.get ('/gallery', (req, res, next) => galleryController.list(req, res, next))
|
||||
routes.get ('/gallery/test', (req, res, next) => galleryController.test(req, res, next))
|
||||
|
||||
module.exports = routes
|
@ -1,21 +1,89 @@
|
||||
const config = require('../config.js')
|
||||
const routes = require('express').Router()
|
||||
const uploadController = require('../controllers/uploadController')
|
||||
const galleryController = require('../controllers/galleryController')
|
||||
const path = require('path')
|
||||
|
||||
routes.get ('/info', (req, res, next) => {
|
||||
routes.get('/', (req, res) => {
|
||||
|
||||
let options = {
|
||||
root: 'pages/',
|
||||
dotfiles: 'deny',
|
||||
headers: {
|
||||
'x-timestamp': Date.now(),
|
||||
'x-sent': true
|
||||
}
|
||||
}
|
||||
|
||||
res.sendFile('home.html', options, function (err) {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
res.status(err.status).end()
|
||||
} else {
|
||||
console.log('Sent: home.html')
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
routes.get('/admin', function (req, res, next) {
|
||||
|
||||
let options = {
|
||||
root: 'pages/admin/',
|
||||
dotfiles: 'deny',
|
||||
headers: {
|
||||
'x-timestamp': Date.now(),
|
||||
'x-sent': true
|
||||
}
|
||||
}
|
||||
|
||||
res.sendFile('index.html', options, function (err) {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
res.status(err.status).end()
|
||||
} else {
|
||||
console.log('Sent: index.html')
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
routes.get('/admin/:name', function (req, res, next) {
|
||||
|
||||
let options = {
|
||||
root: 'pages/admin/',
|
||||
dotfiles: 'deny',
|
||||
headers: {
|
||||
'x-timestamp': Date.now(),
|
||||
'x-sent': true
|
||||
}
|
||||
}
|
||||
|
||||
let fileName = req.params.name
|
||||
|
||||
res.sendFile(fileName, options, function (err) {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
res.status(err.status).end()
|
||||
} else {
|
||||
console.log('Sent:', fileName)
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
/*
|
||||
routes.get('/', (req, res) => {
|
||||
res.sendFile('pages/home.html')
|
||||
})
|
||||
|
||||
routes.get('/dashboard', (req, res, next) => {
|
||||
|
||||
if(config.TOKEN !== '')
|
||||
if(req.headers.auth !== config.TOKEN)
|
||||
return res.status(401).send('not-authorized')
|
||||
|
||||
return res.json({
|
||||
maxFileSize: config.uploads.maxsize.slice(0, -2)
|
||||
})
|
||||
})
|
||||
|
||||
return res.sendFile('pages/home.html')
|
||||
|
||||
routes.post ('/upload', (req, res, next) => uploadController.upload(req, res, next))
|
||||
routes.get ('/gallery', (req, res, next) => galleryController.list(req, res, next))
|
||||
routes.get ('/gallery/test', (req, res, next) => galleryController.test(req, res, next))
|
||||
})
|
||||
*/
|
||||
|
||||
module.exports = routes
|
Loading…
Reference in New Issue
Block a user