# articles_helper.rb - a sample script for Ruby on Rails # # Copyright (C) 2005-2008 Masao Mutoh # # This file is distributed under the same license as Ruby-GetText-Package. # # ArticlesHelper is bound a textdomain which is bound in application.rb or # articles_controller.rb. # So you don't need to call bindtextdomain here. # module ArticlesHelper def show_article(article, show_link = true) ret = %Q[

#{article["title"]} (#{article["lastupdate"]})

#{article["description"]}
] if show_link ret += %Q[

#{link_to(_("Show"), :action => 'show', :id => article)}

] end ret end def show_list(articles) ret = "" articles.each_with_index do |article, index| ret << %Q[
  • #{article["lastupdate"]}: #{link_to((h article["title"]), :action => 'show', :id => article)}
  • ] break if index > 9 end ret end def show_navigation articles = Article.find(:all, :order => 'lastupdate desc, id desc') %Q[ ] end end