Module: Skyline::ApplicationHelper

Defined in:
app/helpers/skyline/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#message(type, message, options = {}) ⇒ Object

You can use this method to place a message directly in your view. This also works directly from a render(:update) or an update_page block.

Parameters

type<Symbol>

The type of the message (:error,:notification,:success)

message<String>

The message to show

optiosn<Hash>

Options to be passed to the MessageGenerator (javascript)



27
28
29
# File 'app/helpers/skyline/application_helper.rb', line 27

def message(type,message,options={})
  MessageGenerator.new(type,message,options)
end

#notification(type, message, options = {}) ⇒ Object

You can use this method to place a notification directly in your view. This also works directly from a render(:update) or an update_page block.

Parameters

type<Symbol>

The type of the message (:error,:notification,:success)

message<String>

The message to show

optiosn<Hash>

Options to be passed to the MessageGenerator (javascript)



40
41
42
# File 'app/helpers/skyline/application_helper.rb', line 40

def notification(type,message,options={})
  MessageGenerator.new(type,message,options)    
end

#plugin_hook(name) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/helpers/skyline/application_helper.rb', line 52

def plugin_hook(name)
  template = caller.first[/app\/views\/([^:]*):/,1]
  raise "Cannot determine template from caller: #{caller}" unless template
  plugin_template = template.sub(".html.erb", "_#{name}.html.erb")
  
  logger.debug "Looking for template #{plugin_template} in plugins..."
  Dir[Rails.root + "vendor/skyline_plugins/*/app/views/#{plugin_template}"].each do |file|      
    if RAILS_ENV == "development"
      concat render(:inline => File.read(file), :layout => nil)
    else
      # render :file caches the file somehow, so only use it in production mode
      concat render(:file => file, :layout => nil)
    end
  end    
end

#render_messages(options = {}) ⇒ Object



44
45
46
# File 'app/helpers/skyline/application_helper.rb', line 44

def render_messages(options={})
  _render_volatiles(self.messages,options)
end

#render_notifications(options = {}) ⇒ Object



48
49
50
# File 'app/helpers/skyline/application_helper.rb', line 48

def render_notifications(options={})
  _render_volatiles(self.notifications,options)
end

#tick_image(bool, options = {}) ⇒ Object

Place a tick or a cross depending on the value of bool

Parameters

bool<Boolean>

The value of the tick/cross

options<Hash>

Options will be passed to the image_tag method



9
10
11
12
13
14
15
16
# File 'app/helpers/skyline/application_helper.rb', line 9

def tick_image(bool,options={})
  name = bool ? "true" : "false"
  src = "/skyline/images/icons/#{name}.gif"
  
  options.reverse_merge! :alt => t(name, :scope => [:icons]) 
  
  image_tag(src,options)
end