muck-engine 0.2.12 → 0.2.13

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.12
1
+ 0.2.13
@@ -1,3 +1,5 @@
1
+ require 'md5'
2
+
1
3
  module MuckEngineHelper
2
4
 
3
5
  # Outputs a small bit of javascript that will enable message
@@ -73,19 +75,52 @@ module MuckEngineHelper
73
75
  end
74
76
 
75
77
  # Render a photo for the given object. Note that the object will need a 'photo' method
76
- # provided by paperclip.
77
- # size is commonly one of:
78
- # :medium, :thumb, :icon or :tiny but can be any value provided by the photo object
79
- # object: Object to get icon for.
80
- # size: Size to get.
81
- # default_image: A default image should the photo not be found.
82
- def icon(object, size = :icon, default_image = '/images/profile_default.jpg')
78
+ # provided by paperclip. If the object does not provide an image, but does have an 'email' method
79
+ # this method will attempt to use gravatar.com to find a matching image.
80
+ #
81
+ # object: Object to get icon for.
82
+ # size: Size to get. size is commonly one of:
83
+ # :medium, :thumb, :icon or :tiny but can be any value provided by the photo object
84
+ # default_image: A default image should the photo not be found.
85
+ # gravatar_size: Size in pixels for the gravatar. Can be from 1 to 512. For reference the sizes from muck-profiles are:
86
+ # medium: 300, thumb: 100, icon: 50, tiny: 24. The default is set to 50 to match the default 'size' setting which is icon.
87
+ # rating: Default gravatar rating - g, pg, r, x.
88
+ # gravatar_default: If a gravatar is used, but no image is found several defaults are available. Leaving
89
+ # this value nil will result in the 'default_image' being used. Other wise one of the following can be set:
90
+ # identicon, monsterid, wavatar, 404
91
+ def icon(object, size = :icon, default_image = '/images/profile_default.jpg', use_only_gravatar = false, gravatar_size = 50, rating = 'g', gravatar_default = nil)
83
92
  return "" if object.blank?
84
- image_url = object.photo.url(size) rescue default_image
85
- image_url ||= default_image
93
+
94
+ if object.photo.original_filename && !use_only_gravatar
95
+ image_url = object.photo.url(size) rescue nil
96
+ end
97
+
98
+ if image_url.blank? && defined?(object.email)
99
+ gravatar_default = File.join(root_url, default_image) if gravatar_default.blank?
100
+ image_url = gravatar(object.email, gravatar_default, gravatar_size, rating)
101
+ else
102
+ image_url ||= default_image
103
+ end
104
+
86
105
  link_to(image_tag(image_url, :class => size), object, { :title => object.full_name })
87
106
  end
88
107
 
108
+ # Gets a gravatar for a given email
109
+ #
110
+ # gravatar_default: If a gravatar is used, but no image is found several defaults are available. Leaving
111
+ # this value nil will result in the 'default_image' being used. Other wise one of the following can be set:
112
+ # identicon, monsterid, wavatar, 404
113
+ # size: Size in pixels for the gravatar. Can be from 1 to 512.
114
+ # rating: Default gravatar rating - g, pg, r, x.
115
+ def gravatar(email, gravatar_default, size = 40, rating = 'g')
116
+ hash = MD5::md5(email)
117
+ image_url = "http://www.gravatar.com/avatar/#{hash}"
118
+ image_url << "?d=#{CGI::escape(gravatar_default)}"
119
+ image_url << "&s=#{size}"
120
+ image_url << "&r=#{rating}"
121
+ end
122
+
123
+ # Generates a secure mailto link
89
124
  def secure_mail_to(email)
90
125
  mail_to email, nil, :encode => 'javascript'
91
126
  end
@@ -112,7 +112,13 @@ class MuckEngine
112
112
  gem_lib = muck_gem_lib(gem_name)
113
113
  gem_path = File.join(path, muck_gem_path(gem_name))
114
114
  env_file = File.join(RAILS_ROOT, 'config', 'environment.rb')
115
- version = IO.read(File.join(gem_path, 'VERSION')).strip
115
+ version_file = File.join(gem_path, 'VERSION')
116
+ if !File.exists?(version_file)
117
+ puts "Could not find version file for #{gem_name}. You probably don't have the code for this gem.
118
+ No big deal since if you don't have the code you probably haven't change it. Skipping version for this gem."
119
+ return
120
+ end
121
+ version = IO.read(version_file).strip
116
122
  environment = IO.read(env_file)
117
123
 
118
124
  search = Regexp.new(/\:lib\s*=>\s*['"]#{gem_lib}['"],\s*\:version\s*=>\s*['"][ <>=~]*\d+\.\d+\.\d+['"]/)
data/muck-engine.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{muck-engine}
8
- s.version = "0.2.12"
8
+ s.version = "0.2.13"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Justin Ball"]
12
- s.date = %q{2009-11-07}
12
+ s.date = %q{2009-11-10}
13
13
  s.description = %q{The base engine for the muck system. Contains common tables, custom for, css and javascript.}
14
14
  s.email = %q{justinball@gmail.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muck-engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.12
4
+ version: 0.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Ball
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-07 00:00:00 -07:00
12
+ date: 2009-11-10 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency