Module: Admin::BaseHelper

Defined in:
app/helpers/admin/base_helper.rb

Instance Method Summary collapse

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


20
21
22
23
24
# File 'app/helpers/admin/base_helper.rb', line 20

def link_to_profile(options = {})
  name = options[:name].nil? ? "Profile" : options[: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


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, options = {})
  save_text   = options.delete(:save_text)   || "Save"
  or_text     = options.delete(:or_text)     || "or"
  cancel_text = options.delete(:cancel_text) || "Cancel"
  cancel_url  = options.delete(:cancel_url)

  save_options = options.delete(:save) || {}
  save_options.reverse_merge!(:id => 'commit')
  cancel_options = options.delete(:cancel) || {}

  builder.buttons do
    ''.html_safe.tap do |buttons|
      buttons << submit_tag(save_text, save_options)
      buttons << " #{or_text} #{link_to(cancel_text, cancel_url, cancel_options)}".html_safe if cancel_url
    end
  end.html_safe
end