+ <%- if flash[:notice] -%>
+
<%= flash[:notice] %>
+ <%- else -%>
+
+ <%- end -%>
+
<%= yield :layout %>
diff --git a/app/views/post_sets/_blank.html.erb b/app/views/post_sets/_blank.html.erb
new file mode 100644
index 000000000..460517bfc
--- /dev/null
+++ b/app/views/post_sets/_blank.html.erb
@@ -0,0 +1,3 @@
+<%= link_to "Go back", :back %>.
\ No newline at end of file
diff --git a/app/views/posts/index.html.erb b/app/views/posts/index.html.erb
index 883999f9c..9ddec2df7 100644
--- a/app/views/posts/index.html.erb
+++ b/app/views/posts/index.html.erb
@@ -34,7 +34,7 @@
<% content_for(:page_title) do %>
- /<%= @post_set.tags.join(" ") %>
+ /<%= @post_set.tag_string %>
<% end %>
<%= render :partial => "posts/partials/common/secondary_links" %>
diff --git a/app/views/posts/partials/index/_posts.html.erb b/app/views/posts/partials/index/_posts.html.erb
index 0adae71ec..8a9d83b90 100644
--- a/app/views/posts/partials/index/_posts.html.erb
+++ b/app/views/posts/partials/index/_posts.html.erb
@@ -1,11 +1,11 @@
- <%= smart_paginator(post_set.posts) do |page| %>
- <%= link_to(page, posts_path(:page => page, :tags => post_set.tags)) %>
+ <%= numbered_paginator(post_set.posts) do |page| %>
+ <%= link_to(page, posts_path(:page => page, :tags => post_set.tag_string)) %>
<% end %>
diff --git a/app/views/uploads/index.html.erb b/app/views/uploads/index.html.erb
index 7ac40ddb5..014fdff23 100644
--- a/app/views/uploads/index.html.erb
+++ b/app/views/uploads/index.html.erb
@@ -1,24 +1,32 @@
-
You can <%= link_to "upload another file", new_upload_path %> or <%= link_to "view your current uploads", uploads_path %>.
- <% if CurrentUser.user.is_moderator? %>
+ <% if CurrentUser.user.is_moderator? && @upload.is_pending? %>
<%= link_to "Force update", upload_path(@upload, :format => "js"), :remote => true, :method => :put %>.
<% end %>
diff --git a/config/danbooru_default_config.rb b/config/danbooru_default_config.rb
index 4b93052e3..6e98c33b0 100644
--- a/config/danbooru_default_config.rb
+++ b/config/danbooru_default_config.rb
@@ -111,6 +111,11 @@ module Danbooru
def tag_subscription_post_limit
200
end
+
+ # After this many pages, the paginator will switch to sequential mode.
+ def max_numbered_pages
+ 2
+ end
# Max number of tag subscriptions per user
def max_tag_subscriptions
diff --git a/lib/danbooru/paginator.rb b/lib/danbooru/paginator.rb
index bed83b368..ca9cfdc53 100644
--- a/lib/danbooru/paginator.rb
+++ b/lib/danbooru/paginator.rb
@@ -1,5 +1,4 @@
require "danbooru/paginator/active_record_extension"
-require "danbooru/paginator/collection_extension"
require "danbooru/paginator/numbered_collection_extension"
require "danbooru/paginator/sequential_collection_extension"
diff --git a/lib/danbooru/paginator/active_record_extension.rb b/lib/danbooru/paginator/active_record_extension.rb
index bd946f292..e0954b313 100644
--- a/lib/danbooru/paginator/active_record_extension.rb
+++ b/lib/danbooru/paginator/active_record_extension.rb
@@ -6,29 +6,29 @@ module Danbooru
extend ActiveSupport::Concern
module ClassMethods
- def page(p)
- if use_sequential_paginator?(p)
- paginate_sequential(p)
+ def paginate(page)
+ if use_sequential_paginator?(page)
+ paginate_sequential(page)
else
- paginate_numbered(p)
+ paginate_numbered(page)
end
end
- def use_sequential_paginator?(p)
- p =~ /[ab]\d+/i
+ def use_sequential_paginator?(page)
+ page =~ /[ab]\d+/i
end
- def paginate_sequential(p)
- if p =~ /b(\d+)/
+ def paginate_sequential(page)
+ if page =~ /b(\d+)/
paginate_sequential_before($1)
- elsif p =~ /a(\d+)/
+ elsif page =~ /a(\d+)/
paginate_sequential_after($1)
else
- paginate_numbered(p)
+ paginate_sequential_before
end
end
- def paginate_sequential_before(before_id)
+ def paginate_sequential_before(before_id = nil)
c = limit(records_per_page)
if before_id.to_i > 0
@@ -48,17 +48,17 @@ module Danbooru
end
end
- def paginate_numbered(p)
- p = [p.to_i, 1].max
- limit(records_per_page).offset((p - 1) * records_per_page).tap do |obj|
+ def paginate_numbered(page)
+ page = [page.to_i, 1].max
+ limit(records_per_page).offset((page - 1) * records_per_page).tap do |obj|
obj.extend(NumberedCollectionExtension)
- obj.total_pages = (obj.total_count / records_per_page.to_f).ceil
- obj.current_page = p
+ obj.total_pages = (obj.total_count.to_f / records_per_page).ceil
+ obj.current_page = page
end
end
def records_per_page
- Danbooru.config.posts_per_p
+ Danbooru.config.posts_per_page
end
# taken from kaminari (https://github.com/amatsuda/kaminari)
diff --git a/lib/danbooru/paginator/collection_extension.rb b/lib/danbooru/paginator/collection_extension.rb
deleted file mode 100644
index d15a53c10..000000000
--- a/lib/danbooru/paginator/collection_extension.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-module Danbooru
- module Paginator
- module CollectionExtension
- end
- end
-end
diff --git a/lib/danbooru/paginator/numbered_collection_extension.rb b/lib/danbooru/paginator/numbered_collection_extension.rb
index 644807625..b3dc48ace 100644
--- a/lib/danbooru/paginator/numbered_collection_extension.rb
+++ b/lib/danbooru/paginator/numbered_collection_extension.rb
@@ -3,24 +3,12 @@ module Danbooru
module NumberedCollectionExtension
attr_accessor :current_page, :total_pages
- def self.extended(obj)
- obj.extend(Danbooru::Paginator::CollectionExtension)
- end
-
def is_first_page?
current_page == 1
end
def is_last_page?
- current_page == total_pages
- end
-
- def is_sequential_paginator?
- false
- end
-
- def is_numbered_paginator?
- true
+ current_page >= total_pages
end
end
end
diff --git a/lib/danbooru/paginator/sequential_collection_extension.rb b/lib/danbooru/paginator/sequential_collection_extension.rb
index ba45be58f..85a240168 100644
--- a/lib/danbooru/paginator/sequential_collection_extension.rb
+++ b/lib/danbooru/paginator/sequential_collection_extension.rb
@@ -3,10 +3,6 @@ module Danbooru
module SequentialCollectionExtension
attr_accessor :sequential_paginator_mode
- def self.extended(obj)
- obj.extend(Danbooru::Paginator::CollectionExtension)
- end
-
def is_first_page?
size == 0
end
@@ -15,14 +11,6 @@ module Danbooru
size == 0
end
- def is_sequential_paginator?
- true
- end
-
- def is_numbered_paginator?
- false
- end
-
def to_a
if sequential_paginator_mode == :before
super
@@ -30,22 +18,6 @@ module Danbooru
super.reverse
end
end
-
- def before_id
- if size > 0
- self[-1].id
- else
- nil
- end
- end
-
- def after_id
- if size > 0
- self[0].id
- else
- nil
- end
- end
end
end
end