Module: ApplicationHelper

Includes:
TagsHelper
Defined in:
app/helpers/application_helper.rb

Overview

Methods added to this helper will be available to all templates in the application.

Instance Method Summary collapse

Instance Method Details

#add_error_messageObject



85
86
# File 'app/helpers/application_helper.rb', line 85

def add_error_message
end

See a breadcrumbs in page of gallery



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/helpers/application_helper.rb', line 30

def breadcrumbs
  breadcrumbs = link_to this_webapp.webapp_name, root_path, :class => 'first-breadcrumb'
  unless @breadcrumb.nil?
    breadcrumbs += (:label, " > ")
    if @breadcrumb.kind_of? Picture
      picture = @breadcrumb
      @breadcrumb = @breadcrumb.gallery
    end
    breadcrumbs += parent_breadcrumbs_gallery(@breadcrumb)

    unless picture.nil?
      breadcrumbs += (:label, " > ")
      breadcrumbs += (:label, picture.title, :class => 'end-breadcrumb')
    end
  end
  if @finish_breadcrumb
    breadcrumbs + " > " + @finish_breadcrumb
  else
    breadcrumbs
  end
end

#flash_noticeObject

Display the notice in class Notice in paragraph if there are one



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

def flash_notice
  return '' unless flash[:notice]
   'p', :class => 'notice' do 
    flash[:notice]
  end
end

Get the link of Gallery with name and the number of picture in this gallery



65
66
67
# File 'app/helpers/application_helper.rb', line 65

def link_gallery_with_number(gallery)
  link_to "#{gallery.title} [#{gallery.pictures.count}]", gallery_path(gallery), :class => ('current_gallery' if gallery == @gallery)
end

#page_titleObject

Define the title of page



16
17
18
19
# File 'app/helpers/application_helper.rb', line 16

def page_title
  return "#{this_webapp.webapp_name} - #{@page_title}" if @page_title
  return "#{this_webapp.webapp_name}"
end

Generate the parent breadcrumb with recusive



53
54
55
56
57
58
59
60
61
# File 'app/helpers/application_helper.rb', line 53

def parent_breadcrumbs_gallery(gallery)
  breadcrumbs = ""
  unless gallery.parent.nil?
    breadcrumbs += parent_breadcrumbs_gallery(gallery.parent)
    breadcrumbs += (:label, " > ")
  end
  breadcrumbs += link_to(gallery.name, gallery_path(gallery),
    :class => (@breadcrumb == gallery ? 'end-breadcrumb' : 'middle-breadcrumb'))
end

#status_value(status) ⇒ Object

Return the status of a boolean



7
8
9
10
11
12
13
# File 'app/helpers/application_helper.rb', line 7

def status_value(status)
  if status
    "Active"
  else
    "Disabled"
  end
end

Generate the list by tree of Gallery in sidebar



70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'app/helpers/application_helper.rb', line 70

def tree_gallery(gallery)
  str = ""
  if @gallery == gallery || @gallery.ancestors.include?(gallery)
    str = "<ul>"
    gallery.children.each do |gallery_child|
      str += "<li>"
      str += link_gallery_with_number(gallery_child)
      str += tree_gallery(gallery_child)
      str += "</li>"
    end
    str += "</ul>"
  end
  str
end