[nodebb-plugin-ns-spoiler] NS Spoiler
-
Try
3.0.2
. It should work well. -
@Nicolas said in [nodebb-plugin-ns-spoiler] NS Spoiler:
@exodo Your error is related to V8.
Both issues (@MJ and @exodo ) I can reproduce, when I downgrade to
Node 4.0.0
.
I will investigate issue and push a patch updateJust curious what is v8
I have node 5.0 -
@Nicolas said in [nodebb-plugin-ns-spoiler] NS Spoiler:
Try
3.0.2
. It should work well.just installed, no errors
but it doesnt seem to load spoilers correctly
-
@exodo said in [nodebb-plugin-ns-spoiler] NS Spoiler:
but it doesnt seem to load spoilers correctly
Interesting. This error is generated by the plugin. Plugin can not find a corresponding content of the spoiler. Would be great if you will give more information what you are doing, what type of formatting you use.
It doesn't work for you for all spoilers or only some of them?
-
@Nicolas said in [nodebb-plugin-ns-spoiler] NS Spoiler:
@exodo said in [nodebb-plugin-ns-spoiler] NS Spoiler:
but it doesnt seem to load spoilers correctly
Interesting. This error is generated by the plugin. Plugin can not find a corresponding content of the spoiler. Would be great if you will give more information what you are doing, what type of formatting you use.
It doesn't work for you for all spoilers or only some of them?
@Nicolas said in [nodebb-plugin-ns-spoiler] NS Spoiler:
@exodo said in [nodebb-plugin-ns-spoiler] NS Spoiler:
but it doesnt seem to load spoilers correctly
Interesting. This error is generated by the plugin. Plugin can not find a corresponding content of the spoiler. Would be great if you will give more information what you are doing, what type of formatting you use.
It doesn't work for you for all spoilers or only some of them?
It happens with all of them
I use a custom persona theme. Not sure if that will affect -
-
@Nicolas said in [nodebb-plugin-ns-spoiler] NS Spoiler:
How can I check this? (sorry for asking :()
@Nicolas said in [nodebb-plugin-ns-spoiler] NS Spoiler:
I have visited your link, but I can't see spoiler content, It's unauthorized request for me, I need to register.
It's because no spoiler content can be loaded. That's the error. When users press the spoiler button nothing happens.
-
Easiest test guys:
create a single post with only one spoiler, let's say content of the spoiler like this:
::: spoiler content :::
Three questions:
- Does it render properly your spoiler? It should have only a single button in the post.
- Inspect HTML of your post with a spoiler, what
index
do you see there?data-index
ofdiv.ns-spoiler
- 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:
- Does it render properly your spoiler? It should have only a single button in the post.
- Inspect HTML of your post with a spoiler, what
index
do you see there?data-index
ofdiv.ns-spoiler
- 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?
(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.
-
-
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.
-
-
@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?
-
@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, findnode_modules/nodebb-plugin-ns-spoiler/plugin/parser.js
, lines 11-25Parser.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?