Module: Retter::Page::ViewHelper
- Includes:
- Stationery
- Defined in:
- lib/retter/page/view_helper.rb
Instance Method Summary collapse
- #article_path(*args) ⇒ Object
- #article_path_by_article(article) ⇒ Object
- #article_path_by_date_and_id(date, id) ⇒ Object
- #entry_path(*args) ⇒ Object
- #entry_path_by_date(date, id = nil) ⇒ Object
- #entry_path_by_entry(entry) ⇒ Object
- #render_disqus_comment_form(disqus_shortname = config.disqus_shortname) ⇒ Object
Instance Method Details
#article_path(*args) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/retter/page/view_helper.rb', line 18 def article_path(*args) case args.first when Date, Time article_path_by_date_and_id(*args) when Entry::Article article_path_by_article(args.first) else raise TypeError, "wrong argument type #{args.first.class} (expected Date, Time or Retter::Entry::Article)" end end |
#article_path_by_article(article) ⇒ Object
46 47 48 |
# File 'lib/retter/page/view_helper.rb', line 46 def article_path_by_article(article) article_path(article.entry.date, article.id) end |
#article_path_by_date_and_id(date, id) ⇒ Object
42 43 44 |
# File 'lib/retter/page/view_helper.rb', line 42 def article_path_by_date_and_id(date, id) date.strftime("/entries/%Y%m%d/#{id}.html") end |
#entry_path(*args) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/retter/page/view_helper.rb', line 7 def entry_path(*args) case args.first when Date, Time entry_path_by_date(*args) when Entry entry_path_by_entry(args.first) else raise TypeError, "wrong argument type #{args.first.class} (expected Date, Time or Retter::Entry)" end end |
#entry_path_by_date(date, id = nil) ⇒ Object
50 51 52 |
# File 'lib/retter/page/view_helper.rb', line 50 def entry_path_by_date(date, id = nil) date.strftime('/entries/%Y%m%d.html') + (id ? "##{id}" : '') end |
#entry_path_by_entry(entry) ⇒ Object
54 55 56 |
# File 'lib/retter/page/view_helper.rb', line 54 def entry_path_by_entry(entry) entry_path(entry.date) end |
#render_disqus_comment_form(disqus_shortname = config.disqus_shortname) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/retter/page/view_helper.rb', line 29 def render_disqus_comment_form(disqus_shortname = config.disqus_shortname) Haml::Engine.new("#disqus_thread\n :javascript\nvar disqus_shortname = '\#{disqus_shortname}';\n(function() {\n var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;\n dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';\n (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);\n})();\n HAML\nend\n").render |