Module: Diaspora::Mentionable::MentionsInternal

Extended by:
PeopleHelper
Defined in:
lib/diaspora/mentionable.rb

Overview

inline module for namespacing

Class Method Summary collapse

Methods included from PeopleHelper

birthday_format, local_or_remote_person_path, person_href, person_image_link, person_image_tag, person_link, profile_buttons_class, search_header, sharing_message

Class Method Details

.get_aspect_ids(user, *aspects) ⇒ Array

takes a user and an array of aspect ids or an array containing “all” as the first element. will do some checking on ids and return them in an array in case of “all”, returns an array with all the users aspect ids


124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/diaspora/mentionable.rb', line 124

def self.get_aspect_ids(user, *aspects)
  return [] if aspects.empty?

  if (!aspects.first.is_a?(Integer)) && aspects.first.to_s == 'all'
    return user.aspects.pluck(:id)
  end

  ids = aspects.reject {|id| Integer(id) == nil } # only numeric

  #make sure they really belong to the user
  user.aspects.where(id: ids).pluck(:id)
end

output a formatted mention link as defined by the given options, use the fallback name if the person is unavailable

See Also:

  • Diaspora::Mentions#format

95
96
97
98
99
100
101
102
103
# File 'lib/diaspora/mentionable.rb', line 95

def self.mention_link(person, fallback_name, opts)
  return fallback_name unless person.present?

  if opts[:plain_text]
    person.name
  else
    person_link(person, class: PERSON_HREF_CLASS)
  end
end

output a markdown formatted link to the given person or the given fallback string, in case the person is not present


111
112
113
114
115
# File 'lib/diaspora/mentionable.rb', line 111

def self.profile_link(person, fallback_name)
  return fallback_name unless person.present?

  "[#{person.name}](#{local_or_remote_person_path(person)})"
end