Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 25 additions & 22 deletions app/models/author.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,6 @@ def display_name
end
end

# Return the gravatar url
# Query described [here](http://en.gravatar.com/site/implement/images/#default-image).
def gravatar_url
email_digest = Digest::MD5.hexdigest email
"https://#{GRAVATAR}/avatar/#{email_digest}?s=48&r=r&d=#{ENCODED_DEFAULT_AVATAR}"
end

# Returns an OStatus::Author instance describing this author model
def to_atom

Expand Down Expand Up @@ -245,6 +238,31 @@ def to_atom
author
end

def to_param
username
end

def self.search(params = {})
if params[:search] && !params[:search].empty?
Author.where(:username => /#{params[:search]}/i)
else
[]
end
end

private

# Return the gravatar url
# Query described [here](http://en.gravatar.com/site/implement/images/#default-image).
def gravatar_url
email_digest = Digest::MD5.hexdigest email
"https://#{GRAVATAR}/avatar/#{email_digest}?s=48&r=r&d=#{ENCODED_DEFAULT_AVATAR}"
end

def set_default_use_ssl
self.use_ssl = self.domain.start_with?("https")
end

def normalize_domain
set_default_use_ssl if use_ssl.nil?

Expand All @@ -266,19 +284,4 @@ def modify_twitter_image_url_domain
self.image_url.sub!(/a\d.twimg.com/, "twimg0-a.akamaihd.net") if self.image_url.present?
end

def to_param
username
end

def self.search(params = {})
if params[:search] && !params[:search].empty?
Author.where(:username => /#{params[:search]}/i)
else
[]
end
end

def set_default_use_ssl
self.use_ssl = self.domain.start_with?("https")
end
end