refactors site map

This commit is contained in:
Wojciech Zawistowski
2013-11-27 21:58:36 +01:00
parent a2b70f64ca
commit 8eef779d38
17 changed files with 457 additions and 86 deletions

View File

@@ -11,22 +11,10 @@ Discourse.HeaderController = Discourse.Controller.extend({
showExtraInfo: null,
notifications: null,
categories: function() {
return Discourse.Category.list();
}.property(),
showFavoriteButton: function() {
return Discourse.User.current() && !this.get('topic.isPrivateMessage');
}.property('topic.isPrivateMessage'),
mobileView: function() {
return Discourse.Mobile.mobileView;
}.property(),
showMobileToggle: function() {
return Discourse.SiteSettings.enable_mobile_theme;
}.property(),
actions: {
toggleStar: function() {
var topic = this.get('topic');
@@ -34,10 +22,6 @@ Discourse.HeaderController = Discourse.Controller.extend({
return false;
},
toggleMobileView: function() {
Discourse.Mobile.toggleMobileView();
},
showNotifications: function(headerView) {
var self = this;

View File

@@ -0,0 +1,5 @@
Discourse.SiteMapCategoryController = Ember.ObjectController.extend({
showBadges: function() {
return !!Discourse.User.current();
}.property().volatile()
});

View File

@@ -0,0 +1,33 @@
Discourse.SiteMapController = Ember.ArrayController.extend(Discourse.HasCurrentUser, {
itemController: "siteMapCategory",
showAdminLinks: function() {
return this.get("currentUser.staff");
}.property("currentUser.staff"),
flaggedPostsCount: function() {
return this.get("currentUser.site_flagged_posts_count");
}.property("currentUser.site_flagged_posts_count"),
faqUrl: function() {
return Discourse.SiteSettings.faq_url ? Discourse.SiteSettings.faq_url : Discourse.getURL('/faq');
}.property(),
showMobileToggle: function() {
return Discourse.SiteSettings.enable_mobile_theme;
}.property(),
mobileViewLinkTextKey: function() {
return Discourse.Mobile.mobileView ? "desktop_view" : "mobile_view";
}.property(),
categories: function() {
return Discourse.Category.list();
}.property(),
actions: {
toggleMobileView: function() {
Discourse.Mobile.toggleMobileView();
}
}
});

View File

@@ -317,17 +317,3 @@ Handlebars.registerHelper('date', function(property, options) {
}
});
/**
Produces a link to the FAQ
@method faqLink
@for Handlebars
**/
Handlebars.registerHelper('faqLink', function(property, options) {
return new Handlebars.SafeString(
"<a href='" +
(Discourse.SiteSettings.faq_url.length > 0 ? Discourse.SiteSettings.faq_url : Discourse.getURL('/faq')) +
"' class='faq-link'>" + I18n.t('faq') + "</a>"
);
});

View File

@@ -1,13 +0,0 @@
{{categoryLink category allowUncategorized=true}}
{{#if currentUser}}
{{#with view.category}}
{{#if unreadTopics}}
<a href={{unbound unreadUrl}} class='badge unread-posts badge-notification' title='{{i18n topic.unread_topics count="unreadTopics"}}'>{{unreadTopics}}</a>
{{/if}}
{{#if newTopics}}
<a href={{unbound newUrl}} class='badge new-posts badge-notification' title='{{i18n topic.new_topics count="newTopics"}}'>{{newTopics}} <i class='icon icon-asterisk'></i></a>
{{/if}}
{{/with}}
{{else}}
<b class="topics-count">{{unbound category.topic_count}}</b>
{{/if}}

View File

@@ -99,49 +99,7 @@
{{render notifications notifications}}
{{#if view.renderSiteMap}}
<section class='d-dropdown' id='site-map-dropdown'>
<ul class="location-links">
{{#if currentUser.staff}}
<li><a href="/admin" class="admin-link"><i class='icon icon-wrench'></i>{{i18n admin_title}}</a></li>
<li>
<a href="/admin/flags/active" class="flagged-posts-link"><i class='icon icon-flag'></i>{{i18n flags_title}}</a>
{{#if currentUser.site_flagged_posts_count}}
<a href='/admin/flags/active' title='{{i18n notifications.total_flagged}}' class='badge-notification flagged-posts'>{{currentUser.site_flagged_posts_count}}</a>
{{/if}}
</li>
{{/if}}
<li>
{{#titledLinkTo "list.latest" titleKey="filters.latest.help" class="latest-topics-link"}}{{i18n filters.latest.title}}{{/titledLinkTo}}
</li>
<li>{{faqLink}}</li>
{{#if showMobileToggle}}
<li>
<a href="#" class="mobile-toggle-link" {{action toggleMobileView}}>
{{#if mobileView}}
{{i18n desktop_view}}
{{else}}
{{i18n mobile_view}}
{{/if}}
</a>
</li>
{{/if}}
</ul>
{{#if categories}}
<ul class="category-links">
<li class='heading' title="{{i18n filters.categories.help}}">
{{#link-to "list.categories"}}{{i18n filters.categories.title}}{{/link-to}}
</li>
{{#each categories}}
<li class='category'>
{{header-category-info category=this currentUser=controller.currentUser}}
</li>
{{/each}}
</ul>
{{/if}}
</section>
{{render siteMap}}
{{/if}}
</div>

View File

@@ -0,0 +1,25 @@
<section class="d-dropdown" id="site-map-dropdown">
<ul class="location-links">
{{#if showAdminLinks}}
<li>{{partial "siteMap/adminLink"}}</li>
<li>{{partial "siteMap/flaggedPostsLinks"}}</li>
{{/if}}
<li>{{partial "siteMap/latestTopicsLink"}}</li>
<li>{{partial "siteMap/faqLink"}}</li>
{{#if showMobileToggle}}
<li>{{partial "siteMap/mobileToggleLink"}}</li>
{{/if}}
</ul>
{{#if categories}}
<ul class="category-links">
<li class="heading" title="{{i18n filters.categories.help}}">
{{partial "siteMap/allCategoriesLink"}}
</li>
{{#each categories itemController=itemController}}
<li class="category">{{partial "siteMap/category"}}</li>
{{/each}}
</ul>
{{/if}}
</section>

View File

@@ -0,0 +1 @@
<a href="/admin" class="admin-link"><i class='icon icon-wrench'></i>{{i18n admin_title}}</a>

View File

@@ -0,0 +1 @@
{{#link-to "list.categories"}}{{i18n filters.categories.title}}{{/link-to}}

View File

@@ -0,0 +1,11 @@
{{categoryLink this allowUncategorized=true}}
{{#if showBadges}}
{{#if unreadTopics}}
<a href={{unbound unreadUrl}} class='badge unread-posts badge-notification' title='{{i18n topic.unread_topics count="unreadTopics"}}'>{{unreadTopics}}</a>
{{/if}}
{{#if newTopics}}
<a href={{unbound newUrl}} class='badge new-posts badge-notification' title='{{i18n topic.new_topics count="newTopics"}}'>{{newTopics}} <i class='icon icon-asterisk'></i></a>
{{/if}}
{{else}}
<b class="topics-count">{{unbound topic_count}}</b>
{{/if}}

View File

@@ -0,0 +1 @@
<a href="{{unbound faqUrl}}" class="faq-link">{{i18n faq}}</a>

View File

@@ -0,0 +1,4 @@
<a href="/admin/flags/active" class="flagged-posts-link"><i class='icon icon-flag'></i>{{i18n flags_title}}</a>
{{#if flaggedPostsCount}}
<a href='/admin/flags/active' title='{{i18n notifications.total_flagged}}' class='badge-notification flagged-posts'>{{flaggedPostsCount}}</a>
{{/if}}

View File

@@ -0,0 +1 @@
{{#titledLinkTo "list.latest" titleKey="filters.latest.help" class="latest-topics-link"}}{{i18n filters.latest.title}}{{/titledLinkTo}}

View File

@@ -0,0 +1 @@
<a href="#" class="mobile-toggle-link" {{action toggleMobileView}}>{{boundI18n mobileViewLinkTextKey}}</a>