|
|
|
@ -1,21 +1,18 @@
|
|
|
|
|
import Book from '../../data/Book';
|
|
|
|
|
const express = require('express');
|
|
|
|
|
const router = express.Router();
|
|
|
|
|
const hljs = require('highlight.js/lib/highlight');
|
|
|
|
|
const hljs_md = require('highlight.js/lib/languages/markdown');
|
|
|
|
|
const moment = require('moment');
|
|
|
|
|
const book = new Book();
|
|
|
|
|
const uuidv4 = require('uuid/v4');
|
|
|
|
|
const settings = require('../../../site/settings.json');
|
|
|
|
|
hljs.registerLanguage('markdown', hljs_md);
|
|
|
|
|
//--------------------------
|
|
|
|
|
// POSTS
|
|
|
|
|
//--------------------------
|
|
|
|
|
router.get('/list/:filter?/:page?', function(req, res) {
|
|
|
|
|
router.get('/list/:filter?/:page?', function (req, res) {
|
|
|
|
|
var pageNum = req.params.page;
|
|
|
|
|
var filter = req.params.filter;
|
|
|
|
|
if (pageNum == '' || pageNum == null) pageNum = 1;
|
|
|
|
|
if (filter == '' || filter == null) filter = "all";
|
|
|
|
|
if (filter == '' || filter == null) filter = 'all';
|
|
|
|
|
if (req.session.user) {
|
|
|
|
|
book.getPage()
|
|
|
|
|
.then(pages => {
|
|
|
|
@ -92,7 +89,7 @@ router.get('/list/:filter?/:page?', function(req, res) {
|
|
|
|
|
//--------------------------
|
|
|
|
|
// BLOG POST ADD DISPLAY
|
|
|
|
|
//--------------------------
|
|
|
|
|
router.get('/add/new', function(req, res) {
|
|
|
|
|
router.get('/add/new', function (req, res) {
|
|
|
|
|
if (req.session.user) {
|
|
|
|
|
res.render('page-edit', {
|
|
|
|
|
id: settings.library_stats.current_index,
|
|
|
|
@ -113,12 +110,11 @@ router.get('/add/new', function(req, res) {
|
|
|
|
|
//--------------------------
|
|
|
|
|
// BLOG POST EDIT DISPLAY
|
|
|
|
|
//--------------------------
|
|
|
|
|
router.get('/edit/:id', function(req, res) {
|
|
|
|
|
router.get('/edit/:id', function (req, res) {
|
|
|
|
|
var id = req.params.id;
|
|
|
|
|
if (req.session.user) {
|
|
|
|
|
book.getPage(id)
|
|
|
|
|
.then(page => {
|
|
|
|
|
let pretty = hljs.highlight('markdown', page.content).value;
|
|
|
|
|
res.render('page-edit', {
|
|
|
|
|
id: page.metadata.id,
|
|
|
|
|
uuid: page.metadata.uuid,
|
|
|
|
@ -127,7 +123,7 @@ router.get('/edit/:id', function(req, res) {
|
|
|
|
|
page: page.metadata,
|
|
|
|
|
date: moment(page.metadata.created).format('YYYY MMM DD'),
|
|
|
|
|
rawDate: page.metadata.created,
|
|
|
|
|
colored: pretty,
|
|
|
|
|
content: page.content,
|
|
|
|
|
feature: page.metadata.feature,
|
|
|
|
|
status: [
|
|
|
|
|
String(page.metadata.menu),
|
|
|
|
|