Module: ArticlesHelper
- Defined in:
- app/helpers/articles_helper.rb
Instance Method Summary collapse
- #article_url(article) ⇒ Object
- #format_date(time) ⇒ Object
- #format_time(time) ⇒ Object
- #html_transform(text) ⇒ Object
- #link_to_archive(archive_month) ⇒ Object
- #link_to_article(article, options = {}) ⇒ Object
- #url_escape(string) ⇒ Object
Instance Method Details
#article_url(article) ⇒ Object
26 27 28 |
# File 'app/helpers/articles_helper.rb', line 26 def article_url(article) blog_article_url :permalink => article.slug, :year => article.date.year, :month => article.date.month, :day => article.date.day end |
#format_date(time) ⇒ Object
9 10 11 |
# File 'app/helpers/articles_helper.rb', line 9 def format_date(time) time.strftime("%B %d %Y") end |
#format_time(time) ⇒ Object
13 14 15 |
# File 'app/helpers/articles_helper.rb', line 13 def format_time(time) time.strftime("%I:%m%p") end |
#html_transform(text) ⇒ Object
5 6 7 |
# File 'app/helpers/articles_helper.rb', line 5 def html_transform(text) RDiscount.new(text.to_s).to_html.html_safe end |
#link_to_archive(archive_month) ⇒ Object
17 18 19 20 |
# File 'app/helpers/articles_helper.rb', line 17 def link_to_archive(archive_month) text = "#{Date::MONTHNAMES[archive_month.last.to_i]} #{archive_month.first.to_i}" link_to text, blog_articles_archive_url(:year => archive_month.first, :month => archive_month.last.to_s.rjust(2, '0')) end |
#link_to_article(article, options = {}) ⇒ Object
22 23 24 |
# File 'app/helpers/articles_helper.rb', line 22 def link_to_article(article, = {}) link_to h(article.title), article_url(article), end |
#url_escape(string) ⇒ Object
30 31 32 33 34 |
# File 'app/helpers/articles_helper.rb', line 30 def url_escape(string) string.gsub(/([^ a-zA-Z0-9_.-]+)/n) do '%' + $1.unpack('H2' * $1.size).join('%').upcase end.tr(' ', '+') end |