Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

javascript to embed comments from discourse forum #335

Merged
merged 2 commits into from
Jun 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ teaser : # filename of teaser fallback teaser image placed in
# breadcrumbs : false # true, false (default)
words_per_minute : 200
comments:
provider : # false (default), "disqus", "facebook", "google-plus", custom"
provider : # false (default), "disqus", "discourse", "facebook", "google-plus", custom"
disqus:
shortname : # https://help.disqus.com/customer/portal/articles/466208-what-s-a-shortname-
discourse:
server : # https://meta.discourse.org/t/embedding-discourse-comments-via-javascript/31963 , e.g.: meta.discourse.org
facebook:
# https://developers.facebook.com/docs/plugins/comments
appid :
Expand Down
14 changes: 14 additions & 0 deletions _includes/comments-providers/discourse.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% if site.comments.discourse.server %}
{% include base_path %}
{% capture canonical %}{{ base_path }}{% if site.permalink contains '.html' %}{{ page.url }}{% else %}{{ page.url | remove:'index.html' | strip_slash }}{% endif %}{% endcapture %}
<script type="text/javascript">
DiscourseEmbed = { discourseUrl: '//{{ site.comments.discourse.server }}/',
discourseEmbedUrl: '{{ canonical }}' };
(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 comments powered by [Discourse](http://forum.beta-europe.org/c/beta/website).</a></noscript>
{% endif %}
2 changes: 2 additions & 0 deletions _includes/comments-providers/scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
{% case site.comments.provider %}
{% when "disqus" %}
{% include /comments-providers/disqus.html %}
{% when "discourse" %}
{% include /comments-providers/discourse.html %}
{% when "facebook" %}
{% include /comments-providers/facebook.html %}
{% when "google-plus" %}
Expand Down