Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[#20 state:closed] [#21 state:closed] froze gravatar, fixed user admi…

…n crud
  • Loading branch information...
commit be7a005d2289fd2eb09dc4ebd07bffbaa748414a 1 parent caf7cdf
@gaffo authored
View
2  app/controllers/admin/users_controller.rb
@@ -1,6 +1,8 @@
class Admin::UsersController < Admin::AdminBaseController
active_scaffold :user do |config|
config.list.columns = [:name, :is_admin, :author_feeds]
+ config.create.columns = [:name, :email, :is_admin, :password]
+ config.update.columns = [:name, :email, :is_admin, :password]
config.columns.exclude :created_at, :updated_at
config.columns[:author_feeds].form_ui = :select
end
View
4 app/views/user/show.html.erb
@@ -1,5 +1,5 @@
-<h1><%= @record.name %></h1>
-<%= image_tag(@record.gravatar_url) unless @record.email.nil? %>
+<h1><%= image_tag(@record.gravatar_url) unless @record.email.nil? %> <%= @record.name %></h1>
+
<% @record.posts.each do |post| %>
<div class="post">
<p class="date"><%= post.posted_date %><b><%= post.author_feed.name %></b></p>
View
20 vendor/gems/gravtastic-2.0.0/LICENSE
@@ -1,20 +0,0 @@
-Copyright (c) 2008 Chris Lloyd
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
95 vendor/gems/gravtastic-2.0.0/README.textile
@@ -1,95 +0,0 @@
-Easily add "Gravatars":http://gravatar.com to your Ruby objects.
-
-
-h2. Install
-
- sudo gem install gravtastic
-
-
-h2. Usage
-
-Somewhere in your application you need to @require 'gravtastic'@. In Rails >= 2.1 you can forego this and just add a dependency gem dependency for Gravtastic.
-
- config.gem 'gravtastic'
-
-If you are using Merb & DataMapper you can add do the same by adding the following to your init.rb file:
-
- dependency 'gravtastic'
-
-Make sure you add this after either the @use_orm :datamapper@ line or after a DataMapper extension. The next step is to give your model a Gravatar:
-
- class User
- is_gravtastic
- end
-
-If you are using a standard Ruby class you have to add the line @include Gravtastic::Resource@ before @is_gravtastic@.
-
-This defaults to looking for the gravatar ID on the @email@ method. So, if your @User@ has an @email@ then it will send that to Gravatar to get their picture. You can change the default gravatar source like this:
-
- is_gravtastic :with => :author_email
-
-Now, you can access your object's gravatar with the @gravatar_url@ method:
-
- current_user.gravatar_url
- => "http://gravatar.com/e9e719b44653a9300e1567f09f6b2e9e.png?r=PG"
-
-Note that it defaults to a PG rating. You can specify extra options with a hash:
-
- current_user.gravatar_url(:rating => 'R18', :size => 512)
- => "http://gravatar.com/e9e719b44653a9300e1567f09f6b2e9e.png?r=R18&s=512"
-
- current_user.gravatar_url(:secure => true)
- => "https://secure.gravatar.com/e9e719b44653a9300e1567f09f6b2e9e.png?r=PG"
-
-However, to DRY things up you can specify defaults in the class declaration.
-
- is_gravtastic :with => :author_email, :rating => 'R18', :size => 20
-
-Nice, now all the calls to gravatar_url will have the defaults you have specified. Any options that you pass when you use @gravatar_url@ will over-ride these class-defaults.
-
-PS. Bonus points for anybody who can tell me what that users email is!
-
-
-h2. Authors
-
-* "Chris Lloyd":http://chrislloyd.com.au
-* You
-
-
-h2. Contribute
-
-You can checkout the source or fork it yourself from Github.
-
- git clone git://github.com/chrislloyd/gravtastic.git
-
-If you submit a successful patch then you'll be given full commit rights to the project.
-
-
-h2. Thanks
-
-* "Xavier Shay":http://rhnh.net and others for "Enki":http://enkiblog.com (the reason this was written)
-* "Matthew Moore":http://www.matthewpaulmoore.com/ for helpful suggestions and for submitting it to the official list of Gravatar implementations.
-
-
-h2. License
-
-Copyright (c) 2008 Chris Lloyd.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-'Software'), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
72 vendor/gems/gravtastic-2.0.0/Rakefile
@@ -1,72 +0,0 @@
-require 'rubygems'
-require 'rake/gempackagetask'
-require 'rake/rdoctask'
-require 'rubygems/specification'
-require 'spec/rake/spectask'
-require 'date'
-
-GEM = "gravtastic"
-GEM_VERSION = "2.0.0"
-AUTHOR = "Chris Lloyd"
-EMAIL = "christopher.lloyd@gmail.com"
-HOMEPAGE = "http://github.com/chrislloyd/gravtastic"
-SUMMARY = "Easily add Gravatars to your Ruby objects."
-
-spec = Gem::Specification.new do |s|
- s.name = GEM
- s.version = GEM_VERSION
- s.platform = Gem::Platform::RUBY
- s.rubyforge_project = GEM
- s.has_rdoc = true
- s.extra_rdoc_files = ['README.textile', 'LICENSE']
- s.summary = SUMMARY
- s.description = s.summary
- s.author = AUTHOR
- s.email = EMAIL
- s.homepage = HOMEPAGE
-
- # Uncomment this to add a dependency
- # s.add_dependency "foo"
-
- s.require_path = 'lib'
- s.files = %w(LICENSE README.textile Rakefile) + Dir.glob("{lib,spec}/**/*")
-end
-
-desc "Run Specs"
-Rake::GemPackageTask.new(spec) do |pkg|
- pkg.gem_spec = spec
-end
-
-desc "Generate Documentation"
-Rake::RDocTask.new do |rdoc|
- rdoc.rdoc_dir = 'doc'
- rdoc.title = 'Gravtastic'
- rdoc.options << '--line-numbers' << '--inline-source' << '--main' << 'Gravtastic'
- rdoc.rdoc_files.include(FileList[ 'lib/**/*.rb', 'README.textile', 'LICENSE'])
-end
-
-task :default => :spec
-task :specs => :spec
-
-desc "Run all examples"
-Spec::Rake::SpecTask.new('spec') do |t|
- t.spec_opts = ['--options','spec/spec.opts']
- t.spec_files = FileList['spec/**/*.rb']
- t.rcov = true
-end
-
-desc "install the gem locally"
-task :install => [:package] do
- sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
-end
-
-desc "create a gemspec file"
-task :make_spec do
- File.open("#{GEM}.gemspec", "w") do |file|
- file.puts spec.to_ruby
- end
-end
-
-task :bugs do
- sh %{ditz html ; open html/index.html}
-end
View
182 vendor/gems/gravtastic-2.0.0/lib/gravtastic.rb
@@ -1,182 +0,0 @@
-$:.unshift(File.dirname(__FILE__)) unless
- $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
-
-require 'digest/md5'
-require 'cgi'
-
-# = Gravtastic - Easily add Gravatars to your Ruby objects.
-#
-# Copyright (C) 2008 mailto:christopher.lloyd@gmail.com
-#
-# == Example
-#
-# Somewhere in your application you need to <tt>require 'gravtastic'</tt>. In Rails >= 2.1 you can forego this and just add a dependency gem dependency for Gravtastic.
-#
-# config.gem 'gravtastic'
-#
-# If you are using Merb & DataMapper you can add do the same by adding the following to your init.rb file:
-#
-# dependency 'gravtastic'
-#
-# Make sure you add this after either the <tt>use_orm :datamapper</tt> line or after a DataMapper extension. The next step is to give your model a Gravatar:
-#
-# class User
-# is_gravtastic
-# end
-#
-# If you are using a standard Ruby class you have to add the line <tt>include Gravtastic::Resource</tt> before <tt>is_gravtastic</tt>.
-#
-# This defaults to looking for the gravatar ID on the <tt>email</tt> method. So, if your <tt>User</tt> has an <tt>email</tt> then it will send that to Gravatar to get their picture. You can change the default gravatar source like this:
-#
-# is_gravtastic :with => :author_email
-#
-# Now, you can access your object's gravatar with the <tt>gravatar_url</tt> method:
-#
-# current_user.gravatar_url
-# => "http://gravatar.com/e9e719b44653a9300e1567f09f6b2e9e.png?r=PG"
-#
-# Note that it defaults to a PG rating. You can specify extra options with a hash:
-#
-# current_user.gravatar_url(:rating => 'R18', :size => 512)
-# => "http://gravatar.com/e9e719b44653a9300e1567f09f6b2e9e.png?r=R18&s=512"
-#
-# current_user.gravatar_url(:secure => true)
-# => "https://secure.gravatar.com/e9e719b44653a9300e1567f09f6b2e9e.png?r=PG"
-#
-# However, to DRY things up you can specify defaults in the class declaration.
-#
-# is_gravtastic :with => :author_email, :rating => 'R18', :size => 20
-#
-# Nice, now all the calls to gravatar_url will have the defaults you have specified. Any options that you pass when you use <tt>gravatar_url</tt> will over-ride these class-defaults.
-#
-module Gravtastic
- module Resource
-
- def self.included(base) # :nodoc:
- base.extend(ClassMethods)
- end
-
- module ClassMethods
-
- #
- # Sets the gravatar_source. Basically starts this whole shindig.
- #
- # Examples:
- #
- # is_gravtastic
- #
- # is_gravtastic :with => :author_email
- #
- # is_gravtastic :with => :author_email, :rating => 'R18', :secure => true
- #
- def is_gravtastic(options={})
- @gravatar_source = options[:with] || :email
-
- options.delete_if {|key,_| ![:size, :rating, :default, :secure].include?(key) }
- @gravatar_defaults = {:rating => 'PG', :secure => false}.merge(options)
- end
-
- alias :has_gravatar :is_gravtastic
-
- #
- # Returns a symbol of the instance method where the Gravatar is pulled from.
- #
- # For example, if your users email is returned by the method <tt>#gobagaldy_gook</tt> then it
- # will return the symbol <tt>:gobagaldy_gook</tt>.
- #
- def gravatar_source
- @gravatar_source
- end
-
- #
- # Returns a hash of all the default gravtastic options.
- #
- def gravatar_defaults
- @gravatar_defaults
- end
-
- #
- # Returns <tt>true</tt> if the gravatar_source is set. <tt>false</tt> if not. Easy!
- #
- def has_gravatar?
- !!gravatar_source
- end
-
- end
-
- #
- # The raw MD5 hash used by Gravatar, generated from the ClassMethods#gravatar_source.
- #
- def gravatar_id
- if self.class.gravatar_source && value = send(self.class.gravatar_source)
- @gravatar_id = Digest::MD5.hexdigest(value.to_s.downcase)
- end
- end
-
- #
- # Returns a string with the URL for the instance's Gravatar.
- #
- # It defaults to <tt>:rating => 'PG'</tt> and <tt>:secure => false</tt>
- #
- # Examples:
- #
- # current_user.gravatar_url
- # => "http://gravatar.com/e9e719b44653a9300e1567f09f6b2e9e.png?r=PG"
- #
- # current_user.gravatar_url(:rating => 'R18', :size => 512, :default => 'http://example.com/images/example.jpg')
- # => "http://gravatar.com/e9e719b44653a9300e1567f09f6b2e9e.png?d=http%3A%2F%2Fexample.com%2Fimages%2Fexample.jpg&r=R18&s=512"
- #
- # current_user.gravatar_url(:secure => true)
- # => "https://secure.gravatar.com/e9e719b44653a9300e1567f09f6b2e9e.png?r=PG"
- #
- def gravatar_url(options={})
- options = self.class.gravatar_defaults.merge(options)
-
- @gravatar_url = gravatar_hostname(options[:secure]) + gravatar_filename + parse_url_options_hash(options)
- end
-
- private
-
- #
- # Parses a hash options for the image parameters. Returns a CGI escaped string.
- #
- def parse_url_options_hash(options)
- options.delete_if { |key,_| ![:size, :rating, :default].include?(key) }
-
- unless options.empty?
- '?' + options.map do |pair|
- pair[0] = pair[0].to_s[0,1] # Get the first character of the option
- pair.map{|item| item = CGI::escape(item.to_s) }.join('=') # Join key & value together
- end.sort.join('&') # Join options together
- else
- ''
- end
- end
-
- #
- # Returns the Gravatar.com hostname
- #
- def gravatar_hostname(secure)
- 'http' + (secure ? 's://secure.' : '://') + 'gravatar.com/avatar/'
- end
-
- #
- # Returns the filename of the gravatar image.
- #
- def gravatar_filename
- if gravatar_id
- gravatar_id + '.png'
- else
- ''
- end
- end
-
- end
-end
-
-ActiveRecord::Base.send(:include, Gravtastic::Resource) if defined?(ActiveRecord) # :nodoc:
-
-if defined?(DataMapper) # :nodoc:
- DataMapper::Resource.append_inclusions Gravtastic::Resource
- DataMapper::Model.append_extensions Gravtastic::Resource::ClassMethods
-end
View
38 vendor/gems/gravtastic-2.0.0/spec/gravtastic_integration_spec.rb
@@ -1,38 +0,0 @@
-require File.dirname(__FILE__) + '/spec_helper'
-require 'rubygems'
-
-require 'activerecord'
-require 'dm-core'
-
-reload_gravtastic!
-
-class User
- include DataMapper::Resource
- is_gravtastic
-end
-
-describe ActiveRecord::Base do
-
- it "includes Gravtastic::Resource" do
- ActiveRecord::Base.included_modules.should include(Gravtastic::Resource)
- end
-
- it "responds to .is_gravtastic" do
- ActiveRecord::Base.should respond_to(:is_gravtastic)
- end
-
-end
-
-describe DataMapper::Resource do
-
- it "includes Gravtastic::Resource" do
- User.included_modules.should include(Gravtastic::Resource)
- end
-
- it "responds to .is_gravtastic" do
- User.should respond_to(:is_gravtastic)
- end
-
-end
-
-
View
218 vendor/gems/gravtastic-2.0.0/spec/gravtastic_spec.rb
@@ -1,218 +0,0 @@
-require File.dirname(__FILE__) + '/spec_helper'
-
-describe Gravtastic::Resource do
-
- before(:each) do
- @user = mock('User')
- @user.class.send(:include, Gravtastic::Resource)
- @klass = @user.class
- end
-
- describe ".gravatar_source" do
-
- it "is nil if unset" do
- @klass.gravatar_source.should be_nil
- end
-
- it "returns the value of @gravatar_source" do
- @klass.instance_variable_set('@gravatar_source', :foo)
- @klass.gravatar_source.should == :foo
- end
-
- end
-
- describe ".gravatar_defaults" do
-
- it "it nil if unset" do
- @klass.gravatar_defaults.should be_nil
- end
-
- it "returns the value of @gravatar_defaults" do
- @klass.instance_variable_set('@gravatar_defaults', :foo)
- @klass.gravatar_source.should == :foo
- end
-
- end
-
- describe ".is_gravtastic" do
-
- it "sets .gravatar_source to :email by default" do
- @klass.is_gravtastic
- @klass.gravatar_source.should == :email
- end
-
- it "sets .gravatar_defaults to { :rating => 'PG', :secure => false } by default" do
- @klass.is_gravtastic
- @klass.gravatar_defaults.should == { :rating => 'PG', :secure => false }
- end
-
- it "sets .gravatar_source to :email by default, even when defaults are supplied" do
- @klass.is_gravtastic :secure => true
- @klass.gravatar_source.should == :email
- end
-
- it "keeps either :rating or :secure if only the other is passed as a default" do
- @klass.is_gravtastic :secure => true
- @klass.gravatar_defaults.should == { :rating => 'PG', :secure => true }
- end
-
- it "changes .gravatar_source" do
- lambda {
- @klass.is_gravtastic :with => :other_method
- }.should change(@klass, :gravatar_source)
- end
-
- it "changes .gravatar_defaults" do
- lambda {
- @klass.is_gravtastic :rating => 'R18'
- }.should change(@klass, :gravatar_defaults)
- end
-
- it "sets .gravatar_source to the value of :on" do
- @klass.is_gravtastic :with => :other_method
- @klass.gravatar_source.should == :other_method
- end
-
- it "sets .gravatar_defaults to the value of :defaults" do
- @klass.is_gravtastic :rating => 'R18'
- @klass.gravatar_defaults.should == { :rating => 'R18', :secure => false }
- end
-
- end
-
- describe ".has_gravatar?" do
-
- it "is true when .gravatar_source is not nil" do
- @user.class.stub!(:gravatar_source).and_return(:email)
- @user.class.should have_gravatar
- end
-
- it "is false when .gravatar_soruce is not is nil" do
- @user.class.stub!(:gravatar_source).and_return(nil)
- @user.class.should_not have_gravatar
- end
-
- end
-
- describe "#gravatar_id" do
-
- before(:each) do
- @user.stub!(:email).and_return('joe@example.com')
- @user.stub!(:name).and_return('Joe Bloggs')
- @user.class.stub!(:gravatar_source).and_return(:email)
- end
-
- it "is not nil when .gravatar_source is not nil" do
- @user.gravatar_id.should_not be_nil
- end
-
- it "is nil when .gravatar_source is nil" do
- @user.class.stub!(:gravatar_source).and_return(nil)
- @user.gravatar_id.should be_nil
- end
-
- it "changes when .gravatar_source is changed" do
- lambda {
- @user.class.stub!(:gravatar_source).and_return(:name)
- }.should change(@user, :gravatar_id)
- end
-
- it "is a MD5 hash" do
- @user.gravatar_id.should == 'f5b8fb60c6116331da07c65b96a8a1d1'
- end
-
- it "downcases any imput" do
- @user.stub!(:email).and_return('JOE@EXAMPLE.COM')
- @user.gravatar_id.should == 'f5b8fb60c6116331da07c65b96a8a1d1'
- end
-
- it "is nil when email is not a string" do
- @user.stub!(:email).and_return(nil)
- @user.gravatar_id.should == nil
- end
-
- end
-
- describe "#gravatar_url" do
-
- before(:each) do
- @user.stub!(:email).and_return('joe@example.com')
- @user.stub!(:name).and_return('Joe Bloggs')
- @user.class.stub!(:gravatar_source).and_return(:email)
- @user.class.stub!(:gravatar_defaults).and_return({:rating => 'PG'})
- end
-
- it "is not nil when .gravatar_source is not nil" do
- @user.gravatar_url.should_not be_nil
- end
-
- it "returns a default Gravatar url when .gravatar_source is nil" do
- @user.class.stub!(:gravatar_source).and_return(nil)
- @user.gravatar_url.should =~ /http:\/\/gravatar.com\/avatar/
- end
-
- it "always specifies a png resource type" do
- @user.gravatar_url.should match(/.png/)
- end
-
- it "returns a valid gravatar URL" do
- @user.gravatar_url.should == valid_gravatar_url + '?r=PG'
- end
-
- it "returns a valid SSL gravatar URL" do
- @user.gravatar_url(:secure => true).should == 'https://secure.gravatar.com/avatar/f5b8fb60c6116331da07c65b96a8a1d1.png?r=PG'
- end
-
- it "returns a url without the 'www'" do
- @user.gravatar_url.should_not match(/www/)
- end
-
- it "returns a valid gravatar URL even when invalid option is passed" do
- @user.gravatar_url(:foo => :bar).should == valid_gravatar_url + '?r=PG'
- end
-
- it "parses a size" do
- @user.gravatar_url(:size => 512).should == valid_gravatar_url + '?r=PG&s=512'
- end
-
- it "parses a rating" do
- @user.gravatar_url(:rating => 'MA').should == valid_gravatar_url + '?r=MA'
- end
-
- it "returns a valid gravatar URL when the rating option is unescaped" do
- @user.gravatar_url(:rating => 'Unescaped String').should == valid_gravatar_url + '?r=Unescaped+String'
- end
-
- it "parses a default image type" do
- @user.gravatar_url(:default => :identicon).should == valid_gravatar_url + '?d=identicon&r=PG'
- end
-
- it "parses a default image URL" do
- @user.gravatar_url(:default => 'http://example.com/images/example.jpg').should == valid_gravatar_url + '?d=http%3A%2F%2Fexample.com%2Fimages%2Fexample.jpg&r=PG'
- end
-
- it "parses multiple options" do
- @user.gravatar_url(:size => 20, :rating => 'R18', :default => :monsterid).should == valid_gravatar_url + '?d=monsterid&r=R18&s=20'
- end
-
- it "defaults to a 'PG' rating" do
- @user.gravatar_url(:rating => 'PG').should == @user.gravatar_url
- end
-
- it "uses the defaults from .gravatar_defaults" do
- @user.class.stub!(:gravatar_defaults).and_return({ :size => 20, :rating => 'R18'})
- @user.gravatar_url.should == valid_gravatar_url + '?r=R18&s=20'
- end
-
- it "returns a default Gravatar url when #gravatar_id is nil" do
- @user.stub!(:email).and_return(nil)
- @user.gravatar_url.should =~ /http:\/\/gravatar.com\/avatar/
- end
-
- def valid_gravatar_url # :nodoc:
- 'http://gravatar.com/avatar/f5b8fb60c6116331da07c65b96a8a1d1.png'
- end
-
- end
-
-end
View
1  vendor/gems/gravtastic-2.0.0/spec/spec.opts
@@ -1 +0,0 @@
---color
View
9 vendor/gems/gravtastic-2.0.0/spec/spec_helper.rb
@@ -1,9 +0,0 @@
-$TESTING=true
-$:.push File.join(File.dirname(__FILE__), '..', 'lib')
-
-def reload_gravtastic!
- Object.class_eval { remove_const :Gravtastic } if defined? Gravtastic
- require File.join(File.dirname(__FILE__),'../lib/gravtastic')
-end
-
-require 'gravtastic'
Please sign in to comment.
Something went wrong with that request. Please try again.