Module: PeopleHelper
- Includes:
- ERB::Util
- Defined in:
- app/helpers/people_helper.rb
Overview
Copyright © 2010-2011, Diaspora Inc. This file is
licensed under the Affero General Public License version 3 or later. See
the COPYRIGHT file.
Instance Method Summary collapse
- #birthday_format(bday) ⇒ Object
-
#local_or_remote_person_path(person, opts = {}) ⇒ Object
Rails.application.routes.url_helpers is needed since this is indirectly called from a model.
- #person_href(person, opts = {}) ⇒ Object
- #person_image_link(person, opts = {}) ⇒ Object
- #person_image_tag(person, size = :thumb_small) ⇒ Object
- #person_link(person, opts = {}) ⇒ Object
- #profile_buttons_class(contact, block) ⇒ Object
- #search_header ⇒ Object
- #sharing_message(person, contact) ⇒ Object
Instance Method Details
#birthday_format(bday) ⇒ Object
18 19 20 21 22 23 24 |
# File 'app/helpers/people_helper.rb', line 18 def birthday_format(bday) if bday.year == 1000 I18n.l bday, :format => I18n.t('date.formats.birthday') else I18n.l bday, :format => I18n.t('date.formats.birthday_with_year') end end |
#local_or_remote_person_path(person, opts = {}) ⇒ Object
Rails.application.routes.url_helpers is needed since this is indirectly called from a model
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/helpers/people_helper.rb', line 58 def local_or_remote_person_path(person, opts={}) opts.merge!(:protocol => AppConfig.pod_uri.scheme, :host => AppConfig.pod_uri.) absolute = opts.delete(:absolute) if person.local? username = person.diaspora_handle.split('@')[0] unless username.include?('.') opts.merge!(:username => username) if absolute return Rails.application.routes.url_helpers.user_profile_url(opts) else return Rails.application.routes.url_helpers.user_profile_path(opts) end end end if absolute return Rails.application.routes.url_helpers.person_url(person, opts) else return Rails.application.routes.url_helpers.person_path(person, opts) end end |
#person_href(person, opts = {}) ⇒ Object
53 54 55 |
# File 'app/helpers/people_helper.rb', line 53 def person_href(person, opts={}) "href=\"#{local_or_remote_person_path(person, opts)}\"".html_safe end |
#person_image_link(person, opts = {}) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/helpers/people_helper.rb', line 38 def person_image_link(person, opts={}) return "" if person.nil? || person.profile.nil? if opts[:to] == :photos link_to person_image_tag(person, opts[:size]), person_photos_path(person) else opts[:class] ||= "" opts[:class] << " self" if defined?(user_signed_in?) && user_signed_in? && current_user.person == person opts[:class] << " hovercardable" if defined?(user_signed_in?) && user_signed_in? && current_user.person != person remote_or_hovercard_link = Rails.application.routes.url_helpers.person_path(person).html_safe "<a href='#{remote_or_hovercard_link}' class='#{opts[:class]}' #{ ("target=" + opts[:target]) if opts[:target]}> #{person_image_tag(person, opts[:size])} </a>".html_safe end end |
#person_image_tag(person, size = :thumb_small) ⇒ Object
34 35 36 |
# File 'app/helpers/people_helper.rb', line 34 def person_image_tag(person, size = :thumb_small) image_tag(person.profile.image_url(size), :alt => person.name, :class => 'avatar', :title => person.name, 'data-person_id' => person.id) end |
#person_link(person, opts = {}) ⇒ Object
26 27 28 29 30 31 32 |
# File 'app/helpers/people_helper.rb', line 26 def person_link(person, opts={}) opts[:class] ||= "" opts[:class] << " self" if defined?(user_signed_in?) && user_signed_in? && current_user.person == person opts[:class] << " hovercardable" if defined?(user_signed_in?) && user_signed_in? && current_user.person != person remote_or_hovercard_link = Rails.application.routes.url_helpers.person_path(person).html_safe "<a data-hovercard='#{remote_or_hovercard_link}' href='#{remote_or_hovercard_link}' class='#{opts[:class]}' #{ ("target=" + opts[:target]) if opts[:target]}>#{h(person.name)}</a>".html_safe end |
#profile_buttons_class(contact, block) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'app/helpers/people_helper.rb', line 93 def (contact, block) if block.present? 'blocked' elsif contact.mutual? 'mutual' elsif contact.sharing? 'only_sharing' elsif contact.receiving? 'receiving' else 'not_sharing' end end |
#search_header ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'app/helpers/people_helper.rb', line 8 def search_header if search_query.blank? content_tag(:h2, t('people.index.no_results')) else content_tag(:h2, id: 'search_title') do t('people.index.results_for', search_term: content_tag(:span, search_query, class: 'term')).html_safe + looking_for_tag_link end end end |
#sharing_message(person, contact) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 |
# File 'app/helpers/people_helper.rb', line 81 def (person, contact) if contact.sharing? content_tag(:div, :class => 'sharing_message_container', :title => I18n.t('people.helper.is_sharing', :name => person.name)) do content_tag(:div, nil, :class => 'icons-check_yes_ok', :id => 'sharing_message') end else content_tag(:div, :class => 'sharing_message_container', :title => I18n.t('people.helper.is_not_sharing', :name => person.name)) do content_tag(:div, nil, :class => 'icons-circle', :id => 'sharing_message') end end end |