Skip to content

Commit 719ec1b

Browse files
committed
work in progress, wide categories page
1 parent b34012b commit 719ec1b

12 files changed

Lines changed: 100 additions & 6 deletions

File tree

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,3 +315,21 @@ Handlebars.registerHelper('faqLink', function(property, options) {
315315
"'>" + I18n.t('faq') + "</a>"
316316
);
317317
});
318+
319+
320+
Ember.Handlebars.registerHelper('link-to-categories', function(){
321+
322+
var options = [].slice.call(arguments, -1)[0],
323+
params = Discourse.SiteSettings.enable_wide_category_list ? ['list.wideCategories'] : ['list.categories'],
324+
hash = options.hash;
325+
326+
hash.disabledBinding = hash.disabledWhen;
327+
328+
hash.parameters = {
329+
context: this,
330+
options: options,
331+
params: params
332+
};
333+
334+
return Ember.Handlebars.helpers.view.call(this, Ember.LinkView, options);
335+
});

app/assets/javascripts/discourse/routes/application_routes.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@ Discourse.Route.buildRoutes(function() {
2929
});
3030

3131
// the homepage is the first item of the 'top_menu' site setting
32-
var settings = Discourse.SiteSettings || PreloadStore.get('siteSettings');
32+
var settings = Discourse.SiteSettings;
3333
var homepage = settings.top_menu.split("|")[0].split(",")[0];
3434
this.route(homepage, { path: '/' });
3535

36-
this.route('categories', { path: '/categories' });
36+
if(settings.enable_wide_category_list) {
37+
this.route('wideCategories', { path: '/categories' });
38+
} else {
39+
this.route('categories', { path: '/categories' });
40+
}
3741
this.route('category', { path: '/category/:slug/more' });
3842
this.route('category', { path: '/category/:slug' });
3943
});

app/assets/javascripts/discourse/routes/list_categories_route.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
**/
99
Discourse.ListCategoriesRoute = Discourse.Route.extend({
1010

11+
template: 'listCategories',
12+
1113
redirect: function() { Discourse.redirectIfLoginRequired(this); },
1214

1315
actions: {
@@ -32,7 +34,7 @@ Discourse.ListCategoriesRoute = Discourse.Route.extend({
3234
},
3335

3436
renderTemplate: function() {
35-
this.render('listCategories', { into: 'list', outlet: 'listView' });
37+
this.render(this.get('template'), { into: 'list', outlet: 'listView' });
3638
},
3739

3840
afterModel: function(categoryList) {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Discourse.ListWideCategoriesRoute = Discourse.ListCategoriesRoute.extend({
2+
template: 'listWideCategories'
3+
});
4+
5+
6+
Discourse.ListWideCategoriesController = Discourse.Controller.extend({
7+
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
{{#if categories}}
140140
<ul class="category-links">
141141
<li class='heading' title="{{i18n filters.categories.help}}">
142-
{{#link-to "list.categories"}}{{i18n filters.categories.title}}{{/link-to}}
142+
{{#link-to-categories}}{{i18n filters.categories.title}}{{/link-to-categories}}
143143
</li>
144144

145145
{{#each categories}}

app/assets/javascripts/discourse/templates/list/topics.js.handlebars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<a href='#' {{action createTopic}}>{{i18n topic.suggest_create_topic}}</a>
6161
{{/if}}
6262
{{else}}
63-
{{#link-to 'list.categories'}}{{i18n topic.browse_all_categories}}{{/link-to}} {{i18n or}} {{#link-to 'list.latest'}}{{i18n topic.view_latest_topics}}{{/link-to}}
63+
{{#link-to-categories}}{{i18n topic.browse_all_categories}}{{/link-to-categories}} {{i18n or}} {{#link-to 'list.latest'}}{{i18n topic.view_latest_topics}}{{/link-to}}
6464
{{/if}}
6565
{{/if}}
6666
</h3>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<div class='contents'>
2+
3+
<table id='topic-list' class='categories'>
4+
<thead>
5+
<tr>
6+
<th class='category'>{{i18n categories.category}}</th>
7+
<th class='posters'>{{i18n categories.participants}}</th>
8+
<th class='num topics'>{{i18n categories.topics}}</th>
9+
<th class='num posts'>{{i18n categories.posts}}</th>
10+
<th class='latest'>{{i18n categories.latest}}</th>
11+
</tr>
12+
</thead>
13+
<tbody>
14+
{{#each model.categories}}
15+
<tr>
16+
<td class='category'>{{categoryLink this}}
17+
{{#if description_excerpt}}
18+
<div class="category-description">
19+
{{{description_excerpt}}}
20+
</div>
21+
{{/if}}
22+
</td>
23+
<td>{{#each featured_users}}
24+
<a href="/users/{{unbound username_lower}}">{{avatar this imageSize="small"}}</a>
25+
{{/each}}
26+
</td>
27+
<td>{{number topics_total}}</td>
28+
<td>{{number posts_total}}</td>
29+
<td><a href="#">this is a link to a post</a> <span class="age" data-bindattr-177="177" title="October 11, 2013 8:37am"><span class="relative-date" data-time="1381441065000" data-format="tiny">4d</span></span></td>
30+
</tr>
31+
{{/each}}
32+
</tbody>
33+
34+
</table>
35+
</div>
36+
37+
<footer id='topic-list-bottom'>
38+
</footer>
39+

app/assets/stylesheets/desktop/topic-list.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,20 @@
191191
}
192192
}
193193

194+
195+
#topic-list.categories {
196+
.category{
197+
width: 50%;
198+
.category-description {
199+
margin-top: 10px;
200+
}
201+
.badge-category {
202+
padding: 6px 10px;
203+
font-size: 14px;
204+
}
205+
}
206+
}
207+
194208
// Category list
195209
// --------------------------------------------------
196210

app/models/site_setting.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class SiteSetting < ActiveRecord::Base
5151
client_setting(:min_body_similar_length, 15)
5252
# cf. https://github.com/discourse/discourse/pull/462#issuecomment-14991562
5353
client_setting(:category_colors, 'BF1E2E|F1592A|F7941D|9EB83B|3AB54A|12A89D|25AAE2|0E76BD|652D90|92278F|ED207B|8C6238|231F20|808281|B3B5B4|283890')
54+
client_setting(:enable_wide_category_list, false)
5455

5556
# auto-replace rules for title
5657
setting(:title_prettify, true)

app/views/common/_discourse_javascript.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
Discourse.BaseUrl = '<%= RailsMultisite::ConnectionManagement.current_hostname %>';
2222
Discourse.BaseUri = '<%= Discourse::base_uri "/" %>';
2323
Discourse.Environment = '<%= Rails.env %>';
24-
Discourse.SiteSettings.login_required && !Discourse.User.current();
24+
Discourse.SiteSettings = PreloadStore.get('siteSettings');
2525
Discourse.Router.map(function() {
2626
Discourse.routeBuilder.call(this);
2727
});

0 commit comments

Comments
 (0)