mirror of
https://github.com/discourse/discourse.git
synced 2025-04-02 01:55:59 +08:00
Upgrade to Babel 6
This commit is contained in:
parent
2f480e21a0
commit
754c1e5438
@ -44,7 +44,7 @@ export default Ember.Component.extend({
|
|||||||
self.set("totalOthersWithSameIP", result.total);
|
self.set("totalOthersWithSameIP", result.total);
|
||||||
});
|
});
|
||||||
|
|
||||||
const AdminUser = require('admin/models/admin-user').default;
|
const AdminUser = requirejs('admin/models/admin-user').default;
|
||||||
AdminUser.findAll("active", data).then(function (users) {
|
AdminUser.findAll("active", data).then(function (users) {
|
||||||
self.setProperties({
|
self.setProperties({
|
||||||
other_accounts: users,
|
other_accounts: users,
|
||||||
|
@ -18,7 +18,7 @@ export default Ember.Component.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
submit: function() {
|
submit: function() {
|
||||||
const Permalink = require('admin/models/permalink').default;
|
const Permalink = requirejs('admin/models/permalink').default;
|
||||||
|
|
||||||
if (!this.get('formSubmitted')) {
|
if (!this.get('formSubmitted')) {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
@ -37,7 +37,7 @@ ApiKey.reopenClass({
|
|||||||
@returns {ApiKey} the ApiKey instance
|
@returns {ApiKey} the ApiKey instance
|
||||||
**/
|
**/
|
||||||
create: function() {
|
create: function() {
|
||||||
const AdminUser = require('admin/models/admin-user').default;
|
const AdminUser = requirejs('admin/models/admin-user').default;
|
||||||
var result = this._super.apply(this, arguments);
|
var result = this._super.apply(this, arguments);
|
||||||
if (result.user) {
|
if (result.user) {
|
||||||
result.user = AdminUser.create(result.user);
|
result.user = AdminUser.create(result.user);
|
||||||
|
@ -10,7 +10,7 @@ export default Discourse.Route.extend({
|
|||||||
queryParams: { mode: {}, "start_date": {}, "end_date": {}, "category_id": {}, "group_id": {} },
|
queryParams: { mode: {}, "start_date": {}, "end_date": {}, "category_id": {}, "group_id": {} },
|
||||||
|
|
||||||
model: function(params) {
|
model: function(params) {
|
||||||
const Report = require('admin/models/report').default;
|
const Report = requirejs('admin/models/report').default;
|
||||||
return Report.find(params.type, params['start_date'], params['end_date'], params['category_id'], params['group_id']);
|
return Report.find(params.type, params['start_date'], params['end_date'], params['category_id'], params['group_id']);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
(function() {
|
(function() {
|
||||||
var Discourse = require('discourse').default;
|
var Discourse = requirejs('discourse').default;
|
||||||
|
|
||||||
Discourse.dialect_deprecated = true;
|
Discourse.dialect_deprecated = true;
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ export function buildResolver(baseName) {
|
|||||||
resolveRouter(parsedName) {
|
resolveRouter(parsedName) {
|
||||||
const routerPath = `${baseName}/router`;
|
const routerPath = `${baseName}/router`;
|
||||||
if (requirejs.entries[routerPath]) {
|
if (requirejs.entries[routerPath]) {
|
||||||
const module = require(routerPath, null, null, true);
|
const module = requirejs(routerPath, null, null, true);
|
||||||
return module.default;
|
return module.default;
|
||||||
}
|
}
|
||||||
return this._super(parsedName);
|
return this._super(parsedName);
|
||||||
@ -79,7 +79,7 @@ export function buildResolver(baseName) {
|
|||||||
|
|
||||||
var module;
|
var module;
|
||||||
if (moduleName) {
|
if (moduleName) {
|
||||||
module = require(moduleName, null, null, true /* force sync */);
|
module = requirejs(moduleName, null, null, true /* force sync */);
|
||||||
if (module && module['default']) { module = module['default']; }
|
if (module && module['default']) { module = module['default']; }
|
||||||
}
|
}
|
||||||
return module;
|
return module;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
var define, require, requirejs;
|
var define, requirejs;
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ var define, require, requirejs;
|
|||||||
var name = this.name;
|
var name = this.name;
|
||||||
|
|
||||||
return this._require || (this._require = function(dep) {
|
return this._require || (this._require = function(dep) {
|
||||||
return require(resolve(dep, name));
|
return requirejs(resolve(dep, name));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ var define, require, requirejs;
|
|||||||
if (!mod) {
|
if (!mod) {
|
||||||
throw new Error('Could not find module `' + name + '` imported from `' + origin + '`');
|
throw new Error('Could not find module `' + name + '` imported from `' + origin + '`');
|
||||||
}
|
}
|
||||||
return require(name);
|
return requirejs(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
function missingModule(name) {
|
function missingModule(name) {
|
||||||
|
@ -102,7 +102,7 @@ const Discourse = Ember.Application.extend({
|
|||||||
|
|
||||||
Object.keys(requirejs._eak_seen).forEach(function(key) {
|
Object.keys(requirejs._eak_seen).forEach(function(key) {
|
||||||
if (/\/pre\-initializers\//.test(key)) {
|
if (/\/pre\-initializers\//.test(key)) {
|
||||||
const module = require(key, null, null, true);
|
const module = requirejs(key, null, null, true);
|
||||||
if (!module) { throw new Error(key + ' must export an initializer.'); }
|
if (!module) { throw new Error(key + ' must export an initializer.'); }
|
||||||
|
|
||||||
const init = module.default;
|
const init = module.default;
|
||||||
@ -117,7 +117,7 @@ const Discourse = Ember.Application.extend({
|
|||||||
|
|
||||||
Object.keys(requirejs._eak_seen).forEach(function(key) {
|
Object.keys(requirejs._eak_seen).forEach(function(key) {
|
||||||
if (/\/initializers\//.test(key)) {
|
if (/\/initializers\//.test(key)) {
|
||||||
const module = require(key, null, null, true);
|
const module = requirejs(key, null, null, true);
|
||||||
if (!module) { throw new Error(key + ' must export an initializer.'); }
|
if (!module) { throw new Error(key + ' must export an initializer.'); }
|
||||||
|
|
||||||
const init = module.default;
|
const init = module.default;
|
||||||
@ -131,7 +131,7 @@ const Discourse = Ember.Application.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Plugins that are registered via `<script>` tags.
|
// Plugins that are registered via `<script>` tags.
|
||||||
const withPluginApi = require('discourse/lib/plugin-api').withPluginApi;
|
const withPluginApi = requirejs('discourse/lib/plugin-api').withPluginApi;
|
||||||
let initCount = 0;
|
let initCount = 0;
|
||||||
_pluginCallbacks.forEach(function(cb) {
|
_pluginCallbacks.forEach(function(cb) {
|
||||||
Discourse.instanceInitializer({
|
Discourse.instanceInitializer({
|
||||||
|
@ -525,12 +525,12 @@ export default Em.Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
groupFinder(term) {
|
groupFinder(term) {
|
||||||
const Group = require('discourse/models/group').default;
|
const Group = requirejs('discourse/models/group').default;
|
||||||
return Group.findAll({search: term, ignore_automatic: false});
|
return Group.findAll({search: term, ignore_automatic: false});
|
||||||
},
|
},
|
||||||
|
|
||||||
badgeFinder(term) {
|
badgeFinder(term) {
|
||||||
const Badge = require('discourse/models/badge').default;
|
const Badge = requirejs('discourse/models/badge').default;
|
||||||
return Badge.findAll({search: term});
|
return Badge.findAll({search: term});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -60,7 +60,7 @@ const controllerOpts = {
|
|||||||
|
|
||||||
this.topicTrackingState.resetTracking();
|
this.topicTrackingState.resetTracking();
|
||||||
this.store.findFiltered('topicList', {filter}).then(list => {
|
this.store.findFiltered('topicList', {filter}).then(list => {
|
||||||
const TopicList = require('discourse/models/topic-list').default;
|
const TopicList = requirejs('discourse/models/topic-list').default;
|
||||||
TopicList.hideUniformCategory(list, this.get('category'));
|
TopicList.hideUniformCategory(list, this.get('category'));
|
||||||
|
|
||||||
this.setProperties({ model: list });
|
this.setProperties({ model: list });
|
||||||
|
@ -158,7 +158,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||||||
|
|
||||||
fetchUserDetails() {
|
fetchUserDetails() {
|
||||||
if (Discourse.User.currentProp('staff') && this.get('model.username')) {
|
if (Discourse.User.currentProp('staff') && this.get('model.username')) {
|
||||||
const AdminUser = require('admin/models/admin-user').default;
|
const AdminUser = requirejs('admin/models/admin-user').default;
|
||||||
AdminUser.find(this.get('model.user_id')).then(user => this.set('userDetails', user));
|
AdminUser.find(this.get('model.user_id')).then(user => this.set('userDetails', user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||||||
}.property('isPrivateTopic'),
|
}.property('isPrivateTopic'),
|
||||||
|
|
||||||
groupFinder(term) {
|
groupFinder(term) {
|
||||||
const Group = require('discourse/models/group').default;
|
const Group = requirejs('discourse/models/group').default;
|
||||||
return Group.findAll({search: term, ignore_automatic: true});
|
return Group.findAll({search: term, ignore_automatic: true});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||||||
actions: {
|
actions: {
|
||||||
|
|
||||||
createInvite() {
|
createInvite() {
|
||||||
const Invite = require('discourse/models/invite').default;
|
const Invite = requirejs('discourse/models/invite').default;
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
if (this.get('disabled')) { return; }
|
if (this.get('disabled')) { return; }
|
||||||
@ -237,7 +237,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
generateInvitelink() {
|
generateInvitelink() {
|
||||||
const Invite = require('discourse/models/invite').default;
|
const Invite = requirejs('discourse/models/invite').default;
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
if (this.get('disabled')) { return; }
|
if (this.get('disabled')) { return; }
|
||||||
|
@ -87,7 +87,7 @@ export default Ember.Controller.extend(CanCheckEmails, {
|
|||||||
|
|
||||||
adminDelete() {
|
adminDelete() {
|
||||||
// I really want this deferred, don't want to bring in all this code till used
|
// I really want this deferred, don't want to bring in all this code till used
|
||||||
const AdminUser = require('admin/models/admin-user').default;
|
const AdminUser = requirejs('admin/models/admin-user').default;
|
||||||
AdminUser.find(this.get('model.id')).then(user => user.destroy({deletePosts: true}));
|
AdminUser.find(this.get('model.id')).then(user => user.destroy({deletePosts: true}));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ function renderRaw(ctx, container, template, templateName, params) {
|
|||||||
|
|
||||||
const module = `discourse/raw-views/${templateName}`;
|
const module = `discourse/raw-views/${templateName}`;
|
||||||
if (requirejs.entries[module]) {
|
if (requirejs.entries[module]) {
|
||||||
const viewClass = require(module, null, null, true);
|
const viewClass = requirejs(module, null, null, true);
|
||||||
if (viewClass && viewClass.default) {
|
if (viewClass && viewClass.default) {
|
||||||
params.view = viewClass.default.create(params, _injections);
|
params.view = viewClass.default.create(params, _injections);
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,10 @@ import { registerHelpers } from 'discourse-common/lib/helpers';
|
|||||||
export function autoLoadModules(container, registry) {
|
export function autoLoadModules(container, registry) {
|
||||||
Object.keys(requirejs.entries).forEach(entry => {
|
Object.keys(requirejs.entries).forEach(entry => {
|
||||||
if ((/\/helpers\//).test(entry)) {
|
if ((/\/helpers\//).test(entry)) {
|
||||||
require(entry, null, null, true);
|
requirejs(entry, null, null, true);
|
||||||
}
|
}
|
||||||
if ((/\/widgets\//).test(entry)) {
|
if ((/\/widgets\//).test(entry)) {
|
||||||
require(entry, null, null, true);
|
requirejs(entry, null, null, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerHelpers(registry);
|
registerHelpers(registry);
|
||||||
|
@ -132,15 +132,9 @@ function assign(ta, {setOverflowX = true, setOverflowY = true} = {}) {
|
|||||||
set.delete(ta);
|
set.delete(ta);
|
||||||
|
|
||||||
Object.keys(style).forEach(key => {
|
Object.keys(style).forEach(key => {
|
||||||
ta.style[key] = style[key];
|
ta.style[key] = style[key];
|
||||||
});
|
});
|
||||||
}.bind(ta, {
|
}
|
||||||
height: ta.style.height,
|
|
||||||
resize: ta.style.resize,
|
|
||||||
overflowY: ta.style.overflowY,
|
|
||||||
overflowX: ta.style.overflowX,
|
|
||||||
wordWrap: ta.style.wordWrap,
|
|
||||||
});
|
|
||||||
|
|
||||||
ta.addEventListener('autosize:destroy', destroy, false);
|
ta.addEventListener('autosize:destroy', destroy, false);
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ function findClass(outletName, uniqueName) {
|
|||||||
if (!_classPaths) {
|
if (!_classPaths) {
|
||||||
_classPaths = {};
|
_classPaths = {};
|
||||||
findOutlets(require._eak_seen, (outlet, res, un) => {
|
findOutlets(require._eak_seen, (outlet, res, un) => {
|
||||||
_classPaths[`${outlet}/${un}`] = require(res).default;
|
_classPaths[`${outlet}/${un}`] = requirejs(res).default;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,9 +9,9 @@ import { userPath } from 'discourse/lib/url';
|
|||||||
|
|
||||||
export function translateResults(results, opts) {
|
export function translateResults(results, opts) {
|
||||||
|
|
||||||
const User = require('discourse/models/user').default;
|
const User = requirejs('discourse/models/user').default;
|
||||||
const Post = require('discourse/models/post').default;
|
const Post = requirejs('discourse/models/post').default;
|
||||||
const Topic = require('discourse/models/topic').default;
|
const Topic = requirejs('discourse/models/topic').default;
|
||||||
|
|
||||||
if (!opts) opts = {};
|
if (!opts) opts = {};
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ export function mapRoutes() {
|
|||||||
// can define admin routes.
|
// can define admin routes.
|
||||||
Object.keys(requirejs._eak_seen).forEach(function(key) {
|
Object.keys(requirejs._eak_seen).forEach(function(key) {
|
||||||
if (/route-map$/.test(key)) {
|
if (/route-map$/.test(key)) {
|
||||||
var module = require(key, null, null, true);
|
var module = requirejs(key, null, null, true);
|
||||||
if (!module || !module.default) { throw new Error(key + ' must export a route map.'); }
|
if (!module || !module.default) { throw new Error(key + ' must export a route map.'); }
|
||||||
|
|
||||||
const mapObj = module.default;
|
const mapObj = module.default;
|
||||||
|
@ -104,7 +104,7 @@ const Post = RestModel.extend({
|
|||||||
|
|
||||||
createProperties() {
|
createProperties() {
|
||||||
// composer only used once, defer the dependency
|
// composer only used once, defer the dependency
|
||||||
const Composer = require('discourse/models/composer').default;
|
const Composer = requirejs('discourse/models/composer').default;
|
||||||
const data = this.getProperties(Composer.serializedFieldsForCreate());
|
const data = this.getProperties(Composer.serializedFieldsForCreate());
|
||||||
data.reply_to_post_number = this.get('reply_to_post_number');
|
data.reply_to_post_number = this.get('reply_to_post_number');
|
||||||
data.image_sizes = this.get('imageSizes');
|
data.image_sizes = this.get('imageSizes');
|
||||||
|
@ -58,7 +58,7 @@ const ApplicationRoute = Discourse.Route.extend(OpenComposer, {
|
|||||||
reply = post ? window.location.protocol + "//" + window.location.host + post.get("url") : null;
|
reply = post ? window.location.protocol + "//" + window.location.host + post.get("url") : null;
|
||||||
|
|
||||||
// used only once, one less dependency
|
// used only once, one less dependency
|
||||||
const Composer = require('discourse/models/composer').default;
|
const Composer = requirejs('discourse/models/composer').default;
|
||||||
return this.controllerFor('composer').open({
|
return this.controllerFor('composer').open({
|
||||||
action: Composer.PRIVATE_MESSAGE,
|
action: Composer.PRIVATE_MESSAGE,
|
||||||
usernames: recipient,
|
usernames: recipient,
|
||||||
|
@ -54,7 +54,6 @@ export var not = macroAlias(Ember.computed.not);
|
|||||||
export var notEmpty = macroAlias(Ember.computed.notEmpty);
|
export var notEmpty = macroAlias(Ember.computed.notEmpty);
|
||||||
export var oneWay = macroAlias(Ember.computed.oneWay);
|
export var oneWay = macroAlias(Ember.computed.oneWay);
|
||||||
export var or = macroAlias(Ember.computed.or);
|
export var or = macroAlias(Ember.computed.or);
|
||||||
export var readOnly = macroAlias(Ember.computed.readOnly);
|
|
||||||
export var reads = macroAlias(Ember.computed.reads);
|
export var reads = macroAlias(Ember.computed.reads);
|
||||||
export var setDiff = macroAlias(Ember.computed.setDiff);
|
export var setDiff = macroAlias(Ember.computed.setDiff);
|
||||||
export var sort = macroAlias(Ember.computed.sort);
|
export var sort = macroAlias(Ember.computed.sort);
|
||||||
|
@ -119,7 +119,7 @@ export function setup(opts, siteSettings, state) {
|
|||||||
|
|
||||||
Object.keys(require._eak_seen).forEach(entry => {
|
Object.keys(require._eak_seen).forEach(entry => {
|
||||||
if (check.test(entry)) {
|
if (check.test(entry)) {
|
||||||
const module = require(entry);
|
const module = requirejs(entry);
|
||||||
if (module && module.setup) {
|
if (module && module.setup) {
|
||||||
|
|
||||||
const featureName = entry.split('/').reverse()[0];
|
const featureName = entry.split('/').reverse()[0];
|
||||||
|
@ -358,7 +358,7 @@ class DialectHelper {
|
|||||||
|
|
||||||
Object.keys(require._eak_seen).forEach(entry => {
|
Object.keys(require._eak_seen).forEach(entry => {
|
||||||
if (entry.indexOf('discourse-markdown') !== -1) {
|
if (entry.indexOf('discourse-markdown') !== -1) {
|
||||||
const module = require(entry);
|
const module = requirejs(entry);
|
||||||
if (module && module.setup) {
|
if (module && module.setup) {
|
||||||
const featureName = entry.split('/').reverse()[0];
|
const featureName = entry.split('/').reverse()[0];
|
||||||
helper.whiteList = info => whiteListFeature(featureName, info);
|
helper.whiteList = info => whiteListFeature(featureName, info);
|
||||||
@ -397,7 +397,7 @@ export function cook(raw, opts) {
|
|||||||
|
|
||||||
if (currentOpts.enableExperimentalMarkdownIt) {
|
if (currentOpts.enableExperimentalMarkdownIt) {
|
||||||
result = opts.sanitizer(
|
result = opts.sanitizer(
|
||||||
require('pretty-text/engines/markdown-it/instance').default(opts).render(raw),
|
requirejs('pretty-text/engines/markdown-it/instance').default(opts).render(raw),
|
||||||
whiteLister
|
whiteLister
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -6,7 +6,7 @@ export default {
|
|||||||
initialize(application) {
|
initialize(application) {
|
||||||
Object.keys(requirejs.entries).forEach(entry => {
|
Object.keys(requirejs.entries).forEach(entry => {
|
||||||
if ((/\/helpers\//).test(entry)) {
|
if ((/\/helpers\//).test(entry)) {
|
||||||
require(entry, null, null, true);
|
requirejs(entry, null, null, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerHelpers(application);
|
registerHelpers(application);
|
||||||
|
@ -35,7 +35,7 @@ if (window.Logster) {
|
|||||||
}
|
}
|
||||||
Ember.Test.adapter = window.QUnitAdapter.create();
|
Ember.Test.adapter = window.QUnitAdapter.create();
|
||||||
|
|
||||||
var createPretendServer = require('wizard/test/wizard-pretender', null, null, false).default;
|
var createPretendServer = requirejs('wizard/test/wizard-pretender', null, null, false).default;
|
||||||
|
|
||||||
var server;
|
var server;
|
||||||
QUnit.testStart(function() {
|
QUnit.testStart(function() {
|
||||||
@ -47,12 +47,12 @@ QUnit.testDone(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var _testApp = require('wizard/test/helpers/start-app').default();
|
var _testApp = requirejs('wizard/test/helpers/start-app').default();
|
||||||
var _buildResolver = require('discourse-common/resolver').buildResolver;
|
var _buildResolver = requirejs('discourse-common/resolver').buildResolver;
|
||||||
window.setResolver(_buildResolver('wizard').create({ namespace: _testApp }));
|
window.setResolver(_buildResolver('wizard').create({ namespace: _testApp }));
|
||||||
|
|
||||||
Object.keys(requirejs.entries).forEach(function(entry) {
|
Object.keys(requirejs.entries).forEach(function(entry) {
|
||||||
if ((/\-test/).test(entry)) {
|
if ((/\-test/).test(entry)) {
|
||||||
require(entry, null, null, true);
|
requirejs(entry, null, null, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -7,7 +7,7 @@ export default Ember.Application.extend({
|
|||||||
start() {
|
start() {
|
||||||
Object.keys(requirejs._eak_seen).forEach(key => {
|
Object.keys(requirejs._eak_seen).forEach(key => {
|
||||||
if (/\/initializers\//.test(key)) {
|
if (/\/initializers\//.test(key)) {
|
||||||
const module = require(key, null, null, true);
|
const module = requirejs(key, null, null, true);
|
||||||
if (!module) { throw new Error(key + ' must export an initializer.'); }
|
if (!module) { throw new Error(key + ' must export an initializer.'); }
|
||||||
this.initializer(module.default);
|
this.initializer(module.default);
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ PLUGIN_API_JS
|
|||||||
name = node["name"] || node["data-template-name"] || "broken"
|
name = node["name"] || node["data-template-name"] || "broken"
|
||||||
is_raw = name =~ /\.raw$/
|
is_raw = name =~ /\.raw$/
|
||||||
if is_raw
|
if is_raw
|
||||||
template = "require('discourse-common/lib/raw-handlebars').template(#{Barber::Precompiler.compile(node.inner_html)})"
|
template = "requirejs('discourse-common/lib/raw-handlebars').template(#{Barber::Precompiler.compile(node.inner_html)})"
|
||||||
node.replace <<COMPILED
|
node.replace <<COMPILED
|
||||||
<script>
|
<script>
|
||||||
(function() {
|
(function() {
|
||||||
|
@ -28,7 +28,6 @@ module Tilt
|
|||||||
ctx = MiniRacer::Context.new(timeout: 15000)
|
ctx = MiniRacer::Context.new(timeout: 15000)
|
||||||
ctx.eval("var self = this; #{File.read("#{Rails.root}/vendor/assets/javascripts/babel.js")}")
|
ctx.eval("var self = this; #{File.read("#{Rails.root}/vendor/assets/javascripts/babel.js")}")
|
||||||
ctx.eval("module = {}; exports = {};");
|
ctx.eval("module = {}; exports = {};");
|
||||||
ctx.load("#{Rails.root}/lib/es6_module_transpiler/support/es6-module-transpiler.js")
|
|
||||||
ctx.attach("rails.logger.info", proc{|err| Rails.logger.info(err.to_s)})
|
ctx.attach("rails.logger.info", proc{|err| Rails.logger.info(err.to_s)})
|
||||||
ctx.attach("rails.logger.error", proc{|err| Rails.logger.error(err.to_s)})
|
ctx.attach("rails.logger.error", proc{|err| Rails.logger.error(err.to_s)})
|
||||||
ctx.eval <<JS
|
ctx.eval <<JS
|
||||||
@ -105,12 +104,8 @@ JS
|
|||||||
klass = self.class
|
klass = self.class
|
||||||
klass.protect do
|
klass.protect do
|
||||||
klass.v8.eval("console.prefix = 'BABEL: babel-eval: ';")
|
klass.v8.eval("console.prefix = 'BABEL: babel-eval: ';")
|
||||||
|
transpiled = babel_source(source, module_name: module_name(root_path, logical_path))
|
||||||
transpiled = babel_source(source)
|
@output = klass.v8.eval(transpiled)
|
||||||
|
|
||||||
compiler_source = "new module.exports.Compiler(#{transpiled}, '#{module_name(root_path, logical_path)}', #{compiler_options}).#{compiler_method}()"
|
|
||||||
|
|
||||||
@output = klass.v8.eval(compiler_source)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -120,7 +115,7 @@ JS
|
|||||||
klass = self.class
|
klass = self.class
|
||||||
klass.protect do
|
klass.protect do
|
||||||
klass.v8.eval("console.prefix = 'BABEL: #{scope.logical_path}: ';")
|
klass.v8.eval("console.prefix = 'BABEL: #{scope.logical_path}: ';")
|
||||||
@output = klass.v8.eval(generate_source(scope))
|
@output = klass.v8.eval(babel_source(data, module_name: module_name(scope.root_path, scope.logical_path)))
|
||||||
end
|
end
|
||||||
|
|
||||||
# For backwards compatibility with plugins, for now export the Global format too.
|
# For backwards compatibility with plugins, for now export the Global format too.
|
||||||
@ -159,18 +154,21 @@ JS
|
|||||||
@output
|
@output
|
||||||
end
|
end
|
||||||
|
|
||||||
def babel_source(source)
|
def babel_source(source, opts=nil)
|
||||||
|
|
||||||
|
opts ||= {}
|
||||||
|
|
||||||
js_source = ::JSON.generate(source, quirks_mode: true)
|
js_source = ::JSON.generate(source, quirks_mode: true)
|
||||||
"babel.transform(#{js_source}, {ast: false, whitelist: ['es6.constants', 'es6.properties.shorthand', 'es6.arrowFunctions', 'es6.blockScoping', 'es6.destructuring', 'es6.spread', 'es6.parameters', 'es6.templateLiterals', 'es6.regex.unicode', 'es7.decorators', 'es6.classes']})['code']"
|
|
||||||
|
if opts[:module_name]
|
||||||
|
"Babel.transform(#{js_source}, { moduleId: '#{opts[:module_name]}', ast: false, presets: ['es2015'], plugins: [['transform-es2015-modules-amd', {noInterop: true}], 'transform-decorators-legacy'] }).code"
|
||||||
|
else
|
||||||
|
"Babel.transform(#{js_source}, { ast: false, plugins: ['check-es2015-constants', 'transform-es2015-arrow-functions', 'transform-es2015-block-scoped-functions', 'transform-es2015-block-scoping', 'transform-es2015-classes', 'transform-es2015-computed-properties', 'transform-es2015-destructuring', 'transform-es2015-duplicate-keys', 'transform-es2015-for-of', 'transform-es2015-function-name', 'transform-es2015-literals', 'transform-es2015-object-super', 'transform-es2015-parameters', 'transform-es2015-shorthand-properties', 'transform-es2015-spread', 'transform-es2015-sticky-regex', 'transform-es2015-template-literals', 'transform-es2015-typeof-symbol', 'transform-es2015-unicode-regex', 'transform-regenerator', 'transform-decorators-legacy'] }).code"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def generate_source(scope)
|
|
||||||
js_source = babel_source(data)
|
|
||||||
"new module.exports.Compiler(#{js_source}, '#{module_name(scope.root_path, scope.logical_path)}', #{compiler_options}).#{compiler_method}()"
|
|
||||||
end
|
|
||||||
|
|
||||||
def module_name(root_path, logical_path)
|
def module_name(root_path, logical_path)
|
||||||
path = nil
|
path = nil
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ class Barber::Precompiler
|
|||||||
transpiled = template.babel_transpile(source)
|
transpiled = template.babel_transpile(source)
|
||||||
|
|
||||||
# very hacky but lets us use ES6. I'm ashamed of this code -RW
|
# very hacky but lets us use ES6. I'm ashamed of this code -RW
|
||||||
transpiled.gsub!(/^export .*$/, '')
|
transpiled = transpiled[0...transpiled.index('export ')]
|
||||||
|
|
||||||
@precompiler = StringIO.new <<END
|
@precompiler = StringIO.new <<END
|
||||||
var __RawHandlebars;
|
var __RawHandlebars;
|
||||||
@ -40,11 +40,11 @@ module Discourse
|
|||||||
module Handlebars
|
module Handlebars
|
||||||
module Helper
|
module Helper
|
||||||
def precompile_handlebars(string)
|
def precompile_handlebars(string)
|
||||||
"require('discourse-common/lib/raw-handlebars').template(#{Barber::Precompiler.compile(string)});"
|
"requirejs('discourse-common/lib/raw-handlebars').template(#{Barber::Precompiler.compile(string)});"
|
||||||
end
|
end
|
||||||
|
|
||||||
def compile_handlebars(string)
|
def compile_handlebars(string)
|
||||||
"require('discourse-common/lib/raw-handlebars').compile(#{indent(string).inspect});"
|
"requirejs('discourse-common/lib/raw-handlebars').compile(#{indent(string).inspect});"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -55,11 +55,11 @@ class Ember::Handlebars::Template
|
|||||||
include Discourse::Ember::Handlebars::Helper
|
include Discourse::Ember::Handlebars::Helper
|
||||||
|
|
||||||
def precompile_handlebars(string, input=nil)
|
def precompile_handlebars(string, input=nil)
|
||||||
"require('discourse-common/lib/raw-handlebars').template(#{Barber::Precompiler.compile(string)});"
|
"requirejs('discourse-common/lib/raw-handlebars').template(#{Barber::Precompiler.compile(string)});"
|
||||||
end
|
end
|
||||||
|
|
||||||
def compile_handlebars(string, input=nil)
|
def compile_handlebars(string, input=nil)
|
||||||
"require('discourse-common/lib/raw-handlebars').compile(#{indent(string).inspect});"
|
"requirejs('discourse-common/lib/raw-handlebars').compile(#{indent(string).inspect});"
|
||||||
end
|
end
|
||||||
|
|
||||||
def global_template_target(namespace, module_name, config)
|
def global_template_target(namespace, module_name, config)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { default as PrettyText, buildOptions } from 'pretty-text/pretty-text';
|
import { default as PrettyText, buildOptions } from 'pretty-text/pretty-text';
|
||||||
|
|
||||||
module("lib:details-cooked-test");
|
QUnit.module("lib:details-cooked-test");
|
||||||
|
|
||||||
const defaultOpts = buildOptions({
|
const defaultOpts = buildOptions({
|
||||||
siteSettings: {
|
siteSettings: {
|
||||||
|
@ -40,7 +40,7 @@ window.bootbox.$body = $('#ember-testing');
|
|||||||
$.fn.modal = AcceptanceModal;
|
$.fn.modal = AcceptanceModal;
|
||||||
|
|
||||||
function acceptance(name, options) {
|
function acceptance(name, options) {
|
||||||
module("Acceptance: " + name, {
|
QUnit.module("Acceptance: " + name, {
|
||||||
beforeEach() {
|
beforeEach() {
|
||||||
resetMobile();
|
resetMobile();
|
||||||
|
|
||||||
|
@ -34,10 +34,10 @@ QUnit.module("initializer:localization", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("translation overrides", assert => {
|
QUnit.test("translation overrides", function(assert) {
|
||||||
PreloadStore.store('translationOverrides', {"js.composer.reply":"WAT","js.topic.reply.help":"foobar"});
|
PreloadStore.store('translationOverrides', {"js.composer.reply":"WAT","js.topic.reply.help":"foobar"});
|
||||||
LocalizationInitializer.initialize(this.registry);
|
LocalizationInitializer.initialize(this.registry);
|
||||||
|
|
||||||
assert.equal(I18n.t("composer.reply"), "WAT", "overrides existing translation in current locale");
|
assert.equal(I18n.t("composer.reply"), "WAT", "overrides existing translation in current locale");
|
||||||
assert.equal(I18n.t("topic.reply.help"), "foobar", "overrides translation in default locale");
|
assert.equal(I18n.t("topic.reply.help"), "foobar", "overrides translation in default locale");
|
||||||
});
|
});
|
||||||
|
@ -3,7 +3,7 @@ import { default as PrettyText, buildOptions } from 'pretty-text/pretty-text';
|
|||||||
import { hashString } from 'discourse/lib/hash';
|
import { hashString } from 'discourse/lib/hash';
|
||||||
|
|
||||||
// Run the MDTest spec
|
// Run the MDTest spec
|
||||||
module("MDTest");
|
QUnit.module("MDTest");
|
||||||
|
|
||||||
// This is cheating, but the trivial differences between sanitization
|
// This is cheating, but the trivial differences between sanitization
|
||||||
// do not affect formatting.
|
// do not affect formatting.
|
||||||
|
129871
vendor/assets/javascripts/babel.js
vendored
129871
vendor/assets/javascripts/babel.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user