From fc3c93d2379fd1d6a7cf35d19c385380ae20960c Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 23 May 2013 16:38:29 +1000 Subject: [PATCH] almost fixed the regression of not allowing top level filters --- app/assets/javascripts/discourse/models/nav_item.js | 2 +- app/assets/javascripts/discourse/views/nav_item_view.js | 4 ++-- app/models/site_setting.rb | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse/models/nav_item.js b/app/assets/javascripts/discourse/models/nav_item.js index 802b47e0fde..0e256d6658b 100644 --- a/app/assets/javascripts/discourse/models/nav_item.js +++ b/app/assets/javascripts/discourse/models/nav_item.js @@ -18,7 +18,7 @@ Discourse.NavItem = Discourse.Model.extend({ // href from this item href: function() { var name = this.get('name'), - href = Discourse.getURL("/") + name; + href = Discourse.getURL("/") + name.replace(' ', '-'); if (name === 'category') href += "/" + this.get('categoryName'); return href; }.property('name') diff --git a/app/assets/javascripts/discourse/views/nav_item_view.js b/app/assets/javascripts/discourse/views/nav_item_view.js index 34afd68658e..cbbb978069b 100644 --- a/app/assets/javascripts/discourse/views/nav_item_view.js +++ b/app/assets/javascripts/discourse/views/nav_item_view.js @@ -25,7 +25,7 @@ Discourse.NavItemView = Discourse.View.extend({ }).property("content.filter"), isActive: (function() { - if (this.get("content.name") === this.get("controller.filterMode")) return "active"; + if (this.get("content.name").replace(' ','-') === this.get("controller.filterMode")) return "active"; return ""; }).property("content.name", "controller.filterMode"), @@ -42,7 +42,7 @@ Discourse.NavItemView = Discourse.View.extend({ }; if (categoryName) { name = 'category'; - extra.categoryName = categoryName.capitalize(); + extra.categoryName = categoryName.titleize(); } return I18n.t("js.filters." + name + ".title", extra); }).property('count'), diff --git a/app/models/site_setting.rb b/app/models/site_setting.rb index 5a770f0d2e2..e4196ab3233 100644 --- a/app/models/site_setting.rb +++ b/app/models/site_setting.rb @@ -216,11 +216,13 @@ class SiteSetting < ActiveRecord::Base end def self.homepage - top_menu.split('|')[0] + # TODO objectify this + x = top_menu.split('|')[0].split(',')[0] end def self.anonymous_homepage - top_menu.split('|').select{ |f| ['latest', 'hot', 'categories', 'category'].include? f }[0] + # TODO objectify this + top_menu.split('|').map{|f| f.split(',')[0] }.select{ |f| ['latest', 'hot', 'categories', 'category'].include? f}[0] end end