Skip to content
Browse files

Upgraded to Rails 2.2.2

  • Loading branch information...
1 parent 28d8a0a commit b88e3d92397bff9afa7b1ff72a87913734709757 conrad committed
Showing with 9,503 additions and 9 deletions.
  1. +4 −0 .gitignore
  2. +1 −8 app/models/post.rb
  3. +2 −1 config/environment.rb
  4. 0 log/.gitignore
  5. 0 tmp/.gitignore
  6. +152 −0 vendor/plugins/classic_pagination/CHANGELOG
  7. +18 −0 vendor/plugins/classic_pagination/README
  8. +22 −0 vendor/plugins/classic_pagination/Rakefile
  9. +33 −0 vendor/plugins/classic_pagination/init.rb
  10. +1 −0 vendor/plugins/classic_pagination/install.rb
  11. +405 −0 vendor/plugins/classic_pagination/lib/pagination.rb
  12. +135 −0 vendor/plugins/classic_pagination/lib/pagination_helper.rb
  13. +24 −0 vendor/plugins/classic_pagination/test/fixtures/companies.yml
  14. +9 −0 vendor/plugins/classic_pagination/test/fixtures/company.rb
  15. +7 −0 vendor/plugins/classic_pagination/test/fixtures/developer.rb
  16. +21 −0 vendor/plugins/classic_pagination/test/fixtures/developers.yml
  17. +13 −0 vendor/plugins/classic_pagination/test/fixtures/developers_projects.yml
  18. +3 −0 vendor/plugins/classic_pagination/test/fixtures/project.rb
  19. +7 −0 vendor/plugins/classic_pagination/test/fixtures/projects.yml
  20. +13 −0 vendor/plugins/classic_pagination/test/fixtures/replies.yml
  21. +5 −0 vendor/plugins/classic_pagination/test/fixtures/reply.rb
  22. +42 −0 vendor/plugins/classic_pagination/test/fixtures/schema.sql
  23. +3 −0 vendor/plugins/classic_pagination/test/fixtures/topic.rb
  24. +22 −0 vendor/plugins/classic_pagination/test/fixtures/topics.yml
  25. +117 −0 vendor/plugins/classic_pagination/test/helper.rb
  26. +38 −0 vendor/plugins/classic_pagination/test/pagination_helper_test.rb
  27. +177 −0 vendor/plugins/classic_pagination/test/pagination_test.rb
  28. +349 −0 vendor/rails/actionmailer/CHANGELOG
  29. +21 −0 vendor/rails/actionmailer/MIT-LICENSE
  30. +149 −0 vendor/rails/actionmailer/README
  31. +98 −0 vendor/rails/actionmailer/Rakefile
  32. +30 −0 vendor/rails/actionmailer/install.rb
  33. +52 −0 vendor/rails/actionmailer/lib/action_mailer.rb
  34. +30 −0 vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb
  35. +690 −0 vendor/rails/actionmailer/lib/action_mailer/base.rb
  36. +111 −0 vendor/rails/actionmailer/lib/action_mailer/helpers.rb
  37. +19 −0 vendor/rails/actionmailer/lib/action_mailer/mail_helper.rb
  38. +110 −0 vendor/rails/actionmailer/lib/action_mailer/part.rb
  39. +51 −0 vendor/rails/actionmailer/lib/action_mailer/part_container.rb
  40. +61 −0 vendor/rails/actionmailer/lib/action_mailer/quoting.rb
  41. +64 −0 vendor/rails/actionmailer/lib/action_mailer/test_case.rb
  42. +67 −0 vendor/rails/actionmailer/lib/action_mailer/test_helper.rb
  43. +8 −0 vendor/rails/actionmailer/lib/action_mailer/utils.rb
  44. +14 −0 vendor/rails/actionmailer/lib/action_mailer/vendor.rb
  45. +1,466 −0 vendor/rails/actionmailer/lib/action_mailer/vendor/text-format-0.6.3/text/format.rb
  46. +5 −0 vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail.rb
  47. +426 −0 vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/address.rb
  48. +46 −0 vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/attachments.rb
  49. +46 −0 vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/base64.rb
  50. +41 −0 vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/compat.rb
  51. +67 −0 vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/config.rb
  52. +63 −0 vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/core_extensions.rb
  53. +581 −0 vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/encode.rb
  54. +960 −0 vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/header.rb
  55. +9 −0 vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/index.rb
  56. +1,130 −0 vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/interface.rb
  57. +3 −0 vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/loader.rb
  58. +578 −0 vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/mail.rb
  59. +495 −0 vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/mailbox.rb
  60. +6 −0 vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/main.rb
  61. +3 −0 vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/mbox.rb
  62. +248 −0 vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/net.rb
  63. +132 −0 vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/obsolete.rb
