aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrr-2016-10-02 17:04:56 +0200
committerrr-2016-10-02 17:07:08 +0200
commitb0c50310011eaafd55956ddea4b2d37b3556fc7e (patch)
tree24ba5b1f7d092e0e1ec256024ab1105bf4f0dcb0
parent8f275206af77b4c34f58f2aca9354d36d9cfcd6a (diff)
client+server/posts: reverse next/prev post role
In the post list, when we navigate to the page with ">" button, we navigate to older posts. In the post view, when we navigate to the page with ">" button, we navigate to older posts as well. However, in the post list, the ">" button is called "next page". At the same time, in the post view, the ">" button was called "previous post". Now it's called "next post". The difference isn't visible to normal users nor even API consumers as the "get posts around post X" request isn't documented. The change is motivated not only by consistency, but to also improve compatibility with Vimperator's `[[` and `]]`. Vimperator assumes the word "next" refers to ">" and the word "previous" refers to "<".
-rw-r--r--client/html/post.tpl20
-rw-r--r--client/js/controllers/post_controller.js2
-rw-r--r--client/js/views/post_view.js8
-rw-r--r--server/szurubooru/search/executor.py12
4 files changed, 21 insertions, 21 deletions
diff --git a/client/html/post.tpl b/client/html/post.tpl
index a1f7518..07ade0b 100644
--- a/client/html/post.tpl
+++ b/client/html/post.tpl
@@ -1,32 +1,32 @@
<div class='content-wrapper transparent post-view'>
<aside class='sidebar'>
<nav class='buttons'>
- <article class='next-post'>
- <% if (ctx.nextPostId) { %>
+ <article class='previous-post'>
+ <% if (ctx.prevPostId) { %>
<% if (ctx.editMode) { %>
- <a href='<%= ctx.getPostEditUrl(ctx.nextPostId, ctx.parameters) %>'>
+ <a href='<%= ctx.getPostEditUrl(ctx.prevPostId, ctx.parameters) %>'>
<% } else { %>
- <a href='<%= ctx.getPostUrl(ctx.nextPostId, ctx.parameters) %>'>
+ <a href='<%= ctx.getPostUrl(ctx.prevPostId, ctx.parameters) %>'>
<% } %>
<% } else { %>
<a class='inactive'>
<% } %>
<i class='fa fa-chevron-left'></i>
- <span class='vim-nav-hint'>&lt; Next post</span>
+ <span class='vim-nav-hint'>&lt; Previous post</span>
</a>
</article>
- <article class='previous-post'>
- <% if (ctx.prevPostId) { %>
+ <article class='next-post'>
+ <% if (ctx.nextPostId) { %>
<% if (ctx.editMode) { %>
- <a href='<%= ctx.getPostEditUrl(ctx.prevPostId, ctx.parameters) %>'>
+ <a href='<%= ctx.getPostEditUrl(ctx.nextPostId, ctx.parameters) %>'>
<% } else { %>
- <a href='<%= ctx.getPostUrl(ctx.prevPostId, ctx.parameters) %>'>
+ <a href='<%= ctx.getPostUrl(ctx.nextPostId, ctx.parameters) %>'>
<% } %>
<% } else { %>
<a class='inactive'>
<% } %>
<i class='fa fa-chevron-right'></i>
- <span class='vim-nav-hint'>Previous post &gt;</span>
+ <span class='vim-nav-hint'>Next post &gt;</span>
</a>
</article>
<article class='edit-post'>
diff --git a/client/js/controllers/post_controller.js b/client/js/controllers/post_controller.js
index 7644e26..384643a 100644
--- a/client/js/controllers/post_controller.js
+++ b/client/js/controllers/post_controller.js
@@ -45,8 +45,8 @@ class PostController {
this._view = new PostView({
post: post,
editMode: editMode,
- nextPostId: aroundResponse.next ? aroundResponse.next.id : null,
prevPostId: aroundResponse.prev ? aroundResponse.prev.id : null,
+ nextPostId: aroundResponse.next ? aroundResponse.next.id : null,
canEditPosts: api.hasPrivilege('posts:edit'),
canDeletePosts: api.hasPrivilege('posts:delete'),
canFeaturePosts: api.hasPrivilege('posts:feature'),
diff --git a/client/js/views/post_view.js b/client/js/views/post_view.js
index 87d19ac..256eb2d 100644
--- a/client/js/views/post_view.js
+++ b/client/js/views/post_view.js
@@ -67,13 +67,13 @@ class PostView {
}
});
keyboard.bind(['a', 'left'], () => {
- if (ctx.nextPostId) {
- router.show('/post/' + ctx.nextPostId);
+ if (ctx.prevPostId) {
+ router.show('/post/' + ctx.prevPostId);
}
});
keyboard.bind(['d', 'right'], () => {
- if (ctx.prevPostId) {
- router.show('/post/' + ctx.prevPostId);
+ if (ctx.nextPostId) {
+ router.show('/post/' + ctx.nextPostId);
}
});
}
diff --git a/server/szurubooru/search/executor.py b/server/szurubooru/search/executor.py
index 511a9c2..39b1d56 100644
--- a/server/szurubooru/search/executor.py
+++ b/server/szurubooru/search/executor.py
@@ -41,27 +41,27 @@ class Executor(object):
filter_query, search_query, False)
prev_filter_query = (
filter_query
- .filter(self.config.id_column < entity_id)
+ .filter(self.config.id_column > entity_id)
.order_by(None)
.order_by(sqlalchemy.func.abs(
self.config.id_column - entity_id).asc())
.limit(1))
next_filter_query = (
filter_query
- .filter(self.config.id_column > entity_id)
+ .filter(self.config.id_column < entity_id)
.order_by(None)
.order_by(sqlalchemy.func.abs(
self.config.id_column - entity_id).asc())
.limit(1))
return [
- next_filter_query.one_or_none(),
- prev_filter_query.one_or_none()]
+ prev_filter_query.one_or_none(),
+ next_filter_query.one_or_none()]
def get_around_and_serialize(self, ctx, entity_id, serializer):
entities = self.get_around(ctx.get_param_as_string('query'), entity_id)
return {
- 'next': serializer(entities[0]),
- 'prev': serializer(entities[1]),
+ 'prev': serializer(entities[0]),
+ 'next': serializer(entities[1]),
}
def execute(self, query_text, page, page_size):

© 2015 - 2026 Jakob L. Kreuze