[nodebb-plugin-blog-comments] Blog Commenting Engine (Ghost, Wordpress widget)
-
@psychobunny said:
Not today. Ghost has a long way to go in terms of development - if you see their ACP you can tell that they are missing a lot. And more importantly, Ghost is currently single account only; they do not have multiple sign-ups yet.
When the time comes, I'm down for writing a deeper integration
Hi I'm new to the NodeBB and I'm interested in the current/future state of "ghost comments" integration?
I'm asking because multiple user support has been "finally" added this month to the Ghost 0.5The thing is I would like to design a theme for Ghost and NodeBB with this integration in mind
-
@Feomathar the problem right now is that the Ghost API isn't exactly finalized/available for public consumption (heck, there isn't even any official documentation available ), which may make things a bit difficult to implement/mantain.
@psychobunny, I forgot to ask if contributions to the plugin are welcome, so I just assumed that it being on GitHub and public means that I can spam you with PRs :shipit:
-
I have to look into the API, I haven't gotten up to speed with 0.5 just yet. As @fuzzmz says as well, I'm a little bit wary of jumping headfirst because I know I'm probably going to have to refactor things again a month from now
I forgot to ask if contributions to the plugin are welcome
If you're enjoying it I can even just give you the repo if you promise to continue developing on it but otherwise yeah of course contributions are welcome. Thanks for the new feature
-
Hi...
Its loading a url that doesnt exist
agiletesters . com . br/comments/get/7/0
i tried to change the plugin to get the url agiletesters.com.br / topic / 45 / get / 0 but it seems its looking for a topic id doesnt exist.. (embed.min.js)
( i got 2 posts.. one that had the comments working and the other that i didnt created the post on forum )
Any clues?
update.. crap.. cache..
and API problem on ghost{"type":"error","message":"Please Sign In","status":"passive"}
-
Right now the plugin doesn't work with Ghost's 0.5x but only 0.4x - I'll be looking into this later in the week but atm just a little bit busy with things Hopefully downgrading Ghost for now will help
-
Also looking into the Ghost 0.5 compatibility, but considering my knowledge of JS/NodeJS is pretty slim it might take some time. In any case, if I find anything I'll submit a pull request and update the thread here.
The problem comes mainly from the lack of an official Ghost API (well, it exists but not documented or officially released) so no bugs can be logged against it. For example, retrieving post information should be doable without having to authenticate as an admin, but right now it returns that error.
So far I've got a hackish solution to authenticating against the Ghost API and retrieving the token, but it involves hardcoded admin credentials. The next step is to pass that token as an auth header when asking for the post information.
I've got the source up on GitHub on the ghost_0.5_auth branch so any tips/info/PRs are welcome.
-
It looks like removing the authentication requirement for public Ghost endpoints finally appeared on their tracker (Remove authentication for public endpoints #4181), which means that at some point the comments plugin should work without any changes.
In the meantime, Ghost looks like it can be hacked to give a public route to the posts listing (haven't tested it yet - via this forum post):
- Edit
/ghost/core/server/routes/frontend.js
- Append
api = require('../api');
to the initial listing of required items. - Prepend
router.get('/api/public/posts/', api.http(api.posts.browse));
to the route listing - Restart Ghost
Then the comment plugin needs to be modified so that it uses the new API route to get the post information.
- Edit
-
This is exactly why I decided that I'm not going to look into this immediately I think it's an oversight on their end so I'll just wait for the dust to settle (they just released 0.5 not too long ago). Hopefully they will make those routes public, if they decide not to then I will update my plugin to authenticate
-
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