diff --git a/app/helpers/pagination_helper.rb b/app/helpers/pagination_helper.rb
index cb57aa851..c0e5174d9 100644
--- a/app/helpers/pagination_helper.rb
+++ b/app/helpers/pagination_helper.rb
@@ -11,11 +11,11 @@ module PaginationHelper
html = "
"
diff --git a/app/logical/post_sets/base.rb b/app/logical/post_sets/base.rb
new file mode 100644
index 000000000..518ffbb56
--- /dev/null
+++ b/app/logical/post_sets/base.rb
@@ -0,0 +1,37 @@
+module PostSets
+ class Base
+ def has_wiki?
+ false
+ end
+
+ def wiki_page
+ nil
+ end
+
+ def presenter
+ @presenter ||= PostSetPresenter.new(self)
+ end
+
+ def is_single_tag?
+ false
+ end
+
+ def tag
+ tag_string
+ end
+
+ def arbitrary_sql_order_clause(ids, table_name)
+ if ids.empty?
+ return "#{table_name}.id desc"
+ end
+
+ conditions = []
+
+ ids.each_with_index do |x, n|
+ conditions << "when #{x} then #{n}"
+ end
+
+ "case #{table_name}.id " + conditions.join(" ") + " end"
+ end
+ end
+end
diff --git a/app/logical/post_sets/favorite.rb b/app/logical/post_sets/favorite.rb
new file mode 100644
index 000000000..c37d9b909
--- /dev/null
+++ b/app/logical/post_sets/favorite.rb
@@ -0,0 +1,24 @@
+module PostSets
+ class Favorite < Base
+ attr_reader :user, :page, :favorites, :posts
+
+ def initialize(params)
+ @user = ::User.find(params[:id])
+ @page = [params[:page].to_i, 1].max
+ @favorites = ::Favorite.model_for(@user.id).for_user(@user.id).paginate(page)
+ @posts = ::Post.where("id in (?)", post_ids).order(arbitrary_sql_order_clause(post_ids, "posts")).paginate("a0")
+ end
+
+ def post_ids
+ @post_ids ||= favorites.map(&:post_id)
+ end
+
+ def offset
+ (page - 1) * records_per_page
+ end
+
+ def tag_string
+ @tag_string ||= "fav:#{user.name}"
+ end
+ end
+end
diff --git a/app/logical/post_sets/post.rb b/app/logical/post_sets/post.rb
index 30432a084..947da44a9 100644
--- a/app/logical/post_sets/post.rb
+++ b/app/logical/post_sets/post.rb
@@ -1,5 +1,5 @@
module PostSets
- class Post
+ class Post < Base
attr_reader :tags, :page, :posts
def initialize(params)
@@ -31,13 +31,5 @@ module PostSets
def is_single_tag?
tags.size == 1
end
-
- def tag
- tag_string
- end
-
- def presenter
- @presenter ||= PostSetPresenter.new(self)
- end
end
end
diff --git a/app/models/favorite.rb b/app/models/favorite.rb
index 900cccad2..bc7f82d47 100644
--- a/app/models/favorite.rb
+++ b/app/models/favorite.rb
@@ -2,6 +2,8 @@ class Favorite < ActiveRecord::Base
TABLE_COUNT = 100
belongs_to :post
+ scope :for_user, lambda {|user_id| where("user_id = ?", user_id)}
+
def self.model_for(user_id)
mod = user_id.to_i % TABLE_COUNT
Object.const_get("Favorite#{mod}")
diff --git a/app/views/artist_versions/index.html.erb b/app/views/artist_versions/index.html.erb
index d9f4ab802..d69e4edd7 100644
--- a/app/views/artist_versions/index.html.erb
+++ b/app/views/artist_versions/index.html.erb
@@ -30,7 +30,7 @@
- <%= will_paginate(@artist_versions) %>
+ <%= sequential_paginator(@artist_versions) %>
<%= render "artists/secondary_links" %>
diff --git a/app/views/artists/index.html.erb b/app/views/artists/index.html.erb
index 82464e52d..56863b6d7 100644
--- a/app/views/artists/index.html.erb
+++ b/app/views/artists/index.html.erb
@@ -27,7 +27,9 @@
- <%= will_paginate(@artists) %>
+ <%= numbered_paginator(@artists) do |page| %>
+ <%= link_to(page, artists_path(:page => page, :search => params[:search])) %>
+ <% end %>
<%= render "secondary_links" %>
diff --git a/app/views/comments/index_by_comment.html.erb b/app/views/comments/index_by_comment.html.erb
index cae406415..fce4fb6dc 100644
--- a/app/views/comments/index_by_comment.html.erb
+++ b/app/views/comments/index_by_comment.html.erb
@@ -7,6 +7,10 @@
<% end %>
+
+
+ <%= sequential_paginator(@comments) %>
+
diff --git a/app/views/comments/index_by_post.html.erb b/app/views/comments/index_by_post.html.erb
index 44058699e..b067a8d83 100644
--- a/app/views/comments/index_by_post.html.erb
+++ b/app/views/comments/index_by_post.html.erb
@@ -9,6 +9,10 @@
<% end %>
+
+
+ <%= sequential_paginator(@posts) %>
+
diff --git a/app/views/favorites/index.html.erb b/app/views/favorites/index.html.erb
index dee98b2bc..0d09ac3dd 100644
--- a/app/views/favorites/index.html.erb
+++ b/app/views/favorites/index.html.erb
@@ -30,7 +30,7 @@
- <%= @post_set.presenter.pagination_html(self) %>
+ <%= sequential_paginator(@post_set.favorites) %>
diff --git a/app/views/forum_posts/index.html.erb b/app/views/forum_posts/index.html.erb
index 769e583b0..da42f9034 100644
--- a/app/views/forum_posts/index.html.erb
+++ b/app/views/forum_posts/index.html.erb
@@ -20,7 +20,9 @@
- <%= will_paginate @forum_posts %>
+ <%= numbered_paginator(@forum_posts) do |page| %>
+ <%= link_to(page, forum_posts_path(:search => params[:search], :page => page)) %>
+ <% end %>
<%= render "forum_topics/secondary_links" %>
\ No newline at end of file
diff --git a/app/views/forum_topics/index.html.erb b/app/views/forum_topics/index.html.erb
index 053fccb37..c03170149 100644
--- a/app/views/forum_topics/index.html.erb
+++ b/app/views/forum_topics/index.html.erb
@@ -1,4 +1,4 @@
-Forum
+Forum
diff --git a/app/views/note_versions/index.html.erb b/app/views/note_versions/index.html.erb
index 656d15bb1..7b3f09bd5 100644
--- a/app/views/note_versions/index.html.erb
+++ b/app/views/note_versions/index.html.erb
@@ -32,7 +32,7 @@
- <%= will_paginate(@note_versions) %>
+ <%= sequential_paginator(@note_versions) %>
<%= render :partial => "footer" %>
diff --git a/app/views/pool_versions/index.html.erb b/app/views/pool_versions/index.html.erb
index 44eee79ac..ef577ad9d 100644
--- a/app/views/pool_versions/index.html.erb
+++ b/app/views/pool_versions/index.html.erb
@@ -34,7 +34,7 @@
- <%= will_paginate(@pool_versions) %>
+ <%= sequential_paginator(@pool_versions) %>
<%= render :partial => "pools/secondary_links" %>
diff --git a/app/views/pools/index.html.erb b/app/views/pools/index.html.erb
index 9878c749f..279f61acf 100644
--- a/app/views/pools/index.html.erb
+++ b/app/views/pools/index.html.erb
@@ -26,7 +26,7 @@
- <%= will_paginate(@pools) %>
+ <%= sequential_paginator(@pools) %>
<%= render "secondary_links" %>
diff --git a/app/views/wiki_pages/index.html.erb b/app/views/wiki_pages/index.html.erb
index 2e590b818..c23d3d107 100644
--- a/app/views/wiki_pages/index.html.erb
+++ b/app/views/wiki_pages/index.html.erb
@@ -17,7 +17,9 @@
- <%= will_paginate(@wiki_pages) %>
+ <%= smart_paginator(@wiki_pages) do |page| %>
+ <%= link_to(page, wiki_pages_path(:page => page, :search => params[:search])) %>
+ <% end %>