Module: Elabs::ApplicationHelper
- Defined in:
- app/helpers/elabs/application_helper.rb
Instance Method Summary collapse
- #boolean_icon_tag(value, true_icon = 'check', false_icon = 'times') ⇒ Object
- #icon(name, classes = [], base = 'fas') ⇒ Object
- #icon_text(icon, text, icon_options = [], reverse = false) ⇒ Object
- #license_icon(license, classes = ['fw']) ⇒ Object
- #page_title(title, namespace = nil) ⇒ Object
- #show_item?(entity) ⇒ Boolean
- #show_nsfw? ⇒ Boolean
- #user_is_author_of(entity) ⇒ Object
Instance Method Details
#boolean_icon_tag(value, true_icon = 'check', false_icon = 'times') ⇒ Object
22 23 24 25 26 27 |
# File 'app/helpers/elabs/application_helper.rb', line 22 def boolean_icon_tag(value, true_icon = 'check', false_icon = 'times') icon_class = [ "fas fa-#{value ? true_icon : false_icon} fa-fw" ] content_tag(:i, nil, class: icon_class) end |
#icon(name, classes = [], base = 'fas') ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/helpers/elabs/application_helper.rb', line 29 def icon(name, classes = [], base = 'fas') icon_class = ["#{base} fa-#{name}"] icon_class += classes.map do |c| if %w[2x 3x 4x fw].include? c "fa-#{c}" else c end end content_tag(:i, nil, class: icon_class) end |
#icon_text(icon, text, icon_options = [], reverse = false) ⇒ Object
15 16 17 18 19 20 |
# File 'app/helpers/elabs/application_helper.rb', line 15 def icon_text(icon, text, = [], reverse = false) format( reverse ? _('%<text>s %<icon>s') : _('%<icon>s %<text>s'), icon: icon(icon, ), text: text ).html_safe end |
#license_icon(license, classes = ['fw']) ⇒ Object
42 43 44 |
# File 'app/helpers/elabs/application_helper.rb', line 42 def license_icon(license, classes = ['fw']) icon license.icon, classes, 'fab' end |
#page_title(title, namespace = nil) ⇒ Object
46 47 48 49 50 51 52 |
# File 'app/helpers/elabs/application_helper.rb', line 46 def page_title(title, namespace = nil) out = [Elabs.site_name] out.push(namespace) if namespace out.push(title) if title out.join('::') end |
#show_item?(entity) ⇒ Boolean
7 8 9 |
# File 'app/helpers/elabs/application_helper.rb', line 7 def show_item?(entity) (entity.sfw? || show_nsfw?) && !entity.locked? end |
#show_nsfw? ⇒ Boolean
3 4 5 |
# File 'app/helpers/elabs/application_helper.rb', line 3 def show_nsfw? session[:show_nsfw] end |
#user_is_author_of(entity) ⇒ Object
11 12 13 |
# File 'app/helpers/elabs/application_helper.rb', line 11 def (entity) current_user&.id && entity.user_id == current_user.id end |