Module: Admin::PagesHelper

Includes:
PagesCore::Admin::PageBlocksHelper
Defined in:
app/helpers/admin/pages_helper.rb

Instance Method Summary collapse

Methods included from PagesCore::Admin::PageBlocksHelper

#page_block_field, #page_block_select, #page_block_text_field

Instance Method Details

#available_templates_for_selectObject



7
8
9
10
11
12
13
14
15
# File 'app/helpers/admin/pages_helper.rb', line 7

def available_templates_for_select
  PagesCore::Templates.names.collect do |template|
    if template == "index"
      ["[Default]", "index"]
    else
      [template.humanize, template]
    end
  end
end

#file_embed_code(file) ⇒ Object



17
18
19
# File 'app/helpers/admin/pages_helper.rb', line 17

def file_embed_code(file)
  "[file:#{file.id}]"
end

#news_section_name(page, news_pages) ⇒ Object



21
22
23
24
25
26
27
# File 'app/helpers/admin/pages_helper.rb', line 21

def news_section_name(page, news_pages)
  if news_pages.select { |p| p.name == page.name }.length > 1
    page_name(page, include_parents: true)
  else
    page_name(page)
  end
end

#page_authors(page) ⇒ Object



29
30
31
# File 'app/helpers/admin/pages_helper.rb', line 29

def page_authors(page)
  ([page.author] + User.activated).uniq
end

#page_name(page, options = {}) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'app/helpers/admin/pages_helper.rb', line 33

def page_name(page, options = {})
  page_names = if options[:include_parents]
                 page.self_and_ancestors.reverse
               else
                 [page]
               end
  safe_join(
    page_names.map { |p| page_name_with_fallback(p) },
    raw(" » ")
  )
end

#publish_time(time) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'app/helpers/admin/pages_helper.rb', line 45

def publish_time(time)
  if time.year != Time.zone.now.year
    time.strftime("on %b %d %Y at %H:%M")
  elsif time.to_date != Time.zone.now.to_date
    time.strftime("on %b %d at %H:%M")
  else
    time.strftime("at %H:%M")
  end
end