Sorry, we could not display the entire diff because too many files (1,492) changed.
View
4 .gitignore
@@ -0,0 +1,4 @@
+log/*.log
+tmp/**/*
+*~
+.#*
View
9 app/models/post.rb
@@ -4,14 +4,7 @@ class Post < ActiveRecord::Base
validates_presence_of :title, :description, :category_id, :author, :email
def Post.recent_items
- num_recent = 0
-
- posts = Post.find_all
- posts.each do |p|
- num_recent += 1 if p.created_at > (7.days/NOTIFY_FREQUENCY).ago
- end
-
- num_recent
+ Post.find(:all, :conditions => ['created_at > ?', (7.days/NOTIFY_FREQUENCY).ago]).length
end
end
View
3 config/environment.rb
@@ -39,6 +39,7 @@
# config.active_record.default_timezone = :utc
# See Rails::Configuration for more options
+ config.action_controller.session = { :session_key => "_gracelist_session", :secret => "beimitatorsofgodthereforeasdearlylovedchildrenandlivealifeoflovejustaschristlovedus" }
end
# Add new inflection rules using the following format
@@ -58,7 +59,7 @@
c = YAML::load(File.open("#{RAILS_ROOT}/config/config.yml"))
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.delivery_method = c[RAILS_ENV]['email']['delivery_method']
-ActionMailer::Base.server_settings = {
+ActionMailer::Base.smtp_settings = {
:address => c[RAILS_ENV]['email']['server'],
:port => c[RAILS_ENV]['email']['port'],
:domain => c[RAILS_ENV]['email']['domain'],
View
0 log/.gitignore
No changes.
View
0 tmp/.gitignore
No changes.
View
152 vendor/plugins/classic_pagination/CHANGELOG
@@ -0,0 +1,152 @@
+* Exported the changelog of Pagination code for historical reference.
+
+* Imported some patches from Rails Trac (others closed as "wontfix"):
+ #8176, #7325, #7028, #4113. Documentation is much cleaner now and there
+ are some new unobtrusive features!
+
+* Extracted Pagination from Rails trunk (r6795)
+
+#
+# ChangeLog for /trunk/actionpack/lib/action_controller/pagination.rb
+#
+# Generated by Trac 0.10.3
+# 05/20/07 23:48:02
+#
+
+09/03/06 23:28:54 david [4953]
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ Docs and deprecation
+
+08/07/06 12:40:14 bitsweat [4715]
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ Deprecate direct usage of @params. Update ActionView::Base for
+ instance var deprecation.
+
+06/21/06 02:16:11 rick [4476]
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ Fix indent in pagination documentation. Closes #4990. [Kevin Clark]
+
+04/25/06 17:42:48 marcel [4268]
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ Remove all remaining references to @params in the documentation.
+
+03/16/06 06:38:08 rick [3899]
+ * trunk/actionpack/lib/action_view/helpers/pagination_helper.rb (modified)
+ trivial documentation patch for #pagination_links [Francois
+ Beausoleil] closes #4258
+
+02/20/06 03:15:22 david [3620]
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ * trunk/actionpack/test/activerecord/pagination_test.rb (modified)
+ * trunk/activerecord/CHANGELOG (modified)
+ * trunk/activerecord/lib/active_record/base.rb (modified)
+ * trunk/activerecord/test/base_test.rb (modified)
+ Added :count option to pagination that'll make it possible for the
+ ActiveRecord::Base.count call to using something else than * for the
+ count. Especially important for count queries using DISTINCT #3839
+ [skaes]. Added :select option to Base.count that'll allow you to
+ select something else than * to be counted on. Especially important
+ for count queries using DISTINCT (closes #3839) [skaes].
+
+02/09/06 09:17:40 nzkoz [3553]
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ * trunk/actionpack/test/active_record_unit.rb (added)
+ * trunk/actionpack/test/activerecord (added)
+ * trunk/actionpack/test/activerecord/active_record_assertions_test.rb (added)
+ * trunk/actionpack/test/activerecord/pagination_test.rb (added)
+ * trunk/actionpack/test/controller/active_record_assertions_test.rb (deleted)
+ * trunk/actionpack/test/fixtures/companies.yml (added)
+ * trunk/actionpack/test/fixtures/company.rb (added)
+ * trunk/actionpack/test/fixtures/db_definitions (added)
+ * trunk/actionpack/test/fixtures/db_definitions/sqlite.sql (added)
+ * trunk/actionpack/test/fixtures/developer.rb (added)
+ * trunk/actionpack/test/fixtures/developers_projects.yml (added)
+ * trunk/actionpack/test/fixtures/developers.yml (added)
+ * trunk/actionpack/test/fixtures/project.rb (added)
+ * trunk/actionpack/test/fixtures/projects.yml (added)
+ * trunk/actionpack/test/fixtures/replies.yml (added)
+ * trunk/actionpack/test/fixtures/reply.rb (added)
+ * trunk/actionpack/test/fixtures/topic.rb (added)
+ * trunk/actionpack/test/fixtures/topics.yml (added)
+ * Fix pagination problems when using include
+ * Introduce Unit Tests for pagination
+ * Allow count to work with :include by using count distinct.
+
+ [Kevin Clark &amp; Jeremy Hopple]
+
+11/05/05 02:10:29 bitsweat [2878]
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ Update paginator docs. Closes #2744.
+
+10/16/05 15:42:03 minam [2649]
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ Update/clean up AP documentation (rdoc)
+
+08/31/05 00:13:10 ulysses [2078]
+ * trunk/actionpack/CHANGELOG (modified)
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ Add option to specify the singular name used by pagination. Closes
+ #1960
+
+08/23/05 14:24:15 minam [2041]
+ * trunk/actionpack/CHANGELOG (modified)
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ Add support for :include with pagination (subject to existing
+ constraints for :include with :limit and :offset) #1478
+ [michael@schubert.cx]
+
+07/15/05 20:27:38 david [1839]
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ * trunk/actionpack/lib/action_view/helpers/pagination_helper.rb (modified)
+ More pagination speed #1334 [Stefan Kaes]
+
+07/14/05 08:02:01 david [1832]
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ * trunk/actionpack/lib/action_view/helpers/pagination_helper.rb (modified)
+ * trunk/actionpack/test/controller/addresses_render_test.rb (modified)
+ Made pagination faster #1334 [Stefan Kaes]
+
+04/13/05 05:40:22 david [1159]
+ * trunk/actionpack/CHANGELOG (modified)
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ * trunk/activerecord/lib/active_record/base.rb (modified)
+ Fixed pagination to work with joins #1034 [scott@sigkill.org]
+
+04/02/05 09:11:17 david [1067]
+ * trunk/actionpack/CHANGELOG (modified)
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ * trunk/actionpack/lib/action_controller/scaffolding.rb (modified)
+ * trunk/actionpack/lib/action_controller/templates/scaffolds/list.rhtml (modified)
+ * trunk/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb (modified)
+ * trunk/railties/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml (modified)
+ Added pagination for scaffolding (10 items per page) #964
+ [mortonda@dgrmm.net]
+
+03/31/05 14:46:11 david [1048]
+ * trunk/actionpack/lib/action_view/helpers/pagination_helper.rb (modified)
+ Improved the message display on the exception handler pages #963
+ [Johan Sorensen]
+
+03/27/05 00:04:07 david [1017]
+ * trunk/actionpack/CHANGELOG (modified)
+ * trunk/actionpack/lib/action_view/helpers/pagination_helper.rb (modified)
+ Fixed that pagination_helper would ignore :params #947 [Sebastian
+ Kanthak]
+
+03/22/05 13:09:44 david [976]
+ * trunk/actionpack/lib/action_view/helpers/pagination_helper.rb (modified)
+ Fixed documentation and prepared for 0.11.0 release
+
+03/21/05 14:35:36 david [967]
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ * trunk/actionpack/lib/action_view/helpers/pagination_helper.rb (modified)
+ Tweaked the documentation
+
+03/20/05 23:12:05 david [949]
+ * trunk/actionpack/CHANGELOG (modified)
+ * trunk/actionpack/lib/action_controller.rb (modified)
+ * trunk/actionpack/lib/action_controller/pagination.rb (added)
+ * trunk/actionpack/lib/action_view/helpers/pagination_helper.rb (added)
+ * trunk/activesupport/lib/active_support/core_ext/kernel.rb (added)
+ Added pagination support through both a controller and helper add-on
+ #817 [Sam Stephenson]
View
18 vendor/plugins/classic_pagination/README
@@ -0,0 +1,18 @@
+Pagination
+==========
+
+To install:
+
+ script/plugin install svn://errtheblog.com/svn/plugins/classic_pagination
+
+This code was extracted from Rails trunk after the release 1.2.3.
+WARNING: this code is dead. It is unmaintained, untested and full of cruft.
+
+There is a much better pagination plugin called will_paginate.
+Install it like this and glance through the README:
+
+ script/plugin install svn://errtheblog.com/svn/plugins/will_paginate
+
+It doesn't have the same API, but is in fact much nicer. You can
+have both plugins installed until you change your controller/view code that
+handles pagination. Then, simply uninstall classic_pagination.
View
22 vendor/plugins/classic_pagination/Rakefile
@@ -0,0 +1,22 @@
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+desc 'Default: run unit tests.'
+task :default => :test
+
+desc 'Test the classic_pagination plugin.'
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+end
+
+desc 'Generate documentation for the classic_pagination plugin.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'Pagination'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
View
33 vendor/plugins/classic_pagination/init.rb
@@ -0,0 +1,33 @@
+#--
+# Copyright (c) 2004-2006 David Heinemeier Hansson
+#
+# 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.
+#++
+
+require 'pagination'
+require 'pagination_helper'
+
+ActionController::Base.class_eval do
+ include ActionController::Pagination
+end
+
+ActionView::Base.class_eval do
+ include ActionView::Helpers::PaginationHelper
+end
View
1 vendor/plugins/classic_pagination/install.rb
@@ -0,0 +1 @@
+puts "\n\n" + File.read(File.dirname(__FILE__) + '/README')
View
405 vendor/plugins/classic_pagination/lib/pagination.rb
@@ -0,0 +1,405 @@
+module ActionController
+ # === Action Pack pagination for Active Record collections
+ #
+ # The Pagination module aids in the process of paging large collections of
+ # Active Record objects. It offers macro-style automatic fetching of your
+ # model for multiple views, or explicit fetching for single actions. And if
+ # the magic isn't flexible enough for your needs, you can create your own
+ # paginators with a minimal amount of code.
+ #
+ # The Pagination module can handle as much or as little as you wish. In the
+ # controller, have it automatically query your model for pagination; or,
+ # if you prefer, create Paginator objects yourself.
+ #
+ # Pagination is included automatically for all controllers.
+ #
+ # For help rendering pagination links, see
+ # ActionView::Helpers::PaginationHelper.
+ #
+ # ==== Automatic pagination for every action in a controller
+ #
+ # class PersonController < ApplicationController
+ # model :person
+ #
+ # paginate :people, :order => 'last_name, first_name',
+ # :per_page => 20
+ #
+ # # ...
+ # end
+ #
+ # Each action in this controller now has access to a <tt>@people</tt>
+ # instance variable, which is an ordered collection of model objects for the
+ # current page (at most 20, sorted by last name and first name), and a
+ # <tt>@person_pages</tt> Paginator instance. The current page is determined
+ # by the <tt>params[:page]</tt> variable.
+ #
+ # ==== Pagination for a single action
+ #
+ # def list
+ # @person_pages, @people =
+ # paginate :people, :order => 'last_name, first_name'
+ # end
+ #
+ # Like the previous example, but explicitly creates <tt>@person_pages</tt>
+ # and <tt>@people</tt> for a single action, and uses the default of 10 items
+ # per page.
+ #
+ # ==== Custom/"classic" pagination
+ #
+ # def list
+ # @person_pages = Paginator.new self, Person.count, 10, params[:page]
+ # @people = Person.find :all, :order => 'last_name, first_name',
+ # :limit => @person_pages.items_per_page,
+ # :offset => @person_pages.current.offset
+ # end
+ #
+ # Explicitly creates the paginator from the previous example and uses
+ # Paginator#to_sql to retrieve <tt>@people</tt> from the model.
+ #
+ module Pagination
+ unless const_defined?(:OPTIONS)
+ # A hash holding options for controllers using macro-style pagination
+ OPTIONS = Hash.new
+
+ # The default options for pagination
+ DEFAULT_OPTIONS = {
+ :class_name => nil,
+ :singular_name => nil,
+ :per_page => 10,
+ :conditions => nil,
+ :order_by => nil,
+ :order => nil,
+ :join => nil,
+ :joins => nil,
+ :count => nil,
+ :include => nil,
+ :select => nil,
+ :group => nil,
+ :parameter => 'page'
+ }
+ else
+ DEFAULT_OPTIONS[:group] = nil
+ end
+
+ def self.included(base) #:nodoc:
+ super
+ base.extend(ClassMethods)
+ end
+
+ def self.validate_options!(collection_id, options, in_action) #:nodoc:
+ options.merge!(DEFAULT_OPTIONS) {|key, old, new| old}
+
+ valid_options = DEFAULT_OPTIONS.keys
+ valid_options << :actions unless in_action
+
+ unknown_option_keys = options.keys - valid_options
+ raise ActionController::ActionControllerError,
+ "Unknown options: #{unknown_option_keys.join(', ')}" unless
+ unknown_option_keys.empty?
+
+ options[:singular_name] ||= ActiveSupport::Inflector.singularize(collection_id.to_s)
+ options[:class_name] ||= ActiveSupport::Inflector.camelize(options[:singular_name])
+ end
+
+ # Returns a paginator and a collection of Active Record model instances
+ # for the paginator's current page. This is designed to be used in a
+ # single action; to automatically paginate multiple actions, consider
+ # ClassMethods#paginate.
+ #
+ # +options+ are:
+ # <tt>:singular_name</tt>:: the singular name to use, if it can't be inferred by singularizing the collection name
+ # <tt>:class_name</tt>:: the class name to use, if it can't be inferred by
+ # camelizing the singular name
+ # <tt>:per_page</tt>:: the maximum number of items to include in a
+ # single page. Defaults to 10
+ # <tt>:conditions</tt>:: optional conditions passed to Model.find(:all, *params) and
+ # Model.count
+ # <tt>:order</tt>:: optional order parameter passed to Model.find(:all, *params)
+ # <tt>:order_by</tt>:: (deprecated, used :order) optional order parameter passed to Model.find(:all, *params)
+ # <tt>:joins</tt>:: optional joins parameter passed to Model.find(:all, *params)
+ # and Model.count
+ # <tt>:join</tt>:: (deprecated, used :joins or :include) optional join parameter passed to Model.find(:all, *params)
+ # and Model.count
+ # <tt>:include</tt>:: optional eager loading parameter passed to Model.find(:all, *params)
+ # and Model.count
+ # <tt>:select</tt>:: :select parameter passed to Model.find(:all, *params)
+ #
+ # <tt>:count</tt>:: parameter passed as :select option to Model.count(*params)
+ #
+ # <tt>:group</tt>:: :group parameter passed to Model.find(:all, *params). It forces the use of DISTINCT instead of plain COUNT to come up with the total number of records
+ #
+ def paginate(collection_id, options={})
+ Pagination.validate_options!(collection_id, options, true)
+ paginator_and_collection_for(collection_id, options)
+ end
+
+ # These methods become class methods on any controller
+ module ClassMethods
+ # Creates a +before_filter+ which automatically paginates an Active
+ # Record model for all actions in a controller (or certain actions if
+ # specified with the <tt>:actions</tt> option).
+ #
+ # +options+ are the same as PaginationHelper#paginate, with the addition
+ # of:
+ # <tt>:actions</tt>:: an array of actions for which the pagination is
+ # active. Defaults to +nil+ (i.e., every action)
+ def paginate(collection_id, options={})
+ Pagination.validate_options!(collection_id, options, false)
+ module_eval do
+ before_filter :create_paginators_and_retrieve_collections
+ OPTIONS[self] ||= Hash.new
+ OPTIONS[self][collection_id] = options
+ end
+ end
+ end
+
+ def create_paginators_and_retrieve_collections #:nodoc:
+ Pagination::OPTIONS[self.class].each do |collection_id, options|
+ next unless options[:actions].include? action_name if
+ options[:actions]
+
+ paginator, collection =
+ paginator_and_collection_for(collection_id, options)
+
+ paginator_name = "@#{options[:singular_name]}_pages"
+ self.instance_variable_set(paginator_name, paginator)
+
+ collection_name = "@#{collection_id.to_s}"
+ self.instance_variable_set(collection_name, collection)
+ end
+ end
+
+ # Returns the total number of items in the collection to be paginated for
+ # the +model+ and given +conditions+. Override this method to implement a
+ # custom counter.
+ def count_collection_for_pagination(model, options)
+ model.count(:conditions => options[:conditions],
+ :joins => options[:join] || options[:joins],
+ :include => options[:include],
+ :select => (options[:group] ? "DISTINCT #{options[:group]}" : options[:count]))
+ end
+
+ # Returns a collection of items for the given +model+ and +options[conditions]+,
+ # ordered by +options[order]+, for the current page in the given +paginator+.
+ # Override this method to implement a custom finder.
+ def find_collection_for_pagination(model, options, paginator)
+ model.find(:all, :conditions => options[:conditions],
+ :order => options[:order_by] || options[:order],
+ :joins => options[:join] || options[:joins], :include => options[:include],
+ :select => options[:select], :limit => options[:per_page],
+ :group => options[:group], :offset => paginator.current.offset)
+ end
+
+ protected :create_paginators_and_retrieve_collections,
+ :count_collection_for_pagination,
+ :find_collection_for_pagination
+
+ def paginator_and_collection_for(collection_id, options) #:nodoc:
+ klass = options[:class_name].constantize
+ page = params[options[:parameter]]
+ count = count_collection_for_pagination(klass, options)
+ paginator = Paginator.new(self, count, options[:per_page], page)
+ collection = find_collection_for_pagination(klass, options, paginator)
+
+ return paginator, collection
+ end
+
+ private :paginator_and_collection_for
+
+ # A class representing a paginator for an Active Record collection.
+ class Paginator
+ include Enumerable
+
+ # Creates a new Paginator on the given +controller+ for a set of items
+ # of size +item_count+ and having +items_per_page+ items per page.
+ # Raises ArgumentError if items_per_page is out of bounds (i.e., less
+ # than or equal to zero). The page CGI parameter for links defaults to
+ # "page" and can be overridden with +page_parameter+.
+ def initialize(controller, item_count, items_per_page, current_page=1)
+ raise ArgumentError, 'must have at least one item per page' if
+ items_per_page <= 0
+
+ @controller = controller
+ @item_count = item_count || 0
+ @items_per_page = items_per_page
+ @pages = {}
+
+ self.current_page = current_page
+ end
+ attr_reader :controller, :item_count, :items_per_page
+
+ # Sets the current page number of this paginator. If +page+ is a Page
+ # object, its +number+ attribute is used as the value; if the page does
+ # not belong to this Paginator, an ArgumentError is raised.
+ def current_page=(page)
+ if page.is_a? Page
+ raise ArgumentError, 'Page/Paginator mismatch' unless
+ page.paginator == self
+ end
+ page = page.to_i
+ @current_page_number = has_page_number?(page) ? page : 1
+ end
+
+ # Returns a Page object representing this paginator's current page.
+ def current_page
+ @current_page ||= self[@current_page_number]
+ end
+ alias current :current_page
+
+ # Returns a new Page representing the first page in this paginator.
+ def first_page
+ @first_page ||= self[1]
+ end
+ alias first :first_page
+
+ # Returns a new Page representing the last page in this paginator.
+ def last_page
+ @last_page ||= self[page_count]
+ end
+ alias last :last_page
+
+ # Returns the number of pages in this paginator.
+ def page_count
+ @page_count ||= @item_count.zero? ? 1 :
+ (q,r=@item_count.divmod(@items_per_page); r==0? q : q+1)
+ end
+
+ alias length :page_count
+
+ # Returns true if this paginator contains the page of index +number+.
+ def has_page_number?(number)
+ number >= 1 and number <= page_count
+ end
+
+ # Returns a new Page representing the page with the given index
+ # +number+.
+ def [](number)
+ @pages[number] ||= Page.new(self, number)
+ end
+
+ # Successively yields all the paginator's pages to the given block.
+ def each(&block)
+ page_count.times do |n|
+ yield self[n+1]
+ end
+ end
+
+ # A class representing a single page in a paginator.
+ class Page
+ include Comparable
+
+ # Creates a new Page for the given +paginator+ with the index
+ # +number+. If +number+ is not in the range of valid page numbers or
+ # is not a number at all, it defaults to 1.
+ def initialize(paginator, number)
+ @paginator = paginator
+ @number = number.to_i
+ @number = 1 unless @paginator.has_page_number? @number
+ end
+ attr_reader :paginator, :number
+ alias to_i :number
+
+ # Compares two Page objects and returns true when they represent the
+ # same page (i.e., their paginators are the same and they have the
+ # same page number).
+ def ==(page)
+ return false if page.nil?
+ @paginator == page.paginator and
+ @number == page.number
+ end
+
+ # Compares two Page objects and returns -1 if the left-hand page comes
+ # before the right-hand page, 0 if the pages are equal, and 1 if the
+ # left-hand page comes after the right-hand page. Raises ArgumentError
+ # if the pages do not belong to the same Paginator object.
+ def <=>(page)
+ raise ArgumentError unless @paginator == page.paginator
+ @number <=> page.number
+ end
+
+ # Returns the item offset for the first item in this page.
+ def offset
+ @paginator.items_per_page * (@number - 1)
+ end
+
+ # Returns the number of the first item displayed.
+ def first_item
+ offset + 1
+ end
+
+ # Returns the number of the last item displayed.
+ def last_item
+ [@paginator.items_per_page * @number, @paginator.item_count].min
+ end
+
+ # Returns true if this page is the first page in the paginator.
+ def first?
+ self == @paginator.first
+ end
+
+ # Returns true if this page is the last page in the paginator.
+ def last?
+ self == @paginator.last
+ end
+
+ # Returns a new Page object representing the page just before this
+ # page, or nil if this is the first page.
+ def previous
+ if first? then nil else @paginator[@number - 1] end
+ end
+
+ # Returns a new Page object representing the page just after this
+ # page, or nil if this is the last page.
+ def next
+ if last? then nil else @paginator[@number + 1] end
+ end
+
+ # Returns a new Window object for this page with the specified
+ # +padding+.
+ def window(padding=2)
+ Window.new(self, padding)
+ end
+
+ # Returns the limit/offset array for this page.
+ def to_sql
+ [@paginator.items_per_page, offset]
+ end
+
+ def to_param #:nodoc:
+ @number.to_s
+ end
+ end
+
+ # A class for representing ranges around a given page.
+ class Window
+ # Creates a new Window object for the given +page+ with the specified
+ # +padding+.
+ def initialize(page, padding=2)
+ @paginator = page.paginator
+ @page = page
+ self.padding = padding
+ end
+ attr_reader :paginator, :page
+
+ # Sets the window's padding (the number of pages on either side of the
+ # window page).
+ def padding=(padding)
+ @padding = padding < 0 ? 0 : padding
+ # Find the beginning and end pages of the window
+ @first = @paginator.has_page_number?(@page.number - @padding) ?
+ @paginator[@page.number - @padding] : @paginator.first
+ @last = @paginator.has_page_number?(@page.number + @padding) ?
+ @paginator[@page.number + @padding] : @paginator.last
+ end
+ attr_reader :padding, :first, :last
+
+ # Returns an array of Page objects in the current window.
+ def pages
+ (@first.number..@last.number).to_a.collect! {|n| @paginator[n]}
+ end
+ alias to_a :pages
+ end
+ end
+
+ end
+end
View
135 vendor/plugins/classic_pagination/lib/pagination_helper.rb
@@ -0,0 +1,135 @@
+module ActionView
+ module Helpers
+ # Provides methods for linking to ActionController::Pagination objects using a simple generator API. You can optionally
+ # also build your links manually using ActionView::Helpers::AssetHelper#link_to like so:
+ #
+ # <%= link_to "Previous page", { :page => paginator.current.previous } if paginator.current.previous %>
+ # <%= link_to "Next page", { :page => paginator.current.next } if paginator.current.next %>
+ module PaginationHelper
+ unless const_defined?(:DEFAULT_OPTIONS)
+ DEFAULT_OPTIONS = {
+ :name => :page,
+ :window_size => 2,
+ :always_show_anchors => true,
+ :link_to_current_page => false,
+ :params => {}
+ }
+ end
+
+ # Creates a basic HTML link bar for the given +paginator+. Links will be created
+ # for the next and/or previous page and for a number of other pages around the current
+ # pages position. The +html_options+ hash is passed to +link_to+ when the links are created.
+ #
+ # ==== Options
+ # <tt>:name</tt>:: the routing name for this paginator
+ # (defaults to +page+)
+ # <tt>:prefix</tt>:: prefix for pagination links
+ # (i.e. Older Pages: 1 2 3 4)
+ # <tt>:suffix</tt>:: suffix for pagination links
+ # (i.e. 1 2 3 4 <- Older Pages)
+ # <tt>:window_size</tt>:: the number of pages to show around
+ # the current page (defaults to <tt>2</tt>)
+ # <tt>:always_show_anchors</tt>:: whether or not the first and last
+ # pages should always be shown
+ # (defaults to +true+)
+ # <tt>:link_to_current_page</tt>:: whether or not the current page
+ # should be linked to (defaults to
+ # +false+)
+ # <tt>:params</tt>:: any additional routing parameters
+ # for page URLs
+ #
+ # ==== Examples
+ # # We'll assume we have a paginator setup in @person_pages...
+ #
+ # pagination_links(@person_pages)
+ # # => 1 <a href="/?page=2/">2</a> <a href="/?page=3/">3</a> ... <a href="/?page=10/">10</a>
+ #
+ # pagination_links(@person_pages, :link_to_current_page => true)
+ # # => <a href="/?page=1/">1</a> <a href="/?page=2/">2</a> <a href="/?page=3/">3</a> ... <a href="/?page=10/">10</a>
+ #
+ # pagination_links(@person_pages, :always_show_anchors => false)
+ # # => 1 <a href="/?page=2/">2</a> <a href="/?page=3/">3</a>
+ #
+ # pagination_links(@person_pages, :window_size => 1)
+ # # => 1 <a href="/?page=2/">2</a> ... <a href="/?page=10/">10</a>
+ #
+ # pagination_links(@person_pages, :params => { :viewer => "flash" })
+ # # => 1 <a href="/?page=2&amp;viewer=flash/">2</a> <a href="/?page=3&amp;viewer=flash/">3</a> ...
+ # # <a href="/?page=10&amp;viewer=flash/">10</a>
+ def pagination_links(paginator, options={}, html_options={})
+ name = options[:name] || DEFAULT_OPTIONS[:name]
+ params = (options[:params] || DEFAULT_OPTIONS[:params]).clone
+
+ prefix = options[:prefix] || ''
+ suffix = options[:suffix] || ''
+
+ pagination_links_each(paginator, options, prefix, suffix) do |n|
+ params[name] = n
+ link_to(n.to_s, params, html_options)
+ end
+ end
+
+ # Iterate through the pages of a given +paginator+, invoking a
+ # block for each page number that needs to be rendered as a link.
+ #
+ # ==== Options
+ # <tt>:window_size</tt>:: the number of pages to show around
+ # the current page (defaults to +2+)
+ # <tt>:always_show_anchors</tt>:: whether or not the first and last
+ # pages should always be shown
+ # (defaults to +true+)
+ # <tt>:link_to_current_page</tt>:: whether or not the current page
+ # should be linked to (defaults to
+ # +false+)
+ #
+ # ==== Example
+ # # Turn paginated links into an Ajax call
+ # pagination_links_each(paginator, page_options) do |link|
+ # options = { :url => {:action => 'list'}, :update => 'results' }
+ # html_options = { :href => url_for(:action => 'list') }
+ #
+ # link_to_remote(link.to_s, options, html_options)
+ # end
+ def pagination_links_each(paginator, options, prefix = nil, suffix = nil)
+ options = DEFAULT_OPTIONS.merge(options)
+ link_to_current_page = options[:link_to_current_page]
+ always_show_anchors = options[:always_show_anchors]
+
+ current_page = paginator.current_page
+ window_pages = current_page.window(options[:window_size]).pages
+ return if window_pages.length <= 1 unless link_to_current_page
+
+ first, last = paginator.first, paginator.last
+
+ html = ''
+
+ html << prefix if prefix
+
+ if always_show_anchors and not (wp_first = window_pages[0]).first?
+ html << yield(first.number)
+ html << ' ... ' if wp_first.number - first.number > 1
+ html << ' '
+ end
+
+ window_pages.each do |page|
+ if current_page == page && !link_to_current_page
+ html << page.number.to_s
+ else
+ html << yield(page.number)
+ end
+ html << ' '
+ end
+
+ if always_show_anchors and not (wp_last = window_pages[-1]).last?
+ html << ' ... ' if last.number - wp_last.number > 1
+ html << yield(last.number)
+ end
+
+ html << suffix if suffix
+
+ html
+ end
+
+ end # PaginationHelper
+ end # Helpers
+end # ActionView
View
24 vendor/plugins/classic_pagination/test/fixtures/companies.yml
@@ -0,0 +1,24 @@
+thirty_seven_signals:
+ id: 1
+ name: 37Signals
+ rating: 4
+
+TextDrive:
+ id: 2
+ name: TextDrive
+ rating: 4
+
+PlanetArgon:
+ id: 3
+ name: Planet Argon
+ rating: 4
+
+Google:
+ id: 4
+ name: Google
+ rating: 4
+
+Ionist:
+ id: 5
+ name: Ioni.st
+ rating: 4
View
9 vendor/plugins/classic_pagination/test/fixtures/company.rb
@@ -0,0 +1,9 @@
+class Company < ActiveRecord::Base
+ attr_protected :rating
+ set_sequence_name :companies_nonstd_seq
+
+ validates_presence_of :name
+ def validate
+ errors.add('rating', 'rating should not be 2') if rating == 2
+ end
+end
View
7 vendor/plugins/classic_pagination/test/fixtures/developer.rb
@@ -0,0 +1,7 @@
+class Developer < ActiveRecord::Base
+ has_and_belongs_to_many :projects
+end
+
+class DeVeLoPeR < ActiveRecord::Base
+ set_table_name "developers"
+end
View
21 vendor/plugins/classic_pagination/test/fixtures/developers.yml
@@ -0,0 +1,21 @@
+david:
+ id: 1
+ name: David
+ salary: 80000
+
+jamis:
+ id: 2
+ name: Jamis
+ salary: 150000
+
+<% for digit in 3..10 %>
+dev_<%= digit %>:
+ id: <%= digit %>
+ name: fixture_<%= digit %>
+ salary: 100000
+<% end %>
+
+poor_jamis:
+ id: 11
+ name: Jamis
+ salary: 9000
View
13 vendor/plugins/classic_pagination/test/fixtures/developers_projects.yml
@@ -0,0 +1,13 @@
+david_action_controller:
+ developer_id: 1
+ project_id: 2
+ joined_on: 2004-10-10
+
+david_active_record:
+ developer_id: 1
+ project_id: 1
+ joined_on: 2004-10-10
+
+jamis_active_record:
+ developer_id: 2
+ project_id: 1
View
3 vendor/plugins/classic_pagination/test/fixtures/project.rb
@@ -0,0 +1,3 @@
+class Project < ActiveRecord::Base
+ has_and_belongs_to_many :developers, :uniq => true
+end
View
7 vendor/plugins/classic_pagination/test/fixtures/projects.yml
@@ -0,0 +1,7 @@
+action_controller:
+ id: 2
+ name: Active Controller
+
+active_record:
+ id: 1
+ name: Active Record
View
13 vendor/plugins/classic_pagination/test/fixtures/replies.yml
@@ -0,0 +1,13 @@
+witty_retort:
+ id: 1
+ topic_id: 1
+ content: Birdman is better!
+ created_at: <%= 6.hours.ago.to_s(:db) %>
+ updated_at: nil
+
+another:
+ id: 2
+ topic_id: 2
+ content: Nuh uh!
+ created_at: <%= 1.hour.ago.to_s(:db) %>
+ updated_at: nil
View
5 vendor/plugins/classic_pagination/test/fixtures/reply.rb
@@ -0,0 +1,5 @@
+class Reply < ActiveRecord::Base
+ belongs_to :topic, :include => [:replies]
+
+ validates_presence_of :content
+end
View
42 vendor/plugins/classic_pagination/test/fixtures/schema.sql
@@ -0,0 +1,42 @@
+CREATE TABLE 'companies' (
+ 'id' INTEGER PRIMARY KEY NOT NULL,
+ 'name' TEXT DEFAULT NULL,
+ 'rating' INTEGER DEFAULT 1
+);
+
+CREATE TABLE 'replies' (
+ 'id' INTEGER PRIMARY KEY NOT NULL,
+ 'content' text,
+ 'created_at' datetime,
+ 'updated_at' datetime,
+ 'topic_id' integer
+);
+
+CREATE TABLE 'topics' (
+ 'id' INTEGER PRIMARY KEY NOT NULL,
+ 'title' varchar(255),
+ 'subtitle' varchar(255),
+ 'content' text,
+ 'created_at' datetime,
+ 'updated_at' datetime
+);
+
+CREATE TABLE 'developers' (
+ 'id' INTEGER PRIMARY KEY NOT NULL,
+ 'name' TEXT DEFAULT NULL,
+ 'salary' INTEGER DEFAULT 70000,
+ 'created_at' DATETIME DEFAULT NULL,
+ 'updated_at' DATETIME DEFAULT NULL
+);
+
+CREATE TABLE 'projects' (
+ 'id' INTEGER PRIMARY KEY NOT NULL,
+ 'name' TEXT DEFAULT NULL
+);
+
+CREATE TABLE 'developers_projects' (
+ 'developer_id' INTEGER NOT NULL,
+ 'project_id' INTEGER NOT NULL,
+ 'joined_on' DATE DEFAULT NULL,
+ 'access_level' INTEGER DEFAULT 1
+);
View
3 vendor/plugins/classic_pagination/test/fixtures/topic.rb
@@ -0,0 +1,3 @@
+class Topic < ActiveRecord::Base
+ has_many :replies, :include => [:user], :dependent => :destroy
+end
View
22 vendor/plugins/classic_pagination/test/fixtures/topics.yml
@@ -0,0 +1,22 @@
+futurama:
+ id: 1
+ title: Isnt futurama awesome?
+ subtitle: It really is, isnt it.
+ content: I like futurama
+ created_at: <%= 1.day.ago.to_s(:db) %>
+ updated_at:
+
+harvey_birdman:
+ id: 2
+ title: Harvey Birdman is the king of all men
+ subtitle: yup
+ content: It really is
+ created_at: <%= 2.hours.ago.to_s(:db) %>
+ updated_at:
+
+rails:
+ id: 3
+ title: Rails is nice
+ subtitle: It makes me happy
+ content: except when I have to hack internals to fix pagination. even then really.
+ created_at: <%= 20.minutes.ago.to_s(:db) %>
View
117 vendor/plugins/classic_pagination/test/helper.rb
@@ -0,0 +1,117 @@
+require 'test/unit'
+
+unless defined?(ActiveRecord)
+ plugin_root = File.join(File.dirname(__FILE__), '..')
+
+ # first look for a symlink to a copy of the framework
+ if framework_root = ["#{plugin_root}/rails", "#{plugin_root}/../../rails"].find { |p| File.directory? p }
+ puts "found framework root: #{framework_root}"
+ # this allows for a plugin to be tested outside an app
+ $:.unshift "#{framework_root}/activesupport/lib", "#{framework_root}/activerecord/lib", "#{framework_root}/actionpack/lib"
+ else
+ # is the plugin installed in an application?
+ app_root = plugin_root + '/../../..'
+
+ if File.directory? app_root + '/config'
+ puts 'using config/boot.rb'
+ ENV['RAILS_ENV'] = 'test'
+ require File.expand_path(app_root + '/config/boot')
+ else
+ # simply use installed gems if available
+ puts 'using rubygems'
+ require 'rubygems'
+ gem 'actionpack'; gem 'activerecord'
+ end
+ end
+
+ %w(action_pack active_record action_controller active_record/fixtures action_controller/test_process).each {|f| require f}
+
+ Dependencies.load_paths.unshift "#{plugin_root}/lib"
+end
+
+# Define the connector
+class ActiveRecordTestConnector
+ cattr_accessor :able_to_connect
+ cattr_accessor :connected
+
+ # Set our defaults
+ self.connected = false
+ self.able_to_connect = true
+
+ class << self
+ def setup
+ unless self.connected || !self.able_to_connect
+ setup_connection
+ load_schema
+ require_fixture_models
+ self.connected = true
+ end
+ rescue Exception => e # errors from ActiveRecord setup
+ $stderr.puts "\nSkipping ActiveRecord assertion tests: #{e}"
+ #$stderr.puts " #{e.backtrace.join("\n ")}\n"
+ self.able_to_connect = false
+ end
+
+ private
+
+ def setup_connection
+ if Object.const_defined?(:ActiveRecord)
+ defaults = { :database => ':memory:' }
+ begin
+ options = defaults.merge :adapter => 'sqlite3', :timeout => 500
+ ActiveRecord::Base.establish_connection(options)
+ ActiveRecord::Base.configurations = { 'sqlite3_ar_integration' => options }
+ ActiveRecord::Base.connection
+ rescue Exception # errors from establishing a connection
+ $stderr.puts 'SQLite 3 unavailable; trying SQLite 2.'
+ options = defaults.merge :adapter => 'sqlite'
+ ActiveRecord::Base.establish_connection(options)
+ ActiveRecord::Base.configurations = { 'sqlite2_ar_integration' => options }
+ ActiveRecord::Base.connection
+ end
+
+ Object.send(:const_set, :QUOTED_TYPE, ActiveRecord::Base.connection.quote_column_name('type')) unless Object.const_defined?(:QUOTED_TYPE)
+ else
+ raise "Can't setup connection since ActiveRecord isn't loaded."
+ end
+ end
+
+ # Load actionpack sqlite tables
+ def load_schema
+ File.read(File.dirname(__FILE__) + "/fixtures/schema.sql").split(';').each do |sql|
+ ActiveRecord::Base.connection.execute(sql) unless sql.blank?
+ end
+ end
+
+ def require_fixture_models
+ Dir.glob(File.dirname(__FILE__) + "/fixtures/*.rb").each {|f| require f}
+ end
+ end
+end
+
+# Test case for inheritance
+class ActiveRecordTestCase < Test::Unit::TestCase
+ # Set our fixture path
+ if ActiveRecordTestConnector.able_to_connect
+ self.fixture_path = "#{File.dirname(__FILE__)}/fixtures/"
+ self.use_transactional_fixtures = false
+ end
+
+ def self.fixtures(*args)
+ super if ActiveRecordTestConnector.connected
+ end
+
+ def run(*args)
+ super if ActiveRecordTestConnector.connected
+ end
+
+ # Default so Test::Unit::TestCase doesn't complain
+ def test_truth
+ end
+end
+
+ActiveRecordTestConnector.setup
+ActionController::Routing::Routes.reload rescue nil
+ActionController::Routing::Routes.draw do |map|
+ map.connect ':controller/:action/:id'
+end
View
38 vendor/plugins/classic_pagination/test/pagination_helper_test.rb
@@ -0,0 +1,38 @@
+require File.dirname(__FILE__) + '/helper'
+require File.dirname(__FILE__) + '/../init'
+
+class PaginationHelperTest < Test::Unit::TestCase
+ include ActionController::Pagination
+ include ActionView::Helpers::PaginationHelper
+ include ActionView::Helpers::UrlHelper
+ include ActionView::Helpers::TagHelper
+
+ def setup
+ @controller = Class.new do
+ attr_accessor :url, :request
+ def url_for(options, *parameters_for_method_reference)
+ url
+ end
+ end
+ @controller = @controller.new
+ @controller.url = "http://www.example.com"
+ end
+
+ def test_pagination_links
+ total, per_page, page = 30, 10, 1
+ output = pagination_links Paginator.new(@controller, total, per_page, page)
+ assert_equal "1 <a href=\"http://www.example.com\">2</a> <a href=\"http://www.example.com\">3</a> ", output
+ end
+
+ def test_pagination_links_with_prefix
+ total, per_page, page = 30, 10, 1
+ output = pagination_links Paginator.new(@controller, total, per_page, page), :prefix => 'Newer '
+ assert_equal "Newer 1 <a href=\"http://www.example.com\">2</a> <a href=\"http://www.example.com\">3</a> ", output
+ end
+
+ def test_pagination_links_with_suffix
+ total, per_page, page = 30, 10, 1
+ output = pagination_links Paginator.new(@controller, total, per_page, page), :suffix => 'Older'
+ assert_equal "1 <a href=\"http://www.example.com\">2</a> <a href=\"http://www.example.com\">3</a> Older", output
+ end
+end
View
177 vendor/plugins/classic_pagination/test/pagination_test.rb
@@ -0,0 +1,177 @@
+require File.dirname(__FILE__) + '/helper'
+require File.dirname(__FILE__) + '/../init'
+
+class PaginationTest < ActiveRecordTestCase
+ fixtures :topics, :replies, :developers, :projects, :developers_projects
+
+ class PaginationController < ActionController::Base
+ if respond_to? :view_paths=
+ self.view_paths = [ "#{File.dirname(__FILE__)}/../fixtures/" ]
+ else
+ self.template_root = [ "#{File.dirname(__FILE__)}/../fixtures/" ]
+ end
+
+ def simple_paginate
+ @topic_pages, @topics = paginate(:topics)
+ render :nothing => true
+ end
+
+ def paginate_with_per_page
+ @topic_pages, @topics = paginate(:topics, :per_page => 1)
+ render :nothing => true
+ end
+
+ def paginate_with_order
+ @topic_pages, @topics = paginate(:topics, :order => 'created_at asc')
+ render :nothing => true
+ end
+
+ def paginate_with_order_by
+ @topic_pages, @topics = paginate(:topics, :order_by => 'created_at asc')
+ render :nothing => true
+ end
+
+ def paginate_with_include_and_order
+ @topic_pages, @topics = paginate(:topics, :include => :replies, :order => 'replies.created_at asc, topics.created_at asc')
+ render :nothing => true
+ end
+
+ def paginate_with_conditions
+ @topic_pages, @topics = paginate(:topics, :conditions => ["created_at > ?", 30.minutes.ago])
+ render :nothing => true
+ end
+
+ def paginate_with_class_name
+ @developer_pages, @developers = paginate(:developers, :class_name => "DeVeLoPeR")
+ render :nothing => true
+ end
+
+ def paginate_with_singular_name
+ @developer_pages, @developers = paginate()
+ render :nothing => true
+ end
+
+ def paginate_with_joins
+ @developer_pages, @developers = paginate(:developers,
+ :joins => 'LEFT JOIN developers_projects ON developers.id = developers_projects.developer_id',
+ :conditions => 'project_id=1')
+ render :nothing => true
+ end
+
+ def paginate_with_join
+ @developer_pages, @developers = paginate(:developers,
+ :join => 'LEFT JOIN developers_projects ON developers.id = developers_projects.developer_id',
+ :conditions => 'project_id=1')
+ render :nothing => true
+ end
+
+ def paginate_with_join_and_count
+ @developer_pages, @developers = paginate(:developers,
+ :join => 'd LEFT JOIN developers_projects ON d.id = developers_projects.developer_id',
+ :conditions => 'project_id=1',
+ :count => "d.id")
+ render :nothing => true
+ end
+
+ def paginate_with_join_and_group
+ @developer_pages, @developers = paginate(:developers,
+ :join => 'INNER JOIN developers_projects ON developers.id = developers_projects.developer_id',
+ :group => 'developers.id')
+ render :nothing => true
+ end
+
+ def rescue_errors(e) raise e end
+
+ def rescue_action(e) raise end
+
+ end
+
+ def setup
+ @controller = PaginationController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ super
+ end
+
+ # Single Action Pagination Tests
+
+ def test_simple_paginate
+ get :simple_paginate
+ assert_equal 1, assigns(:topic_pages).page_count
+ assert_equal 3, assigns(:topics).size
+ end
+
+ def test_paginate_with_per_page
+ get :paginate_with_per_page
+ assert_equal 1, assigns(:topics).size
+ assert_equal 3, assigns(:topic_pages).page_count
+ end
+
+ def test_paginate_with_order
+ get :paginate_with_order
+ expected = [topics(:futurama),
+ topics(:harvey_birdman),
+ topics(:rails)]
+ assert_equal expected, assigns(:topics)
+ assert_equal 1, assigns(:topic_pages).page_count
+ end
+
+ def test_paginate_with_order_by
+ get :paginate_with_order
+ expected = assigns(:topics)
+ get :paginate_with_order_by
+ assert_equal expected, assigns(:topics)
+ assert_equal 1, assigns(:topic_pages).page_count
+ end
+
+ def test_paginate_with_conditions
+ get :paginate_with_conditions
+ expected = [topics(:rails)]
+ assert_equal expected, assigns(:topics)
+ assert_equal 1, assigns(:topic_pages).page_count
+ end
+
+ def test_paginate_with_class_name
+ get :paginate_with_class_name
+
+ assert assigns(:developers).size > 0
+ assert_equal DeVeLoPeR, assigns(:developers).first.class
+ end
+
+ def test_paginate_with_joins
+ get :paginate_with_joins
+ assert_equal 2, assigns(:developers).size
+ developer_names = assigns(:developers).map { |d| d.name }
+ assert developer_names.include?('David')
+ assert developer_names.include?('Jamis')
+ end
+
+ def test_paginate_with_join_and_conditions
+ get :paginate_with_joins
+ expected = assigns(:developers)
+ get :paginate_with_join
+ assert_equal expected, assigns(:developers)
+ end
+
+ def test_paginate_with_join_and_count
+ get :paginate_with_joins
+ expected = assigns(:developers)
+ get :paginate_with_join_and_count
+ assert_equal expected, assigns(:developers)
+ end
+
+ def test_paginate_with_include_and_order
+ get :paginate_with_include_and_order
+ expected = Topic.find(:all, :include => 'replies', :order => 'replies.created_at asc, topics.created_at asc', :limit => 10)
+ assert_equal expected, assigns(:topics)
+ end
+
+ def test_paginate_with_join_and_group
+ get :paginate_with_join_and_group
+ assert_equal 2, assigns(:developers).size
+ assert_equal 2, assigns(:developer_pages).item_count
+ developer_names = assigns(:developers).map { |d| d.name }
+ assert developer_names.include?('David')
+ assert developer_names.include?('Jamis')
+ end
+end
View
349 vendor/rails/actionmailer/CHANGELOG
@@ -0,0 +1,349 @@
+*2.2.1 [RC2] (November 14th, 2008)*
+
+* Turn on STARTTLS if it is available in Net::SMTP (added in Ruby 1.8.7) and the SMTP server supports it (This is required for Gmail's SMTP server) #1336 [Grant Hollingworth]
+
+
+*2.2.0 [RC1] (October 24th, 2008)*
+
+* Add layout functionality to mailers [Pratik]
+
+ Mailer layouts behaves just like controller layouts, except layout names need to
+ have '_mailer' postfix for them to be automatically picked up.
+
+
+*2.1.0 (May 31st, 2008)*
+
+* Fixed that a return-path header would be ignored #7572 [joost]
+
+* Less verbose mail logging: just recipients for :info log level; the whole email for :debug only. #8000 [iaddict, Tarmo Tänav]
+
+* Updated TMail to version 1.2.1 [raasdnil]
+
+* Fixed that you don't have to call super in ActionMailer::TestCase#setup #10406 [jamesgolick]
+
+
+*2.0.2* (December 16th, 2007)
+
+* Included in Rails 2.0.2
+
+
+*2.0.1* (December 7th, 2007)
+
+* Update ActionMailer so it treats ActionView the same way that ActionController does. Closes #10244 [rick]
+
+ * Pass the template_root as an array as ActionView's view_path
+ * Request templates with the "#{mailer_name}/#{action}" as opposed to just "#{action}"
+
+* Fixed that partials would be broken when using text.plain.erb as the extension #10130 [java]
+
+* Update README to use new smtp settings configuration API. Closes #10060 [psq]
+
+* Allow ActionMailer subclasses to individually set their delivery method (so two subclasses can have different delivery methods) #10033 [zdennis]
+
+* Update TMail to v1.1.0. Use an updated version of TMail if available. [mikel]
+
+* Introduce a new base test class for testing Mailers. ActionMailer::TestCase [Koz]
+
+* Fix silent failure of rxml templates. #9879 [jstewart]
+
+* Fix attachment decoding when using the TMail C extension. #7861 [orangechicken]
+
+* Increase mail delivery test coverage. #8692 [Kamal Fariz Mahyuddin]
+
+* Register alternative template engines using ActionMailer::Base.register_template_extension('haml'). #7534 [cwd, Josh Peek]
+
+* Only load ActionController::UrlWriter if ActionController is present [Rick Olson]
+
+* Make sure parsed emails recognized attachments nested inside multipart parts. #6714 [Jamis Buck]
+
+* Allow mailer actions named send by using __send__ internally. #6467 [iGEL]
+
+* Add assert_emails and assert_no_emails to test the number of emails delivered. #6479 [Jonathan Viney]
+ # Assert total number of emails delivered:
+ assert_emails 0
+ ContactMailer.deliver_contact
+ assert_emails 1
+
+ # Assert number of emails delivered within a block:
+ assert_emails 1 do
+ post :signup, :name => 'Jonathan'
+ end
+
+
+*1.3.3* (March 12th, 2007)
+
+* Depend on Action Pack 1.13.3
+
+
+*1.3.2* (February 5th, 2007)
+
+* Deprecate server_settings renaming it to smtp_settings, add sendmail_settings to allow you to override the arguments to and location of the sendmail executable. [Koz]
+
+
+*1.3.1* (January 16th, 2007)
+
+* Depend on Action Pack 1.13.1
+
+
+*1.3.0* (January 16th, 2007)
+
+* Make mime version default to 1.0. closes #2323 [ror@andreas-s.net]
+
+* Make sure quoted-printable text is decoded correctly when only portions of the text are encoded. closes #3154. [jon@siliconcircus.com]
+
+* Make sure DOS newlines in quoted-printable text are normalized to unix newlines before unquoting. closes #4166 and #4452. [Jamis Buck]
+
+* Fixed that iconv decoding should catch InvalidEncoding #3153 [jon@siliconcircus.com]
+
+* Tighten rescue clauses. #5985 [james@grayproductions.net]
+
+* Automatically included ActionController::UrlWriter, such that URL generation can happen within ActionMailer controllers. [DHH]
+
+* Replace Reloadable with Reloadable::Deprecated. [Nicholas Seckar]
+
+* Mailer template root applies to a class and its subclasses rather than acting globally. #5555 [somekool@gmail.com]
+
+* Resolve action naming collision. #5520 [ssinghi@kreeti.com]
+
+* ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, Marcel Molina Jr.]
+
+* Replace alias method chaining with Module#alias_method_chain. [Marcel Molina Jr.]
+
+* Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.]
+
+* Correct spurious documentation example code which results in a SyntaxError. [Marcel Molina Jr.]
+
+
+*1.2.1* (April 6th, 2006)
+
+* Be part of Rails 1.1.1
+
+
+*1.2.0* (March 27th, 2006)
+
+* Nil charset caused subject line to be improperly quoted in implicitly multipart messages #2662 [ehalvorsen+rails@runbox.com]
+
+* Parse content-type apart before using it so that sub-parts of the header can be set correctly #2918 [Jamis Buck]
+
+* Make custom headers work in subparts #4034 [elan@bluemandrill.com]
+
+* Template paths with dot chars in them no longer mess up implicit template selection for multipart messages #3332 [Chad Fowler]
+
+* Make sure anything with content-disposition of "attachment" is passed to the attachment presenter when parsing an email body [Jamis Buck]
+
+* Make sure TMail#attachments includes anything with content-disposition of "attachment", regardless of content-type [Jamis Buck]
+
+
+*1.1.5* (December 13th, 2005)
+
+* Become part of Rails 1.0
+
+
+*1.1.4* (December 7th, 2005)
+
+* Rename Version constant to VERSION. #2802 [Marcel Molina Jr.]
+
+* Stricter matching for implicitly multipart filenames excludes files ending in unsupported extensions (such as foo.rhtml.bak) and without a two-part content type (such as foo.text.rhtml or foo.text.really.plain.rhtml). #2398 [Dave Burt <dave@burt.id.au>, Jeremy Kemper]
+
+
+*1.1.3* (November 7th, 2005)
+
+* Allow Mailers to have custom initialize methods that set default instance variables for all mail actions #2563 [mrj@bigpond.net.au]
+
+
+*1.1.2* (October 26th, 2005)
+
+* Upgraded to Action Pack 1.10.2
+
+
+*1.1.1* (October 19th, 2005)
+
+* Upgraded to Action Pack 1.10.1
+
+
+*1.1.0* (October 16th, 2005)
+
+* Update and extend documentation (rdoc)
+
+* Minero Aoki made TMail available to Rails/ActionMailer under the MIT license (instead of LGPL) [RubyConf '05]
+
+* Austin Ziegler made Text::Simple available to Rails/ActionMailer under a MIT-like licens [See rails ML, subject "Text::Format Licence Exception" on Oct 15, 2005]
+
+* Fix vendor require paths to prevent files being required twice
+
+* Don't add charset to content-type header for a part that contains subparts (for AOL compatibility) #2013 [John Long]
+
+* Preserve underscores when unquoting message bodies #1930
+
+* Encode multibyte characters correctly #1894
+
+* Multipart messages specify a MIME-Version header automatically #2003 [John Long]
+
+* Add a unified render method to ActionMailer (delegates to ActionView::Base#render)
+
+* Move mailer initialization to a separate (overridable) method, so that subclasses may alter the various defaults #1727
+
+* Look at content-location header (if available) to determine filename of attachments #1670
+
+* ActionMailer::Base.deliver(email) had been accidentally removed, but was documented in the Rails book #1849
+
+* Fix problem with sendmail delivery where headers should be delimited by \n characters instead of \r\n, which confuses some mail readers #1742 [Kent Sibilev]
+
+
+*1.0.1* (11 July, 2005)
+
+* Bind to Action Pack 1.9.1
+
+
+*1.0.0* (6 July, 2005)
+
+* Avoid adding nil header values #1392
+
+* Better multipart support with implicit multipart/alternative and sorting of subparts [John Long]
+
+* Allow for nested parts in multipart mails #1570 [Flurin Egger]
+
+* Normalize line endings in outgoing mail bodies to "\n" #1536 [John Long]
+
+* Allow template to be explicitly specified #1448 [tuxie@dekadance.se]
+
+* Allow specific "multipart/xxx" content-type to be set on multipart messages #1412 [Flurin Egger]
+
+* Unquoted @ characters in headers are now accepted in spite of RFC 822 #1206
+
+* Helper support (borrowed from ActionPack)
+
+* Silently ignore Errno::EINVAL errors when converting text.
+
+* Don't cause an error when parsing an encoded attachment name #1340 [lon@speedymac.com]
+
+* Nested multipart message parts are correctly processed in TMail::Mail#body
+
+* BCC headers are removed when sending via SMTP #1402
+
+* Added 'content_type' accessor, to allow content type to be set on a per-message basis. content_type defaults to "text/plain".
+
+* Silently ignore Iconv::IllegalSequence errors when converting text #1341 [lon@speedymac.com]
+
+* Support attachments and multipart messages.
+
+* Added new accessors for the various mail properties.
+
+* Fix to only perform the charset conversion if a 'from' and a 'to' charset are given (make no assumptions about what the charset was) #1276 [Jamis Buck]
+
+* Fix attachments and content-type problems #1276 [Jamis Buck]
+
+* Fixed the TMail#body method to look at the content-transfer-encoding header and unquote the body according to the rules it specifies #1265 [Jamis Buck]
+
+* Added unquoting even if the iconv lib can't be loaded--in that case, only the charset conversion is skipped #1265 [Jamis Buck]
+
+* Added automatic decoding of base64 bodies #1214 [Jamis Buck]
+
+* Added that delivery errors are caught in a way so the mail is still returned whether the delivery was successful or not
+
+* Fixed that email address like "Jamis Buck, M.D." <wild.medicine@example.net> would cause the quoter to generate emails resulting in "bad address" errors from the mail server #1220 [Jamis Buck]
+
+
+*0.9.1* (20th April, 2005)
+
+* Depend on Action Pack 1.8.1
+
+
+*0.9.0* (19th April, 2005)
+
+* Added that deliver_* will now return the email that was sent
+
+* Added that quoting to UTF-8 only happens if the characters used are in that range #955 [Jamis Buck]
+
+* Fixed quoting for all address headers, not just to #955 [Jamis Buck]
+
+* Fixed unquoting of emails that doesn't have an explicit charset #1036 [wolfgang@stufenlos.net]
+
+
+*0.8.1* (27th March, 2005)
+
+* Fixed that if charset was found that the end of a mime part declaration TMail would throw an error #919 [lon@speedymac.com]
+
+* Fixed that TMail::Unquoter would fail to recognize quoting method if it was in lowercase #919 [lon@speedymac.com]
+
+* Fixed that TMail::Encoder would fail when it attempts to parse e-mail addresses which are encoded using something other than the messages encoding method #919 [lon@speedymac.com]
+
+* Added rescue for missing iconv library and throws warnings if subject/body is called on a TMail object without it instead
+
+
+*0.8.0* (22th March, 2005)
+
+* Added framework support for processing incoming emails with an Action Mailer class. See example in README.
+
+
+*0.7.1* (7th March, 2005)
+
+* Bind to newest Action Pack (1.5.1)
+
+
+*0.7.0* (24th February, 2005)
+
+* Added support for charsets for both subject and body. The default charset is now UTF-8 #673 [Jamis Buck]. Examples:
+
+ def iso_charset(recipient)
+ @recipients = recipient
+ @subject = "testing iso charsets"
+ @from = "system@loudthinking.com"
+ @body = "Nothing to see here."
+ @charset = "iso-8859-1"
+ end
+
+ def unencoded_subject(recipient)
+ @recipients = recipient
+ @subject = "testing unencoded subject"
+ @from = "system@loudthinking.com"
+ @body = "Nothing to see here."
+ @encode_subject = false
+ @charset = "iso-8859-1"
+ end
+
+
+*0.6.1* (January 18th, 2005)
+
+* Fixed sending of emails to use Tmail#from not the deprecated Tmail#from_address
+
+
+*0.6* (January 17th, 2005)
+
+* Fixed that bcc and cc should be settable through @bcc and @cc -- not just @headers["Bcc"] and @headers["Cc"] #453 [Eric Hodel]
+
+* Fixed Action Mailer to be "warnings safe" so you can run with ruby -w and not get framework warnings #453 [Eric Hodel]
+
+
+*0.5*
+
+* Added access to custom headers, like cc, bcc, and reply-to #268 [Andreas Schwarz]. Example:
+
+ def post_notification(recipients, post)
+ @recipients = recipients
+ @from = post.author.email_address_with_name
+ @headers["bcc"] = SYSTEM_ADMINISTRATOR_EMAIL
+ @headers["reply-to"] = "notifications@example.com"
+ @subject = "[#{post.account.name} #{post.title}]"
+ @body["post"] = post
+ end
+
+*0.4* (5)
+
+* Consolidated the server configuration options into Base#server_settings= and expanded that with controls for authentication and more [Marten]
+ NOTE: This is an API change that could potentially break your application if you used the old application form. Please do change!
+
+* Added Base#deliveries as an accessor for an array of emails sent out through that ActionMailer class when using the :test delivery option. [Jeremy Kemper]
+
+* Added Base#perform_deliveries= which can be set to false to turn off the actual delivery of the email through smtp or sendmail.
+ This is especially useful for functional testing that shouldn't send off real emails, but still trigger delivery_* methods.
+
+* Added option to specify delivery method with Base#delivery_method=. Default is :smtp and :sendmail is currently the only other option.
+ Sendmail is assumed to be present at "/usr/sbin/sendmail" if that option is used. [Kent Sibilev]
+
+* Dropped "include TMail" as it added to much baggage into the default namespace (like Version) [Chad Fowler]
+
+
+*0.3*
+
+* First release
View
21 vendor/rails/actionmailer/MIT-LICENSE
@@ -0,0 +1,21 @@
+Copyright (c) 2004-2008 David Heinemeier Hansson
+
+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
149 vendor/rails/actionmailer/README
@@ -0,0 +1,149 @@
+= Action Mailer -- Easy email delivery and testing
+
+Action Mailer is a framework for designing email-service layers. These layers
+are used to consolidate code for sending out forgotten passwords, welcome
+wishes on signup, invoices for billing, and any other use case that requires
+a written notification to either a person or another system.
+
+Additionally, an Action Mailer class can be used to process incoming email,
+such as allowing a weblog to accept new posts from an email (which could even
+have been sent from a phone).
+
+== Sending emails
+
+The framework works by setting up all the email details, except the body,
+in methods on the service layer. Subject, recipients, sender, and timestamp
+are all set up this way. An example of such a method:
+
+ def signed_up(recipient)
+ recipients recipient
+ subject "[Signed up] Welcome #{recipient}"
+ from "system@loudthinking.com"
+ body :recipient => recipient
+ end
+
+The body of the email is created by using an Action View template (regular
+ERb) that has the content of the body hash parameter available as instance variables.
+So the corresponding body template for the method above could look like this:
+
+ Hello there,
+
+ Mr. <%= @recipient %>
+
+And if the recipient was given as "david@loudthinking.com", the email
+generated would look like this:
+
+ Date: Sun, 12 Dec 2004 00:00:00 +0100
+ From: system@loudthinking.com
+ To: david@loudthinking.com
+ Subject: [Signed up] Welcome david@loudthinking.com
+
+ Hello there,
+
+ Mr. david@loudthinking.com
+
+You never actually call the instance methods like signed_up directly. Instead,
+you call class methods like deliver_* and create_* that are automatically
+created for each instance method. So if the signed_up method sat on
+ApplicationMailer, it would look like this:
+
+ ApplicationMailer.create_signed_up("david@loudthinking.com") # => tmail object for testing
+ ApplicationMailer.deliver_signed_up("david@loudthinking.com") # sends the email
+ ApplicationMailer.new.signed_up("david@loudthinking.com") # won't work!
+
+== Receiving emails
+
+To receive emails, you need to implement a public instance method called receive that takes a
+tmail object as its single parameter. The Action Mailer framework has a corresponding class method,
+which is also called receive, that accepts a raw, unprocessed email as a string, which it then turns
+into the tmail object and calls the receive instance method.
+
+Example:
+
+ class Mailman < ActionMailer::Base
+ def receive(email)
+ page = Page.find_by_address(email.to.first)
+ page.emails.create(
+ :subject => email.subject, :body => email.body
+ )
+
+ if email.has_attachments?
+ for attachment in email.attachments
+ page.attachments.create({
+ :file => attachment, :description => email.subject
+ })
+ end
+ end
+ end
+ end
+
+This Mailman can be the target for Postfix or other MTAs. In Rails, you would use the runner in the
+trivial case like this:
+
+ ./script/runner 'Mailman.receive(STDIN.read)'
+
+However, invoking Rails in the runner for each mail to be received is very resource intensive. A single
+instance of Rails should be run within a daemon if it is going to be utilized to process more than just
+a limited number of email.
+
+== Configuration
+
+The Base class has the full list of configuration options. Here's an example:
+
+ ActionMailer::Base.smtp_settings = {
+ :address => 'smtp.yourserver.com', # default: localhost
+ :port => '25', # default: 25
+ :user_name => 'user',
+ :password => 'pass',
+ :authentication => :plain # :plain, :login or :cram_md5
+ }
+
+== Dependencies
+
+Action Mailer requires that the Action Pack is either available to be required immediately
+or is accessible as a GEM.
+
+
+== Bundled software
+
+* tmail 0.10.8 by Minero Aoki released under LGPL
+ Read more on http://i.loveruby.net/en/prog/tmail.html
+
+* Text::Format 0.63 by Austin Ziegler released under OpenSource
+ Read more on http://www.halostatue.ca/ruby/Text__Format.html
+
+
+== Download
+
+The latest version of Action Mailer can be found at
+
+* http://rubyforge.org/project/showfiles.php?group_id=361
+
+Documentation can be found at
+
+* http://actionmailer.rubyonrails.org
+
+
+== Installation
+
+You can install Action Mailer with the following command.
+
+ % [sudo] ruby install.rb
+
+from its distribution directory.
+
+
+== License
+
+Action Mailer is released under the MIT license.
+
+
+== Support
+
+The Action Mailer homepage is http://www.rubyonrails.org. You can find
+the Action Mailer RubyForge page at http://rubyforge.org/projects/actionmailer.
+And as Jim from Rake says:
+
+ Feel free to submit commits or feature requests. If you send a patch,
+ remember to update the corresponding unit tests. If fact, I prefer
+ new feature to be submitted in the form of new unit tests.
View
98 vendor/rails/actionmailer/Rakefile
@@ -0,0 +1,98 @@
+require 'rubygems'
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+require 'rake/packagetask'
+require 'rake/gempackagetask'
+require 'rake/contrib/sshpublisher'
+require File.join(File.dirname(__FILE__), 'lib', 'action_mailer', 'version')
+
+PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
+PKG_NAME = 'actionmailer'
+PKG_VERSION = ActionMailer::VERSION::STRING + PKG_BUILD
+PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
+
+RELEASE_NAME = "REL #{PKG_VERSION}"
+
+RUBY_FORGE_PROJECT = "actionmailer"
+RUBY_FORGE_USER = "webster132"
+
+desc "Default Task"
+task :default => [ :test ]
+
+# Run the unit tests
+Rake::TestTask.new { |t|
+ t.libs << "test"
+ t.pattern = 'test/*_test.rb'
+ t.verbose = true
+ t.warning = false
+}
+
+
+# Generate the RDoc documentation
+Rake::RDocTask.new { |rdoc|
+ rdoc.rdoc_dir = 'doc'
+ rdoc.title = "Action Mailer -- Easy email delivery and testing"
+ rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
+ rdoc.options << '--charset' << 'utf-8'
+ rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo'
+ rdoc.rdoc_files.include('README', 'CHANGELOG')
+ rdoc.rdoc_files.include('lib/action_mailer.rb')
+ rdoc.rdoc_files.include('lib/action_mailer/*.rb')
+}
+
+
+# Create compressed packages
+spec = Gem::Specification.new do |s|
+ s.platform = Gem::Platform::RUBY
+ s.name = PKG_NAME
+ s.summary = "Service layer for easy email delivery and testing."
+ s.description = %q{Makes it trivial to test and deliver emails sent from a single service layer.}
+ s.version = PKG_VERSION
+
+ s.author = "David Heinemeier Hansson"
+ s.email = "david@loudthinking.com"
+ s.rubyforge_project = "actionmailer"
+ s.homepage = "http://www.rubyonrails.org"
+
+ s.add_dependency('actionpack', '= 2.2.2' + PKG_BUILD)
+
+ s.has_rdoc = true
+ s.requirements << 'none'
+ s.require_path = 'lib'
+ s.autorequire = 'action_mailer'
+
+ s.files = [ "Rakefile", "install.rb", "README", "CHANGELOG", "MIT-LICENSE" ]
+ s.files = s.files + Dir.glob( "lib/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
+ s.files = s.files + Dir.glob( "test/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
+end
+
+Rake::GemPackageTask.new(spec) do |p|
+ p.gem_spec = spec
+ p.need_tar = true
+ p.need_zip = true
+end
+
+
+desc "Publish the API documentation"
+task :pgem => [:package] do
+ Rake::SshFilePublisher.new("gems.rubyonrails.org", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
+ `ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'`
+end
+
+desc "Publish the API documentation"
+task :pdoc => [:rdoc] do
+ Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/am", "doc").upload
+end
+
+desc "Publish the release files to RubyForge."
+task :release => [ :package ] do
+ require 'rubyforge'
+ require 'rake/contrib/rubyforgepublisher'
+
+ packages = %w( gem tgz zip ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" }
+
+ rubyforge = RubyForge.new
+ rubyforge.login
+ rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages)
+end
View
30 vendor/rails/actionmailer/install.rb
@@ -0,0 +1,30 @@
+require 'rbconfig'
+require 'find'
+require 'ftools'
+
+include Config
+
+# this was adapted from rdoc's install.rb by way of Log4r
+
+$sitedir = CONFIG["sitelibdir"]
+unless $sitedir
+ version = CONFIG["MAJOR"] + "." + CONFIG["MINOR"]
+ $libdir = File.join(CONFIG["libdir"], "ruby", version)
+ $sitedir = $:.find {|x| x =~ /site_ruby/ }
+ if !$sitedir
+ $sitedir = File.join($libdir, "site_ruby")
+ elsif $sitedir !~ Regexp.quote(version)
+ $sitedir = File.join($sitedir, version)
+ end
+end
+
+# the actual gruntwork
+Dir.chdir("lib")
+
+Find.find("action_mailer", "action_mailer.rb") { |f|
+ if f[-3..-1] == ".rb"
+ File::install(f, File.join($sitedir, *f.split(/\//)), 0644, true)
+ else
+ File::makedirs(File.join($sitedir, *f.split(/\//)))
+ end
+}
View
52 vendor/rails/actionmailer/lib/action_mailer.rb
@@ -0,0 +1,52 @@
+#--
+# Copyright (c) 2004-2008 David Heinemeier Hansson
+#
+# 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.
+#++
+
+begin
+ require 'action_controller'
+rescue LoadError
+ actionpack_path = "#{File.dirname(__FILE__)}/../../actionpack/lib"
+ if File.directory?(actionpack_path)
+ $:.unshift actionpack_path
+ require 'action_controller'
+ end
+end
+
+require 'action_mailer/vendor'
+require 'tmail'
+
+require 'action_mailer/base'
+require 'action_mailer/helpers'
+require 'action_mailer/mail_helper'
+require 'action_mailer/quoting'
+require 'action_mailer/test_helper'
+
+require 'net/smtp'
+
+ActionMailer::Base.class_eval do
+ include ActionMailer::Quoting
+ include ActionMailer::Helpers
+
+ helper MailHelper
+end
+
+silence_warnings { TMail::Encoder.const_set("MAX_LINE_LEN", 200) }
View
30 vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb
@@ -0,0 +1,30 @@
+module ActionMailer
+ module AdvAttrAccessor #:nodoc:
+ def self.included(base)
+ base.extend(ClassMethods)
+ end
+
+ module ClassMethods #:nodoc:
+ def adv_attr_accessor(*names)
+ names.each do |name|
+ ivar = "@#{name}"
+
+ define_method("#{name}=") do |value|
+ instance_variable_set(ivar, value)
+ end
+
+ define_method(name) do |*parameters|
+ raise ArgumentError, "expected 0 or 1 parameters" unless parameters.length <= 1
+ if parameters.empty?
+ if instance_variable_names.include?(ivar)
+ instance_variable_get(ivar)
+ end
+ else
+ instance_variable_set(ivar, parameters.first)
+ end
+ end
+ end
+ end
+ end
+ end
+end
View
690 vendor/rails/actionmailer/lib/action_mailer/base.rb
@@ -0,0 +1,690 @@
+require 'action_mailer/adv_attr_accessor'
+require 'action_mailer/part'
+require 'action_mailer/part_container'
+require 'action_mailer/utils'
+require 'tmail/net'
+
+module ActionMailer #:nodoc:
+ # Action Mailer allows you to send email from your application using a mailer model and views.
+ #
+ #
+ # = Mailer Models
+ #
+ # To use Action Mailer, you need to create a mailer model.
+ #
+ # $ script/generate mailer Notifier
+ #
+ # The generated model inherits from ActionMailer::Base. Emails are defined by creating methods within the model which are then
+ # used to set variables to be used in the mail template, to change options on the mail, or
+ # to add attachments.
+ #
+ # Examples:
+ #
+ # class Notifier < ActionMailer::Base
+ # def signup_notification(recipient)
+ # recipients recipient.email_address_with_name
+ # from "system@example.com"
+ # subject "New account information"
+ # body :account => recipient
+ # end
+ # end
+ #
+ # Mailer methods have the following configuration methods available.
+ #
+ # * <tt>recipients</tt> - Takes one or more email addresses. These addresses are where your email will be delivered to. Sets the <tt>To:</tt> header.
+ # * <tt>subject</tt> - The subject of your email. Sets the <tt>Subject:</tt> header.
+ # * <tt>from</tt> - Who the email you are sending is from. Sets the <tt>From:</tt> header.
+ # * <tt>cc</tt> - Takes one or more email addresses. These addresses will receive a carbon copy of your email. Sets the <tt>Cc:</tt> header.
+ # * <tt>bcc</tt> - Takes one or more email addresses. These addresses will receive a blind carbon copy of your email. Sets the <tt>Bcc:</tt> header.
+ # * <tt>reply_to</tt> - Takes one or more email addresses. These addresses will be listed as the default recipients when replying to your email. Sets the <tt>Reply-To:</tt> header.
+ # * <tt>sent_on</tt> - The date on which the message was sent. If not set, the header wil be set by the delivery agent.
+ # * <tt>content_type</tt> - Specify the content type of the message. Defaults to <tt>text/plain</tt>.
+ # * <tt>headers</tt> - Specify additional headers to be set for the message, e.g. <tt>headers 'X-Mail-Count' => 107370</tt>.
+ #
+ # When a <tt>headers 'return-path'</tt> is specified, that value will be used as the 'envelope from'
+ # address. Setting this is useful when you want delivery notifications sent to a different address than
+ # the one in <tt>from</tt>.
+ #
+ # The <tt>body</tt> method has special behavior. It takes a hash which generates an instance variable
+ # named after each key in the hash containing the value that that key points to.
+ #
+ # So, for example, <tt>body :account => recipient</tt> would result
+ # in an instance variable <tt>@account</tt> with the value of <tt>recipient</tt> being accessible in the
+ # view.
+ #
+ #
+ # = Mailer views
+ #
+ # Like Action Controller, each mailer class has a corresponding view directory
+ # in which each method of the class looks for a template with its name.
+ # To define a template to be used with a mailing, create an <tt>.erb</tt> file with the same name as the method
+ # in your mailer model. For example, in the mailer defined above, the template at
+ # <tt>app/views/notifier/signup_notification.erb</tt> would be used to generate the email.
+ #
+ # Variables defined in the model are accessible as instance variables in the view.
+ #
+ # Emails by default are sent in plain text, so a sample view for our model example might look like this:
+ #
+ # Hi <%= @account.name %>,
+ # Thanks for joining our service! Please check back often.
+ #
+ # You can even use Action Pack helpers in these views. For example:
+ #
+ # You got a new note!
+ # <%= truncate(note.body, 25) %>
+ #
+ #
+ # = Generating URLs
+ #
+ # URLs can be generated in mailer views using <tt>url_for</tt> or named routes.
+ # Unlike controllers from Action Pack, the mailer instance doesn't have any context about the incoming request,
+ # so you'll need to provide all of the details needed to generate a URL.
+ #
+ # When using <tt>url_for</tt> you'll need to provide the <tt>:host</tt>, <tt>:controller</tt>, and <tt>:action</tt>:
+ #
+ # <%= url_for(:host => "example.com", :controller => "welcome", :action => "greeting") %>
+ #
+ # When using named routes you only need to supply the <tt>:host</tt>:
+ #
+ # <%= users_url(:host => "example.com") %>
+ #
+ # You will want to avoid using the <tt>name_of_route_path</tt> form of named routes because it doesn't make sense to
+ # generate relative URLs in email messages.
+ #
+ # It is also possible to set a default host that will be used in all mailers by setting the <tt>:host</tt> option in
+ # the <tt>ActionMailer::Base.default_url_options</tt> hash as follows:
+ #
+ # ActionMailer::Base.default_url_options[:host] = "example.com"
+ #
+ # This can also be set as a configuration option in <tt>config/environment.rb</tt>:
+ #
+ # config.action_mailer.default_url_options = { :host => "example.com" }
+ #
+ # If you do decide to set a default <tt>:host</tt> for your mailers you will want to use the
+ # <tt>:only_path => false</tt> option when using <tt>url_for</tt>. This will ensure that absolute URLs are generated because
+ # the <tt>url_for</tt> view helper will, by default, generate relative URLs when a <tt>:host</tt> option isn't
+ # explicitly provided.
+ #
+ # = Sending mail
+ #
+ # Once a mailer action and template are defined, you can deliver your message or create it and save it
+ # for delivery later:
+ #
+ # Notifier.deliver_signup_notification(david) # sends the email
+ # mail = Notifier.create_signup_notification(david) # => a tmail object
+ # Notifier.deliver(mail)
+ #
+ # You never instantiate your mailer class. Rather, your delivery instance
+ # methods are automatically wrapped in class methods that start with the word
+ # <tt>deliver_</tt> followed by the name of the mailer method that you would
+ # like to deliver. The <tt>signup_notification</tt> method defined above is
+ # delivered by invoking <tt>Notifier.deliver_signup_notification</tt>.
+ #
+ #
+ # = HTML email
+ #
+ # To send mail as HTML, make sure your view (the <tt>.erb</tt> file) generates HTML and
+ # set the content type to html.
+ #
+ # class MyMailer < ActionMailer::Base
+ # def signup_notification(recipient)
+ # recipients recipient.email_address_with_name
+ # subject "New account information"
+ # from "system@example.com"
+ # body :account => recipient
+ # content_type "text/html"
+ # end
+ # end
+ #
+ #
+ # = Multipart email
+ #
+ # You can explicitly specify multipart messages:
+ #
+ # class ApplicationMailer < ActionMailer::Base
+ # def signup_notification(recipient)
+ # recipients recipient.email_address_with_name
+ # subject "New account information"
+ # from "system@example.com"
+ # content_type "multipart/alternative"
+ #
+ # part :content_type => "text/html",
+ # :body => render_message("signup-as-html", :account => recipient)
+ #
+ # part "text/plain" do |p|
+ # p.body = render_message("signup-as-plain", :account => recipient)
+ # p.transfer_encoding = "base64"
+ # end
+ # end
+ # end
+ #
+ # Multipart messages can also be used implicitly because Action Mailer will automatically
+ # detect and use multipart templates, where each template is named after the name of the action, followed
+ # by the content type. Each such detected template will be added as separate part to the message.
+ #
+ # For example, if the following templates existed:
+ # * signup_notification.text.plain.erb
+ # * signup_notification.text.html.erb
+ # * signup_notification.text.xml.builder