• @Nicolas Is this working with 1.13.1?


  • This plugin isn't working anymore on my forum since a couple of months.

    I'm on version 8.0.0 of the plugin, Nodebb version 1.19.1

    The problem is that the spoilered text isn't loading when pressing on the spoiler header.

    When turning on the JavaScript debugger, I get an

    Error has occurred, error: [[error:no-privileges]]

    in spoiler.js:50.

    The relevant JavaScript function that triggers the error is this one:

        function toggle($button) {
            var $spoiler = $button.parents(elements.MAIN),
                $content = $spoiler.find(elements.CONTENT),
                open     = $spoiler.attr('data-open') === 'true',
                postId   = parseInt($spoiler.attr('data-pid')),
                index    = parseInt($spoiler.attr('data-index')),
                icon     = $button.find('i');
    
            $spoiler.attr('data-open', !open);
    
            if (!open) {
                icon.removeClass(classes.OPEN_EYE).addClass(classes.CLOSE_EYE);
            } else {
                icon.removeClass(classes.CLOSE_EYE).addClass(classes.OPEN_EYE);
            }
    
            // Check if content is empty
            if ($content.html().length === 0) {
                socket.emit(
                    'plugins.ns-spoiler.getSpoilerContent',
                    {index: index, postId: postId},
                    function (error, content) {
                        if (error) {
                            return console.error('Error has occurred, error: %s', error.message);
                        }
                        $content.html(content);
                    }
                );
            }
    
        }
    

    The socket.emit call always yields the "no privilege" error.

    Any ideas?


  • Is there really no way to get a working spoiler plugin for the current version of NodeBB? All alternatives seem to be even more outdated than this one.


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

    Is there really no way to get a working spoiler plugin for the current version of NodeBB? All alternatives seem to be even more outdated than this one.

    Do you think you can switch to this one?

    https://github.com/prosas82/nodebb-plugin-btn-spoilers#readme

    this one works with 1.19.1 , I can confirm.


  • Thanks for the suggestion @crazycells ! That plugin works indeed (I used this version which seems to be more up to date). The only problem my users have with that plugin is that the spoiler content is displayed in the post preview. Any suggestions on how to block spoiler content in post previews?


  • @Klaus6 where exactly in the post previews? Do you mean when you hover the mouse over a post link? Because in this case I still see the spoiler. Do you mean in /categories page?


  • @crazycells On the main page with the listing of the posts, there is a preview that reveals the spoiler content.

    For instance, I put a spoiler with the text "Spoiler content" into a post, and on the post listing page the text is revealed.

    ad6c416e-4662-40fd-9028-85a33154c80d-image.png


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

    @crazycells On the main page with the listing of the posts, there is a preview that reveals the spoiler content.

    For instance, I put a spoiler with the text "Spoiler content" into a post, and on the post listing page the text is revealed.

    ad6c416e-4662-40fd-9028-85a33154c80d-image.png

    Yes, you are right. I do not know the exact reason, but probably it is plugin related. I believe markdown is working on the last post previews because some of the other text functions work; so I assume the plugin is not made to apply there...

    This is not a direct solution, but in our case, this shows differently because we customized our last posts to show the title first... It makes more sense from our perspective that the title is shown in the last post. Therefore "spoiler" does not have enough lines to reveal the content. In case you think you can use this, here is how to achieve this:

    Screen Shot 2022-02-12 at 11.03.03 AM.png

    To change the last post previews in categories page, use customize plugin to edit this file:

    partials/categories/lastpost.tpl

    change line 12-14
    from:

    		<div class="post-content">
    			{../content}
    		</div>
    

    to:

    		<div class="post-content">
    				<div class="title">
    			        <a href="{config.relative_path}/topic/{../topic.slug}<!-- IF ../index -->/{../index}<!-- ENDIF ../index -->">{../topic.title}</a>
    			    </div>
    			        {../content}
    		</div>
    

  • Thanks a ton, that looks interesting.

    I wonder, though: Shouldn't it be possible to just strip the spoiler content in the preview? That is, filter the content and remove the spoiler content for the preview? I don't know how NodeBB is programmed - maybe the template language supports some kind of transformation/filtering?


  • Hi, all:

    Are there plans to update this for 2.0? The formatting in this one looks easier for users than the formatting in nodebb-plugin-btn-spoilers, so I would prefer to use this.


Suggested Topics

| | |

© 2014 – 2022 NodeBB, Inc. — Made in Canada.