diff --git a/LICENSE b/LICENSE index b86168b..7830dee 100644 --- a/LICENSE +++ b/LICENSE @@ -1,8 +1,21 @@ -Copyright (c) 2013-2014, psychobunny -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. -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. \ No newline at end of file +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. \ No newline at end of file diff --git a/lib/controllers.js b/lib/controllers.js new file mode 100644 index 0000000..d843f03 --- /dev/null +++ b/lib/controllers.js @@ -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; \ No newline at end of file diff --git a/library.js b/library.js index b021549..f70d0c1 100644 --- a/library.js +++ b/library.js @@ -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; \ No newline at end of file diff --git a/package.json b/package.json index fa962a5..ad9eddc 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/plugin.json b/plugin.json index 5624f44..c6f0b69 100644 --- a/plugin.json +++ b/plugin.json @@ -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" } \ No newline at end of file diff --git a/static/lib/admin.js b/static/lib/admin.js new file mode 100644 index 0000000..d9a12c3 --- /dev/null +++ b/static/lib/admin.js @@ -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; +}); \ No newline at end of file diff --git a/static/lib/main.js b/static/lib/main.js index 2e3d8d1..cdac738 100644 --- a/static/lib/main.js +++ b/static/lib/main.js @@ -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 }()); \ No newline at end of file diff --git a/static/templates/admin/plugins/quickstart.tpl b/static/templates/admin/plugins/quickstart.tpl index 7f17a4c..7f837a3 100644 --- a/static/templates/admin/plugins/quickstart.tpl +++ b/static/templates/admin/plugins/quickstart.tpl @@ -29,26 +29,3 @@ - - \ No newline at end of file