プロジェクト

全般

プロフィール

Vote #64503

未完了

Partially decouple application_helper.rb from Gravatar

Admin Redmine さんがほぼ2年前に追加.

ステータス:
New
優先度:
通常
担当者:
-
カテゴリ:
-
対象バージョン:
-
開始日:
2009/01/24
期日:
進捗率:

0%

予定工数:
category_id:
0
version_id:
0
issue_org_id:
2576
author_id:
2928
assigned_to_id:
0
comments:
6
status_id:
1
tracker_id:
3
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[New]

説明

The application_helper.rb directly accesses the Gravatar function by email. I would argue that it would be better to instead use vendor/plugins/gravatar/lib/gravatar.rb's gravatar_for function with the user object.

The situation I have here is that my local instance has modified the Gravatar plugin to use locally stored avatars linked by email address (as dictated by application_helper.rb). Occasionally, users change their email addresses, which requires renaming their avatar files. If the change I proposed was implemented, this local avatar plugin would be doable. Without it, the avatar system is intrinsically tied to email addresses.

I'm not sure what patch formats you prefer, so here's the proposed change:


def avatar(user, options = { })
    if Setting.gravatar_enabled?
      return gravatar_for(user) unless user.mail.blank? rescue nil
    end
  end

Apologies if my syntax is wrong. I'm so very, very new to Ruby.


journals

@avatar@ was used because @Gravatar#for@ looks for the @email@ attribute whereas Redmine uses the @mail@ attribute. With a bit of Ruby you can override @ApplicationHelper#avatar@ to use a local store (or anything else) from within a plugin. Let me know if you need some sample code for this, I have some on GitHub but the site's been slow for me today.
--------------------------------------------------------------------------------
Eric Davis wrote:
> @avatar@ was used because @Gravatar#for@ looks for the @email@ attribute whereas Redmine uses the @mail@ attribute. With a bit of Ruby you can override @ApplicationHelper#avatar@ to use a local store (or anything else) from within a plugin. Let me know if you need some sample code for this, I have some on GitHub but the site's been slow for me today.

I should be okay throwing it together. What I'd like to see is plugins not directly referenced in base code, and I think I can make the necessary changes to make that happen. I was playing around with it last night and made a bit of progress on this. Will post a patch once it's complete.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Any progress on the patch Brad?
--------------------------------------------------------------------------------
Eric Davis wrote:
>I was playing around with it last night and made a bit of progress on this. Will post a patch once it's complete.

Eric Davis wrote:
> Any progress on the patch Brad?

Ah, I thought you were looking at it. If not, I'll look into it when I get a chance in the next few days.
--------------------------------------------------------------------------------
Hrm. Modifying the rest of Redmine was easy enough, but I got stuck at calling the GravatarHelper from the hook I created.
--------------------------------------------------------------------------------

表示するデータがありません

他の形式にエクスポート: Atom PDF

いいね!0