Module: Admin::BaseHelper
- Defined in:
- app/helpers/admin/base_helper.rb
Instance Method Summary collapse
- #editor_class_for(content) ⇒ Object
- #link_to_profile(options = {}) ⇒ Object
-
#page_cached_at(page) ⇒ Object
FIXME: translations.
- #save_or_cancel_links(builder, options = {}) ⇒ Object
Instance Method Details
#editor_class_for(content) ⇒ Object
39 40 41 |
# File 'app/helpers/admin/base_helper.rb', line 39 def editor_class_for content "big wysiwyg" end |
#link_to_profile(options = {}) ⇒ Object
20 21 22 23 24 |
# File 'app/helpers/admin/base_helper.rb', line 20 def link_to_profile( = {}) name = [:name].nil? ? "Profile" : [:name] path = admin_user_path(current_user) link_to(name, path) end |
#page_cached_at(page) ⇒ Object
FIXME: translations
27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/helpers/admin/base_helper.rb', line 27 def page_cached_at(page) if Date.today == page.updated_at.to_date if page.updated_at > Time.zone.now - 4.hours "#{time_ago_in_words(page.updated_at).gsub(/about /,'~ ')} ago" else "Today, #{page.updated_at.strftime('%l:%M %p')}" end else page.updated_at.strftime("%b %d, %Y") end end |
#save_or_cancel_links(builder, options = {}) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/helpers/admin/base_helper.rb', line 2 def save_or_cancel_links(builder, = {}) save_text = .delete(:save_text) || "Save" or_text = .delete(:or_text) || "or" cancel_text = .delete(:cancel_text) || "Cancel" cancel_url = .delete(:cancel_url) = .delete(:save) || {} .reverse_merge!(:id => 'commit') = .delete(:cancel) || {} builder. do ''.html_safe.tap do || << submit_tag(save_text, ) << " #{or_text} #{link_to(cancel_text, cancel_url, )}".html_safe if cancel_url end end.html_safe end |