Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moved to github version of alphabetical paginate

  • Loading branch information...
commit bfacca7b99c2ac87bf2ee5078b759061b826c1cb 1 parent 715c58f
@chrismdp chrismdp authored
View
1  Gemfile
@@ -4,6 +4,7 @@ gem 'rails', '3.0.7'
gem 'pg'
gem 'configurable_engine'
+gem 'paginate_alphabetically', git: 'git://github.com/edendevelopment/paginate_alphabetically.git', branch: 'bundler'
gem 'haml'
gem 'compass'
View
8 Gemfile.lock
@@ -1,3 +1,10 @@
+GIT
+ remote: git://github.com/edendevelopment/paginate_alphabetically.git
+ revision: f9ed9c1b043de06a2c60dd11a324b2eb4657635b
+ branch: bundler
+ specs:
+ paginate_alphabetically (0.3.3)
+
GEM
remote: http://rubygems.org/
specs:
@@ -279,6 +286,7 @@ DEPENDENCIES
jelly
launchy
metric_fu
+ paginate_alphabetically!
pg
rack-cache
rails (= 3.0.7)
View
2  app/views/people/index.html.haml
@@ -10,7 +10,7 @@
- else
%h2 List of people
- = alphabetically_paginate(@people)
+ = alphabetically_paginate(@people, :always_display => true)
- if @people.any?
%ul.people
View
5 vendor/plugins/paginate_alphabetically/.document
@@ -1,5 +0,0 @@
-README.rdoc
-lib/**/*.rb
-bin/*
-features/**/*.feature
-LICENSE
View
20 vendor/plugins/paginate_alphabetically/LICENSE
@@ -1,20 +0,0 @@
-Copyright (c) 2010 Eden Development
-
-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
38 vendor/plugins/paginate_alphabetically/README.textile
@@ -1,38 +0,0 @@
-h2. PaginateAlphabetically
-
-An easy way to paginate a list of ActiveRecord objects alphabetically by any given attribute.
-
-
-h2. Example
-
-h3. Model
-
-bc. class User < ActiveRecord::Base
- paginate_alphabetically :by => :surname
-end
-
-h3. Controller
-
-bc. class UsersController < ApplicationController
- def index
- @users = User.alphabetical_group(params[:letter])
- end
-end
-
-h3. View (haml example)
-
-bc. = alphabetically_paginate(@users)
-%ul.users
- - @users.each do |user|
- %li= user.surname
-
-
-h2. Testing
-
-The tests use a sqlite3 in-memory database to be able to run separately from your application.
-
-bc. rake test
-
-
-
-Copyright (c) 2010 Eden Development, released under the MIT license
View
55 vendor/plugins/paginate_alphabetically/Rakefile
@@ -1,55 +0,0 @@
-require 'rubygems'
-require 'rake'
-
-begin
- require 'jeweler'
- Jeweler::Tasks.new do |gem|
- gem.name = "paginate_alphabetically"
- gem.summary = %Q{An easy way to paginate a list of ActiveRecord objects alphabetically by any given attribute.}
- gem.description = %Q{Provides a list of available letters, and a way of fetching the records for each letter.}
- gem.email = "dev+gems@edendevelopment.co.uk"
- gem.homepage = "http://github.com/edendevelopment/paginate_alphabetically"
- gem.authors = ["Eden Development"]
- gem.add_development_dependency "activerecord", ">= 2.3.5"
- gem.add_development_dependency "mocha"
- gem.add_development_dependency "sqlite3-ruby", "1.2.5"
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
- end
- Jeweler::GemcutterTasks.new
-rescue LoadError
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
-end
-
-require 'rake/testtask'
-Rake::TestTask.new(:test) do |test|
- test.libs << 'lib' << 'test'
- test.pattern = 'test/**/test_*.rb'
- test.verbose = true
-end
-
-begin
- require 'rcov/rcovtask'
- Rcov::RcovTask.new do |test|
- test.libs << 'test'
- test.pattern = 'test/**/test_*.rb'
- test.verbose = true
- end
-rescue LoadError
- task :rcov do
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
- end
-end
-
-task :test => :check_dependencies
-
-task :default => :test
-
-require 'rake/rdoctask'
-Rake::RDocTask.new do |rdoc|
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
-
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = "paginate_alphabetically #{version}"
- rdoc.rdoc_files.include('README*')
- rdoc.rdoc_files.include('lib/**/*.rb')
-end
View
1  vendor/plugins/paginate_alphabetically/VERSION
@@ -1 +0,0 @@
-0.2.3
View
5 vendor/plugins/paginate_alphabetically/init.rb
@@ -1,5 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), 'lib/paginate_alphabetically'))
-require File.expand_path(File.join(File.dirname(__FILE__), 'lib/view_helpers'))
-
-ActiveRecord::Base.extend(PaginateAlphabetically)
-ActionView::Base.class_eval { include PaginateAlphabetically::ViewHelpers }
View
1  vendor/plugins/paginate_alphabetically/install.rb
@@ -1 +0,0 @@
-# Install hook code here
View
22 vendor/plugins/paginate_alphabetically/lib/paginate_alphabetically.rb
@@ -1,22 +0,0 @@
-module PaginateAlphabetically
- def paginate_alphabetically(params)
- @attribute = params[:by]
- self.extend ClassMethods
- end
-
- module ClassMethods
- def pagination_letters
- all.sort_by{|obj| obj.send(@attribute).upcase}.group_by {|group| group.send(@attribute)[0].chr.upcase}.keys
- end
-
- def first_letter
- first_instance = find(:first, :order => @attribute, :conditions => ["#{@attribute.to_s} >= ?", 'a'])
- return 'A' if first_instance.nil?
- first_instance.send(@attribute)[0].chr.upcase
- end
-
- def alphabetical_group(letter = nil)
- find(:all, :conditions => ["#{@attribute.to_s} LIKE ?", "#{letter || first_letter}%"], :order => @attribute)
- end
- end
-end
View
31 vendor/plugins/paginate_alphabetically/lib/view_helpers.rb
@@ -1,31 +0,0 @@
-module PaginateAlphabetically
- module ViewHelpers
- def alphabetically_paginate(collection)
- return "" if collection.empty?
- available_letters = collection.first.class.pagination_letters
- content_tag(:ul, safe(alphabetical_links_to(available_letters)),
- :class => "pagination")
- end
-
- def safe(content)
- if content.respond_to?(:html_safe)
- return content.html_safe
- end
- content
- end
-
- def alphabetical_links_to(available_letters)
- ('A'..'Z').map do |letter|
- content_tag(:li, paginated_letter(available_letters, letter))
- end.join(" ")
- end
-
- def paginated_letter(available_letters, letter)
- if available_letters.include?(letter)
- link_to(letter, "#{request.path}?letter=#{letter}")
- else
- letter
- end
- end
- end
-end
View
5 vendor/plugins/paginate_alphabetically/test/db/schema.rb
@@ -1,5 +0,0 @@
-ActiveRecord::Schema.define do
- create_table "things", :force => true do |t|
- t.column "name", :text
- end
-end
View
24 vendor/plugins/paginate_alphabetically/test/helper.rb
@@ -1,24 +0,0 @@
-require 'rubygems'
-require 'active_support'
-require 'active_support/test_case'
-require 'test/unit'
-require 'sqlite3'
-require 'active_record'
-require 'action_view'
-require 'mocha'
-include ActionView::Helpers
-require File.expand_path(File.join(File.dirname(__FILE__), '../init.rb'))
-
-ActiveRecord::Base.establish_connection(
- :adapter => "sqlite3",
- :database => ":memory:"
-)
-
-load File.expand_path(File.join(File.dirname(__FILE__), 'db/schema.rb'))
-
-class Thing < ActiveRecord::Base
- paginate_alphabetically :by => :name
-end
-
-class Numpty < ActiveRecord::Base
-end
View
46 vendor/plugins/paginate_alphabetically/test/test_paginate_alphabetically.rb
@@ -1,46 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
-
-class PaginateAlphabeticallyTest < ActiveSupport::TestCase
- def setup
- %w(one two Three four Five Six).map {|name| Thing.create!(:name => name)}
- end
-
- test "pagination letters" do
- assert_equal ['F', 'O', 'S', 'T'], Thing.pagination_letters
- end
-
- test "first letter" do
- assert_equal 'F', Thing.first_letter
- end
-
- test "first letter is alphabetical" do
- Thing.create!(:name => ' o noes a space :(')
- Thing.create!(:name => '1')
- Thing.create!(:name => '®')
- Thing.create!(:name => '$')
- assert_equal 'F', Thing.first_letter
- end
-
- test "first letter when there are no things" do
- Thing.destroy_all
- assert_equal 'A', Thing.first_letter
- end
-
- test "alphabetical group without specifying letter" do
- assert_equal ['Five', 'four'], Thing.alphabetical_group.map(&:name)
- end
-
- test "alphabetical group specifying letter" do
- assert_equal ['Three', 'two'], Thing.alphabetical_group('t').map(&:name)
- end
-
- test "class without pagination has no pagination methods" do
- assert_raise NoMethodError do
- Numpty.alphabetical_group
- end
- end
-
- def teardown
- Thing.destroy_all
- end
-end
View
43 vendor/plugins/paginate_alphabetically/test/test_view_helpers.rb
@@ -1,43 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
-include PaginateAlphabetically::ViewHelpers
-
-
-module PaginateAlphabetically
- module ViewHelpers
- def request
- stub(:path => '')
- end
- end
-end
-
-class ViewHelperTest < ActiveSupport::TestCase
- def setup
- @result = alphabetically_paginate([Thing.create!(:name => 'a')])
- end
-
- test "it includes all the letters" do
- ('A'..'Z').each do |letter|
- assert @result.include?(letter)
- end
- end
-
- test "it links to the available letters" do
- assert @result.include?('<a href="?letter=A">')
- end
-
- test "it returns nothing when the collection is empty" do
- assert_equal "", alphabetically_paginate([])
- end
-
- test "it does not link to letters that have no content" do
- assert_equal false, @result.include?('href="?letter=B"')
- end
-
- test "it wraps the letters as list items" do
- assert @result.include?('<li>B</li>')
- end
-
- test "it wraps the result in a ul" do
- assert @result.include?('<ul class="pagination">')
- end
-end
View
1  vendor/plugins/paginate_alphabetically/uninstall.rb
@@ -1 +0,0 @@
-# Uninstall hook code here
Please sign in to comment.
Something went wrong with that request. Please try again.