From b902d8effe049545afddcc48d6bc2b645ec9a360 Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Thu, 22 Mar 2012 01:51:39 +0400 Subject: [PATCH 1/2] [issue #195] Fixed avatar in commits & comments --- app/presenters/comment_presenter.rb | 2 +- .../git_presenters/commit_as_message_presenter.rb | 8 +++++++- db/schema.rb | 5 ++--- lib/rosa_presenter/lib/base.rb | 4 ++++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/presenters/comment_presenter.rb b/app/presenters/comment_presenter.rb index bdc16785f..7575f1819 100644 --- a/app/presenters/comment_presenter.rb +++ b/app/presenters/comment_presenter.rb @@ -55,7 +55,7 @@ class CommentPresenter < ApplicationPresenter end def image - @image ||= "https://secure.gravatar.com/avatar/#{Digest::MD5.hexdigest(@user.email.downcase)}?s=40&r=pg" + @image ||= helpers.avatar_url(@user, :medium) end def date diff --git a/app/presenters/git_presenters/commit_as_message_presenter.rb b/app/presenters/git_presenters/commit_as_message_presenter.rb index fe85874de..495a7edc5 100644 --- a/app/presenters/git_presenters/commit_as_message_presenter.rb +++ b/app/presenters/git_presenters/commit_as_message_presenter.rb @@ -22,7 +22,13 @@ class GitPresenters::CommitAsMessagePresenter < ApplicationPresenter end def image - @image ||= "https://secure.gravatar.com/avatar/#{Digest::MD5.hexdigest(committer.email.downcase)}?s=40&r=pg" + #@image ||= "https://secure.gravatar.com/avatar/#{Digest::MD5.hexdigest(committer.email.downcase)}?s=40&r=pg" + c = committer + @image ||= if c.class == User + helpers.avatar_url(c, :medium) + else + helpers.gravatar_url(c.email, 40) + end end def date diff --git a/db/schema.rb b/db/schema.rb index b145fe88c..7c7a52e57 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -286,11 +286,11 @@ ActiveRecord::Schema.define(:version => 20120321130436) do t.text "description" t.string "ancestry" t.boolean "has_issues", :default => true + t.boolean "has_wiki", :default => false t.string "srpm_file_name" t.string "srpm_content_type" t.integer "srpm_file_size" t.datetime "srpm_updated_at" - t.boolean "has_wiki", :default => false t.string "default_branch", :default => "master" t.boolean "is_rpm", :default => true end @@ -311,7 +311,6 @@ ActiveRecord::Schema.define(:version => 20120321130436) do end add_index "register_requests", ["email"], :name => "index_register_requests_on_email", :unique => true, :case_sensitive => false - add_index "register_requests", ["token"], :name => "index_register_requests_on_token", :unique => true, :case_sensitive => false create_table "relations", :force => true do |t| t.integer "object_id" @@ -371,6 +370,7 @@ ActiveRecord::Schema.define(:version => 20120321130436) do t.string "email", :default => "", :null => false t.string "encrypted_password", :limit => 128, :default => "", :null => false t.string "reset_password_token" + t.datetime "reset_password_sent_at" t.datetime "remember_created_at" t.datetime "created_at" t.datetime "updated_at" @@ -378,7 +378,6 @@ ActiveRecord::Schema.define(:version => 20120321130436) do t.string "uname" t.string "role" t.string "language", :default => "en" - t.datetime "reset_password_sent_at" t.integer "own_projects_count", :default => 0, :null => false t.text "professional_experience" t.string "site" diff --git a/lib/rosa_presenter/lib/base.rb b/lib/rosa_presenter/lib/base.rb index 46c94fedf..eff0f3387 100644 --- a/lib/rosa_presenter/lib/base.rb +++ b/lib/rosa_presenter/lib/base.rb @@ -15,6 +15,10 @@ module RosaPresenter Thread.current[:rosa_presenter_controller] end + def helpers + controller.view_context + end + # TODO it needs to be refactored! class << self def present(item, opts, &block) From 65e4e0f74843819b962677786a7af0cab39a9be7 Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Thu, 22 Mar 2012 02:06:33 +0400 Subject: [PATCH 2/2] [issue #195] use avatar_url_by_email instead of gravatar_url --- app/presenters/git_presenters/commit_as_message_presenter.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/presenters/git_presenters/commit_as_message_presenter.rb b/app/presenters/git_presenters/commit_as_message_presenter.rb index 495a7edc5..e09ad4172 100644 --- a/app/presenters/git_presenters/commit_as_message_presenter.rb +++ b/app/presenters/git_presenters/commit_as_message_presenter.rb @@ -22,12 +22,11 @@ class GitPresenters::CommitAsMessagePresenter < ApplicationPresenter end def image - #@image ||= "https://secure.gravatar.com/avatar/#{Digest::MD5.hexdigest(committer.email.downcase)}?s=40&r=pg" c = committer @image ||= if c.class == User helpers.avatar_url(c, :medium) else - helpers.gravatar_url(c.email, 40) + helpers.avatar_url_by_email(c.email, :medium) end end