Discourse on Kirby?

I’ve seen Discourse threads displayed on otherwise “standard” html pages. Has anyone worked on integrating Discourse threads in a Kirby context? For instance, to display the the comments on a blog post?

I’ve just located http://eviltrout.com/2014/01/22/embedding-discourse.html. Gonna try and do some research in this direction.

I think all you really have to do is to copy the js code and add it to your article template for blog posts. There’s nothing to worry about on Kirby’s end.

Be advised, Discourse forwards your users to your Discours forum; users can not add a comment on the actual blog page.

I think, this would be very confusing for most of your users. At least it is for me :disappointed:

That’s true!! It would at least need some kind of explanation. While I really like Discourse for the forum, I’m not sure how well it would work for blog comments. There’s also no way to import old comments from something like Disqus as it seems. I was thinking about adding it to the Kirby blog, but those reasons kept me from doing it so far.

@takaminacchan I’m looking for a self hosted commenting solution by myself for several months now.

If you need only commenting you could try https://muut.com/ ‹— Free, but hosted solution. Or, for a self hosted solution http://vanillaforums.org/. Vanilla seems to be a great—and free—forum.

They have some addons for commenting/blogging:

1. http://vanillaforums.org/addon/articles-application
2. http://vanillaforums.org/addon/nillablog-plugin

I’m not sure how they work exactly; I haven’t tried any of them.

Vanilla is available as a hosted solution too

http://vanillaforums.com/

The hosted version supports blog commenting out of the box:

http://blog.vanillaforums.com/help/use-vanilla-comments-without-wordpress/#more-7573

PS: Wasn’t allowed to post more then two links :smile:

I’m trying to work with Discourse because I’m trying to create a community around my site, and Discourse really seems excellent on that regard. I’ve grabbed a droplet at Digital Ocean ($20 a month), it works like a charm so far - now to get the embedding to work exactly the way I want it to work (shouldn’t be hard, I just haven’t had time to work on it yesterday).

I will definitely need to explain the whole “you need to go to the forum to comment” thing, yup… but it seems appropriate.

EDIT: Actually, not sure it’s this trivial. I’ve embedded the js code (after some modifications to get the pointers to aim at the right URLs, at least supposedly), but so far nothing is coming up except a blank space that wastn’t there before. Example here: http://beckyverse.com/writing/the-edgarverse-chronicles/star-eater (the discourse-comments div is just above the credits section).

Should I try and create an RSS flux, or is there something else I’m missing?

SECOND EDIT: Doesn’t look like it’s working, even with an RSS feed. I’m pretty unexperienced when it comes to RSS though, so maybe that’s just me not being efficient.

Feed is here: http://beckyverse.com/feed

I’m at a loss about where to dig next…

You’re adding a JS script to your page, so your best bet is looking at the browser console, to see a) if the script runs and b) if yes, at which point it fails. Your first place to look would be the browser’s console, looking for:

  • syntax errors
  • JS exceptions
  • security warnings

And if there’s nothing there, looking at the network requests (in the Chrome/Firefox devtools as well). To see if a request for your post’s comments is actually going out, what the response is, etc.

Turns out you have a cross-domain security issue:

Load denied by X-Frame-Options: talk.domain.tld/embed/comments?embed_url=http%3A%2F%2Fbeckyverse.com%2Fwriting%2Fthe-edgarverse-chronicles%2Fstar-eater does not permit cross-origin framing.

Looking at the page’s DOM, the script added an <iframe>, but your talk.domain.tld subdomain is not configured to allow embedding on different origins (domains or subdomains). It’s probably a security option that you have to enable, so that talk.yourdomain.tld (aka your Discourse site) sends the right X-Frame-Options header.

(I can’t tell what the right values for X-Frame-Options are, perhaps that’s in the Discourse doc somewhere, or you will have to search a bit.)

@fvsch Thanks for the tips! Upon investigating, I found out there was an option meant to help with CORS, which apparently is the name of what I’m trying to do. It’s documented here: https://meta.discourse.org/t/how-to-enable-cross-origin-resource-sharing-with-docker/15413 .

I have rebuilt my Discourse server after updating the app.yml file, so I… suppose that part of the issue has been solved (at least, it should be fine on Discourse’s end?).

Unfortunately, still doesn’t work as intended and I’m not sure how to read or react to the error I’m getting.

At the current time, I’m getting this: https://www.dropbox.com/s/om1oywqb7ls7jq3/Screenshot%202015-03-09%2021.01.13.png?dl=0 . I’m not sure whether this means CORS is still being blocked (possibly not at the same point than before), or something else entirely.

EDIT: Turns out I didn’t manage to fix CORS. Gonna investigate further in this direction.

EDIT 2: I found this conversation (https://meta.discourse.org/t/x-frame-options-sameorigin-header-prevents-embedding/14928) and this allowed me to progress with my error message (I think). The line “X-Frame-Options” now displays “ALLOWALL” instead of “SAMEORIGIN” (https://www.dropbox.com/s/x4zhh6md4znqgs7/Screenshot%202015-03-10%2010.21.34.png?dl=0). I assume this should mean cross-origin framing to be allowed now?

… But I’m still getting 403. Biggest problem is I’m not sure how to read the error messages (@fvsch, where exactly did you find the “Load denied by X-Frame-Options” line in the log?), so I don’t know where to try and search to advance more.

I got that line in the Firefox console (Ctrl+Shift+K).

I don’t know anything about CORS so I can’t tell your more. But in any case your Discourse instance is still responding with a 403 to the request, so Discourse is still disallowing embedding. It’s probably something you have to configure.

Also that “ALLOWALL” value does not seem standard, or useful: http://ipsec.pl/web-application-security/2013/mess-x-frame-options-allowall.html

Okay, nevermind, the error had nothing to do with CORS.

When setting up a Discourse instance as a comments engine, it’s vital that the embeddable_host setting is correct as is discussed here.