client/tags: fix post search links
This commit is contained in:
parent
2ec6b978ac
commit
93910a1655
7 changed files with 16 additions and 7 deletions
|
@ -89,7 +89,7 @@
|
|||
--></a><!--
|
||||
--><% } %><!--
|
||||
--><% if (ctx.canListPosts) { %><!--
|
||||
--><a href='<%- ctx.formatClientLink('posts', {query: tag.names[0]}) %>' class='<%= ctx.makeCssName(tag.category, 'tag') %>'><!--
|
||||
--><a href='<%- ctx.formatClientLink('posts', {query: ctx.escapeColons(tag.names[0])}) %>' class='<%= ctx.makeCssName(tag.category, 'tag') %>'><!--
|
||||
--><% } %><!--
|
||||
--><%- tag.names[0] %> <!--
|
||||
--><% if (ctx.canListPosts) { %><!--
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div class='tag-delete'>
|
||||
<form>
|
||||
<p>This tag has <a href='<%- ctx.formatClientLink('posts', {query: ctx.tag.names[0]}) %>'><%- ctx.tag.postCount %> usage(s)</a>.</p>
|
||||
<p>This tag has <a href='<%- ctx.formatClientLink('posts', {query: ctx.escapeColons(ctx.tag.names[0])}) %>'><%- ctx.tag.postCount %> usage(s)</a>.</p>
|
||||
|
||||
<ul class='input'>
|
||||
<li>
|
||||
|
|
|
@ -36,6 +36,6 @@
|
|||
<section class='description'>
|
||||
<hr/>
|
||||
<%= ctx.makeMarkdown(ctx.tag.description || 'This tag has no description yet.') %>
|
||||
<p>This tag has <a href='<%- ctx.formatClientLink('posts', {query: ctx.tag.names[0]}) %>'><%- ctx.tag.postCount %> usage(s)</a>.</p>
|
||||
<p>This tag has <a href='<%- ctx.formatClientLink('posts', {query: ctx.escapeColons(ctx.tag.names[0])}) %>'><%- ctx.tag.postCount %> usage(s)</a>.</p>
|
||||
</section>
|
||||
</div>
|
||||
|
|
|
@ -47,6 +47,7 @@ class TagController {
|
|||
canMerge: api.hasPrivilege('tags:merge'),
|
||||
canDelete: api.hasPrivilege('tags:delete'),
|
||||
categories: categories,
|
||||
escapeColons: uri.escapeColons,
|
||||
});
|
||||
|
||||
this._view.addEventListener('change', e => this._evtChange(e));
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
const api = require('../api.js');
|
||||
const events = require('../events.js');
|
||||
const views = require('../util/views.js');
|
||||
const uri = require('../util/uri.js');
|
||||
|
||||
const template = views.getTemplate('post-readonly-sidebar');
|
||||
const scoreTemplate = views.getTemplate('score');
|
||||
|
@ -24,6 +25,7 @@ class PostReadonlySidebarControl extends events.EventTarget {
|
|||
canListPosts: api.hasPrivilege('posts:list'),
|
||||
canEditPosts: api.hasPrivilege('posts:edit'),
|
||||
canViewTags: api.hasPrivilege('tags:view'),
|
||||
escapeColons: uri.escapeColons,
|
||||
}));
|
||||
|
||||
this._installFav();
|
||||
|
|
|
@ -270,7 +270,8 @@ class TagInputControl extends events.EventTarget {
|
|||
searchLinkNode.classList.add(className);
|
||||
}
|
||||
searchLinkNode.setAttribute(
|
||||
'href', uri.formatClientLink('posts', {query: tag.names[0]}));
|
||||
'href', uri.formatClientLink(
|
||||
'posts', {query: uri.escapeColons(tag.names[0])}));
|
||||
searchLinkNode.textContent = tag.names[0] + ' ';
|
||||
searchLinkNode.addEventListener('click', e => {
|
||||
e.preventDefault();
|
||||
|
|
|
@ -80,9 +80,14 @@ function extractRootDomain(url) {
|
|||
return domain;
|
||||
}
|
||||
|
||||
function escapeColons(text) {
|
||||
return text.replace(new RegExp(':', 'g'), '\\:');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
formatClientLink: formatClientLink,
|
||||
formatApiLink: formatApiLink,
|
||||
escapeColons: escapeColons,
|
||||
escapeParam: escapeParam,
|
||||
unescapeParam: unescapeParam,
|
||||
extractHostname: extractHostname,
|
||||
|
|
Loading…
Reference in a new issue