Harry Seldon's blog

Psychohistory on Rails

Read

Typo plugins for "recent comments" and "related posts"

Posted by Harry Seldon on October 26, 2008

I have been using Typo for 3 months and I am enjoying it so far. So after 3 months, I want to dynamize my blog. An easy way is to show the recent comments in the sidebar. Fortunately there is a nice plugin to do that: recent_comments_sidebar. To install it, if you have Rails 2.1 or above, simply run:

script/plugin install git://github.com/fdv/recent_comments_sidebar.git

If you have Rails 2.0.2, get the code from github and copy it to your plugin folder.

Looking for the recent comments plugin, I found 2 other nice plugins: recentposts_sidebar and typo_related_posts. The first one allows you to show your recent posts in the sidebar.

script/plugin install git://github.com/fdv/recentposts_sidebar.git

The second one is really neat. It displays a list of related posts at the end of your post (or wherever you want). This list is generated using the tags. The install process is a little more involved.
You still need to get the plugin:

script/plugin install git://github.com/fdv/typo_related_posts.git 

Then you need to add the call to the plugin in your template. Generally in template/views/articles/read.html.erb, you just add: <%= render_related_posts %>. You add this typically at the end of the post. But you may also want to add it after the comments. Moreover, you might want to change the langage. In vendor/plugins/typo_related_posts/lib/typo_related_posts.rb, make this change (personalize according to your wishes, you are welcome to propose here something better):

#    html += '<h3>À lire également</h3>'
    html += '<h3>Read also</h3>'
#    html += '<p>Si cet article vous a intéressé, vous pouvez poursuivre votre lecture avec ces billets similaires :</p>'   
    html += '<p>If this article has interested you, we suggest you read these related posts:</p>'

One more thing, I needed to make this change in the previous file because the permalink was not created. I do not know why though.

#    html += "<li><a href='#{this_blog.base_url}#{article.permalink}'>#{article.title}</a></li>"
    html += "<li><a href='#{article.permalink_url}'>#{article.title}</a></li>"

This blog uses the 3 mentioned plugins. So you can see them here at work.

In case you use recent_comments_sidebar and recentposts_sidebar there is a little catch. Both names begin by recent and at some point typo creates an id named recent. In the admin interface this prevents you from moving the recentposts plugin from the plugin list to the used plugin list. To solve this bug, in vendor/plugins/recentposts_sidebar/lib/recentposts_sidebar.rb, simply rename the class RecentPostsSidebar to LastPostsSidebar and change the call accordingly in init.rb.

While you are on github/fdv, have a look and browse for other plugins of your interests.

For info, the move of typo to github is very recent, see this post (in French) from Frederic De villamil.

Thanks Fred for Typo and all these neat plugins.

Posted in | no comments | Tags , , , , | atom

Delicious Add to Technorati Favorites Slashdot Sphere: Related Content

Trackbacks

Use the following link to trackback from your own site:
http://harryseldon.thinkosphere.com/trackbacks?article_id=typo-plugins-for-recent-comments-and-related-posts&day=26&month=10&year=2008

Comments

Leave a response

Leave a comment

Markdown enabled

Search