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 "<".
This commit is contained in:
parent
8f275206af
commit
b0c5031001
|
@ -1,20 +1,6 @@
|
|||
<div class='content-wrapper transparent post-view'>
|
||||
<aside class='sidebar'>
|
||||
<nav class='buttons'>
|
||||
<article class='next-post'>
|
||||
<% if (ctx.nextPostId) { %>
|
||||
<% if (ctx.editMode) { %>
|
||||
<a href='<%= ctx.getPostEditUrl(ctx.nextPostId, ctx.parameters) %>'>
|
||||
<% } else { %>
|
||||
<a href='<%= ctx.getPostUrl(ctx.nextPostId, ctx.parameters) %>'>
|
||||
<% } %>
|
||||
<% } else { %>
|
||||
<a class='inactive'>
|
||||
<% } %>
|
||||
<i class='fa fa-chevron-left'></i>
|
||||
<span class='vim-nav-hint'>< Next post</span>
|
||||
</a>
|
||||
</article>
|
||||
<article class='previous-post'>
|
||||
<% if (ctx.prevPostId) { %>
|
||||
<% if (ctx.editMode) { %>
|
||||
|
@ -24,9 +10,23 @@
|
|||
<% } %>
|
||||
<% } else { %>
|
||||
<a class='inactive'>
|
||||
<% } %>
|
||||
<i class='fa fa-chevron-left'></i>
|
||||
<span class='vim-nav-hint'>< Previous post</span>
|
||||
</a>
|
||||
</article>
|
||||
<article class='next-post'>
|
||||
<% if (ctx.nextPostId) { %>
|
||||
<% if (ctx.editMode) { %>
|
||||
<a href='<%= ctx.getPostEditUrl(ctx.nextPostId, ctx.parameters) %>'>
|
||||
<% } else { %>
|
||||
<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 ></span>
|
||||
<span class='vim-nav-hint'>Next post ></span>
|
||||
</a>
|
||||
</article>
|
||||
<article class='edit-post'>
|
||||
|
|
|
@ -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'),
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue