Update Schamper's Shoutbox

NodeBB Plugins
  • Hello,

    I have updated Schamper's shoutbox plugin https://github.com/Schamper/nodebb-plugin-shoutbox
    Since I only changed 2 files could somebody update it, or should I send a pull request. I dont see a point to share the same plugin with some changed lines as a new shoutbox plugin

    plugin.json

    {
      "id": "nodebb-plugin-shoutbox",
      "name": "Shoutbox",
      "description": "NodeBB Plugin Shoutbox",
      "url": "https://github.com/Schamper/nodebb-plugin-shoutbox",
      "library": "./library.js",
      "hooks": [
        { "hook": "static:app.load", "method": "init.load" },
        { "hook": "filter:admin.header.build", "method": "init.addAdminNavigation" },
        { "hook": "filter:header.build", "method": "init.addGlobalNavigation" },
        { "hook": "filter:sounds.get", "method": "init.getSounds" },
    
        { "hook": "filter:user.customSettings", "method": "settings.addUserSettings" },
        { "hook": "filter:user.getSettings", "method": "settings.getUserSettings" },
        { "hook": "action:user.saveSettings", "method": "settings.saveUserSettings" },
    
        { "hook": "filter:widgets.getWidgets", "method": "widget.define" },
        { "hook": "filter:widget.render:shoutbox", "method": "widget.render" }
      ],
      "staticDirs": {
        "public": "./public"
      },
      "less": [
        "public/less/style.less"
      ],
      "scripts": [
        "public/js/loader.js",
        "public/js/lib/actions.js",
        "public/js/lib/base.js",
        "public/js/lib/commands.js",
        "public/js/lib/settings.js",
        "public/js/lib/sockets.js",
        "public/js/lib/utils.js",
        "public/js/lib/actions/bug.js",
        "public/js/lib/actions/default.js",
        "public/js/lib/actions/gist.js",
        "public/js/lib/actions/hide.js",
        "public/js/lib/actions/settings.js",
        "public/js/lib/commands/default.js"
      ],
      "acpScripts": [
        "public/js/admin.js"
      ],
      "templates": "./templates"
    }
    
    

    library.js

    "use strict";
    
    var	NodeBB = require('./lib/nodebb'),
    	Config = require('./lib/config'),
    	Sockets = require('./lib/sockets'),
    	Commands = require('./lib/commands'),
    
    	app,
    
    	Shoutbox = {};
    
    Shoutbox.init = {};
    Shoutbox.widget = {};
    Shoutbox.settings = {};
    
    Shoutbox.init.load = function(params, callback) {
    	function renderGlobal(req, res, next) {
    		Config.getTemplateData(function(data) {
    			res.render(Config.plugin.id, data);
    		});
    	}
    
    	function renderAdmin(req, res, next) {
    		Config.getTemplateData(function(data) {
    			res.render('admin/plugins/' + Config.plugin.id, data);
    		});
    	}
    
    	var router = params.router;
    	router.get('/' + Config.plugin.id, params.middleware.buildHeader, renderGlobal);
    	router.get('/api/' + Config.plugin.id, renderGlobal);
    
    	router.get('/admin/plugins/' + Config.plugin.id, params.middleware.admin.buildHeader, renderAdmin);
    	router.get('/api/admin/plugins/' + Config.plugin.id, renderAdmin);
    
    	NodeBB.SocketPlugins[Config.plugin.id] = Sockets.events;
    	NodeBB.SocketAdmin[Config.plugin.id] = Config.adminSockets;
    
    	app = params.app;
    
    	Config.init(callback);
    };
    
    Shoutbox.init.addGlobalNavigation = function(header, callback) {
    	if (Config.global.get('toggles.headerLink')) {
    		header.navigation.push({
    			class: '',
    			iconClass: 'fa fa-fw ' + Config.plugin.icon,
    			route: '/' + Config.plugin.id,
    			text: Config.plugin.name
    		});
    	}
    
    	callback(null, header);
    };
    
    Shoutbox.init.addAdminNavigation = function(header, callback) {
    	header.plugins.push({
    		route: '/plugins/' + Config.plugin.id,
    		icon: Config.plugin.icon,
    		name: Config.plugin.name
    	});
    
    	callback(null, header);
    };
    
    Shoutbox.init.getSounds = function(sounds, callback) {
    	sounds.push(__dirname + '/public/sounds/shoutbox-notification.mp3');
    	sounds.push(__dirname + '/public/sounds/shoutbox-wobble.mp3');
    	sounds.push(__dirname + '/public/sounds/shoutbox-cena.mp3');
    	callback(null, sounds);
    };
    
    Shoutbox.widget.define = function(widgets, callback) {
    	widgets.push({
    		name: Config.plugin.name,
    		widget: Config.plugin.id,
    		description: Config.plugin.description,
    		content: ''
    	});
    
    	callback(null, widgets);
    };
    
    Shoutbox.widget.render = function(widget, callback) {
    	//Remove any container
    	widget.data.container = '';
    
    	Config.user.get({ uid: widget.uid, settings: {} }, function(err, result) {
    		Config.getTemplateData(function(data) {
    
    			data.hiddenStyle = '';
    			if (!err && result && result.settings && parseInt(result.settings['shoutbox:toggles:hide'], 10) == 1) {
    				data.hiddenStyle = 'display: none;';
    			}
    
    			app.render('shoutbox/panel', { html: '<div id="tablediv"></div>', time: Date.now() }, function(err, html){   
    			    widget.html = html;
    			    callback(err, widget);
    			});
    		});
    	});
    };
    
    Shoutbox.settings.addUserSettings = function(settings, callback) {
    	app.render('shoutbox/user/settings', { settings: settings.settings }, function(err, html) {
    		settings.customSettings.push({
    			title: Config.plugin.name,
    			content: html
    		});
    
    		callback(null, settings);
    	});
    };
    
    Shoutbox.settings.getUserSettings = function(data, callback) {
    	Config.user.get(data, callback);
    };
    
    Shoutbox.settings.saveUserSettings = function(data) {
    	Config.user.save(data);
    };
    
    module.exports = Shoutbox;
    
    
  • You can try creating a PR, but I doubt it will get you anywhere since last commits there were on 2018 and that was a PR too. The creator was last online on this forum in 2017, so I doubt he'll help you here.
    Making a fork is probably the best idea here, since it's unlikely you'll get your changes to the main repo.

  • I ended up with this https://github.com/byNeHo/nodebb-plugin-shoutbox
    maybe I can learn from this for some feature plugins

  • @Ne-Ho Is it working on 1.13.3?

  • @fais3000 yes

  • @ne-ho

    Is it working on 1.17.1?

  • @ne-ho I'd recommend you try to open a PR to Schamper's plugin anyway -- we can help ping him for you to get it merged 😄

  • @julian @Ne-Ho @Schamper

    Any news ?
    It's tagged compatible 1.17.2 now but not !

    61f7231e-33a2-4360-909a-eac2ac9425aa-image.png

  • @psychobunny is working on an alternative plugin 🙂

  • @julian This is good news. Will the plugin be developed from scratch or will the old one be modified?

  • @volanar the plan is we will open source an alternative we've created from scratch. We created it for a client (though heavily customised) and we need to genericise it

  • @julian I understood. This means that the old data from the shoutbox plugin will not be saved😦

  • @volanar whoops! I thought this was the poll thread.

    Then to clarify, we're not making an alternative of this. The existing plugin should be updated. Can look into doing this.

  • @julian It's still good news. Thank you for your work and for the wonderful script.

  • @downpw @volanar What is the problem when this plugin is installed on latest NodeBB?

  • @Julian Lam

    sorry for the response time
    Nothing happen :

    b6d0f18f-a95e-4484-ba4a-05897bc66950-image.png

    if I click on Shoutbox, it is split and the forum disappears 🙂

    Gist, archives buttons doesn't work

    6f610c8b-1f1d-4334-b0b8-9c83b3a4d219-image.png


Suggested Topics