GithubHelp home page GithubHelp logo

mdeering / gravatar_image_tag Goto Github PK

View Code? Open in Web Editor NEW
368.0 8.0 67.0 51 KB

A configurable and documented Rails view helper for adding gravatars into your Rails application

License: MIT License

Ruby 100.00%
ruby rails gravatar

gravatar_image_tag's People

Contributors

bf4 avatar chrisyour avatar geocom avatar jjb avatar mdeering avatar petergoldstein avatar vahtel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gravatar_image_tag's Issues

Double-escaping with &

The url_params function joins the bits with &, which results in double-encoding if you attempt to use the results of gravatar_url anywhere; it should just produce a clean URL and let Rails do its own escaping as appropriate.

Allow overriding `include_size_attributes`

I would like to have the width and height attributes set in most cases, but be able to override this behavior in some cases, when I am using the tag in a responsive situation.

Is there any reason that this is looking into the configuration directly, instead of looking into the provided options? Or am I not reading this right?

Adding more option to helper via hash

How do I add more options (such as class or id) to the helper call?

I have a hash options with the attributes I want to add

I tried gravatar_image_tag(email, options)
I tried gravatar_image_tag(email, :options => options)
I tried gravatar_image_tag(email, :gravatar => { .. }.merge(option))

none work..

Always generate width= and height= attributes

Since browsers layout web pages faster when they don't have to wait for an image (or fifty) to come down the net pipe, and gravatar_image_tag always knows what sizes they will be, could you add the corresponding width/height attributes to the img tag, too?

Thanks!

keyword arguments in ruby 3+

Hi, I'm not sure if you are supporting this gem anymore but if you are is there any change you can take a look at it for Ruby 3, specifically the keyword arguments breaking change?

Default Gravatar that is external and that actually resizes properly?

As asked on stackoverflow, I'm having issues when mixing 2 config options: having an external default image and resizing it. Using v1.0.0, here is my scenario:

  1. If the user doesn't have a gravatar attached to his email a default image is rendered; but I want it to reference an external file (e.g., http://www.iconfinder.com/ajax/download/png/?id=43350&s=128 instead of :identicon or others)
  2. I also want the image to be resized on the fly to, let's say 50px.

Independently, both options work as expected, but when I put them together:

def gravatar_for(user, options = { :default => 'http://www.iconfinder.com/ajax/download/png/?id=43350&s=128', :size => 50 })
  gravatar_image_tag(user.email.downcase, :alt => user.full_name,
                                          :class => 'gravatar',
                                          :gravatar => options)
end

the size option is not applied, and the gravatar gets rendered in it's full size (128px in this case).

What am I doing wrong, or how can I achieve this combination?

rails 3 -- undefined method 'gravatar_image_tag'

I am getting this error after I installed the gem:

ActionView::Template::Error (undefined method `gravatar_image_tag' for #<#Class:0x1940c580x193ef18):
1:


2: <%= gravatar_image_tag @user.email %>
3: <%= @user.name %>
4:


5:

app/views/users/show.html.erb:2:in '_app_views_users_show_html_erb__623389499_13233936__799847888'

I am using version 1.0.0.pre2, although I had the same error with 0.1.0.
I am Windows XP SP3, if that matters. Is this a routing issue?
Sorry, I am quite new to this and am running through a tutorial that uses this gem.

any help would be appreciated.

Retina display support

Would be cool to be able to specify an option that would enable support for Hi DPI displays.

I think it could be fairly simple - right now, the "size" attribute is used for both the <img> tag width and height, and the gravatar image URL. If there was a way to separate these two, so the <img> width/height were say 40, and the gravatar request would use size=80, I think that would cover it...

Strange default url in development mode

Hi,

I use your great gem in my opensource project but it fails to use default image uri correctly in development and production. I have this code :

gravatar_image_tag user.email, :alt => user.name, :class => "preview", :gravatar => { :default => http://localhost:3000/assets/icons/user.png , :size => size }

And when I can't use gravatar image for user I have this uri :

http://gravatar.com/avatar/f393a47b554d5812bd0b59bf8b19de13?default=http%3A%2F%2Flocalhost%3A3000%2Fassets%2Ficons%2Fuser.png&size=16

This uri fails because when I execute on my brower redirect to :

http://i0.wp.com/localhost/assets/icons/user.png

And when I use github picture like in your README it works ('https://assets.github.com/images/gravatars/gravatar-140.png').

Do you have encounter a problem like this?

Thanks for your work
Luc Donnet

Omit protocol

You can consume images just starting the url with //instead of use configuration {secure: true}. The browser uses the current page location's protocol when the img-src starts with //.

Rails Tutorial Users Please README

Restart you server after you run 'bundle install'. Please don't log an issue here if you have not done a restart of your rails server at a minimum to try and resolve your problem.

URI.escape is deprecated

Running on Ruby 2.7, I get this warning a lot:

vendor/bundle/ruby/2.7.0/gems/gravatar_image_tag-1.2.0/lib/gravatar_image_tag.rb:121: warning: URI.escape is obsolete

Everything still seems to work fine, but I'm afraid it might break on a newer version.

Invalid width/height attributes

I'm not terribly worried about it, as every browser under the sun will correctly interpret this, but we're generating image tags that have something like

<img ... height="55px" width="55px">

The "px" isn't technically valid HTML, and the W3C validator will puke on it. This should be

<img ... height="55" width="55">

The code responsible is here...

Gravatar URL contains unescaped ampersands

The Gravatar URL output by gravatar_image_tag contains unescaped ampersands. A simple fix would be to change the parameter to join the end of GravatarImageTag#url_params:89 from & to &amp;.

Thanks!

Invalid HTML

Hi!

This

def self.url_params(gravatar_params)
  return nil if gravatar_params.keys.size == 0
  array = gravatar_params.map { |k, v| "#{k}=#{value_cleaner(v)}" }
  "?#{array.join('&')}"
end

causes invalid html, if I run the http://validator.w3.org

Line 93, Column 122: & did not start a character reference. (& probably should have been escaped as &amp;.)…e66872a973005f1dae67?default=identicon&secure=true&size=50" width="50" height=…
Line 93, Column 134: & did not start a character reference. (& probably should have been escaped as &amp;.)…a973005f1dae67?default=identicon&secure=true&size=50" width="50" height="50" />

Changing the "&" to "&' would fix it..

Can you fix this, or should i provide a pull request?

I know it is just a little "error", but if all other validations pass it would be fine if also this last one pass :-)..

Matthias

License missing from gemspec

RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.

via e.g.

  spec.license = 'MIT'
  # or
  spec.licenses = ['MIT', 'GPL-2']

Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.

There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!

Appendix:

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies

p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.