Compare commits

..

No commits in common. "ecff52392630fd289cea47a6ea97747624807f41" and "8e5cb9dfcc4d6fc3054fc777dab5329cc2250494" have entirely different histories.

14 changed files with 38 additions and 221 deletions

View File

@ -38,11 +38,6 @@ Article.structure = {
gpgsign: {
type: DataTypes.TEXT,
allowNull: true
},
hidden: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
}
};

View File

@ -66,21 +66,6 @@ class User extends Model {
session.secret = crypto.randomBytes(256).toString('base64');
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 = {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 490 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 638 B

File diff suppressed because one or more lines are too long

View File

@ -1,20 +0,0 @@
(
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');
})
}
)()

View File

@ -39,11 +39,10 @@ a:visited {
.side_menu {
width: 200px;
border-right: 1px solid #c2c4c2;
padding: 0;
font-size: 9pt;
padding: 0
}
.side_menu h1 {
font-size: 1.75em;
font-size: 1.5em;
padding-left: 3px;
}
.side_menu h1 a {
@ -55,13 +54,10 @@ a:visited {
.side_menu ul {
list-style: none;
padding: 0;
font-size: 10pt;
font-size: 11pt;
padding-left: 4px;
line-height: 125%;
}
.side_menu p {
padding-left: 14px;
}
.main_contents {
padding: 16px 12px;
}
@ -92,20 +88,3 @@ hr {
text-decoration:none;
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);
}

View File

@ -1,15 +1,8 @@
.control_panel {
border-collapse: separate;
border-spacing: 5px;
}
.cp_panel_panel {
border: 1px solid #c2c4c2;
border-radius: 2px;
padding: 4px 8px;
padding: 4px;
min-height: 300px;
font-size: 9pt;
max-width: 386px;
box-shadow: 0 2px 1px #20202010;
}
.cp_panel_panel h5 {
font-size: 1.1em;
@ -21,24 +14,9 @@
color: blue;
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 {
filter: opacity(0.7)
}
input[type=submit] {
cursor: pointer;
}

View File

@ -1,7 +1,6 @@
const handler = require('express-async-handler')
const Helpers = require('../helpers');
const db = require('../models');
const express = require('express');
async function login(req, res) {
res.send(await Helpers.ViewLoader.load('admin/login.pug', {
@ -29,22 +28,13 @@ async function apiLogin(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({
order: [['id', 'DESC']]
});
const articles = await db.Article.findAll({where: {hidden: true}});
res.send(await Helpers.ViewLoader.load('admin/panel.pug', {
current_route: req.originalUrl,
gb_records,
access_level: user.accessLevel
gb_records
}));
return;
}
@ -52,11 +42,6 @@ async function panel(req, res) {
async function gb_api(req, res) {
let action = false;
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';
@ -73,10 +58,6 @@ async function gb_api(req, res) {
}
}
async function article_new(req, res) {
res.send(await Helpers.ViewLoader.load('articles/new.pug'))
}
module.exports = (router) => {
// login
@ -84,12 +65,8 @@ module.exports = (router) => {
router.get('/admin/login', handler(login));
router.post('/admin/login', handler(apiLogin));
router.post('/gb_api', handler(gb_api));
// 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));
}

View File

@ -19,13 +19,7 @@ async function handler(req, res) {
{
current_route: '/',
gb_entries,
articles,
og: {
title: 'blek! Site',
type: 'website',
image: req.protocol + '://' + req.get('host') + '/content/transylveonia.jpg',
url: req.protocol + '://' + req.get('host') + req.originalUrl
}
articles
}
)
);

View File

@ -13,74 +13,34 @@ block content
| Warning: Your access level is unkown, so everything is displayed and some funtions may not work.
hr
- access_level = 4
table(class='control_panel')
table
tr
td(class='cp_panel_panel')
h5 Guestbook panel
hr
p
if (access_level >= 3)
a(href='/admin/panel/guestbook.editor') Edit data
br
a(href='/admin/panel/guestbook.csv') Download data (.CSV)
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
div(style='max-height:160px;overflow-y:scroll')
table(width='100%')
if (!gb_records || gb_records.length == 0)
p Nothing to show.
table
each record of gb_records
tr(class='cp_gb_entry' + (record.hidden ? ' cp_gb_entry_hidden' : ''))
tr(class='' + (record.hidden ? 'cp_gb_entry_hidden' : ''))
form(action='/admin/panel/gb_api' method='POST')
input(type='hidden' name='id' value=record.id)
td(class='cp_gb_entry_name')
a(href='/guestbook#gb_entry_' + record.id)= record.id
| :
b= record.name + ' says:'
td
if (record.text.length > 30)
| #{record.text.substr(0, 340)}...
a(href='/guestbook#gb_entry_' + record.id)= record.id
| : #{record.name}
td
if (record.text.length > 40)
| #{record.text.substr(0, 40)}...
else
| #{record.text}
if (access_level >= 3)
td(class='cp_gb_entry_hide')
td
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.

View File

@ -20,16 +20,16 @@ block content
tr
td Your name:
td
input(type='text' name='name' value='' + (name ? name : '') style='width:50%')
input(type='text' name='name' value='' + name style='width:50%')
span(style='font-size:9pt;color:red;user-select:none' title='required') *
tr
td Your email:
td
input(type='email' name='email' value='' + (email ? email : ''))
input(type='email' name='email' value='' + email)
tr
td Hide your email?
td
input(type='checkbox' name='hidemail' checked=(hidemail ? true : 'off'))
input(type='checkbox' name='hidemail' checked=hidemail)
// span(style='font-size:9pt;color:red;user-select:none' title='required') *
p(style='margin:6px 0')
| Your message (512 chars max):

View File

@ -13,24 +13,12 @@ block root
}
doctype html
html(style='overflow-y:auto' lang='en_US')
html(style='overflow-y:auto')
head
title blek! Site #{title ? "- " + title : ""}
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
body(style='overflow-y:auto')
table(width='100%' height='100%' class='body_table')
@ -49,25 +37,8 @@ html(style='overflow-y:auto' lang='en_US')
| > #{name}
else
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')
block content
block foot
//- 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