[nodebb-plugin-blog-comments] Blog Commenting Engine (Ghost, Wordpress widget)
-
Haha I'm sure they have more important things to worry about at the moment. But keeping track of their progress and am liking what I see so far
-
Hey @psychobunny, should the plugin work with v0.5.1 of NodeBB? Was currently testing with a modified version of Ghost so that I could have public API access to the posts data, but it seems that every time the comments/get/:postid/0 query hits my NodeBB instance it crashes and restarts it.
The main problem I have is that it's running on a OpenShift gear, which means that logging isn't really available (that or I can't seem to configure it properly).
-
Ok, I managed to get the comments plugin working by hacking around Ghost and the plugin itself.
Please note though that Ghost has changed the way the JSON output of a post query is formed, so the plugin can't work (even with auth) until it gets updated to account for that. I have opened #17 - Ghost post JSON changed breaking comment publish.
The hackish workaround implies modifying both Ghost so we can have public access to the posts API and we get back the format understood by the comments plugin, as well as modifying the plugin to use the new public API URL.
- Hacking Ghost
==============
In order to expose the JSON post information we need to modify two files:
- /core/server/api/posts.js
- /core/server/routes/frontend.js
posts.js - find the
read: function read(options) {
block (it should start around line 72) and duplicate it making the following changes:- change the function declaration from
read: function read(options) {
toreadN: function readN(options) {
- change the return value from
return {posts: [result.toJSON()]};
toreturn result.toJSON();
You can see how the change looks by going here. This will return the post info in JSON format which can then be consumed by the comments plugin.
frontend.js - the following changes must be made so the new API call we wrote in posts.js gets exposed without having to authenticate.
- under the
utils = require('../utils'),
line at the begining of the file we must addapi = require('../api'),
- before
return router;
addrouter.get('/api/public/posts/:id', api.http(api.posts.readN));
How the file should look can be seen here. Now going to http://your_blog/api/public/posts/1 for example will show you the post information in JSON format even without being logged to the Ghost blog.
- Modifying nodebb-plugin-blog-comments
===================================
We now must modify the comments plugin to use the new API we just created at step 1.
To do this we simply edit the
/public/lib/embed.js
file and changeadminXHR.open('GET', '/ghost/api/v0.1/posts/' + articleID);
toadminXHR.open('GET', '/api/public/posts/' + articleID);
The only change required is to update the embed code in the
posts.hbs
file to useembed.js
instead ofembed.min.js
.To do this we replace
nbb.src = nodeBBURL + '/plugins/nodebb-plugin-blog-comments/lib/embed.min.js';
withnbb.src = nodeBBURL + '/plugins/nodebb-plugin-blog-comments/lib/embed.js';
And that's it, you should now have NodeBB comments running on your Ghost v0.5.x blog.
- Hacking Ghost
-
@psychobunny
The plugin is not compatible with 0.5.3-dev
Uncaught TypeError: Cannot read property 'prepare' of undefined
In cause :require(['forum/admin/settings'], function(Settings) { Settings.prepare(); });
Maybe it's because of the new admin panel, settings were moved ?
-
suggestions:
-option to only show comments with at least x number of upvote/favorite
-or way to filter comments and not show all of them in blog -
I am using Ghost v0.5.8 and the required APIs that this plugin expects are not publicly accessible, my workaround was to monkey-patch the embed.js script in a very ugly hackish way, basically removing the ajax calls to the API and using a simple markdown with just the link to the post as the initial topic post on nodeBB, here is the gist:
https://gist.github.com/fczuardi/72a5103b5c1f0ba87eb3
if (data.isAdmin) { //var adminXHR = newXHR(); //adminXHR.open('GET', '/ghost/api/v0.1/posts/' + articleID); //adminXHR.onload = function() { //if (adminXHR.status >= 200 && adminXHR.status < 400) { //var articleData = JSON.parse(adminXHR.responseText), //markdown = articleData.markdown.split('\n\n').slice(0,2).join('\n\n') + '\n\n**Click [here]('+articlePath+') to see the fu$ var markdown = '\n\n**Click [here]('+articlePath+') to see the full blog post**'; var title = $('.post-title').text(); document.getElementById('nodebb-content-markdown').value = markdown; document.getElementById('nodebb-content-title').value = title; //document.getElementById('nodebb-content-title').value = articleData.title; //} else { //nodebbDiv.innerHTML = 'Welcome ' + data.user.username + ', <a href="/ghost">sign in to Ghost</a> to enable the publish button.</a>$ //} //} //adminXHR.send(); }
The file lives under
nodebb/node_modules/nodebb-plugin-blog-comments/public/lib/embed.js
I've also made a blog post in Portuguese about how to install NodeBB and this plugin to be the comments system of a Ghost blog.
The solution is not clean, you have to go through all your posts and click the green button to make the initial topics on nodeBB, displaying an error json in the browser (but the thread is created anyways) and nodeBB will crash almost every time you create the new topics, but all this hassle is hopefully one-time-per-post only, so it is something I can live with for now.
I suggest people waiting for the clean solution to subscribe to the Ghost bug https://github.com/TryGhost/Ghost/issues/4181 and the nodebb-plugin-blog-comments bug https://github.com/psychobunny/nodebb-plugin-blog-comments/issues/17 to track the updates, or even beter, to submit a nice pull request to this plugin.
-
Which is the last compatible version from ghost that can manage the plugin?
-
I've just released v0.3.0 of this plugin:
- Fixed quite a few server crashes (especially when publishing)
- Compatible with NodeBB 0.6x+ and Ghost 0.5.10
- Added tags support for Ghost
EDIT: Updated OP
-
@psychobunny
I've recently upgraded to NodeBB V0.8.0 and I encounter a wordpress comment plugins problem.
When I'm on wordpress, I still can view comments and respond to them, no problem, but when I created a new blog entry and wanted to create the entry on nodeBB but when I click on the button "Publish This Article to NodeBB" I got
{"error":"unable to post topic"} in browser return page
Do you think this can come from V0.8.0 update ?
thanks for your help -
Can you post the error on nodebb server?
-
@psychobunny
I launched./nodebb dev
but once launched it does not give me any error as soon as I click on publish button in wordpressI put the full trace in case (and yes once started I clicked to publish ;-))
NodeBB v0.8.0 Copyright (C) 2013-2014 NodeBB Inc. This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. For the full license, please visit: http://www.gnu.org/copyleft/gpl.html Clustering enabled: Spinning up 1 process(es). 2/9 13:11 [11619] - info: Time: Wed Sep 02 2015 13:11:29 GMT+0200 (CEST) 2/9 13:11 [11619] - info: Initializing NodeBB v0.8.0 2/9 13:11 [11619] - verbose: * using configuration stored in: /usr/local/share/nodebb/config.json 2/9 13:11 [11619] - verbose: * using redis store at 127.0.0.1:6379 2/9 13:11 [11619] - verbose: * using themes stored in: /usr/local/share/nodebb/node_modules 2/9 13:11 [11619] - verbose: Checking dependencies for outdated modules 2/9 13:11 [11619] - verbose: [notifications.init] Registering jobs. 2/9 13:11 [11619] - info: [themes] Using theme nodebb-theme-persona 2/9 13:11 [11619] - verbose: [plugins] Initializing plugins system 2/9 13:11 [11619] - verbose: [plugins] Found 1 less file(s) for plugin nodebb-plugin-composer-default 2/9 13:11 [11619] - verbose: [plugins] Found 10 js file(s) for plugin nodebb-plugin-composer-default 2/9 13:11 [11619] - verbose: [plugins] Loaded plugin: nodebb-plugin-composer-default 2/9 13:11 [11619] - verbose: [plugins] Found 1 less file(s) for plugin nodebb-plugin-markdown 2/9 13:11 [11619] - verbose: [plugins] Found 2 js file(s) for plugin nodebb-plugin-markdown 2/9 13:11 [11619] - verbose: [plugins] Loaded plugin: nodebb-plugin-markdown 2/9 13:11 [11619] - verbose: [plugins] Found 1 less file(s) for plugin nodebb-plugin-mentions 2/9 13:11 [11619] - verbose: [plugins] Found 1 js file(s) for plugin nodebb-plugin-mentions 2/9 13:11 [11619] - verbose: [plugins] Loaded plugin: nodebb-plugin-mentions 2/9 13:11 [11619] - verbose: [plugins] Found 1 css file(s) for plugin nodebb-widget-essentials 2/9 13:11 [11619] - verbose: [plugins] Loaded plugin: nodebb-widget-essentials 2/9 13:11 [11619] - verbose: [plugins] Found 1 js file(s) for plugin nodebb-rewards-essentials 2/9 13:11 [11619] - verbose: [plugins] Loaded plugin: nodebb-rewards-essentials 2/9 13:11 [11619] - verbose: [plugins] Loaded plugin: nodebb-plugin-soundpack-default 2/9 13:11 [11619] - verbose: [plugins] Found 1 js file(s) for plugin nodebb-plugin-google-analytics 2/9 13:11 [11619] - verbose: [plugins] Loaded plugin: nodebb-plugin-google-analytics 2/9 13:11 [11619] - verbose: [plugins] Loaded plugin: nodebb-plugin-emailer-ssl-smtp 2/9 13:11 [11619] - verbose: [plugins] Found 1 js file(s) for plugin nodebb-plugin-blog-comments 2/9 13:11 [11619] - verbose: [plugins] Loaded plugin: nodebb-plugin-blog-comments 2/9 13:11 [11619] - verbose: [plugins] Loaded plugin: nodebb-plugin-dbsearch 2/9 13:11 [11619] - verbose: [plugins] Found 1 less file(s) for plugin nodebb-plugin-custom-pages 2/9 13:11 [11619] - verbose: [plugins] Found 1 js file(s) for plugin nodebb-plugin-custom-pages 2/9 13:11 [11619] - verbose: [plugins] Loaded plugin: nodebb-plugin-custom-pages 2/9 13:11 [11619] - verbose: [plugins] Loaded plugin: nodebb-plugin-gravatar-extended 2/9 13:11 [11619] - verbose: [plugins] Found 1 less file(s) for plugin nodebb-plugin-spam-be-gone 2/9 13:11 [11619] - verbose: [plugins] Found 1 js file(s) for plugin nodebb-plugin-spam-be-gone 2/9 13:11 [11619] - verbose: [plugins] Loaded plugin: nodebb-plugin-spam-be-gone 2/9 13:11 [11619] - verbose: [plugins] Loaded plugin: nodebb-plugin-sso-github 2/9 13:11 [11619] - warn: [plugins/nodebb-plugin-sso-google] Hook `filter:user.delete` is deprecated, please use an alternative 2/9 13:11 [11619] - verbose: [plugins] Loaded plugin: nodebb-plugin-sso-google 2/9 13:11 [11619] - warn: [plugins/nodebb-plugin-sso-facebook] Hook `filter:user.delete` is deprecated, please use an alternative 2/9 13:11 [11619] - verbose: [plugins] Found 1 js file(s) for plugin nodebb-plugin-sso-facebook 2/9 13:11 [11619] - verbose: [plugins] Loaded plugin: nodebb-plugin-sso-facebook 2/9 13:11 [11619] - warn: [plugins/nodebb-plugin-sso-twitter] Hook `filter:user.delete` is deprecated, please use an alternative 2/9 13:11 [11619] - verbose: [plugins] Loaded plugin: nodebb-plugin-sso-twitter 2/9 13:11 [11619] - verbose: [plugins] Found 4 js file(s) for plugin nodebb-theme-persona 2/9 13:11 [11619] - verbose: [plugins] Loaded plugin: nodebb-theme-persona 2/9 13:11 [11619] - warn: [plugins/load] The following plugins may not be compatible with your version of NodeBB. This may cause unintended behaviour or crashing. In the event of an unresponsive NodeBB caused by this plugin, run `./nodebb reset -p PLUGINNAME` to disable it. * nodebb-plugin-emailer-ssl-smtp * nodebb-plugin-blog-comments * nodebb-plugin-custom-pages * nodebb-plugin-gravatar-extended * nodebb-plugin-spam-be-gone 2/9 13:11 [11619] - info: [plugins] Plugins OK 2/9 13:11 [11619] - verbose: [meta/css] Minifying LESS/CSS 2/9 13:11 [11619] - verbose: [sounds] Sounds OK 2/9 13:11 [11619] - verbose: [meta/templates] Compiling templates 2/9 13:11 [11619] - verbose: [meta/js] Minification complete 2/9 13:11 [11619] - verbose: [meta/js] Client-side minfile committed to disk. 2/9 13:11 [11619] - verbose: [meta/templates] Successfully compiled templates. 2/9 13:11 [11619] - verbose: [meta/css] admin.css committed to disk. 2/9 13:11 [11619] - info: NodeBB Ready 2/9 13:11 [11619] - info: Enabling 'trust proxy' 2/9 13:11 [11619] - info: NodeBB is now listening on: 0.0.0.0:4567 2/9 13:11 [11619] - info: [plugins/spam-be-gone] Settings loaded 2/9 13:11 [11619] - verbose: [hotswap] Router with id `plugins` replaced successfully 2/9 13:11 [11619] - verbose: [plugins] All plugins reloaded and rerouted 2/9 13:11 [11619] - verbose: [meta/css] stylesheet.css committed to disk. 2/9 13:11 [11619] - verbose: [hotswap] Router with id `auth` replaced successfully
the browser windows is
hope this help
-
Anyway, as a temp solution, I digged into the code but was unable to find what I needed, so maybe you can help me.
I wanted to try this (sure it should works)- I Create a new post on my nodebb forum and I get the database postID
- I create a new Blog article on my wordpress forum and get ArticleID
Where do I put the link between both (I can do it manually inserting value in database), I think I just need to put NodeBB postID in wordpress database (near it's ArticleID), but I didn't found where. Any ideas ?
oH, just to let you know, my wordpress blog and my nodebb community are hosted on same VM (not same fqdn)
Thks
-
@psychobunny
Oh, got a workaround, I really need to sleep more than 4 hours a night, the table was in front of my eyes it's in nodeBB database tableblog-comments
, just needed to add into this a new entry with key='blog post ID' and value='NodeBB topic ID'In Wordpress database I get the post ID going to admin panel/posts then leaving the mouse on post link and looking the link in browser status bar
or with this mysql query on wordpress database to list them allSELECT post_date, ID, post_title, guid, post_status, post_type FROM wp_posts WHERE post_parent=0 ORDER BY `post_date` DESC
To find the NodeBB topic number into NodeBB, just create a topic then in Forum then find the post in the forum and leave the mouse on post link and looking the link in browser status bar
I've done it with Redis Desktop Mananager
In case it can help
-
Experiencing this issue on Wordpress as well.
-
@overlawled
Not sure if the problem comes from NodeBB upgrade or wordpress upgrade. Would be cool to have this fixed -
Is it related to this issue?
https://github.com/psychobunny/nodebb-plugin-blog-comments/issues/20
I haven't used WP in a while so I'm not up to date with their changes. If not can you submit another issue?