mirror of
https://hk.gh-proxy.com/https://github.com/NodeBB/nodebb-plugin-quickstart.git
synced 2025-10-04 04:41:05 +08:00
Merge branch 'master' of https://github.com/NodeBB/nodebb-plugin-quickstart
This commit is contained in:
commit
0e2cc54a72
12 changed files with 733 additions and 762 deletions
|
@ -18,4 +18,3 @@ Controllers.renderAdminPage = function (req, res/* , next */) {
|
|||
title: 'Quick Start',
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
const nconf = require.main.require('nconf');
|
||||
const winston = require.main.require('winston');
|
||||
|
||||
const meta = require.main.require('./src/meta');
|
||||
|
||||
const controllers = require('./lib/controllers');
|
||||
|
||||
const routeHelpers = require.main.require('./src/routes/helpers');
|
||||
|
@ -11,6 +14,12 @@ const plugin = {};
|
|||
plugin.init = async (params) => {
|
||||
const { router /* , middleware , controllers */ } = params;
|
||||
|
||||
// Settings saved in the plugin settings can be retrieved via settings methods
|
||||
const { setting1, setting2 } = await meta.settings.get('quickstart');
|
||||
if (setting1) {
|
||||
console.log(setting2);
|
||||
}
|
||||
|
||||
/**
|
||||
* We create two routes for every view. One API call, and the actual route itself.
|
||||
* Use the `setupPageRoute` helper and NodeBB will take care of everything for you.
|
||||
|
|
16
package.json
16
package.json
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "nodebb-plugin-quickstart",
|
||||
"version": "0.4.2",
|
||||
"version": "0.4.3",
|
||||
"description": "A starter kit for quickly creating NodeBB plugins",
|
||||
"main": "library.js",
|
||||
"repository": {
|
||||
|
@ -34,12 +34,12 @@
|
|||
"compatibility": "^3.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "17.1.2",
|
||||
"@commitlint/config-angular": "17.1.0",
|
||||
"eslint": "8.23.0",
|
||||
"eslint-config-nodebb": "0.1.1",
|
||||
"eslint-plugin-import": "2.26.0",
|
||||
"husky": "8.0.1",
|
||||
"lint-staged": "13.0.3"
|
||||
"@commitlint/cli": "17.6.5",
|
||||
"@commitlint/config-angular": "17.6.5",
|
||||
"eslint": "8.42.0",
|
||||
"eslint-config-nodebb": "0.2.1",
|
||||
"eslint-plugin-import": "2.27.5",
|
||||
"husky": "8.0.3",
|
||||
"lint-staged": "13.2.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
"staticDirs": {
|
||||
"static": "./static"
|
||||
},
|
||||
"less": [
|
||||
"static/less/quickstart.less"
|
||||
"scss": [
|
||||
"static/scss/quickstart.scss"
|
||||
],
|
||||
"scripts": [
|
||||
"static/lib/main.js"
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
/* Place any LESS in here */
|
|
@ -6,8 +6,8 @@
|
|||
It is not bundled into the min file that is served on the first load of the page.
|
||||
*/
|
||||
define('admin/plugins/quickstart', [
|
||||
'settings', 'uploader', 'alerts',
|
||||
], function (settings, uploader, alerts) {
|
||||
'settings', 'uploader',
|
||||
], function (settings, uploader) {
|
||||
var ACP = {};
|
||||
|
||||
ACP.init = function () {
|
||||
|
@ -19,17 +19,7 @@ define('admin/plugins/quickstart', [
|
|||
};
|
||||
|
||||
function saveSettings() {
|
||||
settings.save('quickstart', $('.quickstart-settings'), function () {
|
||||
alerts.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');
|
||||
},
|
||||
});
|
||||
});
|
||||
settings.save('quickstart', $('.quickstart-settings')); // pass in a function in the 3rd parameter to override the default success/failure handler
|
||||
}
|
||||
|
||||
function setupColorInputs() {
|
||||
|
|
|
@ -1,18 +1,27 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* There are two (standard) ways to wait for when NodeBB is ready.
|
||||
* This one below executes when NodeBB reports it is ready...
|
||||
*/
|
||||
|
||||
(async () => {
|
||||
const hooks = await app.require('hooks');
|
||||
hooks.on('action:ajaxify.end', (/* data */) => {
|
||||
// ...
|
||||
});
|
||||
})();
|
||||
|
||||
/**
|
||||
* ... and this one reports when the DOM is loaded (but NodeBB might not be fully ready yet).
|
||||
* For most cases, you'll want the one above.
|
||||
*/
|
||||
|
||||
$(document).ready(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
|
||||
// ...
|
||||
});
|
||||
|
|
1
static/scss/quickstart.scss
Normal file
1
static/scss/quickstart.scss
Normal file
|
@ -0,0 +1 @@
|
|||
/* Place any SASS in here */
|
|
@ -1,10 +1,10 @@
|
|||
<form>
|
||||
<div class="form-group">
|
||||
<label for="name">Name</label>
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="name">Name</label>
|
||||
<input type="text" id="name" name="name" class="form-control" placeholder="Name" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="description">Description</label>
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="description">Description</label>
|
||||
<input type="text" id="description" name="description" class="form-control" placeholder="Description" />
|
||||
</div>
|
||||
</form>
|
|
@ -1,5 +1,5 @@
|
|||
<div class="well">
|
||||
<p>This is a custom page. </p>
|
||||
<p>Your uid is {uid}!</p>
|
||||
<p id="last-p"></p>
|
||||
<div class="card card-body text-bg-light">
|
||||
<p>This is a custom page.</p>
|
||||
<p>Your uid is {uid}!</p>
|
||||
<p id="last-p"></p>
|
||||
</div>
|
9
test/.eslintrc
Normal file
9
test/.eslintrc
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"env": {
|
||||
"mocha": true
|
||||
},
|
||||
"rules": {
|
||||
"no-unused-vars": "off"
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue