Sha256: 68c54bc30de1f96fc9a2c7227c70f2067350d1db9d0383fd3e655c70afc5073d
Contents?: true
Size: 1.97 KB
Versions: 1
Compression:
Stored size: 1.97 KB
Contents
# SocialAvatarProxy This gem acts as a proxy for avatars on Twitter & Facebook. [![Build Status][2]][1] [![Code Climate][3]][4] [1]: http://travis-ci.org/platformq/social-avatar-proxy [2]: https://secure.travis-ci.org/platformq/social-avatar-proxy.png?branch=master [3]: https://codeclimate.com/badge.png [4]: https://codeclimate.com/github/platformq/social-avatar-proxy ## Installation Add this line to your application's Gemfile: ```ruby gem "social-avatar-proxy" ``` And then execute: $ bundle Or install it yourself as: $ gem install social-avatar-proxy ## Usage ### Rails In your `config/routes.rb` file: ```ruby mount SocialAvatarProxy::Engine, at: "/avatars" ``` The engine is basically a proxy for the Rack app, it also adds the path helpers below: In your views: ```ruby # for a Twitter user, by username: image_tag(twitter_avatar_path("username")) # by ID: image_tag(twitter_avatar_path(12345)) # for a Facebook user, by username: image_tag(facebook_avatar_path("username")) # by ID: image_tag(facebook_avatar_path(12345)) ``` You might wish to configure a default image which will be rendered if an avatar could not be found, or if the remote service has an error (e.g. times out or has a redirect loop), this is simple with an initializer: ```ruby require "social_avatar_proxy/config" # choose our image image_path = Rails.root.join("public", "default_avatar.jpg") # set the config SocialAvatarProxy::Config.default_image = image_path ``` ### Rack The Rack app is available at: SocialAvatarProxy::App. Both the class and an instance respond to `call` so either can be mounted. The reason for this is that you might wish to set some options first, example: ```ruby use SocialAvatarProxy::App.new(cache_control: false) ``` ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
social-avatar-proxy-1.2.0 | README.md |