sinisterchipmunk / gravatar Goto Github PK
View Code? Open in Web Editor NEWA gem for interfacing with the entire Gravatar API: not just images, but the XML-RPC API too!
Home Page: http://www.thoughtsincomputation.com
License: MIT License
A gem for interfacing with the entire Gravatar API: not just images, but the XML-RPC API too!
Home Page: http://www.thoughtsincomputation.com
License: MIT License
this line in dependencies.rb is incorrect:
Rails.configuration.gem "sc-core-ext", ">= 1.2.0"
this should be (I think):
Rails.configuration.gem "sc-core-ext", :version => ">= 1.2.0"
the bad code ends up triggering "sc-core-ext"[:requirement], which harmlessly returns nil in ruby 1.8, but throws in ruby 1.9.
I think the api has changed, and no longer needs a hashed array of emails. For example, the following code works now:
def use_user_image!(image_hash, emails)
emails = [emails] unless emails.is_a?(Array)
hash = call('grav.useUserimage', :userimage => image_hash, :addresses => emails)
expire_cache!
return hash
end
I would have submitted a pull request, but I didn't understand your 'dehashify_emails' method. So I've just hacked it up for now.
gravatar-ultimate
requires rack
to run. If you don't have it installed, it will produce an error:
LoadError: cannot load such file -- rack/utils
from /Users/joe/.rbenv/versions/1.9.3-p448/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/joe/.rbenv/versions/1.9.3-p448/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/cache/file_store.rb:4:in `<top (required)>'
from /Users/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/gravatar-ultimate-1.0.3/lib/gravatar/cache.rb:101:in `default_cache_instance'
from /Users/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/gravatar-ultimate-1.0.3/lib/gravatar/cache.rb:109:in `cache'
from /Users/joe/.rbenv/versions/1.9.3-p448/
Best solution would probably be to include it as a dependency in the gemfile
Hey there,
I was just getting going with it, and copied and pasted from the readme for my Gemfile, but it couldn't find the gem. I realized it's just spelled wrong โ
gem install gravitar-ultimate
should be
gem install gravatar-ultimate
Adding 'forcedefault' or 'f' allows you to ignore the user's gravatar and force it into one of the options (monsterid, identicon, etc...).
I forked the repo and made what I think are the required changes, but I was not able to install the forked gem, and hence I can't test it to see if it works. I've only been doing Ruby and RoR for three days...
More of the f option can be found here: http://en.gravatar.com/site/implement/images/ under "Force Default"
This is the erorr i get when i try to do this using Sinatra framework
Gravatar.new(current_user.email).image_url(:ssl => true)
NoMethodError - undefined method cache' for Rails:Module: gems/gravatar-ultimate-2.0.0/lib/gravatar/cache.rb:101:in
default_cache_instance'
gems/gravatar-ultimate-2.0.0/lib/gravatar/cache.rb:109:in cache' gems/gravatar-ultimate-2.0.0/lib/gravatar.rb:44:in
initialize'
Can this be fixed? or is there any work-around? Please help.
I had to take a look at the source to find out I could pass :secure as an option to image_url. Maybe you could mention that somewhere in the Wiki? It might make life a little bit easier for users. Not a big deal at all, of course.
I did not see anywhere in your docs how to override the ugly blue "G" that gravatar serves if the user email is not in the system. Can I check if the default image is going to come back and if so, serve a local image as a default instead of the blue "G"?
More of a feature request - can the gem bring avatars in via https ?
gravatar now supports profile information.
see:
https://en.gravatar.com/site/implement/profiles/
support would be great.
Howdy,
I believe the newer versions of Ruby have removed xmlrpc support. It's available as a gem though. Could the xmlrpc gem be added as a dependency of this gem?
Thanks!
It would be nice if I could write.
Gravatar.new("[email protected]").signup_url
# => https://en.gravatar.com/site/signup/generic%40example.com
Would you be interested in coding this or reviewing a push request?
References:
http://blog.gravatar.com/2009/08/10/what-has-been-going-on-in-the-world-of-gravatar/ ( did you know tidbit 2)
http://stackoverflow.com/questions/7371690/is-there-a-gravatar-signup-link-to-pre-populate-the-users-email-address
Thank you very much!
in rails console
url = Gravatar.new("[email protected]").image_data
Errno::ENAMETOOLONG: File name too long @ rb_sysopen - /home/tomi/rubyrubyruby/github/company/app_name/tmp/cache/gravatar-f6efe2ad4860e6774104c88114ad9dec-none%2Fhttp%3A%2F%2Fwww.gravatar.com%2Favatar%2Ff6efe2ad4860e6774104c88114ad9dec20140801-14666-1868pl1
ruby 2.1.1
rails 4.0.2 (I know I should upgrade :( )
gravatar-ultimate (2.0.0)
I have a mailer that will include a gravatar. I return to this awesome gem once again. I want a custom default icon to appear inline and embedded in an html email. Reason for being embedded is because I don't want the user to have to wait to load the resource from heroku if the app is "sleeping". If the device doesn't cache it, it will then be making multiple requests. Having it embedded would also make development easier. When specifying a default image with gravatar and this gem, gravatar makes an http request for your image and forwards it as their own. This is obviously not going to work for me.
There is no way for me to use this gem to check if a user has a gravatar image or not. Silly. However, I can specify gravatar to return a status header of 404 if there is no gravatar image for the user (or if they are not a user). Hmm...
Searching google, I found this snippet. It seemed to work, though I didn't test it thoroughly. Credit goes to Henrik Nyh. http://henrik.nyh.se/2008/11/gravatar-check/
require 'net/http'
require 'digest/md5'
# Is there a Gravatar for this email? Optionally specify :rating and :timeout.
def gravatar?(email, options = {})
hash = Digest::MD5.hexdigest(email.to_s.downcase)
options = { :rating => 'x', :timeout => 2 }.merge(options)
http = Net::HTTP.new('www.gravatar.com', 80)
http.read_timeout = options[:timeout]
response = http.request_head("/avatar/#{hash}?rating=#{options[:rating]}&default=http://gravatar.com/avatar")
response.code != '302'
rescue StandardError, Timeout::Error
true # Don't show "no gravatar" if the service is down or slow
end
This inspired me to come up with my own solution. I choose to use httparty, though I'm sure you can do it without if you choose. https://github.com/jnunemaker/httparty
if HTTParty.get(Gravatar.new(@user.email).image_url :default => 404).code == 404
It's as simple as that. Rework the if statement however you like to fit your situation. If there is no gravatar image, it will return true. Then do whatever you wish.
PS Adding this feature to the gem would be wonderful. ;)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.