mirror of
https://github.com/discourse/discourse.git
synced 2025-04-03 05:39:41 +08:00
Remove constants from initializers
This commit is contained in:
parent
9b5f506339
commit
e1826e3025
app/assets/javascripts/discourse/initializers
@ -11,7 +11,8 @@ export default {
|
|||||||
app.DiscoveryParentCategoryRoute = buildCategoryRoute('latest');
|
app.DiscoveryParentCategoryRoute = buildCategoryRoute('latest');
|
||||||
app.DiscoveryCategoryNoneRoute = buildCategoryRoute('latest', {no_subcategories: true});
|
app.DiscoveryCategoryNoneRoute = buildCategoryRoute('latest', {no_subcategories: true});
|
||||||
|
|
||||||
Discourse.Site.currentProp('filters').forEach(function(filter) {
|
var site = container.lookup('site:main');
|
||||||
|
site.get('filters').forEach(function(filter) {
|
||||||
app["Discovery" + filter.capitalize() + "Controller"] = DiscoverySortableController.extend();
|
app["Discovery" + filter.capitalize() + "Controller"] = DiscoverySortableController.extend();
|
||||||
app["Discovery" + filter.capitalize() + "Route"] = buildTopicRoute(filter);
|
app["Discovery" + filter.capitalize() + "Route"] = buildTopicRoute(filter);
|
||||||
app["Discovery" + filter.capitalize() + "CategoryRoute"] = buildCategoryRoute(filter);
|
app["Discovery" + filter.capitalize() + "CategoryRoute"] = buildCategoryRoute(filter);
|
||||||
@ -29,7 +30,7 @@ export default {
|
|||||||
|
|
||||||
Discourse.DiscoveryTopCategoryRoute = buildCategoryRoute('top');
|
Discourse.DiscoveryTopCategoryRoute = buildCategoryRoute('top');
|
||||||
Discourse.DiscoveryTopCategoryNoneRoute = buildCategoryRoute('top', {no_subcategories: true});
|
Discourse.DiscoveryTopCategoryNoneRoute = buildCategoryRoute('top', {no_subcategories: true});
|
||||||
Discourse.Site.currentProp('periods').forEach(function(period) {
|
site.get('periods').forEach(function(period) {
|
||||||
app["DiscoveryTop" + period.capitalize() + "Controller"] = DiscoverySortableController.extend();
|
app["DiscoveryTop" + period.capitalize() + "Controller"] = DiscoverySortableController.extend();
|
||||||
app["DiscoveryTop" + period.capitalize() + "Route"] = buildTopicRoute('top/' + period);
|
app["DiscoveryTop" + period.capitalize() + "Route"] = buildTopicRoute('top/' + period);
|
||||||
app["DiscoveryTop" + period.capitalize() + "CategoryRoute"] = buildCategoryRoute('top/' + period);
|
app["DiscoveryTop" + period.capitalize() + "CategoryRoute"] = buildCategoryRoute('top/' + period);
|
||||||
|
@ -5,11 +5,12 @@ export default {
|
|||||||
name: "read-only",
|
name: "read-only",
|
||||||
after: "message-bus",
|
after: "message-bus",
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function (container) {
|
||||||
if (!Discourse.MessageBus) { return; }
|
if (!Discourse.MessageBus) { return; }
|
||||||
|
|
||||||
|
var site = container.lookup('site:main');
|
||||||
Discourse.MessageBus.subscribe("/site/read-only", function (enabled) {
|
Discourse.MessageBus.subscribe("/site/read-only", function (enabled) {
|
||||||
Discourse.Site.currentProp('isReadOnly', enabled);
|
site.currentProp('isReadOnly', enabled);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
export default {
|
export default {
|
||||||
name: "register-discourse-location",
|
name: "register-discourse-location",
|
||||||
|
after: 'inject-objects',
|
||||||
|
|
||||||
initialize: function(container, application) {
|
initialize: function(container, application) {
|
||||||
application.register('location:discourse-location', Ember.DiscourseLocation);
|
application.register('location:discourse-location', Ember.DiscourseLocation);
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,15 @@
|
|||||||
export default {
|
export default {
|
||||||
name: "subscribe-user-notifications",
|
name: "subscribe-user-notifications",
|
||||||
after: 'message-bus',
|
after: 'message-bus',
|
||||||
initialize: function() {
|
initialize: function(container) {
|
||||||
var user = Discourse.User.current();
|
var user = Discourse.User.current();
|
||||||
|
|
||||||
|
var site = container.lookup('site:main'),
|
||||||
|
siteSettings = container.lookup('site-settings:main');
|
||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
var bus = Discourse.MessageBus;
|
var bus = Discourse.MessageBus;
|
||||||
bus.callbackInterval = Discourse.SiteSettings.polling_interval;
|
bus.callbackInterval = siteSettings.polling_interval;
|
||||||
bus.enableLongPolling = true;
|
bus.enableLongPolling = true;
|
||||||
bus.baseUrl = Discourse.getURL("/");
|
bus.baseUrl = Discourse.getURL("/");
|
||||||
|
|
||||||
@ -30,7 +34,6 @@ export default {
|
|||||||
}), user.notification_channel_position);
|
}), user.notification_channel_position);
|
||||||
|
|
||||||
bus.subscribe("/categories", function(data){
|
bus.subscribe("/categories", function(data){
|
||||||
var site = Discourse.Site.current();
|
|
||||||
_.each(data.categories,function(c){
|
_.each(data.categories,function(c){
|
||||||
site.updateCategory(c);
|
site.updateCategory(c);
|
||||||
});
|
});
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
export default {
|
export default {
|
||||||
name: 'verbose-localization',
|
name: 'verbose-localization',
|
||||||
initialize: function() {
|
after: 'inject-objects',
|
||||||
|
|
||||||
if(Discourse.SiteSettings.verbose_localization){
|
initialize: function(container) {
|
||||||
|
var siteSettings = container.lookup('site-settings:main');
|
||||||
|
if (siteSettings.verbose_localization) {
|
||||||
I18n.enable_verbose_localization();
|
I18n.enable_verbose_localization();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user