mirror of
https://github.com/discourse/discourse.git
synced 2025-01-31 13:19:29 +08:00
FEATURE: Include category / subcategory name in document title when
viewing a topic.
This commit is contained in:
parent
e2d40c033a
commit
2b2837fa12
|
@ -23,7 +23,7 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, {
|
|||
// and are sometimes lazily loaded.
|
||||
this.send('refreshTitle');
|
||||
}
|
||||
}.observes('title'),
|
||||
}.observes('title', 'category'),
|
||||
|
||||
termChanged: function() {
|
||||
var dropdown = this.get('controllers.header.visibleDropdown');
|
||||
|
|
|
@ -21,6 +21,10 @@ Discourse.Route = Ember.Route.extend({
|
|||
Em.run.scheduleOnce('afterRender', Discourse.Route, 'cleanDOM');
|
||||
},
|
||||
|
||||
_refreshTitleOnce: function() {
|
||||
this.send('_collectTitleTokens', []);
|
||||
},
|
||||
|
||||
actions: {
|
||||
_collectTitleTokens: function(tokens) {
|
||||
// If there's a title token method, call it and get the token
|
||||
|
@ -40,7 +44,7 @@ Discourse.Route = Ember.Route.extend({
|
|||
},
|
||||
|
||||
refreshTitle: function() {
|
||||
this.send('_collectTitleTokens', []);
|
||||
Ember.run.once(this, this._refreshTitleOnce);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -15,7 +15,20 @@ Discourse.TopicRoute = Discourse.Route.extend({
|
|||
titleToken: function() {
|
||||
var model = this.modelFor('topic');
|
||||
if (model) {
|
||||
return model.get('title');
|
||||
var result = model.get('title'),
|
||||
cat = model.get('category');
|
||||
|
||||
if (cat && !cat.get('isUncategorized')) {
|
||||
var catName = cat.get('name'),
|
||||
parentCategory = cat.get('parentCategory');
|
||||
|
||||
if (parentCategory) {
|
||||
catName = parentCategory.get('name') + " / " + catName;
|
||||
}
|
||||
|
||||
return [result, catName];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user