forked from NodeBB/nodebb-plugin-quickstart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibrary.js
46 lines (33 loc) · 1.1 KB
/
library.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"use strict";
var plugin = {};
plugin.init = function(params, callback) {
console.log('nodebb-plugin-quickstart: loaded');
var app = params.router,
middleware = params.middleware,
controllers = params.controllers;
// We create two routes for every view. One API call, and the actual route itself.
// Just add the buildHeader middleware to your route and NodeBB will take care of everything for you.
app.get('/admin/plugins/quickstart', middleware.admin.buildHeader, renderAdmin);
app.get('/api/admin/plugins/quickstart', renderAdmin);
callback();
};
plugin.addAdminNavigation = function(header, callback) {
header.plugins.push({
route: '/plugins/quickstart',
icon: 'fa-tint',
name: 'Quickstart'
});
callback(null, header);
};
function renderAdmin(req, res, next) {
/*
Make sure the route matches your path to template exactly.
If your route was:
myforum.com/some/complex/route/
your template should be:
templates/some/complex/route.tpl
and you would render it like so:
res.render('some/complex/route'); */
res.render('admin/plugins/quickstart', {});
}
module.exports = plugin;