tsalzer-img_gravatar 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc ADDED
@@ -0,0 +1,49 @@
1
+ = Image Gravatar
2
+
3
+ A simple plugin adding the +img_gravatar+ image link helper to ActionViews.
4
+
5
+ == Install
6
+
7
+ gem install tsalzer-img_gravatar --source http://gems.github.com
8
+
9
+
10
+ == What is a Gravatar?
11
+
12
+ A gravatar is a globally recognized avatar. It is an image hosted on the site
13
+ http://site.gravatar.com, uploaded by the user and referred to on base of
14
+ an eMail address. News on gravatar can be found at http://blog.gravatar.com.
15
+
16
+ Each gravatar image can be rated with respect to its content being suiteable to
17
+ audience.
18
+
19
+ == Usage
20
+
21
+ To use a gravatar on your system, your view needs the eMail address of the
22
+ individual to be displayed. The most simple case is like this:
23
+
24
+ <p>
25
+ <%= img_gravatar('me@email.com') %> That's me.
26
+ </p>
27
+
28
+ This will render the image of the person known under the eMail me@email.com
29
+ in your browser. If there is no person known with this name, it will render
30
+ the Gravatar logo.
31
+
32
+ A more complex szenario would include a size definition, and an alt image tag:
33
+
34
+ <p>
35
+ <%= img_gravetar('me@email.com', { :size => 40, :alt => "That's me." }) %>
36
+ </p>
37
+
38
+ This would render a downsized image of 40x40 with the alt-tag "That's me.".
39
+
40
+ For a complete description of available parameters see
41
+ Gravatar::InstanceMethods#gravatar in the Gravatar::InstanceMethods.
42
+
43
+ === Configuration Options
44
+
45
+ You can modify the following aspects of the displayed gravatar image:
46
+ * :alt - the alternative text for this image
47
+ * :default_url - the default URL for this gravatar
48
+ * :size - the requested gravatar size
49
+ * :rating - the requested maximum rating
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ # Rakefile for img_gravatar
2
+ require 'rubygems'
3
+ require 'rake'
4
+ require 'echoe'
5
+
6
+ Echoe.new('img_gravatar', '0.0.0') do |p|
7
+ p.description = "Add a img_gravatar helper to ActiveView."
8
+ p.url = "http://github.com/tsalzer/img_gravatar"
9
+ p.author = "Till Salzer"
10
+ p.email = "till.salzer@googlemail.com"
11
+ p.ignore_pattern = ["tmp/*", "script/*", "rdoc/*"]
12
+ p.development_dependencies = []
13
+ end
14
+
15
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{img_gravatar}
5
+ s.version = "0.0.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Till Salzer"]
9
+ s.date = %q{2009-01-17}
10
+ s.description = %q{Add a img_gravatar helper to ActiveView.}
11
+ s.email = %q{till.salzer@googlemail.com}
12
+ s.extra_rdoc_files = ["lib/img_gravatar.rb", "README.rdoc", "tasks/img_gravatar_tasks.rake"]
13
+ s.files = ["img_gravatar.gemspec", "init.rb", "install.rb", "lib/img_gravatar.rb", "Manifest", "Rakefile", "README.rdoc", "tasks/img_gravatar_tasks.rake", "test/img_gravatar_test.rb", "uninstall.rb"]
14
+ s.has_rdoc = true
15
+ s.homepage = %q{http://github.com/tsalzer/img_gravatar}
16
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Img_gravatar", "--main", "README.rdoc"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = %q{img_gravatar}
19
+ s.rubygems_version = %q{1.3.1}
20
+ s.summary = %q{Add a img_gravatar helper to ActiveView.}
21
+ s.test_files = ["test/img_gravatar_test.rb"]
22
+
23
+ if s.respond_to? :specification_version then
24
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
+ s.specification_version = 2
26
+
27
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
+ else
29
+ end
30
+ else
31
+ end
32
+ end
data/init.rb ADDED
@@ -0,0 +1,4 @@
1
+ # Include hook code here
2
+ # $Id$
3
+
4
+ require 'gravatar'
data/install.rb ADDED
@@ -0,0 +1,2 @@
1
+ # Install hook code here
2
+ # $Id$
@@ -0,0 +1,88 @@
1
+ require 'md5'
2
+ require 'uri'
3
+
4
+ # = Gravatar
5
+ #
6
+ # Adds the +gravatar+ method to ActionViews.
7
+ #
8
+ # $Id$
9
+ module ImgGravatar #:nodoc:
10
+ # gravatar.com base URL.
11
+ # This is +http://www.gravatar.com/avatar.php+.
12
+ mattr_reader :gravatar_base_url
13
+ @@gravatar_base_url = 'http://www.gravatar.com/avatar.php'
14
+
15
+ # default image URL. Default is +/img/no_gravatar.png+.
16
+ mattr_accessor :default_img_url
17
+ @@default_img_url = '/img/no_gravatar.png'
18
+
19
+ # Default size of the image in pixel. Default is +40+.
20
+ mattr_accessor :default_size
21
+ @@default_size = 40
22
+
23
+ # default rating.
24
+ # Valid values are +G+, default is +G+.
25
+ mattr_accessor :default_rating
26
+ @@default_rating = 'G'
27
+
28
+ # Methods injected in all ActionView classes.
29
+ module Base #:nodoc:
30
+ def self.included(mod) #:nodoc:
31
+ mod.extend(ClassMethods)
32
+ end
33
+ end
34
+
35
+ # Methods injected in all ActionView classes.
36
+ module ClassMethods #:nodoc:
37
+ def self.extended(mod) #:nodoc#
38
+ class_eval do
39
+ include Gravatar::InstanceMethods
40
+ end
41
+ end
42
+ end
43
+
44
+ module InstanceMethods
45
+ ############################################################################
46
+ # get the default Gravatar image.
47
+ # options:
48
+ # :alt - the alternative text for this image
49
+ # :default_url - the default URL for this gravatar
50
+ # :size - the requested gravatar size
51
+ # :rating - the requested maximum rating
52
+ def img_gravatar(email, opts={})
53
+ # the defaults
54
+ alt = nil
55
+ default_img_url = ImgGravatar.default_img_url
56
+ size = ImgGravatar.default_size
57
+ rating = ImgGravatar.default_rating
58
+
59
+ # now, load infos from options
60
+ alt = opts[:alt] if opts[:alt]
61
+ default_img_url = opts[:default_url] if opts[:default_url]
62
+ size = opts[:size] if opts[:size]
63
+ rating = opts[:rating] if opts[:rating]
64
+
65
+ #uri = URI::HTTP.new(Gravatar.gravatar_base_url)
66
+ uri = "%s?gravatar_id=%s&rating=%s&size=%s" % [ImgGravatar.gravatar_base_url,
67
+ MD5.md5(email.strip),
68
+ rating,
69
+ size
70
+ ]
71
+
72
+ if alt then
73
+ "<img src=\"%s\" alt=\"%s\" />" % [uri, alt]
74
+ else
75
+ "<img src=\"%s\" />" % uri
76
+ end
77
+ end
78
+
79
+ end
80
+ end
81
+
82
+ # inject into ActionView.
83
+ #ActionView::Base.class_eval do
84
+ # include Gravatar::Base
85
+ #end
86
+ ActionView::Base.send :include, ImgGravatar::InstanceMethods
87
+
88
+
@@ -0,0 +1,29 @@
1
+ # desc "Explaining what the task does"
2
+ # task :gravatar do
3
+ # # Task goes here
4
+ # end
5
+
6
+ =begin
7
+ require 'rake/testtask'
8
+ require 'rake/rdoctask'
9
+
10
+
11
+ desc 'Default: run unit tests.'
12
+ task :default => :test
13
+
14
+ desc 'Test the gravatar plugin.'
15
+ Rake::TestTask.new(:test) do |t|
16
+ t.libs << 'lib'
17
+ t.pattern = 'test/**/*_test.rb'
18
+ t.verbose = true
19
+ end
20
+
21
+ desc 'Generate documentation for the gravatar plugin.'
22
+ Rake::RDocTask.new(:rdoc) do |rdoc|
23
+ rdoc.rdoc_dir = 'rdoc'
24
+ rdoc.title = 'Image Gravatar'
25
+ rdoc.options << '--line-numbers' << '--inline-source'
26
+ rdoc.rdoc_files.include('README.rdoc')
27
+ rdoc.rdoc_files.include('lib/**/*.rb')
28
+ end
29
+ =end
@@ -0,0 +1,9 @@
1
+ # Unit tests for ImgGravatar
2
+ require 'test/unit'
3
+
4
+ class ImgGravatarTest < Test::Unit::TestCase
5
+ # TODO: Replace this with your real tests.
6
+ def test_this_plugin
7
+ flunk
8
+ end
9
+ end
data/uninstall.rb ADDED
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tsalzer-img_gravatar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Till Salzer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-17 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Add a img_gravatar helper to ActiveView.
17
+ email: till.salzer@googlemail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - lib/img_gravatar.rb
24
+ - README.rdoc
25
+ - tasks/img_gravatar_tasks.rake
26
+ files:
27
+ - img_gravatar.gemspec
28
+ - init.rb
29
+ - install.rb
30
+ - lib/img_gravatar.rb
31
+ - Manifest
32
+ - Rakefile
33
+ - README.rdoc
34
+ - tasks/img_gravatar_tasks.rake
35
+ - test/img_gravatar_test.rb
36
+ - uninstall.rb
37
+ has_rdoc: true
38
+ homepage: http://github.com/tsalzer/img_gravatar
39
+ post_install_message:
40
+ rdoc_options:
41
+ - --line-numbers
42
+ - --inline-source
43
+ - --title
44
+ - Img_gravatar
45
+ - --main
46
+ - README.rdoc
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "1.2"
60
+ version:
61
+ requirements: []
62
+
63
+ rubyforge_project: img_gravatar
64
+ rubygems_version: 1.2.0
65
+ signing_key:
66
+ specification_version: 2
67
+ summary: Add a img_gravatar helper to ActiveView.
68
+ test_files:
69
+ - test/img_gravatar_test.rb