Compare commits
10 Commits
8e5cb9dfcc
...
ecff523926
Author | SHA1 | Date |
---|---|---|
b1ek | ecff523926 | |
b1ek | 02979e161a | |
b1ek | 2871224a4e | |
b1ek | 492dd382ce | |
b1ek | 8e3812c9e4 | |
b1ek | 12f4abc6ec | |
b1ek | c90a144d1a | |
b1ek | 7b3c7f5678 | |
b1ek | aa1f6e072b | |
b1ek | 3a1b0d9dbc |
|
@ -38,6 +38,11 @@ Article.structure = {
|
||||||
gpgsign: {
|
gpgsign: {
|
||||||
type: DataTypes.TEXT,
|
type: DataTypes.TEXT,
|
||||||
allowNull: true
|
allowNull: true
|
||||||
|
},
|
||||||
|
hidden: {
|
||||||
|
type: DataTypes.BOOLEAN,
|
||||||
|
allowNull: false,
|
||||||
|
defaultValue: false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,21 @@ class User extends Model {
|
||||||
session.secret = crypto.randomBytes(256).toString('base64');
|
session.secret = crypto.randomBytes(256).toString('base64');
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a user object from express session
|
||||||
|
* @param {*} session
|
||||||
|
* @returns User
|
||||||
|
*/
|
||||||
|
static async bySession(session) {
|
||||||
|
if (session.user == undefined) return;
|
||||||
|
if (session.user.user_id == undefined) return;
|
||||||
|
const user = await User.findOne({where: {id: session.user.user_id}});
|
||||||
|
if (!user) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return user;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const structure = {
|
const structure = {
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 490 B |
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 638 B |
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,20 @@
|
||||||
|
(
|
||||||
|
function() {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
$('span.flag_btn').css('visibility', 'visible');
|
||||||
|
|
||||||
|
const au_btn = $('#aussy_language span');
|
||||||
|
const body = $('body')
|
||||||
|
|
||||||
|
let isAustralian = false;
|
||||||
|
au_btn.on('click', () => {
|
||||||
|
au_btn.attr('title', isAustralian ? 'Australian' : 'English');
|
||||||
|
au_btn.css('background', isAustralian ? 'url(/content/au_flag.jpg)' : 'url(/content/uk_flag.jpg)')
|
||||||
|
isAustralian = !isAustralian;
|
||||||
|
|
||||||
|
body.css('transform', isAustralian ? 'rotate(180deg)' : 'none');
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
)()
|
|
@ -39,10 +39,11 @@ a:visited {
|
||||||
.side_menu {
|
.side_menu {
|
||||||
width: 200px;
|
width: 200px;
|
||||||
border-right: 1px solid #c2c4c2;
|
border-right: 1px solid #c2c4c2;
|
||||||
padding: 0
|
padding: 0;
|
||||||
|
font-size: 9pt;
|
||||||
}
|
}
|
||||||
.side_menu h1 {
|
.side_menu h1 {
|
||||||
font-size: 1.5em;
|
font-size: 1.75em;
|
||||||
padding-left: 3px;
|
padding-left: 3px;
|
||||||
}
|
}
|
||||||
.side_menu h1 a {
|
.side_menu h1 a {
|
||||||
|
@ -54,10 +55,13 @@ a:visited {
|
||||||
.side_menu ul {
|
.side_menu ul {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
font-size: 11pt;
|
font-size: 10pt;
|
||||||
padding-left: 4px;
|
padding-left: 4px;
|
||||||
line-height: 125%;
|
line-height: 125%;
|
||||||
}
|
}
|
||||||
|
.side_menu p {
|
||||||
|
padding-left: 14px;
|
||||||
|
}
|
||||||
.main_contents {
|
.main_contents {
|
||||||
padding: 16px 12px;
|
padding: 16px 12px;
|
||||||
}
|
}
|
||||||
|
@ -88,3 +92,20 @@ hr {
|
||||||
text-decoration:none;
|
text-decoration:none;
|
||||||
text-shadow:0px 1px 0px #ffffff;
|
text-shadow:0px 1px 0px #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
span.flag_btn {
|
||||||
|
width: 30px;
|
||||||
|
height: 20px;
|
||||||
|
border: 1px solid #606060;
|
||||||
|
border-radius: 2px;
|
||||||
|
display: inline-block;
|
||||||
|
box-shadow:
|
||||||
|
inset 0 -2px 3px #a0a0a080,
|
||||||
|
inset 0 1px 1px #f1f4f280;
|
||||||
|
margin-left: 10px;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
span.au_flag {
|
||||||
|
background: url(/content/au_flag.jpg);
|
||||||
|
}
|
|
@ -1,8 +1,15 @@
|
||||||
|
.control_panel {
|
||||||
|
border-collapse: separate;
|
||||||
|
border-spacing: 5px;
|
||||||
|
}
|
||||||
.cp_panel_panel {
|
.cp_panel_panel {
|
||||||
border: 1px solid #c2c4c2;
|
border: 1px solid #c2c4c2;
|
||||||
padding: 4px;
|
border-radius: 2px;
|
||||||
|
padding: 4px 8px;
|
||||||
min-height: 300px;
|
min-height: 300px;
|
||||||
font-size: 9pt;
|
font-size: 9pt;
|
||||||
|
max-width: 386px;
|
||||||
|
box-shadow: 0 2px 1px #20202010;
|
||||||
}
|
}
|
||||||
.cp_panel_panel h5 {
|
.cp_panel_panel h5 {
|
||||||
font-size: 1.1em;
|
font-size: 1.1em;
|
||||||
|
@ -14,9 +21,24 @@
|
||||||
color: blue;
|
color: blue;
|
||||||
font-size: 100%;
|
font-size: 100%;
|
||||||
}
|
}
|
||||||
|
.cp_panel_panel p {
|
||||||
|
margin: 2px 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.cp_gb_entry .cp_gb_entry_name {
|
||||||
|
text-align: left;
|
||||||
|
white-space: nowrap;
|
||||||
|
width: 1px;
|
||||||
|
}
|
||||||
|
.cp_gb_entry .cp_gb_entry_hide {
|
||||||
|
text-align: right;
|
||||||
|
white-space: nowrap;
|
||||||
|
width: 1px;
|
||||||
|
}
|
||||||
.cp_gb_entry_hidden {
|
.cp_gb_entry_hidden {
|
||||||
filter: opacity(0.7)
|
filter: opacity(0.7)
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type=submit] {
|
input[type=submit] {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
const handler = require('express-async-handler')
|
const handler = require('express-async-handler')
|
||||||
const Helpers = require('../helpers');
|
const Helpers = require('../helpers');
|
||||||
const db = require('../models');
|
const db = require('../models');
|
||||||
|
const express = require('express');
|
||||||
|
|
||||||
async function login(req, res) {
|
async function login(req, res) {
|
||||||
res.send(await Helpers.ViewLoader.load('admin/login.pug', {
|
res.send(await Helpers.ViewLoader.load('admin/login.pug', {
|
||||||
|
@ -28,13 +29,22 @@ async function apiLogin(req, res) {
|
||||||
|
|
||||||
async function panel(req, res) {
|
async function panel(req, res) {
|
||||||
|
|
||||||
|
const user = await db.User.bySession(req.session);
|
||||||
|
if (!user) {
|
||||||
|
res.status(401).send('Forbidden');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const gb_records = await db.Guestbook.findAll({
|
const gb_records = await db.Guestbook.findAll({
|
||||||
order: [['id', 'DESC']]
|
order: [['id', 'DESC']]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const articles = await db.Article.findAll({where: {hidden: true}});
|
||||||
|
|
||||||
res.send(await Helpers.ViewLoader.load('admin/panel.pug', {
|
res.send(await Helpers.ViewLoader.load('admin/panel.pug', {
|
||||||
current_route: req.originalUrl,
|
current_route: req.originalUrl,
|
||||||
gb_records
|
gb_records,
|
||||||
|
access_level: user.accessLevel
|
||||||
}));
|
}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -42,6 +52,11 @@ async function panel(req, res) {
|
||||||
async function gb_api(req, res) {
|
async function gb_api(req, res) {
|
||||||
let action = false;
|
let action = false;
|
||||||
const id = req.body.id;
|
const id = req.body.id;
|
||||||
|
const user = await db.User.bySession(req.session);
|
||||||
|
if (!user) {
|
||||||
|
res.status(401).send('Forbidden');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (req.body.hide) action = 'hide';
|
if (req.body.hide) action = 'hide';
|
||||||
|
|
||||||
|
@ -58,6 +73,10 @@ async function gb_api(req, res) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function article_new(req, res) {
|
||||||
|
res.send(await Helpers.ViewLoader.load('articles/new.pug'))
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = (router) => {
|
module.exports = (router) => {
|
||||||
|
|
||||||
// login
|
// login
|
||||||
|
@ -65,8 +84,12 @@ module.exports = (router) => {
|
||||||
router.get('/admin/login', handler(login));
|
router.get('/admin/login', handler(login));
|
||||||
router.post('/admin/login', handler(apiLogin));
|
router.post('/admin/login', handler(apiLogin));
|
||||||
|
|
||||||
|
router.post('/gb_api', handler(gb_api));
|
||||||
|
|
||||||
|
|
||||||
// panel
|
// panel
|
||||||
router.get('/admin/panel', handler(panel));
|
router.get('/admin/panel', handler(panel));
|
||||||
router.post('/admin/panel/gb_api', handler(gb_api));
|
|
||||||
|
|
||||||
|
// article
|
||||||
|
router.get('/admin/article/new', handler(article_new));
|
||||||
}
|
}
|
|
@ -19,7 +19,13 @@ async function handler(req, res) {
|
||||||
{
|
{
|
||||||
current_route: '/',
|
current_route: '/',
|
||||||
gb_entries,
|
gb_entries,
|
||||||
articles
|
articles,
|
||||||
|
og: {
|
||||||
|
title: 'blek! Site',
|
||||||
|
type: 'website',
|
||||||
|
image: req.protocol + '://' + req.get('host') + '/content/transylveonia.jpg',
|
||||||
|
url: req.protocol + '://' + req.get('host') + req.originalUrl
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -13,34 +13,74 @@ block content
|
||||||
| Warning: Your access level is unkown, so everything is displayed and some funtions may not work.
|
| Warning: Your access level is unkown, so everything is displayed and some funtions may not work.
|
||||||
hr
|
hr
|
||||||
- access_level = 4
|
- access_level = 4
|
||||||
table
|
table(class='control_panel')
|
||||||
tr
|
tr
|
||||||
td(class='cp_panel_panel')
|
td(class='cp_panel_panel')
|
||||||
h5 Guestbook panel
|
h5 Guestbook panel
|
||||||
hr
|
hr
|
||||||
p
|
p
|
||||||
a(href='/admin/panel/guestbook.editor') Edit data
|
if (access_level >= 3)
|
||||||
br
|
a(href='/admin/panel/guestbook.editor') Edit data
|
||||||
a(href='/admin/panel/guestbook.csv') Download data (.CSV)
|
br
|
||||||
br
|
a(href='/admin/panel/guestbook.csv') Download data (.CSV)
|
||||||
a(href='/admin/panel/guestbook.csv') Download data (SQL)
|
br
|
||||||
|
a(href='/admin/panel/guestbook.csv') Download data (SQL)
|
||||||
|
if (access_level >= 4)
|
||||||
|
div(style='padding-left:4px')
|
||||||
|
form(action='/admin/panel/gb_api')
|
||||||
|
h5 Import from file
|
||||||
|
p
|
||||||
|
b WARNING:
|
||||||
|
| All the records will be removed and replaced with your values!
|
||||||
|
label(for='filetype') File type:
|
||||||
|
select(name='filetype')
|
||||||
|
option(value='csv') .CSV
|
||||||
|
option(value='sql') .TSV
|
||||||
|
br
|
||||||
|
input(type='file' name='file')
|
||||||
|
br
|
||||||
|
input(type='submit' name='import' value='Send')
|
||||||
hr
|
hr
|
||||||
table
|
div(style='max-height:160px;overflow-y:scroll')
|
||||||
each record of gb_records
|
table(width='100%')
|
||||||
tr(class='' + (record.hidden ? 'cp_gb_entry_hidden' : ''))
|
if (!gb_records || gb_records.length == 0)
|
||||||
form(action='/admin/panel/gb_api' method='POST')
|
p Nothing to show.
|
||||||
input(type='hidden' name='id' value=record.id)
|
each record of gb_records
|
||||||
td
|
tr(class='cp_gb_entry' + (record.hidden ? ' cp_gb_entry_hidden' : ''))
|
||||||
a(href='/guestbook#gb_entry_' + record.id)= record.id
|
form(action='/admin/panel/gb_api' method='POST')
|
||||||
| : #{record.name}
|
input(type='hidden' name='id' value=record.id)
|
||||||
td
|
td(class='cp_gb_entry_name')
|
||||||
if (record.text.length > 40)
|
a(href='/guestbook#gb_entry_' + record.id)= record.id
|
||||||
| #{record.text.substr(0, 40)}...
|
| :
|
||||||
else
|
b= record.name + ' says:'
|
||||||
| #{record.text}
|
td
|
||||||
td
|
if (record.text.length > 30)
|
||||||
if (!record.hidden)
|
| #{record.text.substr(0, 340)}...
|
||||||
input(type='submit' name='hide' value='Hide')
|
else
|
||||||
else
|
| #{record.text}
|
||||||
input(type='submit' name='hide' value='Unhide')
|
if (access_level >= 3)
|
||||||
|
td(class='cp_gb_entry_hide')
|
||||||
|
if (!record.hidden)
|
||||||
|
input(type='submit' name='hide' value='Hide')
|
||||||
|
else
|
||||||
|
input(type='submit' name='hide' value='Unhide')
|
||||||
|
td(class='cp_panel_panel')
|
||||||
|
h5 Articles
|
||||||
|
hr
|
||||||
|
p
|
||||||
|
a(href='/admin/article/new') Create new article
|
||||||
|
if (access_level >= 4)
|
||||||
|
br
|
||||||
|
a(href='/admin/articles.csv') Download data (.CSV)
|
||||||
|
br
|
||||||
|
a(href='/admin/articles.sql') Download data (SQL)
|
||||||
|
div(style='padding-left:4px')
|
||||||
|
form(action='/admin/panel/article_api' method='POST')
|
||||||
|
h5 Import from file
|
||||||
|
p
|
||||||
|
b WARNING:
|
||||||
|
| All the records will be removed and replaced with your values!
|
||||||
|
hr
|
||||||
|
if (!articles)
|
||||||
|
p Nothing to show.
|
||||||
|
|
|
@ -20,16 +20,16 @@ block content
|
||||||
tr
|
tr
|
||||||
td Your name:
|
td Your name:
|
||||||
td
|
td
|
||||||
input(type='text' name='name' value='' + name style='width:50%')
|
input(type='text' name='name' value='' + (name ? name : '') style='width:50%')
|
||||||
span(style='font-size:9pt;color:red;user-select:none' title='required') *
|
span(style='font-size:9pt;color:red;user-select:none' title='required') *
|
||||||
tr
|
tr
|
||||||
td Your email:
|
td Your email:
|
||||||
td
|
td
|
||||||
input(type='email' name='email' value='' + email)
|
input(type='email' name='email' value='' + (email ? email : ''))
|
||||||
tr
|
tr
|
||||||
td Hide your email?
|
td Hide your email?
|
||||||
td
|
td
|
||||||
input(type='checkbox' name='hidemail' checked=hidemail)
|
input(type='checkbox' name='hidemail' checked=(hidemail ? true : 'off'))
|
||||||
// span(style='font-size:9pt;color:red;user-select:none' title='required') *
|
// span(style='font-size:9pt;color:red;user-select:none' title='required') *
|
||||||
p(style='margin:6px 0')
|
p(style='margin:6px 0')
|
||||||
| Your message (512 chars max):
|
| Your message (512 chars max):
|
||||||
|
|
|
@ -13,12 +13,24 @@ block root
|
||||||
}
|
}
|
||||||
|
|
||||||
doctype html
|
doctype html
|
||||||
html(style='overflow-y:auto')
|
html(style='overflow-y:auto' lang='en_US')
|
||||||
head
|
head
|
||||||
title blek! Site #{title ? "- " + title : ""}
|
title blek! Site #{title ? "- " + title : ""}
|
||||||
|
|
||||||
link(rel='stylesheet' href='/static/main.css')
|
link(rel='stylesheet' href='/static/main.css')
|
||||||
|
|
||||||
|
//- basic SEO tags
|
||||||
|
if (typeof description == 'string')
|
||||||
|
meta(name='description' content=description)
|
||||||
|
|
||||||
|
//- Open Graph tags
|
||||||
|
if (typeof og == 'object')
|
||||||
|
each content, tag in og
|
||||||
|
meta(property='og:' + tag content=content)
|
||||||
|
|
||||||
|
//- UX
|
||||||
|
meta(name='viewport' content='width=device-width, initial-scale=1')
|
||||||
|
|
||||||
block head
|
block head
|
||||||
body(style='overflow-y:auto')
|
body(style='overflow-y:auto')
|
||||||
table(width='100%' height='100%' class='body_table')
|
table(width='100%' height='100%' class='body_table')
|
||||||
|
@ -37,8 +49,25 @@ html(style='overflow-y:auto')
|
||||||
| > #{name}
|
| > #{name}
|
||||||
else
|
else
|
||||||
a(href=route) #{name}
|
a(href=route) #{name}
|
||||||
|
|
||||||
|
hr
|
||||||
|
p This site is also available in:
|
||||||
|
p
|
||||||
|
a(href='#' id='aussy_language')
|
||||||
|
span(class='flag_btn au_flag' title='Australian')
|
||||||
td(class='main_contents')
|
td(class='main_contents')
|
||||||
block content
|
block content
|
||||||
block foot
|
block foot
|
||||||
block scripts
|
|
||||||
|
|
||||||
|
//- js dependencies
|
||||||
|
script(src='/static/js/jquery.js')
|
||||||
|
|
||||||
|
//- global js
|
||||||
|
script(src='/static/js/main.js')
|
||||||
|
script(type='text/javascript').
|
||||||
|
setTimeout(function() {
|
||||||
|
alert('Congratulations! You have spent 10 years on this page. Go fuck yourself.\n\nUwU');
|
||||||
|
}, 1000 * 60 * 60 * 24 * 365 * 10);
|
||||||
|
|
||||||
|
//- page js
|
||||||
|
block scripts
|
Loading…
Reference in New Issue