diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/posts.js
index 715cfb571..18048f165 100644
--- a/app/assets/javascripts/posts.js
+++ b/app/assets/javascripts/posts.js
@@ -50,18 +50,26 @@
}
Danbooru.Post.nav_pool_prev = function() {
- location.href = $("#pool-nav a.active[rel=prev]").attr("href");
+ if ($("#tag-seq-nav").length) {
+ location.href = $("#tag-seq-nav a[rel=prev]").attr("href");
+ } else {
+ location.href = $("#pool-nav a.active[rel=prev]").attr("href");
+ }
}
Danbooru.Post.nav_pool_next = function() {
- location.href = $("#pool-nav a.active[rel=next]").attr("href");
+ if ($("#tag-seq-nav").length) {
+ location.href = $("#tag-seq-nav a[rel=next]").attr("href");
+ } else {
+ location.href = $("#pool-nav a.active[rel=next]").attr("href");
+ }
}
Danbooru.Post.nav_pool_scroll = function() {
var scroll_top = $(window).scrollTop() + $(window).height();
if (scroll_top > $("#image").height() + $("#image").offset().top + 100) {
- location.href = $("#pool-nav a.active[rel=next]").attr("href");
+ Danbooru.Post.nav_pool_next();
return;
}
@@ -321,10 +329,10 @@
if (width > 1000) {
width = 1000;
}
- if (width < 400) {
- $("#pool-nav li").css("textAlign", "left");
+ if (width > 700) {
+ width = 700
}
- $("#pool-nav").width(width);
+ $("#pool-nav,#tag-seq-nav").width(width);
}
})();
diff --git a/app/assets/stylesheets/specific/posts.css.scss b/app/assets/stylesheets/specific/posts.css.scss
index 8037f4867..9e1d3ae41 100644
--- a/app/assets/stylesheets/specific/posts.css.scss
+++ b/app/assets/stylesheets/specific/posts.css.scss
@@ -122,6 +122,13 @@ div#c-posts {
}
}
+ div.nav-notice {
+ padding: 1em;
+ margin-bottom: 1em;
+ background: #EEE;
+ border: 1px solid #AAA;
+ }
+
aside#sidebar #tag-list h2 {
font-size: $h4_size;
}
@@ -205,11 +212,11 @@ div#c-posts {
float: right;
}
- .pool-name {
+ .pool-name, .tag-name {
margin: 0 1em;
}
- #pool-nav {
+ #pool-nav, #tag-seq-nav {
margin: 1em 0;
li {
diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb
index fa96fc058..e54299d90 100644
--- a/app/controllers/posts_controller.rb
+++ b/app/controllers/posts_controller.rb
@@ -27,6 +27,15 @@ class PostsController < ApplicationController
respond_with(@post)
end
+ def show_seq
+ context = PostSearchContext.new(params)
+ if context.post_id
+ redirect_to(post_path(context.post_id, :tags => params[:tags]))
+ else
+ redirect_to(post_path(params[:id], :tags => params[:tags]))
+ end
+ end
+
def update
@post = Post.find(params[:id])
@post.update_attributes(params[:post], :as => CurrentUser.role)
diff --git a/app/logical/post_search_context.rb b/app/logical/post_search_context.rb
new file mode 100644
index 000000000..db3b5b38a
--- /dev/null
+++ b/app/logical/post_search_context.rb
@@ -0,0 +1,25 @@
+class PostSearchContext
+ attr_reader :params, :post_id
+
+ def initialize(params)
+ @params = params
+ raise unless params[:seq].present?
+ raise unless params[:id].present?
+
+ @post_id = find_post_id
+ end
+
+ def find_post_id
+ if params[:seq] == "prev"
+ post = Post.tag_match(params[:tags]).where("posts.id > ?", params[:id].to_i).reorder("posts.id asc").first
+ else
+ post = Post.tag_match(params[:tags]).where("posts.id < ?", params[:id].to_i).reorder("posts.id desc").first
+ end
+
+ if post
+ post.id
+ else
+ nil
+ end
+ end
+end
diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb
index d691b7b73..537f4d99a 100644
--- a/app/presenters/post_presenter.rb
+++ b/app/presenters/post_presenter.rb
@@ -16,7 +16,12 @@ class PostPresenter < Presenter
path = options[:path_prefix] || "/posts"
html = %{}
html << %{}
html << %{