From ad90d9710d9ba8d85ccbf3dcc184de2da746cce7 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 13 May 2014 12:41:06 -0400 Subject: [PATCH] Add an ENV variable to enable the stricter, plugin-incompatible ES6 behaviour for development. --- ...poster_expansion_controller.js => poster-expansion.js.es6} | 2 +- .../about.js.es6} | 4 ++-- app/assets/javascripts/discourse/routes/preferences_routes.js | 4 ++-- app/assets/javascripts/discourse/routes/topic_route.js | 4 ++-- .../tilt/es6_module_transpiler_template.rb | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) rename app/assets/javascripts/discourse/controllers/{poster_expansion_controller.js => poster-expansion.js.es6} (96%) rename app/assets/javascripts/discourse/controllers/{preferences_about_controller.js => preferences/about.js.es6} (82%) diff --git a/app/assets/javascripts/discourse/controllers/poster_expansion_controller.js b/app/assets/javascripts/discourse/controllers/poster-expansion.js.es6 similarity index 96% rename from app/assets/javascripts/discourse/controllers/poster_expansion_controller.js rename to app/assets/javascripts/discourse/controllers/poster-expansion.js.es6 index d78edc4fbab..ae4092dae0b 100644 --- a/app/assets/javascripts/discourse/controllers/poster_expansion_controller.js +++ b/app/assets/javascripts/discourse/controllers/poster-expansion.js.es6 @@ -6,7 +6,7 @@ @namespace Discourse @module Discourse **/ -Discourse.PosterExpansionController = Discourse.ObjectController.extend({ +export default Discourse.ObjectController.extend({ needs: ['topic'], visible: false, user: null, diff --git a/app/assets/javascripts/discourse/controllers/preferences_about_controller.js b/app/assets/javascripts/discourse/controllers/preferences/about.js.es6 similarity index 82% rename from app/assets/javascripts/discourse/controllers/preferences_about_controller.js rename to app/assets/javascripts/discourse/controllers/preferences/about.js.es6 index bb80f52889d..2cf612406c7 100644 --- a/app/assets/javascripts/discourse/controllers/preferences_about_controller.js +++ b/app/assets/javascripts/discourse/controllers/preferences/about.js.es6 @@ -6,7 +6,7 @@ @namespace Discourse @module Discourse **/ -Discourse.PreferencesAboutController = Discourse.ObjectController.extend({ +export default Discourse.ObjectController.extend({ saving: false, saveButtonText: function() { @@ -14,4 +14,4 @@ Discourse.PreferencesAboutController = Discourse.ObjectController.extend({ return I18n.t("user.change"); }.property('saving') -}); \ No newline at end of file +}); diff --git a/app/assets/javascripts/discourse/routes/preferences_routes.js b/app/assets/javascripts/discourse/routes/preferences_routes.js index e60da21e53e..1c0f937864a 100644 --- a/app/assets/javascripts/discourse/routes/preferences_routes.js +++ b/app/assets/javascripts/discourse/routes/preferences_routes.js @@ -86,10 +86,10 @@ Discourse.PreferencesAboutRoute = Discourse.RestrictedUserRoute.extend({ this.render('preferences', { into: 'user', outlet: 'userOutlet', controller: 'preferences' }); }, - events: { + actions: { changeAbout: function() { var route = this; - var controller = route.controllerFor('preferencesAbout'); + var controller = route.controllerFor('preferences/about'); controller.setProperties({ saving: true }); return controller.get('model').save().then(function() { diff --git a/app/assets/javascripts/discourse/routes/topic_route.js b/app/assets/javascripts/discourse/routes/topic_route.js index fd361a60e6a..247f7b039a9 100644 --- a/app/assets/javascripts/discourse/routes/topic_route.js +++ b/app/assets/javascripts/discourse/routes/topic_route.js @@ -17,7 +17,7 @@ Discourse.TopicRoute = Discourse.Route.extend({ actions: { // Modals that can pop up within a topic showPosterExpansion: function(post) { - this.controllerFor('posterExpansion').show(post); + this.controllerFor('poster-expansion').show(post); }, composePrivateMessage: function(user) { @@ -137,7 +137,7 @@ Discourse.TopicRoute = Discourse.Route.extend({ // Clear the search context this.controllerFor('search').set('searchContext', null); - this.controllerFor('posterExpansion').set('visible', false); + this.controllerFor('poster-expansion').set('visible', false); var topicController = this.controllerFor('topic'), postStream = topicController.get('postStream'); diff --git a/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb b/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb index 2b2086226f8..574397176e8 100644 --- a/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb +++ b/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb @@ -68,7 +68,7 @@ module Tilt # For backwards compatibility with plugins, for now export the Global format too. # We should eventually have an upgrade system for plugins to use ES6 or some other # resolve based API. - if scope.logical_path =~ /discourse\/controllers\/(.*)/ + if ENV['DISCOURSE_NO_CONSTANTS'].nil? && scope.logical_path =~ /discourse\/controllers\/(.*)/ class_name = Regexp.last_match[1].gsub(/[\-\/]/, '_').classify @output << "\n\nDiscourse.#{class_name}Controller = require('#{scope.logical_path}').default" end