From 560e915c50e80a7ee0527ac59b4e31ad53adab31 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Sun, 2 Aug 2009 04:19:44 +0000 Subject: Upgraded the gravatar plugin from http://github.com/woods/gravatar-plugin This will update the gravatar.com url (#2921) and provide support for SSL gravatars (#2718). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2832 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- vendor/plugins/gravatar/.gitignore | 1 + vendor/plugins/gravatar/README | 52 ------------------------------- vendor/plugins/gravatar/README.rdoc | 55 +++++++++++++++++++++++++++++++++ vendor/plugins/gravatar/Rakefile | 1 - vendor/plugins/gravatar/about.yml | 4 +-- vendor/plugins/gravatar/lib/gravatar.rb | 26 +++++++++++++--- 6 files changed, 80 insertions(+), 59 deletions(-) create mode 100644 vendor/plugins/gravatar/.gitignore delete mode 100644 vendor/plugins/gravatar/README create mode 100644 vendor/plugins/gravatar/README.rdoc (limited to 'vendor') diff --git a/vendor/plugins/gravatar/.gitignore b/vendor/plugins/gravatar/.gitignore new file mode 100644 index 000000000..4ebc8aea5 --- /dev/null +++ b/vendor/plugins/gravatar/.gitignore @@ -0,0 +1 @@ +coverage diff --git a/vendor/plugins/gravatar/README b/vendor/plugins/gravatar/README deleted file mode 100644 index dc516d367..000000000 --- a/vendor/plugins/gravatar/README +++ /dev/null @@ -1,52 +0,0 @@ -== Gravatar Plugin - -This plugin provides a handful of view helpers for displaying gravatars -(globally-recognized avatars). - -Gravatars allow users to configure an avatar to go with their email address at -a central location: http://gravatar.com. Gravatar-aware websites (such -as yours) can then look up and display each user's preferred avatar, without -having to handle avatar management. The user gets the benefit of not having to -set up an avatar for each site that they post on. - -== Installation - - cd ~/myapp - ruby script/plugin install svn://rubyforge.org//var/svn/gravatarplugin/plugins/gravatar - -or, if you're using piston[http://piston.rubyforge.org] (worth it!): - - cd ~/myapp/vendor/plugins - piston import svn://rubyforge.org//var/svn/gravatarplugin/plugins/gravatar - -== Example - -If you represent your users with a model that has an +email+ method (typical -for most rails authentication setups), then you can simply use this method -in your views: - - <%= gravatar_for @user %> - -This will be replaced with the full HTML +img+ tag necessary for displaying -that user's gravatar. - -Other helpers are documented under GravatarHelper::PublicMethods. - -== Acknowledgments - -The following people have also written gravatar-related Ruby libraries: -* Seth Rasmussen created the gravatar gem[http://gravatar.rubyforge.org] -* Matt McCray has also created a gravatar - plugin[http://mattmccray.com/svn/rails/plugins/gravatar_helper] - -== Author - - Scott A. Woods - West Arete Computing, Inc. - http://westarete.com - scott at westarete dot com - -== TODO - -* Get full spec coverage -* Finish rdoc documentation \ No newline at end of file diff --git a/vendor/plugins/gravatar/README.rdoc b/vendor/plugins/gravatar/README.rdoc new file mode 100644 index 000000000..0b95e85e8 --- /dev/null +++ b/vendor/plugins/gravatar/README.rdoc @@ -0,0 +1,55 @@ +== Gravatar Plugin + +This plugin provides a handful of view helpers for displaying gravatars +(globally-recognized avatars). + +Gravatars allow users to configure an avatar to go with their email address at +a central location: http://gravatar.com. Gravatar-aware websites (such +as yours) can then look up and display each user's preferred avatar, without +having to handle avatar management. The user gets the benefit of not having to +set up an avatar for each site that they post on. + +== Installation + + cd ~/myapp + ruby script/plugin install git://github.com/woods/gravatar-plugin.git + +or, if you're using piston[http://piston.rubyforge.org] (worth it!): + + cd ~/myapp/vendor/plugins + piston import git://github.com/woods/gravatar-plugin.git + +== Example + +If you represent your users with a model that has an +email+ method (typical +for most rails authentication setups), then you can simply use this method +in your views: + + <%= gravatar_for @user %> + +This will be replaced with the full HTML +img+ tag necessary for displaying +that user's gravatar. + +Other helpers are documented under GravatarHelper::PublicMethods. + +== Acknowledgments + +Thanks to Magnus Bergmark (http://github.com/Mange), who contributed the SSL +support in this plugin, as well as a few minor fixes. + +The following people have also written gravatar-related Ruby libraries: +* Seth Rasmussen created the gravatar gem[http://gravatar.rubyforge.org] +* Matt McCray has also created a gravatar + plugin[http://mattmccray.com/svn/rails/plugins/gravatar_helper] + +== Author + + Scott A. Woods + West Arete Computing, Inc. + http://westarete.com + scott at westarete dot com + +== TODO + +* Add specs for ssl support +* Finish rdoc documentation \ No newline at end of file diff --git a/vendor/plugins/gravatar/Rakefile b/vendor/plugins/gravatar/Rakefile index 5a8d92a8a..9e4854916 100644 --- a/vendor/plugins/gravatar/Rakefile +++ b/vendor/plugins/gravatar/Rakefile @@ -6,7 +6,6 @@ task :default => :spec desc 'Run all application-specific specs' Spec::Rake::SpecTask.new(:spec) do |t| - t.warning = true t.rcov = true end diff --git a/vendor/plugins/gravatar/about.yml b/vendor/plugins/gravatar/about.yml index a801d2582..aa5b8b19d 100644 --- a/vendor/plugins/gravatar/about.yml +++ b/vendor/plugins/gravatar/about.yml @@ -1,7 +1,7 @@ author: Scott Woods, West Arete Computing summary: View helpers for displaying gravatars. -homepage: http://gravatarplugin.rubyforge.org/ -plugin: svn://rubyforge.org//var/svn/gravatarplugin/plugins/gravatar +homepage: http://github.com/woods/gravatar-plugin/ +plugin: git://github.com/woods/gravatar-plugin.git license: MIT version: 0.1 rails_version: 1.0+ diff --git a/vendor/plugins/gravatar/lib/gravatar.rb b/vendor/plugins/gravatar/lib/gravatar.rb index 58cb4cabe..6246645bc 100644 --- a/vendor/plugins/gravatar/lib/gravatar.rb +++ b/vendor/plugins/gravatar/lib/gravatar.rb @@ -22,11 +22,16 @@ module GravatarHelper # exclude gravatars that may be out of character for your site. :rating => 'PG', - # The alt text to use in the img tag for the gravatar. - :alt => 'avatar', + # The alt text to use in the img tag for the gravatar. Since it's a + # decorational picture, the alt text should be empty according to the + # XHTML specs. + :alt => '', # The class to assign to the img tag for the gravatar. :class => 'gravatar', + + # Whether or not to display the gravatars using HTTPS instead of HTTP + :ssl => false, } # The methods that will be made available to your views. @@ -46,19 +51,32 @@ module GravatarHelper [:class, :alt, :size].each { |opt| options[opt] = h(options[opt]) } "\"#{options[:alt]}\"" end + + # Returns the base Gravatar URL for the given email hash. If ssl evaluates to true, + # a secure URL will be used instead. This is required when the gravatar is to be + # displayed on a HTTPS site. + def gravatar_api_url(hash, ssl=false) + if ssl + "https://secure.gravatar.com/avatar/#{hash}" + else + "http://www.gravatar.com/avatar/#{hash}" + end + end # Return the gravatar URL for the given email address. def gravatar_url(email, options={}) email_hash = Digest::MD5.hexdigest(email) options = DEFAULT_OPTIONS.merge(options) options[:default] = CGI::escape(options[:default]) unless options[:default].nil? - returning "http://www.gravatar.com/avatar.php?gravatar_id=#{email_hash}" do |url| + returning gravatar_api_url(email_hash, options.delete(:ssl)) do |url| + opts = [] [:rating, :size, :default].each do |opt| unless options[opt].nil? value = h(options[opt]) - url << "&#{opt}=#{value}" + opts << [opt, value].join('=') end end + url << "?#{opts.join('&')}" unless opts.empty? end end -- cgit v1.2.3