Fork of nodebb-plugin-shoutbox with room support

NodeBB Plugins
  • Hello guys,

    I just must say that I love nodebb and starting to love nodejs. I primarely program in pyhton and use django , but this is good for me to learn.
    I have created a fork of the original shoutbox plugin and added room support. Rooms are created on fly when you enter /chat/RoomName, RoomName could be anything .
    My first test works as expected, but if I add in the custom route in navigation , like /chat/RoomName , when I click first time , the connection stalls, but if I refresh the page it loads ok , or if I enter the full url in browser it loads from first time as expected, this issue I haven`t managed to solve.
    Sorry for the original name which I have not changed, I hope I will change the name in the future. I will try to solve this issue also.

    The repository url is : https://github.com/claudiutraistaru/nodebb-plugin-shoutbox

  • router.get('/chat/:room', params.middleware.buildHeader, renderChatRoom);
    router.get('/api/chat/:room', params.middleware.buildHeader, renderChatRoom);
    

    API routes don't need the buildHeader middleware, not sure if that is causing the problem though.

  • The api should not get the buildHeader, or am I wrong?
    This shouldn`t be?:

    router.get('/chat/:room', params.middleware.buildHeader, renderChatRoom);
    router.get('/api/chat/:room', renderChatRoom);

    Also tried with :

    router.get('/api/chat/:room',function (req,res){});

    Same issue 😞

  • Right now when testing on my dev system I was able to get an error in chrome:
    Uncaught TypeError: Cannot read property 'name' of undefined , in nodebb.min.js, the part of code that gives error is :

    ajaxify.variables.flush();
    ajaxify.loadData(url, function(err, data) {
    if (err) {
    return onAjaxError(err, url, callback, quiet);
    }

    		app.template = data.template.name;
    
    		require(['translator'], function(translator) {
    			translator.load(config.defaultLang, data.template.name);
    			renderTemplate(url, data.template.name, data, callback);
    		});
    	});
    

    The line with error is : app.template = data.template.name;
    On reload everything is ok as I have said, but doesn`t matter how many times I click on the shortcut or href inside nodebb the connection stalls .

  • What do you get when you go the the route /api/chat/:room in your browser? The data should have a template section with name in it.

  • I get :
    {
    "features": [],
    "room": ":room",
    "loggedIn": true,
    "template": {
    "name": "shoutbox",
    "shoutbox": true
    }
    }

  • Ok I think it was an issue on my side , don`t know witch , now it seems to work . I left everything like in my git, including router.get('/api/chat/:room', renderChatRoom); . I will extend my project and try to add an external widget in the rooms :).

  • Hey @Scuzz, maybe you'll be interested in this 😉

  • If this is updated and compatible with v0.7 then i probably will. @Schamper is slacking and by the time he updates the shoutbox v1.0 will be out 😛

    I'll give it a try on a dev machine.

  • @Scuzz. For the moment for it to work on 0.7 on my install I have removed the hooks for usersettings, but if I have any time soon I will try to make those work also. This at the moment was shown that maybe someone will make use of the code before I will make it stable.


Suggested Topics


  • 0 Votes
    3 Posts
    841 Views

    Screenshot_22.jpg
    I would like to add a new field to the topic submission form

  • 0 Votes
    1 Posts
    864 Views

    I wanted to debug some code I had written in my plugin and did a quick search to see if I could create a Node.js REPL that would function in the context of my plugin. It turned out to be quite simple to do.

    Just add this to your plugin's static:app.load method:

    setTimeout(function() { console.log("About to start REPL"); var repl = require("repl"); var util = require('util'); var replServer = repl.start({ prompt: "swf-cms> ", breakEvalOnSigint: true, ignoreUndefined: true, useGlobal: true, useColors: true }); var context = replServer.context; context.require = require; context.module = module; context.context = util.inspect(replServer.context, {depth: 0}); }, 3000);

    You'll want to wrap this in something to prevent it from running outside of dev mode. Also, load up the context object with anything that you want to be conveniently available in the REPL. FYI, I used the setTimeout to give Nodebb a chance to finish loading before it gives you the prompt.

    Have fun.

  • 0 Votes
    3 Posts
    1k Views

    I think my created menu had Route: javascript:(0) and <i class=" as Text:, the other half of that css underneath

    in ACP -> GENERAL -> NAVIGATION

    I also have a ton of active plugins, 20 plugins running. also tried change the order and it didn't changed ☺

    running drum roll............. 0.7.0

  • How to update plugins?

    NodeBB Plugins
    0 Votes
    8 Posts
    3k Views

    @gaasg that really shouldn't be necessary, but some plugins might be incompatible after an upgrade, you just have to upgrade those or disable them accordingly.