half baked new article
This commit is contained in:
parent
1ea2f3dfaa
commit
e627fa4626
|
@ -1,8 +1,19 @@
|
||||||
const { Model, DataTypes } = require('sequelize');
|
const { Model, DataTypes } = require('sequelize');
|
||||||
|
|
||||||
class Article extends Model {
|
class Article extends Model {
|
||||||
|
/**
|
||||||
|
* @param {{
|
||||||
|
* title: string,
|
||||||
|
* body: string,
|
||||||
|
* shortText: string,
|
||||||
|
* gpgsign: string,
|
||||||
|
* as: import('./user').class
|
||||||
|
* }} data
|
||||||
|
*/
|
||||||
|
static async writenew(data) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Article.structure = {
|
Article.structure = {
|
||||||
id: {
|
id: {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
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 Sequelize = require('../models');
|
const Sequelize = require('../models');
|
||||||
|
|
||||||
async function articles(req, res) {
|
async function articles(req, res) {
|
||||||
|
@ -12,6 +13,47 @@ async function articles(req, res) {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function new_article(req, res) {
|
||||||
|
res.send(await Helpers.ViewLoader.load('admin/data_edit.pug', {
|
||||||
|
current_route: req.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));
|
||||||
|
|
||||||
|
// editor
|
||||||
|
router.get('/articles/new', handler(new_article));
|
||||||
|
router.post('/articles/new', handler(new_article_post));
|
||||||
}
|
}
|
|
@ -68,7 +68,7 @@ block content
|
||||||
h5 Articles
|
h5 Articles
|
||||||
hr
|
hr
|
||||||
p
|
p
|
||||||
a(href='/admin/article/new') Create new article
|
a(href='/articles/new') Create new article
|
||||||
if (access_level >= 4)
|
if (access_level >= 4)
|
||||||
br
|
br
|
||||||
a(href='/admin/articles.csv') Download data (.CSV)
|
a(href='/admin/articles.csv') Download data (.CSV)
|
||||||
|
|
Loading…
Reference in New Issue