Sommerregen / grav-plugin-jscomments

JSComments is a Grav (http://github.com/getgrav/grav) plugin which allows to integrate comments into individual pages from Discourse / Disqus / Facebook / Google+ / HyperComments / IntenseDebate / Isso, and Muut comment systems.
Other
29 stars 9 forks source link

Open-source comment engines #12

Closed zeigerpuppy closed 6 years ago

zeigerpuppy commented 7 years ago

Would it be possible to integrate an open-source comment engine? Two that seem promising are:

This would be a fantastic addition, happy to test if I have some tips on how to integrate!

Sommerregen commented 7 years ago

Hi @zeigerpuppy ,

as long as a specific service provides an API or a javascript file to embed them, it is not a problem to integrate. However documentation for Flarum is rare. I've found one here https://discuss.flarum.org/d/2317-how-to-use-flarum-ext-embed/ . For Talkative I've found an example here https://github.com/talkatv/talkatv/blob/master/examples/talkatv-test/index.html .

Do you know better ones? Can you test them and report your findings back here?

zeigerpuppy commented 7 years ago

I'm trying with self-install of discourse currently. I have it installed and working but when I configure and insert {{ jscomments() }} in a page, all I can see is a link to https://www.discourse.org/ and the text Blog Comments powered by Discourse. I have set the URL of my discourse server, am I missing a setting to get it to direct to my server?

Sommerregen commented 7 years ago

@zeigerpuppy From your description it seem that the URL you provided is wrong. Did you set providers.discourse.host? It must be the domain root of the discourse server.

You may also check the set URL here https://github.com/Sommerregen/grav-plugin-jscomments/blob/develop/templates/plugins/jscomments/discourse.html.twig#L15 . That's the Twig template file discourse.html.twig to be used for this comment provider.

zeigerpuppy commented 7 years ago

Hi @Sommerregen,

Thanks for the details. I have set the URL of the discourse server in providers.discourse.host. The discourse server is set as a private server, I wonder if this may be a problem? I'd be happy to share the URLs by private message if that helps.

zeigerpuppy commented 7 years ago

I had a look at the page source rendered by the plugin and it looks like something is getting mangled in the html links.

In the example below, the grav instance is on https://grav.myserver.net and the discourse forum is on https://forum.myserver.net

<div id="jscomments">
  <div id="discourse-comments"></div>

  <script type="text/javascript">
    var DiscourseEmbed = {
      discourseUrl: 'https\x3A\x2F\x2Fforum.myserver.net\x2F',
      discourseEmbedUrl: 'http\x3A\x2F\x2Fgrav.myserver.net\x2Fblog\x2Ftheme\x2Dsetup'
    };

    (function() {
      var d = document.createElement('script'); d.type = 'text/javascript'; d.async = true;
      d.src = DiscourseEmbed.discourseUrl + 'javascripts/embed.js';
      (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);
    })();
  </script>
  <noscript>Please enable JavaScript to view the <a href="https://www.discourse.org/" rel="nofollow">comments powered by Discourse.</a></noscript>
  <a href="https://www.discourse.org/" rel="nofollow">Blog Comments powered by <span>Discourse</span>.</a>
</div>
zeigerpuppy commented 7 years ago

I tried inserting the javascript directly in the post, but the comments show up as an empty block. I think I may have found the error, however:

Refused to display 'https://forum.myserver.net/embed/comments?embed_url=https%2F%2Fgrav.myserver.net%2Fblog%2Ftheme-setup' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'. 

Looks like the old X-Frame-Options issue!

zeigerpuppy commented 7 years ago

OK, I managed to fix it (mostly)

I fixed some X-Frame options in the apache reverse proxy and the plugin is working well now.

Now the only issue is that discourse is serving some URLs as http but I think that can be resolved fairly easily.

see here for the https issue: https://meta.discourse.org/t/force-https-for-login-url/53554

edit: this is solved by enabling the "force https" option in the discourse settings. Search for "use https" in the settings.

Sommerregen commented 7 years ago

@zeigerpuppy Soory, forgot to respond here. Glad you found it out. It seems a really tricky issue. Maybe this is worth a PR to be added in the README.md?

Legend23 commented 7 years ago

Hello, i'm using it in Grav CMS, and sadely the plugin work fine only with disqus, i would like to use Facebook plugin (i put my Facebook API on the settings).

Sommerregen commented 7 years ago

Hi @Legend23 ,

first can you open a new issue, because your problem is not related with this thread? Secondly, can you provide information (what are your settings, Grav version etc.)? I know that all comment engines are working, because I tested them. Please let me know what you did.

Thanks.

Sommerregen commented 7 years ago

Memo:

UPDATED:

efeefe commented 4 years ago

@zeigerpuppy I know this thread is some years old, but could you share more about your solution? I'm getting a similar problem nowadays.