For adding a blog to your refinery site, there’s pretty much only one option: the refinerycms-blog plugin. Fortunately like most refinery things, it’s pretty easy to customize.
I wanted to use DISQUS to moderate the comments on this particular blog, and here’s how I did it (You obviously need a DISQUS account to do this). If a file referred to doesn’t exist, copy it from vendor/plugins/app/views/blogs to your theme directory.
- Remove the old comment form:
themes/mysite/views/blogs/show.html.erb
remove the render “_form” line since we don’t need a comment form anymore
- Add the Disqus embed code
themes/mytheme/views/blogs/_comments.html.erb
Replace everything in this file with the disqus embed code, replace mysite below with your disqus shortname.
<div id='comments'>
<div id="disqus_thread"></div>
<script type="text/javascript">
var disqus_identifier = "<%= @blog.permalink %>";
<%= "var disqus_developer = 1;" if local_request? %>
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://mysite.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript=mysite">comments powered by Disqus.</a></noscript>
</div>
- Add the disqus comment counter code
/themes/mysite/views/blogs/index.html.erb
Change line 16 to:
<%= link_to 'Read more', blog_post_url(blog.permalink)+"#disqus_thread" -%>
Put this somewhere near the bottom:
<% content_for :footer do -%>
<script type="text/javascript">
//<![CDATA[
(function() {
var links = document.getElementsByTagName('a');
var query = '?';
for(var i = 0; i < links.length; i++) {
if(links[i].href.indexOf('#disqus_thread') >= 0) {
query += 'url' + i + '=' + encodeURIComponent(links[i].href) + '&';
}
}
document.write('<script charset="utf-8" type="text/javascript" src="http://disqus.com/forums/poetrybooths/get_num_replies.js' + query + '"></' + 'script>');
})();
//]]>
</script>
<% end -%>
/themes/mysite/views/shared/_footer.html.erb
add <%= yield :footer %> to your footer file so our comment counter javascript gets placed there.
Pretty easy.