mirror of
https://hk.gh-proxy.com/https://github.com/NodeBB/nodebb-plugin-2factor.git
synced 2025-10-03 09:11:01 +08:00
updated structure, added MIT license, moved ACP js to its own separate file
This commit is contained in:
parent
ca5f98d483
commit
ee219e20f5
8 changed files with 89 additions and 58 deletions
25
LICENSE
25
LICENSE
|
@ -1,8 +1,21 @@
|
||||||
Copyright (c) 2013-2014, psychobunny <psycho.bunny@hotmail.com>
|
The MIT License (MIT)
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
Copyright (c) 2015 NodeBB Inc. <sales@nodebb.org>
|
||||||
|
|
||||||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
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.
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
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.
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
20
lib/controllers.js
Normal file
20
lib/controllers.js
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var Controllers = {};
|
||||||
|
|
||||||
|
Controllers.renderAdminPage = function (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 = Controllers;
|
31
library.js
31
library.js
|
@ -1,19 +1,19 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var plugin = {};
|
var controllers = require('./lib/controllers'),
|
||||||
|
|
||||||
|
plugin = {};
|
||||||
|
|
||||||
plugin.init = function(params, callback) {
|
plugin.init = function(params, callback) {
|
||||||
console.log('nodebb-plugin-quickstart: loaded');
|
var router = params.router,
|
||||||
|
hostMiddleware = params.middleware,
|
||||||
var app = params.router,
|
hostControllers = params.controllers;
|
||||||
middleware = params.middleware,
|
|
||||||
controllers = params.controllers;
|
|
||||||
|
|
||||||
// We create two routes for every view. One API call, and the actual route itself.
|
// 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.
|
// 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);
|
router.get('/admin/plugins/quickstart', hostMiddleware.admin.buildHeader, controllers.renderAdminPage);
|
||||||
app.get('/api/admin/plugins/quickstart', renderAdmin);
|
router.get('/api/admin/plugins/quickstart', controllers.renderAdminPage);
|
||||||
|
|
||||||
callback();
|
callback();
|
||||||
};
|
};
|
||||||
|
@ -28,19 +28,4 @@ plugin.addAdminNavigation = function(header, callback) {
|
||||||
callback(null, header);
|
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;
|
module.exports = plugin;
|
|
@ -17,7 +17,7 @@
|
||||||
"name": "psychobunny",
|
"name": "psychobunny",
|
||||||
"email": "psycho.bunny@hotmail.com"
|
"email": "psycho.bunny@hotmail.com"
|
||||||
},
|
},
|
||||||
"license": "BSD-2-Clause",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/psychobunny/nodebb-plugin-quickstart/issues"
|
"url": "https://github.com/psychobunny/nodebb-plugin-quickstart/issues"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
{
|
{
|
||||||
"id": "nodebb-plugin-quickstart",
|
"id": "nodebb-plugin-quickstart",
|
||||||
"name": "Quickstart Plugin for NodeBB",
|
|
||||||
"description": "A starter kit for quickly creating NodeBB plugins",
|
|
||||||
"url": "https://github.com/NodeBB/nodebb-plugin-quickstart",
|
"url": "https://github.com/NodeBB/nodebb-plugin-quickstart",
|
||||||
"library": "./library.js",
|
"library": "./library.js",
|
||||||
"hooks": [
|
"hooks": [
|
||||||
|
@ -19,7 +17,8 @@
|
||||||
"static/style.less"
|
"static/style.less"
|
||||||
],
|
],
|
||||||
"scripts": [
|
"scripts": [
|
||||||
"static/lib/main.js"
|
"static/lib/main.js",
|
||||||
|
"static/lib/admin.js"
|
||||||
],
|
],
|
||||||
"templates": "static/templates"
|
"templates": "static/templates"
|
||||||
}
|
}
|
26
static/lib/admin.js
Normal file
26
static/lib/admin.js
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
define('admin/plugins/quickstart', ['settings'], function(Settings) {
|
||||||
|
'use strict';
|
||||||
|
/* globals $, app, socket, require */
|
||||||
|
|
||||||
|
var ACP = {};
|
||||||
|
|
||||||
|
ACP.init = function() {
|
||||||
|
Settings.load('quickstart', $('.quickstart-settings'));
|
||||||
|
|
||||||
|
$('#save').on('click', function() {
|
||||||
|
Settings.save('quickstart', $('.quickstart-settings'), function() {
|
||||||
|
app.alert({
|
||||||
|
type: 'success',
|
||||||
|
alert_id: 'quickstart-saved',
|
||||||
|
title: 'Settings Saved',
|
||||||
|
message: 'Please reload your NodeBB to apply these settings',
|
||||||
|
clickfn: function() {
|
||||||
|
socket.emit('admin.reload');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return ACP;
|
||||||
|
});
|
|
@ -1,7 +1,18 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
/*
|
||||||
|
This file shows how client-side javascript can be included via a plugin.
|
||||||
|
If you check `plugin.json`, you'll see that this file is listed under "scripts".
|
||||||
|
That array tells NodeBB which files to bundle into the minified javascript
|
||||||
|
that is served to the end user.
|
||||||
|
|
||||||
|
Some events you can elect to listen for:
|
||||||
|
|
||||||
|
$(document).ready(); Fired when the DOM is ready
|
||||||
|
$(window).on('action:ajaxify.end', function(data) { ... }); "data" contains "url"
|
||||||
|
*/
|
||||||
|
|
||||||
console.log('nodebb-plugin-quickstart: loaded');
|
console.log('nodebb-plugin-quickstart: loaded');
|
||||||
|
// Note how this is shown in the console on the first load of every page
|
||||||
|
|
||||||
}());
|
}());
|
|
@ -29,26 +29,3 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
|
||||||
'use strict';
|
|
||||||
/* globals $, app, socket, require */
|
|
||||||
|
|
||||||
require(['settings'], function(Settings) {
|
|
||||||
Settings.load('quickstart', $('.quickstart-settings'));
|
|
||||||
|
|
||||||
$('#save').on('click', function() {
|
|
||||||
Settings.save('quickstart', $('.quickstart-settings'), function() {
|
|
||||||
app.alert({
|
|
||||||
type: 'success',
|
|
||||||
alert_id: 'quickstart-saved',
|
|
||||||
title: 'Settings Saved',
|
|
||||||
message: 'Please reload your NodeBB to apply these settings',
|
|
||||||
clickfn: function() {
|
|
||||||
socket.emit('admin.reload');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
Loading…
Add table
Add a link
Reference in a new issue