updated structure, added MIT license, moved ACP js to its own separate file

This commit is contained in:
Julian Lam 2015-03-13 14:05:18 -04:00
parent ca5f98d483
commit ee219e20f5
8 changed files with 89 additions and 58 deletions

25
LICENSE
View file

@ -1,8 +1,21 @@
Copyright (c) 2013-2014, psychobunny <psycho.bunny@hotmail.com>
All rights reserved.
The MIT License (MIT)

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.
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.
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.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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
View 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;

View file

@ -1,19 +1,19 @@
"use strict";

var plugin = {};
var controllers = require('./lib/controllers'),

plugin = {};

plugin.init = function(params, callback) {
console.log('nodebb-plugin-quickstart: loaded');

var app = params.router,
middleware = params.middleware,
controllers = params.controllers;
var router = params.router,
hostMiddleware = params.middleware,
hostControllers = 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);
router.get('/admin/plugins/quickstart', hostMiddleware.admin.buildHeader, controllers.renderAdminPage);
router.get('/api/admin/plugins/quickstart', controllers.renderAdminPage);

callback();
};
@ -28,19 +28,4 @@ plugin.addAdminNavigation = function(header, callback) {
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;

View file

@ -17,7 +17,7 @@
"name": "psychobunny",
"email": "psycho.bunny@hotmail.com"
},
"license": "BSD-2-Clause",
"license": "MIT",
"bugs": {
"url": "https://github.com/psychobunny/nodebb-plugin-quickstart/issues"
},

View file

@ -1,7 +1,5 @@
{
"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",
"library": "./library.js",
"hooks": [
@ -19,7 +17,8 @@
"static/style.less"
],
"scripts": [
"static/lib/main.js"
"static/lib/main.js",
"static/lib/admin.js"
],
"templates": "static/templates"
}

26
static/lib/admin.js Normal file
View 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;
});

View file

@ -1,7 +1,18 @@
"use strict";

(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');


// Note how this is shown in the console on the first load of every page
}());

View file

@ -29,26 +29,3 @@
</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>