Module: Homeland::ApplicationHelper
- Defined in:
- app/helpers/homeland/application_helper.rb
Constant Summary collapse
- DEFAULT_AVATAR =
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPAAAADwCAMAAAAJixmgAAAAFVBMVEWkpKSnp6eqqqq3t7fS0tLV1dXZ2dmshcKEAAAAtklEQVR4Ae3XsRGAAAjAQFRk/5HtqaTz5H+DlInvAQAAAAAAAAAAAAAAAAAAAACymiveO6o7BQsWLFiwYMGCBS8PFixYsGDBggULFixYsGDBggULFixYsGDBggULFixYsGDBc4IFCxYsWLBgwYIFC14ZfOeAPRQ8IliwYMGCBQsWLFiwYMGCBQsWLFiwYMGCBQsWLFiwYMGCBQsWLFiwYMGCBQv+JQAAAAAAAAAAAAAAAAAAAOAB4KJfdHmj+kwAAAAASUVORK5CYII='
Instance Method Summary collapse
- #node_tag(node) ⇒ Object
- #notice_message ⇒ Object
- #render_errors(target) ⇒ Object
- #timeago(time, options = {}) ⇒ Object
- #user_avatar_tag(obj, opts = {}) ⇒ Object
- #user_name_tag(obj) ⇒ Object
Instance Method Details
#node_tag(node) ⇒ Object
16 17 18 19 20 21 22 |
# File 'app/helpers/homeland/application_helper.rb', line 16 def node_tag(node) return '' if node.blank? label = [node.badge_html, content_tag(:span, node.name, class: 'name')].join(' ') link_to raw(label), homeland.node_topics_path(node.id), class: 'node' end |
#notice_message ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/helpers/homeland/application_helper.rb', line 45 def = [] flash.each do |type, | type = :danger type = :success if type.to_sym == :notice = raw %(<button type="button" class="close" data-dismiss="alert">×</button>) text = content_tag(:div, + , class: "alert alert-dismissible alert-#{type}") << text if end .join("\n").html_safe end |
#render_errors(target) ⇒ Object
5 6 7 8 9 |
# File 'app/helpers/homeland/application_helper.rb', line 5 def render_errors(target) if target.errors.present? render partial: '/homeland/shared/error_messages', locals: { target: target } end end |
#timeago(time, options = {}) ⇒ Object
11 12 13 14 |
# File 'app/helpers/homeland/application_helper.rb', line 11 def timeago(time, = {}) [:class] ||= "timeago" content_tag(:abbr, time.to_s, .merge(:title => time.getutc.iso8601)) if time end |
#user_avatar_tag(obj, opts = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/helpers/homeland/application_helper.rb', line 31 def user_avatar_tag(obj, opts = {}) default = image_tag(DEFAULT_AVATAR, class: 'avatar media-object') return default if obj.blank? return default if obj.user.blank? if obj.user_avatar_url == nil img = default else img = image_tag(obj.user_avatar_url, class: 'avatar media-object') end link_to img, obj.user_profile_url, title: obj.user_name, class: 'user-avatar' end |
#user_name_tag(obj) ⇒ Object
24 25 26 27 28 29 |
# File 'app/helpers/homeland/application_helper.rb', line 24 def user_name_tag(obj) return '' if obj.blank? return '' if obj.user_name.blank? link_to obj.user_name, obj.user_profile_url, class: 'user-name' end |