[nodebb-plugin-blog-comments] Blog Commenting Engine (Ghost, Wordpress widget)
-
@AOKP I am using the default Casper theme and I just copied the code from this post and implemented in the post.hbs right before the {{/post}} tag.
</aside> <a id="nodebb/comments"></a> <script type="text/javascript"> var nbb = {}; nbb.url = '//z0z0.me/comments'; // EDIT THIS (function() { nbb.articleID = '{{../post.id}}'; nbb.title = '{{../post.title}}'; nbb.tags = [{{#../post.tags}}"{{name}}",{{/../post.tags}}]; nbb.script = document.createElement('script'); nbb.script.type = 'text/javascript'; nbb.script.async = true; nbb.script.src = nbb.url + '/plugins/nodebb-plugin-blog-comments/lib/ghost.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(nbb.script); })(); </script> <script id="nbb-markdown" type="text/markdown">{{{../post.markdown}}}</script> <noscript>Please enable JavaScript to view comments</noscript> {{/post}}
-
@Peter-Zoltan-Keresztes try to insert it right after the share section.
-
@AOKP said:
@Peter-Zoltan-Keresztes try to insert it right after the share section.
reply
After a sleepless night where I have reinstalled everything. New VPS, new blog, new nodebb and I am back at square 1 where out of 15 posts only on 3 I was able to enable the comments. On rest I am getting in the logs the 31/12 08:10 [6749] - warn: [nodebb-plugin-blog-comments] Origin (undefined) does not match hostUrls: http://z0z0.me. It seam to me that nodebb cannot read the Origin header from most of the blog posts.
-
@Peter-Zoltan-Keresztes had the same in my logs though and it worked as I showed you yesterday.
-
Not sure what can I do. Right now I am using your exact same configs for node and ghost in nginx.
-
This post is deleted!
-
The latest updates fixed all the issues I had on enabling comments on most of the ghost blog posts.
-
Just a heads up for anyone else using this with Wordpress. After the latest update the categoryID variable in comments.php of your theme isn't optional. If it isn't defined publishing doesn't work.
-
Currently, I can't change the category id to another category. It's always posting to category id 1
-
@Hưng-Thành-Nguyễn are you using Wordpress or Ghost?
-
@overlawled
Hi, I'm using wordpress -
I did a integration between forum.mysensors.org and my new open hardware sharing site https://www.openhardware.io using parts of the blog-comments plugin to allow commenting on each project.
From the forum side: http://forum.mysensors.org/category/30/openhardware-io
And from openhardware: https://www.openhardware.io/view/4/EasyNewbie-PCB-for-MySensors#tab-commentsBut as we have to keep title/tags in forum in-sync with the open-hardware-site I had to create a new endpoint which besides creating, also updates the post each time someone published changes. The publishing/update request is sent from our backend.
Here is the interesting part of the code:
Comments.publishProject = function(req, res, callback) { var markdown = req.body.markdown, title = req.body.title, url = req.body.url, commentID = req.body.id, tags = req.body.tags, uid = xxx; if (req.body.token !== "XXXXXXXXXXXXXX") return res.json({error: "Unknown token"}); Comments.getTopicIDByCommentID(commentID, function(err, tid) { if (err || !tid) { var hostUrls = (meta.config['blog-comments:url'] || '').split(','), position = 0; hostUrls.forEach(function(hostUrl, i) { hostUrl = hostUrl.trim(); if (hostUrl[hostUrl.length - 1] === '/') { hostUrl = hostUrl.substring(0, hostUrl.length - 1); } if (hostUrl === req.get('origin')) { position = i; } }); var cid = meta.config['blog-comments:cid'].toString() || ''; cid = parseInt(cid.split(',')[position], 10) || parseInt(cid.split(',')[0], 10) || 1; topics.post({ uid: uid, title: title, content: markdown, tags: tags, req: req, cid: cid }, function(err, result) { //console.log(err); //console.log(err.stack); if (!err && result && result.postData && result.postData.tid) { posts.setPostField(result.postData.pid, 'blog-comments:url', url, function(err) { if (err) { return res.json({error: "Unable to post topic", result: result}); } db.setObjectField('blog-comments', commentID, result.postData.tid); res.redirect((req.header('Referer') || '/') + '#tabs-comments'); }); } else { res.json({error: "Unable to post topic", result: result}); } }); } else { topics.getMainPost(tid, uid, function(err, post) { if (err) return res.json({ok:false}); var payload = { title: title, uid: uid, pid: post.pid, content: markdown, tags: tags, options: { tags: tags } }; posts.edit(payload, function(err, returnData) { if (err) return res.json({ok:false}); //errorHandler.handle(err, res, returnData); res.json({ok:true}); }); }); } }); };
-
Just wanted to point out that there are compatibility issues with the ns-plugin-ns-points plugin. The following error is thrown when accessing any of the posts on Ghost
error: TypeError: Cannot read property 'uid' of undefined at nodebbpath/node_modules/nodebb-plugin-ns-points/app/filters.js:68:36
It worked once I disabled the points plugin.
-
@overlawled said:
Just a heads up for anyone else using this with Wordpress. After the latest update the categoryID variable in comments.php of your theme isn't optional. If it isn't defined publishing doesn't work.
@overlawled @Hưng-Thành-Nguyễn Could you try to set
var categoryID = 0;
orvar categoryID = null;
? Any falsy value should work. -
I have tried to use the plugin on multiple ghost platforms and it only works with the first blog entry. Anything special needs to be done?
-
Is anyone still using this plugin successfully on WordPress? Just having issues on my end, configured everything as noted in the readme, but am not even getting the "Publish Post to NodeBB" button to show in WordPress. @psychobunny @julian
-
Made a little progress by deactivating the recommended WordPress JSON API plugin and installing/activating Jetpack's JSON plugin. Also uninstalled then reinstalled the NodeBB Blog Comments plugin.
Now I'm seeing the "Publish Article to NodeBB" button, but when I hit it, I get the following error:
Internal error. Oops! Looks like something went wrong! /comments/publish Unexpected end of input
Any thoughts on where I should be looking for the missing
}
or whatever it could be? -
I've checked the syntax in several of the files, such as library.js, wordpress.js, and everything looks fine there. Still not sure where this error is originating. @psychobunny
-
@julian @psychobunny If anyone could even point me in the direction of any freelance NodeBB devs who would have experience with this plugin, I'd really appreciate it. Trying to get this working by this evening to meet a deadline. Thanks!
-
@psychobunny Has no one else experienced this error?
'''
Internal error.Oops! Looks like something went wrong!
/comments/publish
Unexpected end of input
'''