hardcode articles

This commit is contained in:
b1ek 2023-08-17 21:03:26 +10:00 committed by blek
parent 45bce661dc
commit c7f4cc1562
Signed by: blek
GPG Key ID: 14546221E3595D0C
2 changed files with 10 additions and 62 deletions

View File

@ -3,57 +3,19 @@ const Helpers = require('../helpers');
const db = require('../models'); const db = require('../models');
const Sequelize = require('../models'); const Sequelize = require('../models');
async function articles(req, res) { function articles(req, res) {
const articles = await Sequelize.Article.findAll();
res.template('articles/articles.pug', { res.template('articles/articles.pug', {
current_route: res.originalUrl, current_route: res.originalUrl
articles
}); });
} }
async function new_article(req, res) { function manga(req, res) {
res.template('admin/data_edit.pug', { res.template('articles/manga.pug', {
current_route: req.originalUrl, current_route: res.originalUrl
data: { })
'title': {
name: 'Title',
type: 'text'
},
'body': {
name: 'Contents',
type: 'textarea'
},
'shortText': {
name: 'Short description',
type: 'textarea'
},
'gpgsign': {
name: 'Body sign',
type: 'codearea'
},
},
description: 'Write a new article',
title: 'New article',
endpoint: '/articles/new',
pref_method: 'POST'
});
}
async function new_article_post(req, res) {
// let data = await db.Article.
res.send(req.body);
return;
} }
module.exports = (router) => { module.exports = (router) => {
router.get('/articles', handler(articles)); router.get('/articles', handler(articles));
router.get('/articles/manga', handler(manga));
// editor
router.get('/articles/new', handler(new_article));
router.post('/articles/new', handler(new_article_post));
} }

View File

@ -6,20 +6,6 @@ block content
h2 Articles h2 Articles
p. p.
This is a bunch of articles written by me (like a tech blog of some sort) This is a bunch of articles written by me (like a tech blog of some sort)
if articles ul
table(style='max-width:600px;min-width:600px;border-collapse:collapse;border:0') li
each article of articles a(href='/articles/manga') Manga advice
tr
td(style='border:1px solid #c2c4c2;box-shadow:0 2px 2px #c2c4c280;border-radius:8px;padding:4px 24px')
h4(style='margin:8px 0;padding:0')
span(style='font-family:monospace') [<a style='font-family:monospace' href='/article/#{article.id}'>##{article.id}</a>]
= article.title
hr
p= article.shortText
p
a(href='/article/' + article.id class='web_link') Open full article
tr
td
div(style='min-height:12px;max-height:12px')
else
p Error while loading articles: data is not present