[nodebb-plugin-blog-comments] Blog Commenting Engine (Ghost, Wordpress widget)
-
@psychobunny, excellent work. This makes my intended usage schema perfect.
-
It's strange, I can't get this to work with Ghost as it seems that they changed the way the API works. The placeholder API documentation says that it should return posts with status published for calls with NoAuth.
I am stuck on the "sign in to Ghost to enable the publish button." page.
The GET call to
/ghost/api/v0.1/posts/22/
returns a 401 Unauthorized, with the response{"type":"error","message":"Please Sign In","status":"passive"}
In the meantime I opened an issue on the nodebb-plugin-blog-comments Git repo as well as submitting a pull request to enable protocol relative links in the comment embed scripts to stop displaying mixed content warnings when the blog is served via https.
-
afaik, I've always had to be signed in to publish. I'm assuming that if you're signed in it does work? thanks for the PR btw
EDIT: nvm, read your issue, I guess this is a problem on our end then - time to upgrade our blog to v0.5
-
@psychobunny the problem is that I am signed in when that message appears. Going to spin up an instance of Ghost 0.4 (the same that you're using on the nodeBB blog) and try that. From what I see the API responses have changed between 0.4 and 0.5 (which I'm currently running).
-
yeah, looks like it might be an easy fix actually
-
@psychobunny glad to hear that.
I also stumbled upon a bug when testing with that Ghost v0.4 instance. If you delete the thread in the NodeBB instance the blog embedded comments section still thinks it has a thread in which to post comments. Any way to manually unlink the two after purging a thread from the forum that is linked to a blog post?
-
@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 ?