What we're listening to:
Jared

The Album Leaf:
Into The Blue Again
Jeff

Paper Route:
Absence

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.

  1. 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
  2. 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>
  3. 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.

Recently I’ve been evaluating refinerycms for a few client projects that it seemed suited for, and I really like that while it’s not always 100% what I want, it’s very easy to modify to get it to where I need it.

Here’s an example: My site needs a main nav to link offsite in a new window by adding target=”_blank” to the link, which is not handled out of the box by refinery.  So I copied vendor/refinery/app/views/shared/_menu_branch.html.erb into my theme directory to override the functionality and modified line 11 to the following:

<%= link_to menu_branch.title, menu_branch.url, \
:target => menu_branch.url.include?("http://") ? "_blank" : "" %>

Now any link containing http:// is automatically given a blank target. Presto.

getting git

October 15th, 2008

I’ve been hesitant to explore git since subversion was (I thought) really handling all my needs just fine. Why waste time learning another version control workflow?

Over time, I started to realize there were things about git that would be really nice, like nice branching and merging in particular, but I thought, that’s for some day when I have time to learn it, or my pain becomes too great with branches (which I don’t use that often in svn).

Just a couple days ago I needed to extend some code that was hosted on github, so I forked it, cloned it, and just started to work. In that process I’m discovering things that are just making git start to click. Whoops, didn’t mean to commit that yet: git-reset. I need to pull in some other changes, but can’t yet because I have uncommitted changes: git-stash.

Combined with the git bundle for textmate, I’m actually having fun learning git.

Moral: Try new stuff (in a real-life scenario), it’s fun and can make your life better.