1 | 'use strict';
|
2 |
|
3 | const parent = module.parent.exports;
|
4 | const posts = require.main.require('./src/posts');
|
5 | const Controllers = {};
|
6 |
|
7 | Controllers.renderAdmin = function renderAdmin(req, res) {
|
8 | res.render('admin/plugins/markdown', {
|
9 | themes: parent.themes,
|
10 | });
|
11 | };
|
12 |
|
13 | Controllers.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 |
|
32 | module.exports = Controllers;
|