27 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | # Custom Pages for NodeBB
4 |
5 | Allows you to add as many new pages as you like to your NodeBB forum. Each new page has four widget areas (header, footer, content, and sidebar) which you can use to add HTML to in the Widgets ACP.
6 |
7 | ### Tips
8 |
9 | * You can set custom permissions for each individual page (ex. group-level access, or registered users only access, etc).
10 | * Use NodeBB's widget system (_Extend -> Widgets_) to add any type of content.
11 | * Utilize [benchpress](https://github.com/benchpressjs/benchpressjs) markup for advanced logic.
12 | * Add a navigation link in the header that points to your custom page in _General -> Navigation_ and selecting "Custom Route".
13 | * Make a custom page your landing page / homepage under _General -> Homepage_ and selecting "Custom"
14 |
15 | ## Manual Installation
16 |
17 | npm install nodebb-plugin-custom-pages
18 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nodebb-plugin-custom-pages",
3 | "version": "2.1.1",
4 | "description": "Allows you to add as many new pages as you like to your NodeBB forum",
5 | "main": "library.js",
6 | "repository": {
7 | "type": "git",
8 | "url": "https://github.com/psychobunny/nodebb-plugin-custom-pages"
9 | },
10 | "keywords": [
11 | "nodebb",
12 | "plugin",
13 | "static",
14 | "custom",
15 | "page"
16 | ],
17 | "author": {
18 | "name": "psychobunny",
19 | "email": "psycho.bunny@hotmail.com"
20 | },
21 | "nbbpm": {
22 | "compatibility": "^4.0.0"
23 | },
24 | "dependencies": {
25 | "async": "3.2.4",
26 | "mkdirp": "1.0.4"
27 | },
28 | "devDependencies": {
29 | "eslint": "^6.0.0",
30 | "eslint-config-airbnb-base": "^13.1.0",
31 | "eslint-plugin-import": "^2.17.3"
32 | },
33 | "license": "BSD-2-Clause",
34 | "bugs": {
35 | "url": "https://github.com/psychobunny/nodebb-plugin-custom-pages/issues"
36 | },
37 | "readmeFilename": "README.md"
38 | }
39 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013-2014, psychobunny
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5 |
6 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
/static/lib/admin.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /* globals define, $, socket, app, ajaxify, jQuery */
4 |
5 | define('admin/plugins/custom-pages', ['alerts'], function (alerts) {
6 | var admin = {};
7 |
8 | function addCloseHandler() {
9 | $('#custom-pages .fa-times').on('click', function () {
10 | $(this).parents('.card').remove();
11 | });
12 | }
13 |
14 | function addTagsInputForGroups(el) {
15 | el = el || $('#custom-pages .groups-list');
16 |
17 | el.tagsinput({
18 | confirmKeys: [13, 44],
19 | trimValue: true,
20 | });
21 |
22 | app.loadJQueryUI(function () {
23 | var input = $('.page-admin-custom-pages .bootstrap-tagsinput input');
24 | input.autocomplete({
25 | delay: 100,
26 | position: { my: 'left bottom', at: 'left top', collision: 'flip' },
27 | open: function () {
28 | $(this).autocomplete('widget').css('z-index', 20000);
29 | },
30 | source: ajaxify.data.groups,
31 | select: function () {
32 | // when autocomplete is selected from the dropdown simulate a enter key down to turn it into a tag
33 | // http://stackoverflow.com/a/3276819/583363
34 | var e = jQuery.Event('keypress');
35 | e.which = 13;
36 | e.keyCode = 13;
37 | setTimeout(function () {
38 | input.trigger(e);
39 | }, 100);
40 | },
41 | });
42 | });
43 | }
44 |
45 | admin.init = function () {
46 | $('#add').on('click', function () {
47 | var clone = $('.template').clone().removeClass('template hidden');
48 | $('#custom-pages').append(clone);
49 |
50 | addCloseHandler();
51 | addTagsInputForGroups(clone.find('.groups-list'));
52 | });
53 |
54 | addCloseHandler();
55 | addTagsInputForGroups();
56 |
57 | $('#save').on('click', function () {
58 | var arr = [];
59 | $('#custom-pages form').each(function () {
60 | var data = $(this).serializeArray();
61 | if (data[1].value && !data[1].value.match(' ') && data[1].value !== '') {
62 | arr.push({
63 | name: data[0].value,
64 | route: data[1].value,
65 | groups: data[2].value,
66 | });
67 | }
68 | });
69 |
70 | socket.emit('admin.settings.saveCustomPages', arr, function () {
71 | alerts.success('Custom pages saved and activated');
72 | });
73 | });
74 | };
75 |
76 | return admin;
77 | });
78 |
--------------------------------------------------------------------------------
/templates/admin/plugins/custom-pages.tpl:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
{title}
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | Define and customise your new routes here.
16 |
17 |
18 | You can add content to your new routes from Extend → Widgets.
19 |
20 |
21 | You can add your new route to the site navigation from General → Navigation and select "Custom Route".
22 |
23 |
24 | If you wish to set a custom page as your homepage, go to General → Homepage and select "Custom".
25 |