• Plugin & Theme Dev

    Easiest test guys:

    create a single post with only one spoiler, let's say content of the spoiler like this:

    :::
    
    spoiler content
    
    :::
    

    Three questions:

    1. Does it render properly your spoiler? It should have only a single button in the post.
    2. Inspect HTML of your post with a spoiler, what index do you see there? data-index of div.ns-spoiler
    3. When you click a spoiler button, do you see an original content or an error in the console? Content of the error?

  • @Nicolas said in [nodebb-plugin-ns-spoiler] NS Spoiler:

    Easiest test guys:

    create a single post with only one spoiler, let's say content of the spoiler like this:

    :::
    
    spoiler content
    
    :::
    

    Three questions:

    1. Does it render properly your spoiler? It should have only a single button in the post.
    2. Inspect HTML of your post with a spoiler, what index do you see there? data-index of div.ns-spoiler
    3. When you click a spoiler button, do you see an original content or an error in the console? Content of the error?

    Have you seen that?

    https://i.imgur.com/yYanLDm.png

    (posted by @exodo a few days ago)

    Here you have the problem, you must check server side the type of the 'postId' parameter and convert to string to be sure it will return post content. You should add the conversion on this line.

  • Plugin & Theme Dev

  • Plugin & Theme Dev

    Screenshot only gives me an information that it tries to lookup from index 1 in the post, and can not find it. Do you use plugins which parse posts?


  • @Nicolas said in [nodebb-plugin-ns-spoiler] NS Spoiler:

    Screenshot only gives me an information that it tries to lookup from index 1 in the post, and can not find it. Do you use plugins which parse posts?

    Do you know to read?

    Index is irrelevant, if you read your own code you will realize that you don't use the index before parse the post. The error is that "getPostFields" (this line) is not returning any post due to the type of the "postId" variable, which it seems to be string instead of integer.

    Why isn't it working? I don't know, maybe due to some index based on previous NodeBB versions or maybe due to the version of MongoDB.

    I have tested in my local nodebb forum for tests and it works with both integer and string type, but some forums only seems to accept string. As i said, maybe due to previous versions of NodeBB or a different version of MongoDB.

  • Plugin & Theme Dev


  • @Nicolas first of all, I must apologize for my reply. I read it and doesn't sound well. Sorry.

    So NodeBB already convert it to string.. It is strange.. Do you have any idea why is it happening? Why if I send an string instead of a number through the websocket it works? It seems it isn't caused by other plugins which parse the post.

    Maybe is a bug appending string to integer in a old NodeJS version? ๐Ÿ˜ฅ


  • Same problem in 1.3.0

  • Plugin & Theme Dev

    @MJ will be helpful if you will do small experiment.

    Prepare post with exact content:

    :::
    
    hidden content one
    
    :::
    
    content between spoilers
    
    :::
    
    hidden content two
    
    :::
    

    Update parser.js file in spoiler library with logging message, find node_modules/nodebb-plugin-ns-spoiler/plugin/parser.js, lines 11-25

        Parser.getContentAt = function (content, index, done) {
            console.log('CONTENT', JSON.stringify(content), index); // <-- ADD THIS LINE
            async.waterfall([
                async.apply(Parser.prepare, content),
                function (sanitizedContent, next) {
                    console.log('SANITIZED', JSON.stringify(sanitizedContent)); // <-- ADD THIS LINE
                    var spoilerContent;
                    spoiler.lastIndex = index;
                    spoilerContent = spoiler.exec(sanitizedContent);
                    if (spoilerContent) {
                        next(null, spoilerContent[1]);
                    } else {
                        next(new Error('Something went wrong. Spoiler content can not be found.'));
                    }
                }
            ], done);
        };
    

    Edit plugin's file and restart a NodeBB.

    Go to forum, and click on the first spoiler once, click on the second spoiler once, and provide here a logs from NodeBB.

    P.S.
    Also, what Node version do you use?


  • @Nicolas I will do tonight ๐Ÿ™‚ we use 1.3.0


  • Oh, just found this plugin doesn't work. I see spoiler in post, but when click, it doesn't open, only changes eye symbol.

    NodeBB v1.3.0. (work at v1.2.1)
    nodebb-plugin-ns-spoiler 3.0.3 (when update forum from v1.2.1 to 1.3.0 also update this plugin)

    (example: http://forum.veloufa.ru/topic/7033/15-16-ะพะบั‚ัะฑั€ั-2016-ะบะพะปัŒั†ะพ-24)

  • Plugin & Theme Dev

    @alff0x1f does it work, when you are logged in? It it does not, what error do you see in the console?


  • @Nicolas no, when I logget in it also doesn't work. In browser console this:

    Error has occurred, error: Something went wrong. Spoiler content can not be found.
    nodebb.min.js?2c3aa6f6-52d8-4227-9923-187506727d4b:12
    
  • Plugin & Theme Dev

    @alff0x1f

    Could you share these information:

    1. NodeBB version.
    2. Node version.
    3. All installed active plugins with their versions.
    4. Redis or MongoDB? version?

  • @Nicolas

    1. NodeBB v1.3.0
    2. Node v4.2.6 + MongoDB 2.6.10
    3. nodebb-plugin-composer-default 4.2.13
      nodebb-plugin-dbsearch 1.0.3
      nodebb-plugin-embed-combo 0.1.9
      nodebb-plugin-emoji-apple 1.0.4
      nodebb-plugin-emoji-extended 1.1.1
      nodebb-plugin-featured-topics-extended 1.1.5
      nodebb-plugin-google-analytics 0.5.9
      nodebb-plugin-imgur 1.0.17 | Latest 1.0.18
      nodebb-plugin-markdown 6.0.2
      nodebb-plugin-mentions 1.1.3
      nodebb-plugin-ns-spoiler 3.0.3
      nodebb-plugin-soundpack-default 0.1.6
      nodebb-plugin-spam-be-gone 0.4.10
      nodebb-plugin-sso-vk 2.0.7
      nodebb-plugin-telegram-notifications 0.1.3
      nodebb-plugin-youtube-embed 0.6.4 | Latest 0.6.6
      nodebb-rewards-essentials 0.0.9
      nodebb-widget-essentials 2.0.13
  • Plugin & Theme Dev

    I have tried with an environment which is very similar

    Preview

    NodeBB 1.4.1 + Node 4.2.6 + MongoDB 3.4.0 and set of plugins that you have provided.

    If you have time, you could try to do actions from this message: https://community.nodebb.org/post/56205 and post a result here.

  • Anime Lovers

    NodeBB v1.4.2 + Node v7.4.0 + MongoDB v3.4.1

    Error has occurred, error: Something went wrong. Spoiler content can not be found.  nodebb.min.js:15:26743
    	a/< https://example.org/nodebb.min.js:15:26743
    	d.prototype.onack https://example.org/nodebb.min.js:6:4510
    	d.prototype.onpacket https://example.org/nodebb.min.js:6:3833
    	e.exports/< https://example.org/nodebb.min.js:6:5960
    	i.prototype.emit https://example.org/nodebb.min.js:5:26757
    	h.prototype.ondecoded https://example.org/nodebb.min.js:4:25688
    	e.exports/< https://example.org/nodebb.min.js:6:5960
    	n.prototype.emit https://example.org/nodebb.min.js:4:19868
    	f.prototype.add https://example.org/nodebb.min.js:4:5062
    	h.prototype.ondata https://example.org/nodebb.min.js:4:25633
    	e.exports/< https://example.org/nodebb.min.js:6:5960
    	i.prototype.emit https://example.org/nodebb.min.js:5:26757
    	f.prototype.onPacket https://example.org/nodebb.min.js:5:2629
    	f.prototype.setTransport/< https://example.org/nodebb.min.js:5:191
    	i.prototype.emit https://example.org/nodebb.min.js:5:26757
    	o.prototype.onPacket https://example.org/nodebb.min.js:5:15153
    	o.prototype.onData https://example.org/nodebb.min.js:5:15102
    	d.prototype.addEventListeners/this.ws.onmessage https://example.org/nodebb.min.js:5:31691
    

    NodeBB log after parser.js edit:

    7/1 04:06:19 [27805] - info: NodeBB is now listening on: 127.0.0.1:4567
    CONTENT "\n<div class=\"ns-spoiler\" data-index=\"1\" data-open=\"false\"><div class=\"ns-spoiler-control\"><a class=\"btn btn-default\" href=\"#\"><i class=\"fa fa-eye\"></i> spoiler</a></div><div class=\"ns-spoiler-content\"></div></div>\n\n" 1
    SANITIZED "\n<div class=\"ns-spoiler\" data-index=\"1\" data-open=\"false\"><div class=\"ns-spoiler-control\"><a class=\"btn btn-default\" href=\"#\"><i class=\"fa fa-eye\"></i> spoiler</a></div><div class=\"ns-spoiler-content\"></div></div>\n\n"
    CONTENT "\n<div class=\"ns-spoiler\" data-index=\"1\" data-open=\"false\"><div class=\"ns-spoiler-control\"><a class=\"btn btn-default\" href=\"#\"><i class=\"fa fa-eye\"></i> spoiler</a></div><div class=\"ns-spoiler-content\"></div></div>\n\n" 1
    SANITIZED "\n<div class=\"ns-spoiler\" data-index=\"1\" data-open=\"false\"><div class=\"ns-spoiler-control\"><a class=\"btn btn-default\" href=\"#\"><i class=\"fa fa-eye\"></i> spoiler</a></div><div class=\"ns-spoiler-content\"></div></div>\n\n"
    CONTENT "\n<div class=\"ns-spoiler\" data-index=\"1\" data-open=\"false\"><div class=\"ns-spoiler-control\"><a class=\"btn btn-default\" href=\"#\"><i class=\"fa fa-eye\"></i> spoiler</a></div><div class=\"ns-spoiler-content\"></div></div>\n\n" 1
    SANITIZED "\n<div class=\"ns-spoiler\" data-index=\"1\" data-open=\"false\"><div class=\"ns-spoiler-control\"><a class=\"btn btn-default\" href=\"#\"><i class=\"fa fa-eye\"></i> spoiler</a></div><div class=\"ns-spoiler-content\"></div></div>\n\n"
    CONTENT "\n<div class=\"ns-spoiler\" data-index=\"1\" data-open=\"false\"><div class=\"ns-spoiler-control\"><a class=\"btn btn-default\" href=\"#\"><i class=\"fa fa-eye\"></i> spoiler</a></div><div class=\"ns-spoiler-content\"></div></div>\n\n" 1
    SANITIZED "\n<div class=\"ns-spoiler\" data-index=\"1\" data-open=\"false\"><div class=\"ns-spoiler-control\"><a class=\"btn btn-default\" href=\"#\"><i class=\"fa fa-eye\"></i> spoiler</a></div><div class=\"ns-spoiler-content\"></div></div>\n\n"
    

  • @KitsuneSolar said in [nodebb-plugin-ns-spoiler] NS Spoiler:
    confirming the bug on:
    nodebb v1.4.2
    mongodb v3.2.1
    node v4.7.1

    I'm getting this error in browser console:
    Error has occurred, error: Something went wrong. Spoiler content can not be found.

  • Plugin & Theme Dev

    @KitsuneSolar your investigation is very helpful.

    Could you disable all 3-rd party plugins so only Native Plugins and Spoiler Plugin will be active? Am I right that you don't see an issue anymore?

    My theory: some plugin in the chain rewrites a payload. It is not reproducible for me because I'm using different plugins, mostly which I have developed.

  • Anime Lovers

    @Nicolas said in [nodebb-plugin-ns-spoiler] NS Spoiler:

    Could you disable all 3-rd party plugins so only Native Plugins and Spoiler Plugin will be active?

    3-rd party plugins

    I have only nodebb-plugin-poll & spam-be-gone.

Suggested Topics

| |