Skip to content

Commit 8eef779

Browse files
committed
refactors site map
1 parent a2b70f6 commit 8eef779

17 files changed

Lines changed: 457 additions & 86 deletions

app/assets/javascripts/discourse/controllers/header_controller.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,17 @@ Discourse.HeaderController = Discourse.Controller.extend({
1111
showExtraInfo: null,
1212
notifications: null,
1313

14-
categories: function() {
15-
return Discourse.Category.list();
16-
}.property(),
17-
1814
showFavoriteButton: function() {
1915
return Discourse.User.current() && !this.get('topic.isPrivateMessage');
2016
}.property('topic.isPrivateMessage'),
2117

22-
mobileView: function() {
23-
return Discourse.Mobile.mobileView;
24-
}.property(),
25-
26-
showMobileToggle: function() {
27-
return Discourse.SiteSettings.enable_mobile_theme;
28-
}.property(),
29-
3018
actions: {
3119
toggleStar: function() {
3220
var topic = this.get('topic');
3321
if (topic) topic.toggleStar();
3422
return false;
3523
},
3624

37-
toggleMobileView: function() {
38-
Discourse.Mobile.toggleMobileView();
39-
},
40-
4125
showNotifications: function(headerView) {
4226
var self = this;
4327

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Discourse.SiteMapCategoryController = Ember.ObjectController.extend({
2+
showBadges: function() {
3+
return !!Discourse.User.current();
4+
}.property().volatile()
5+
});
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Discourse.SiteMapController = Ember.ArrayController.extend(Discourse.HasCurrentUser, {
2+
itemController: "siteMapCategory",
3+
4+
showAdminLinks: function() {
5+
return this.get("currentUser.staff");
6+
}.property("currentUser.staff"),
7+
8+
flaggedPostsCount: function() {
9+
return this.get("currentUser.site_flagged_posts_count");
10+
}.property("currentUser.site_flagged_posts_count"),
11+
12+
faqUrl: function() {
13+
return Discourse.SiteSettings.faq_url ? Discourse.SiteSettings.faq_url : Discourse.getURL('/faq');
14+
}.property(),
15+
16+
showMobileToggle: function() {
17+
return Discourse.SiteSettings.enable_mobile_theme;
18+
}.property(),
19+
20+
mobileViewLinkTextKey: function() {
21+
return Discourse.Mobile.mobileView ? "desktop_view" : "mobile_view";
22+
}.property(),
23+
24+
categories: function() {
25+
return Discourse.Category.list();
26+
}.property(),
27+
28+
actions: {
29+
toggleMobileView: function() {
30+
Discourse.Mobile.toggleMobileView();
31+
}
32+
}
33+
});

app/assets/javascripts/discourse/helpers/application_helpers.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -317,17 +317,3 @@ Handlebars.registerHelper('date', function(property, options) {
317317
}
318318

319319
});
320-
321-
/**
322-
Produces a link to the FAQ
323-
324-
@method faqLink
325-
@for Handlebars
326-
**/
327-
Handlebars.registerHelper('faqLink', function(property, options) {
328-
return new Handlebars.SafeString(
329-
"<a href='" +
330-
(Discourse.SiteSettings.faq_url.length > 0 ? Discourse.SiteSettings.faq_url : Discourse.getURL('/faq')) +
331-
"' class='faq-link'>" + I18n.t('faq') + "</a>"
332-
);
333-
});

app/assets/javascripts/discourse/templates/components/header-category-info.js.handlebars

Lines changed: 0 additions & 13 deletions
This file was deleted.

app/assets/javascripts/discourse/templates/header.js.handlebars

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -99,49 +99,7 @@
9999
{{render notifications notifications}}
100100

101101
{{#if view.renderSiteMap}}
102-
<section class='d-dropdown' id='site-map-dropdown'>
103-
<ul class="location-links">
104-
{{#if currentUser.staff}}
105-
<li><a href="/admin" class="admin-link"><i class='icon icon-wrench'></i>{{i18n admin_title}}</a></li>
106-
<li>
107-
<a href="/admin/flags/active" class="flagged-posts-link"><i class='icon icon-flag'></i>{{i18n flags_title}}</a>
108-
{{#if currentUser.site_flagged_posts_count}}
109-
<a href='/admin/flags/active' title='{{i18n notifications.total_flagged}}' class='badge-notification flagged-posts'>{{currentUser.site_flagged_posts_count}}</a>
110-
{{/if}}
111-
</li>
112-
{{/if}}
113-
<li>
114-
{{#titledLinkTo "list.latest" titleKey="filters.latest.help" class="latest-topics-link"}}{{i18n filters.latest.title}}{{/titledLinkTo}}
115-
</li>
116-
<li>{{faqLink}}</li>
117-
{{#if showMobileToggle}}
118-
<li>
119-
<a href="#" class="mobile-toggle-link" {{action toggleMobileView}}>
120-
{{#if mobileView}}
121-
{{i18n desktop_view}}
122-
{{else}}
123-
{{i18n mobile_view}}
124-
{{/if}}
125-
</a>
126-
</li>
127-
{{/if}}
128-
</ul>
129-
130-
{{#if categories}}
131-
<ul class="category-links">
132-
<li class='heading' title="{{i18n filters.categories.help}}">
133-
{{#link-to "list.categories"}}{{i18n filters.categories.title}}{{/link-to}}
134-
</li>
135-
136-
{{#each categories}}
137-
<li class='category'>
138-
{{header-category-info category=this currentUser=controller.currentUser}}
139-
</li>
140-
{{/each}}
141-
</ul>
142-
{{/if}}
143-
144-
</section>
102+
{{render siteMap}}
145103
{{/if}}
146104

147105
</div>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<section class="d-dropdown" id="site-map-dropdown">
2+
<ul class="location-links">
3+
{{#if showAdminLinks}}
4+
<li>{{partial "siteMap/adminLink"}}</li>
5+
<li>{{partial "siteMap/flaggedPostsLinks"}}</li>
6+
{{/if}}
7+
<li>{{partial "siteMap/latestTopicsLink"}}</li>
8+
<li>{{partial "siteMap/faqLink"}}</li>
9+
{{#if showMobileToggle}}
10+
<li>{{partial "siteMap/mobileToggleLink"}}</li>
11+
{{/if}}
12+
</ul>
13+
14+
{{#if categories}}
15+
<ul class="category-links">
16+
<li class="heading" title="{{i18n filters.categories.help}}">
17+
{{partial "siteMap/allCategoriesLink"}}
18+
</li>
19+
20+
{{#each categories itemController=itemController}}
21+
<li class="category">{{partial "siteMap/category"}}</li>
22+
{{/each}}
23+
</ul>
24+
{{/if}}
25+
</section>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<a href="/admin" class="admin-link"><i class='icon icon-wrench'></i>{{i18n admin_title}}</a>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{#link-to "list.categories"}}{{i18n filters.categories.title}}{{/link-to}}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{categoryLink this allowUncategorized=true}}
2+
{{#if showBadges}}
3+
{{#if unreadTopics}}
4+
<a href={{unbound unreadUrl}} class='badge unread-posts badge-notification' title='{{i18n topic.unread_topics count="unreadTopics"}}'>{{unreadTopics}}</a>
5+
{{/if}}
6+
{{#if newTopics}}
7+
<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>
8+
{{/if}}
9+
{{else}}
10+
<b class="topics-count">{{unbound topic_count}}</b>
11+
{{/if}}

0 commit comments

Comments
 (0)