Module: Georgia::UiHelper

Defined in:
app/helpers/georgia/ui_helper.rb

Instance Method Summary collapse

Instance Method Details

#avatar_url(email, options = {}) ⇒ Object



4
5
6
7
8
# File 'app/helpers/georgia/ui_helper.rb', line 4

def avatar_url(email, options={})
  gravatar_id = Digest::MD5.hexdigest(email.try(:downcase))
  size = options.fetch(:size, '32')
  "http://gravatar.com/avatar/#{gravatar_id}.png?s=#{size}&d=mm"
end

#caret_tagObject



16
17
18
# File 'app/helpers/georgia/ui_helper.rb', line 16

def caret_tag
   :span, nil, class: 'caret'
end

#icon_tag(icon_name, options = {}) ⇒ Object



10
11
12
13
14
# File 'app/helpers/georgia/ui_helper.rb', line 10

def icon_tag icon_name, options={}
  options[:class] ||= ''
  options[:class] << "fa fa-#{icon_name}"
   :i, nil, options
end


33
34
35
# File 'app/helpers/georgia/ui_helper.rb', line 33

def link_to_back url=:back
  link_to icon_tag('level-up fa-rotate-270'), url, class: 'btn btn-back'
end


37
38
39
40
# File 'app/helpers/georgia/ui_helper.rb', line 37

def link_to_delete url, options={}
  text = options.delete(:text) { "#{icon_tag('trash-o')} Delete".html_safe }
  link_to text, url, options.reverse_merge(data: {confirm: 'Are you sure?'}, method: :delete, class: 'btn btn-danger')
end

#picture_tag(picture, options = {}) ⇒ Object



25
26
27
28
29
30
31
# File 'app/helpers/georgia/ui_helper.rb', line 25

def picture_tag picture, options={}
  return unless picture and picture.url.present?
  format = options.fetch(:format, :tiny)
  link_to picture.url_content, class: 'media-link bg-transparent', rel: 'shadowbox[gallery]' do
    image_tag(picture.url(format), title: picture.data_file_name, class: 'media-image')
  end
end

#spinner_tag(options = {}) ⇒ Object



20
21
22
23
# File 'app/helpers/georgia/ui_helper.rb', line 20

def spinner_tag options={}
  options[:class] = options.fetch(:class, 'spinner')
   :div, icon_tag('spinner fa-spin fa-4x'), options
end

#tooltip_tag(icon, tooltip, options = {}) ⇒ Object



42
43
44
# File 'app/helpers/georgia/ui_helper.rb', line 42

def tooltip_tag icon, tooltip, options={}
  (:span, icon, options.reverse_merge(title: tooltip, class: 'js-tooltip', data: {placement: 'right'}))
end

#welcomed?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'app/helpers/georgia/ui_helper.rb', line 46

def welcomed?
  session[:welcomed] || !(session[:welcomed] = true)
end