Module: Georgia::UiHelper
- Defined in:
- app/helpers/georgia/ui_helper.rb
Instance Method Summary collapse
-
#asset_icon_tag(extension) ⇒ Object
FIXME: Turn into a Hash.
- #avatar_url(email = '', options = {}) ⇒ Object
- #button_to_edit ⇒ Object
- #button_to_settings ⇒ Object
- #caret_tag ⇒ Object
- #link_to_available_locales ⇒ Object
- #link_to_back(url = :back) ⇒ Object
-
#link_to_close ⇒ Object
Link to close modal box.
- #link_to_delete(url, options = {}) ⇒ Object
- #page_actions_tag(page, revision = nil, options = {}) ⇒ Object
- #page_url_minus_slug ⇒ Object
- #picture_tag(picture, options = {}) ⇒ Object
- #revision_status_message(page, revision, options = {}) ⇒ Object
- #tooltip_tag(icon, tooltip, options = {}) ⇒ Object
- #welcomed? ⇒ Boolean
Instance Method Details
#asset_icon_tag(extension) ⇒ Object
FIXME: Turn into a Hash
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/helpers/georgia/ui_helper.rb', line 15 def asset_icon_tag extension icon_name = case extension.downcase when 'avi' then 'file-movie-o' when 'css' then 'file-text-o' when 'csv' then 'file-excel-o' when 'doc' then 'file-word-o' when 'docx' then 'file-word-o' when 'eps' then 'file-powerpoint-o' when 'gif' then 'file-image-o' when 'gz' then 'file-archive-o' when 'html' then 'file-code-o' when 'jpeg' then 'file-image-o' when 'jpg' then 'file-image' when 'mp3' then 'file-audio-o' when 'ods' then 'file-excel-o' when 'odt' then 'file-word-o' when 'pdf' then 'file-pdf-o' when 'png' then 'file-image-o' when 'ppt' then 'file-powerpoint-o' when 'pptx' then 'file-powerpoint-o' when 'rar' then 'file-archive-o' when 'tar' then 'file-archive-o' when 'txt' then 'file-text-o' when 'wav' then 'file-audio-o' when 'xls' then 'file-excel-o' when 'zip' then 'file-archive-o' else 'file' end icon_tag(icon_name) end |
#avatar_url(email = '', options = {}) ⇒ Object
4 5 6 7 8 |
# File 'app/helpers/georgia/ui_helper.rb', line 4 def avatar_url(email='', ={}) gravatar_id = Digest::MD5.hexdigest(email.downcase) if email size = .fetch(:size, '32') "//gravatar.com/avatar/#{gravatar_id}.png?s=#{size}&d=mm" end |
#button_to_edit ⇒ Object
74 75 76 77 |
# File 'app/helpers/georgia/ui_helper.rb', line 74 def return unless policy(@page).update? link_to "#{icon_tag('pencil')} Edit".html_safe, [:edit, @page], class: 'btn btn-info' end |
#button_to_settings ⇒ Object
69 70 71 72 |
# File 'app/helpers/georgia/ui_helper.rb', line 69 def return unless policy(@page).settings? link_to "#{icon_tag('cogs')} Settings".html_safe, [:settings, @page], class: 'btn btn-info' end |
#caret_tag ⇒ Object
10 11 12 |
# File 'app/helpers/georgia/ui_helper.rb', line 10 def caret_tag content_tag :span, nil, class: 'caret' end |
#link_to_available_locales ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'app/helpers/georgia/ui_helper.rb', line 100 def link_to_available_locales return unless I18n.available_locales.length > 1 links = I18n.available_locales.map do |locale| content_tag(:li, link_to(t("georgia.#{locale}"), params.merge(locale: locale) )) end content_tag(:p, class: 'hint') do content_tag(:div, class: 'dropdown') do link_to("Change language <span class='caret'></span>".html_safe, '#', class: 'btn btn-warning', data: {toggle: 'dropdown'}, role: :button) + content_tag(:ul, links.join('').html_safe, class: 'dropdown-menu', role: 'menu') end end end |
#link_to_back(url = :back) ⇒ Object
47 48 49 |
# File 'app/helpers/georgia/ui_helper.rb', line 47 def link_to_back url=:back link_to icon_tag('level-up fa-rotate-270'), url, class: 'btn btn-back' end |
#link_to_close ⇒ Object
Link to close modal box
57 58 59 |
# File 'app/helpers/georgia/ui_helper.rb', line 57 def link_to_close content_tag :button, icon_tag('times'), class: 'close', data: {dismiss: 'modal'}, aria: {hidden: true}, type: 'button' end |
#link_to_delete(url, options = {}) ⇒ Object
51 52 53 54 |
# File 'app/helpers/georgia/ui_helper.rb', line 51 def link_to_delete url, ={} text = .delete(:text) { "#{icon_tag('trash-o')} Delete".html_safe } link_to text, url, .reverse_merge(data: {confirm: 'Are you sure?'}, method: :delete, class: 'btn btn-danger') end |
#page_actions_tag(page, revision = nil, options = {}) ⇒ Object
79 80 81 82 |
# File 'app/helpers/georgia/ui_helper.rb', line 79 def page_actions_tag page, revision=nil, ={} revision ||= page.current_revision Georgia::PageActionsPresenter.new(self, page, revision, ) end |
#page_url_minus_slug ⇒ Object
84 85 86 |
# File 'app/helpers/georgia/ui_helper.rb', line 84 def page_url_minus_slug @page_full_url ||= (Georgia.url + @page.url).gsub(@page.slug, '') end |
#picture_tag(picture, options = {}) ⇒ Object
92 93 94 95 96 97 98 |
# File 'app/helpers/georgia/ui_helper.rb', line 92 def picture_tag picture, ={} return unless picture and picture.url.present? format = .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 |
#revision_status_message(page, revision, options = {}) ⇒ Object
88 89 90 |
# File 'app/helpers/georgia/ui_helper.rb', line 88 def page, revision, ={} Georgia::RevisionStatusMessage.new(self, page, revision, ) end |
#tooltip_tag(icon, tooltip, options = {}) ⇒ Object
61 62 63 |
# File 'app/helpers/georgia/ui_helper.rb', line 61 def tooltip_tag icon, tooltip, ={} content_tag(:span, icon, .reverse_merge(title: tooltip, class: 'js-tooltip', data: {placement: 'right'})) end |
#welcomed? ⇒ Boolean
65 66 67 |
# File 'app/helpers/georgia/ui_helper.rb', line 65 def welcomed? session[:welcomed] || !(session[:welcomed] = true) end |