client/tags: fix post search links
This commit is contained in:
		
							parent
							
								
									2ec6b978ac
								
							
						
					
					
						commit
						93910a1655
					
				@ -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();
 | 
			
		||||
 | 
			
		||||
@ -68,21 +68,26 @@ function extractRootDomain(url) {
 | 
			
		||||
    let splitArr = domain.split('.');
 | 
			
		||||
    let arrLen = splitArr.length;
 | 
			
		||||
 | 
			
		||||
    //if there is a subdomain 
 | 
			
		||||
    // if there is a subdomain
 | 
			
		||||
    if (arrLen > 2) {
 | 
			
		||||
        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) {
 | 
			
		||||
            //this is using a ccTLD
 | 
			
		||||
            // this is using a ccTLD
 | 
			
		||||
            domain = splitArr[arrLen - 3] + '.' + domain;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user