From 993f63ee2b5d24e6ad78b3d8f0e39e2c77659b64 Mon Sep 17 00:00:00 2001 From: scossar Date: Mon, 28 Dec 2015 14:39:27 -0800 Subject: [PATCH 1/3] add category-logo-link component --- .../discourse/components/category-logo-link.js.es6 | 13 +++++++++++++ .../discourse/templates/discovery/categories.hbs | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 app/assets/javascripts/discourse/components/category-logo-link.js.es6 diff --git a/app/assets/javascripts/discourse/components/category-logo-link.js.es6 b/app/assets/javascripts/discourse/components/category-logo-link.js.es6 new file mode 100644 index 00000000000..d5980b0ec87 --- /dev/null +++ b/app/assets/javascripts/discourse/components/category-logo-link.js.es6 @@ -0,0 +1,13 @@ +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 category = this.get('category'); + const categoryLogo = category.get('logo_url'); + buffer.push(``); + } +}); \ No newline at end of file diff --git a/app/assets/javascripts/discourse/templates/discovery/categories.hbs b/app/assets/javascripts/discourse/templates/discovery/categories.hbs index 54545b2d02f..dcd5c6acfd8 100644 --- a/app/assets/javascripts/discourse/templates/discovery/categories.hbs +++ b/app/assets/javascripts/discourse/templates/discovery/categories.hbs @@ -16,7 +16,7 @@ {{category-title-link category=c}} {{category-unread category=c}} {{#if c.logo_url}} - + {{category-logo-link category=c}} {{/if}}
From cc2093f32bd594ffb980100da1aa47c0653d0196 Mon Sep 17 00:00:00 2001 From: scossar Date: Mon, 28 Dec 2015 14:49:24 -0800 Subject: [PATCH 2/3] add semicolon --- .../javascripts/discourse/components/category-logo-link.js.es6 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/components/category-logo-link.js.es6 b/app/assets/javascripts/discourse/components/category-logo-link.js.es6 index d5980b0ec87..c0a6fccf208 100644 --- a/app/assets/javascripts/discourse/components/category-logo-link.js.es6 +++ b/app/assets/javascripts/discourse/components/category-logo-link.js.es6 @@ -2,7 +2,7 @@ export default Em.Component.extend({ tagName: 'a', attributeBindings: ['href'], href: function() { - return Discourse.getURL('/c/') + Discourse.Category.slugFor(this.get('category')) + return Discourse.getURL('/c/') + Discourse.Category.slugFor(this.get('category')); }.property(), render(buffer) { From ee4beca12aab0b36ccdf71228fb1daff52311285 Mon Sep 17 00:00:00 2001 From: scossar Date: Tue, 29 Dec 2015 09:45:40 -0800 Subject: [PATCH 3/3] get logo_url with one request --- .../javascripts/discourse/components/category-logo-link.js.es6 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/components/category-logo-link.js.es6 b/app/assets/javascripts/discourse/components/category-logo-link.js.es6 index c0a6fccf208..d9f9ca235ae 100644 --- a/app/assets/javascripts/discourse/components/category-logo-link.js.es6 +++ b/app/assets/javascripts/discourse/components/category-logo-link.js.es6 @@ -6,8 +6,7 @@ export default Em.Component.extend({ }.property(), render(buffer) { - const category = this.get('category'); - const categoryLogo = category.get('logo_url'); + const categoryLogo = this.get('category.logo_url'); buffer.push(``); } }); \ No newline at end of file