Revert "Proof of concept: Load controller via ES6 module in Discourse"

This reverts commit 0327f469c1.
This commit is contained in:
Robin Ward 2014-05-05 13:58:47 -04:00
parent aa269c92a0
commit fd153623bb
8 changed files with 4 additions and 119 deletions

View File

@ -72,6 +72,5 @@
"white": false,
"eqnull": true,
"quotmark": false,
"lastsemic": true,
"esnext": true
"lastsemic": true
}

View File

@ -139,7 +139,6 @@ gem 'rest-client'
gem 'rinku'
gem 'sanitize'
gem 'sass'
gem 'es6_module_transpiler-rails'
gem 'sidekiq'
gem 'sidekiq-failures'

View File

@ -83,8 +83,6 @@ GEM
ember-source (1.6.0.beta.2)
handlebars-source (~> 1.0)
erubis (2.7.0)
es6_module_transpiler-rails (0.4.0)
execjs
eventmachine (1.0.3)
excon (0.28.0)
execjs (2.0.2)
@ -403,7 +401,6 @@ DEPENDENCIES
email_reply_parser-discourse
ember-rails
ember-source (= 1.6.0.beta.2)
es6_module_transpiler-rails
eventmachine
fabrication
fakeweb (~> 1.3.0)

View File

@ -7,7 +7,7 @@
@uses Discourse.ModalFunctionality
@module Discourse
**/
export default Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
Discourse.HistoryController = Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
loading: false,
viewMode: "side_by_side",
revisionsTextKey: "post.revisions.controls.comparing_previous_to_current_out_of_total",

View File

@ -1,4 +1,3 @@
/* global requirejs, require */
/**
A custom resolver to allow template names in the format we like.
@ -9,17 +8,6 @@
**/
Discourse.Resolver = Ember.DefaultResolver.extend({
resolveController: function(parsedName) {
var moduleName = "discourse/controllers/" + parsedName.fullNameWithoutType,
module = requirejs.entries[moduleName];
if (module) {
module = require(moduleName, null, null, true /* force sync */);
if (module && module['default']) { module = module['default']; }
}
return module || this._super(parsedName);
},
/**
Attaches a view and wires up the container properly

View File

@ -5,9 +5,9 @@
//= require jquery_include.js
//= require ember_include.js
//= require loader
//= require message-bus
//= require jquery.ui.widget.js
//= require_tree ./discourse/ember
//= require LAB.js
//= require Markdown.Converter.js
//= require better_markdown.js
@ -38,4 +38,3 @@
//= require lock-on.js
//= require ember-cloaking
//= require break_string
//= require_tree ./discourse/ember

View File

@ -12,9 +12,6 @@ class DiscourseIIFE < Sprockets::Processor
return data if (path =~ /test\_helper\.js/)
return data if (path =~ /javascripts\/helpers\//)
# Ignore ES6 files
return data if (path =~ /\.es6/)
# Ignore translations
return data if (path =~ /\/translations/)
@ -26,4 +23,4 @@ class DiscourseIIFE < Sprockets::Processor
"(function () {\n\nvar $ = window.jQuery;\n// IIFE Wrapped Content Begins:\n\n#{data}\n\n// IIFE Wrapped Content Ends\n\n })(this);"
end
end
end

View File

@ -1,94 +0,0 @@
var define, requireModule, require, requirejs;
(function() {
var registry = {}, seen = {}, state = {};
var FAILED = false;
define = function(name, deps, callback) {
registry[name] = {
deps: deps,
callback: callback
};
};
function reify(deps, name, seen) {
var length = deps.length;
var reified = new Array(length);
var dep;
var exports;
for (var i = 0, l = length; i < l; i++) {
dep = deps[i];
if (dep === 'exports') {
exports = reified[i] = seen;
} else {
reified[i] = require(resolve(dep, name));
}
}
return {
deps: reified,
exports: exports
};
}
requirejs = require = requireModule = function(name) {
if (state[name] !== FAILED &&
seen.hasOwnProperty(name)) {
return seen[name];
}
if (!registry[name]) {
throw new Error('Could not find module ' + name);
}
var mod = registry[name];
var reified;
var module;
var loaded = false;
seen[name] = { }; // placeholder for run-time cycles
try {
reified = reify(mod.deps, name, seen[name]);
module = mod.callback.apply(this, reified.deps);
loaded = true;
} finally {
if (!loaded) {
state[name] = FAILED;
}
}
return reified.exports ? seen[name] : (seen[name] = module);
};
function resolve(child, name) {
if (child.charAt(0) !== '.') { return child; }
var parts = child.split('/');
var nameParts = name.split('/');
var parentBase;
if (nameParts.length === 1) {
parentBase = nameParts;
} else {
parentBase = nameParts.slice(0, -1);
}
for (var i = 0, l = parts.length; i < l; i++) {
var part = parts[i];
if (part === '..') { parentBase.pop(); }
else if (part === '.') { continue; }
else { parentBase.push(part); }
}
return parentBase.join('/');
}
requirejs.entries = requirejs._eak_seen = registry;
requirejs.clear = function(){
requirejs.entries = requirejs._eak_seen = registry = {};
seen = state = {};
};
})();