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><!--
|
--></a><!--
|
||||||
--><% } %><!--
|
--><% } %><!--
|
||||||
--><% if (ctx.canListPosts) { %><!--
|
--><% 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] %> <!--
|
--><%- tag.names[0] %> <!--
|
||||||
--><% if (ctx.canListPosts) { %><!--
|
--><% if (ctx.canListPosts) { %><!--
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<div class='tag-delete'>
|
<div class='tag-delete'>
|
||||||
<form>
|
<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'>
|
<ul class='input'>
|
||||||
<li>
|
<li>
|
||||||
|
|
|
@ -36,6 +36,6 @@
|
||||||
<section class='description'>
|
<section class='description'>
|
||||||
<hr/>
|
<hr/>
|
||||||
<%= ctx.makeMarkdown(ctx.tag.description || 'This tag has no description yet.') %>
|
<%= 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>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -47,6 +47,7 @@ class TagController {
|
||||||
canMerge: api.hasPrivilege('tags:merge'),
|
canMerge: api.hasPrivilege('tags:merge'),
|
||||||
canDelete: api.hasPrivilege('tags:delete'),
|
canDelete: api.hasPrivilege('tags:delete'),
|
||||||
categories: categories,
|
categories: categories,
|
||||||
|
escapeColons: uri.escapeColons,
|
||||||
});
|
});
|
||||||
|
|
||||||
this._view.addEventListener('change', e => this._evtChange(e));
|
this._view.addEventListener('change', e => this._evtChange(e));
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
const api = require('../api.js');
|
const api = require('../api.js');
|
||||||
const events = require('../events.js');
|
const events = require('../events.js');
|
||||||
const views = require('../util/views.js');
|
const views = require('../util/views.js');
|
||||||
|
const uri = require('../util/uri.js');
|
||||||
|
|
||||||
const template = views.getTemplate('post-readonly-sidebar');
|
const template = views.getTemplate('post-readonly-sidebar');
|
||||||
const scoreTemplate = views.getTemplate('score');
|
const scoreTemplate = views.getTemplate('score');
|
||||||
|
@ -24,6 +25,7 @@ class PostReadonlySidebarControl extends events.EventTarget {
|
||||||
canListPosts: api.hasPrivilege('posts:list'),
|
canListPosts: api.hasPrivilege('posts:list'),
|
||||||
canEditPosts: api.hasPrivilege('posts:edit'),
|
canEditPosts: api.hasPrivilege('posts:edit'),
|
||||||
canViewTags: api.hasPrivilege('tags:view'),
|
canViewTags: api.hasPrivilege('tags:view'),
|
||||||
|
escapeColons: uri.escapeColons,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this._installFav();
|
this._installFav();
|
||||||
|
|
|
@ -270,7 +270,8 @@ class TagInputControl extends events.EventTarget {
|
||||||
searchLinkNode.classList.add(className);
|
searchLinkNode.classList.add(className);
|
||||||
}
|
}
|
||||||
searchLinkNode.setAttribute(
|
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.textContent = tag.names[0] + ' ';
|
||||||
searchLinkNode.addEventListener('click', e => {
|
searchLinkNode.addEventListener('click', e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
|
@ -68,21 +68,26 @@ function extractRootDomain(url) {
|
||||||
let splitArr = domain.split('.');
|
let splitArr = domain.split('.');
|
||||||
let arrLen = splitArr.length;
|
let arrLen = splitArr.length;
|
||||||
|
|
||||||
//if there is a subdomain
|
// if there is a subdomain
|
||||||
if (arrLen > 2) {
|
if (arrLen > 2) {
|
||||||
domain = splitArr[arrLen - 2] + '.' + splitArr[arrLen - 1];
|
domain = splitArr[arrLen - 2] + '.' + splitArr[arrLen - 1];
|
||||||
//check to see if it's using a Country Code Top Level Domain (ccTLD) (i.e. ".me.uk")
|
// check to see if it's using a Country Code Top Level Domain (ccTLD) (i.e. ".me.uk")
|
||||||
if (splitArr[arrLen - 2].length == 2 && splitArr[arrLen - 1].length == 2) {
|
if (splitArr[arrLen - 2].length == 2 && splitArr[arrLen - 1].length == 2) {
|
||||||
//this is using a ccTLD
|
// this is using a ccTLD
|
||||||
domain = splitArr[arrLen - 3] + '.' + domain;
|
domain = splitArr[arrLen - 3] + '.' + domain;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return domain;
|
return domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function escapeColons(text) {
|
||||||
|
return text.replace(new RegExp(':', 'g'), '\\:');
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
formatClientLink: formatClientLink,
|
formatClientLink: formatClientLink,
|
||||||
formatApiLink: formatApiLink,
|
formatApiLink: formatApiLink,
|
||||||
|
escapeColons: escapeColons,
|
||||||
escapeParam: escapeParam,
|
escapeParam: escapeParam,
|
||||||
unescapeParam: unescapeParam,
|
unescapeParam: unescapeParam,
|
||||||
extractHostname: extractHostname,
|
extractHostname: extractHostname,
|
||||||
|
|
Loading…
Reference in a new issue