FIX: Form CDN URL client side instead.

This commit is contained in:
Guo Xiang Tan 2016-09-22 11:51:09 +08:00
parent 9374e5d42d
commit 7dea31adce
4 changed files with 15 additions and 26 deletions

View File

@ -1,12 +0,0 @@
export default Em.Component.extend({
tagName: 'a',
attributeBindings: ['href'],
href: function() {
return Discourse.getURL('/c/') + Discourse.Category.slugFor(this.get('category'));
}.property(),
render(buffer) {
const categoryLogo = this.get('category.logo_url');
buffer.push(`<img class="category-logo" src='${categoryLogo}'/>`);
}
});

View File

@ -1,17 +1,10 @@
import { iconHTML } from 'discourse/helpers/fa-icon'; import computed from 'ember-addons/ember-computed-decorators';
export default Em.Component.extend({ export default Em.Component.extend({
tagName: 'h3', tagName: 'h3',
render(buffer) { @computed("category.name")
const category = this.get('category'); categoryName(name) {
const categoryUrl = Discourse.getURL('/c/') + Discourse.Category.slugFor(category); return Handlebars.Utils.escapeExpression(name);
const categoryName = Handlebars.Utils.escapeExpression(category.get('name'));
if (category.get('read_restricted')) { buffer.push(iconHTML('lock')); }
buffer.push(`<a href='${categoryUrl}'>`);
buffer.push(`<span class='category-name'>${categoryName}</span>`);
buffer.push(`</a>`);
} }
}); });

View File

@ -15,9 +15,6 @@
<td class="category" style={{border-color c.color}}> <td class="category" style={{border-color c.color}}>
<div> <div>
{{category-title-link category=c}} {{category-title-link category=c}}
{{#if c.logo_url}}
{{category-logo-link category=c}}
{{/if}}
<div class="category-description"> <div class="category-description">
{{{c.description_excerpt}}} {{{c.description_excerpt}}}
</div> </div>

View File

@ -0,0 +1,11 @@
<a href={{category.url}}>
{{#if category.read_restricted}}
{{fa-icon 'lock'}}
{{/if}}
<span class="category-name">{{categoryName}}</span>
{{#if category.logo_url}}
<div>{{cdn-img src=category.logo_url class="category-logo"}}</div>
{{/if}}
</a>