<% if (ctx.nextPostId) { %> - + <% if (ctx.searchQuery && ctx.searchQuery.text) { %> + + <% } else { %> + + <% } %> <% } else { %> <% } %> @@ -13,7 +17,11 @@
<% if (ctx.prevPostId) { %> - + <% if (ctx.searchQuery && ctx.searchQuery.text) { %> + + <% } else { %> + + <% } %> <% } else { %> <% } %> @@ -29,7 +37,11 @@ <% } else { %> <% if (ctx.canEditPosts) { %> - + <% if (ctx.searchQuery && ctx.searchQuery.text) { %> + + <% } else { %> + + <% } %> <% } else { %> <% } %> diff --git a/client/html/posts_page.tpl b/client/html/posts_page.tpl index 8024be02..96e1b524 100644 --- a/client/html/posts_page.tpl +++ b/client/html/posts_page.tpl @@ -4,7 +4,11 @@ <% for (let post of ctx.results) { %> <% if (ctx.canViewPosts) { %> - '> + <% if (ctx.searchQuery && ctx.searchQuery.text) { %> + '> + <% } else { %> + '> + <% } %> <% } else { %> <% } %> diff --git a/client/js/controllers/post_controller.js b/client/js/controllers/post_controller.js index a6b2430f..cc87f289 100644 --- a/client/js/controllers/post_controller.js +++ b/client/js/controllers/post_controller.js @@ -10,13 +10,14 @@ const PostView = require('../views/post_view.js'); const EmptyView = require('../views/empty_view.js'); class PostController { - constructor(id, editMode) { + constructor(id, editMode, searchQuery) { topNavigation.activate('posts'); Promise.all([ Post.get(id), api.get(`/post/${id}/around?fields=id&query=` + - this._decorateSearchQuery('')), + this._decorateSearchQuery( + searchQuery ? searchQuery.text : '')), ]).then(responses => { const [post, aroundResponse] = responses; this._post = post; @@ -28,6 +29,7 @@ class PostController { canEditPosts: api.hasPrivilege('posts:edit'), canListComments: api.hasPrivilege('comments:list'), canCreateComments: api.hasPrivilege('comments:create'), + searchQuery: searchQuery, }); if (this._view.sidebarControl) { this._view.sidebarControl.addEventListener( @@ -138,10 +140,17 @@ class PostController { } module.exports = router => { - router.enter('/post/:id', (ctx, next) => { - ctx.controller = new PostController(ctx.params.id, false); - }); - router.enter('/post/:id/edit', (ctx, next) => { - ctx.controller = new PostController(ctx.params.id, true); - }); + router.enter('/post/:id/edit/:query?', + (ctx, next) => { misc.parseSearchQueryRoute(ctx, next); }, + (ctx, next) => { + ctx.controller = new PostController( + ctx.params.id, true, ctx.searchQuery); + }); + router.enter( + '/post/:id/:query?', + (ctx, next) => { misc.parseSearchQueryRoute(ctx, next); }, + (ctx, next) => { + ctx.controller = new PostController( + ctx.params.id, false, ctx.searchQuery); + }); };