UNPKG

630 BJavaScriptView Raw
1'use strict';
2
3const parent = module.parent.exports;
4const posts = require.main.require('./src/posts');
5const Controllers = {};
6
7Controllers.renderAdmin = function renderAdmin(req, res) {
8 res.render('admin/plugins/markdown', {
9 themes: parent.themes,
10 });
11};
12
13Controllers.retrieveRaw = function retrieveRaw(req, res, next) {
14 const pid = parseInt(req.params.pid, 10);
15
16 if (!pid) {
17 return next();
18 }
19
20 posts.getPostField(pid, 'content', function (err, content) {
21 if (err) {
22 return next(err);
23 }
24
25 res.json({
26 pid: pid,
27 content: content,
28 });
29 });
30};
31
32module.exports = Controllers;