mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 01:26:18 -05:00
Split out common functions into discourse-common
module
This commit is contained in:
parent
3a4615c205
commit
be1d74d207
89 changed files with 335 additions and 354 deletions
|
@ -1,3 +1,3 @@
|
|||
import { htmlHelper } from 'discourse/lib/helpers';
|
||||
import { htmlHelper } from 'discourse-common/lib/helpers';
|
||||
|
||||
export default htmlHelper(size => I18n.toHumanSize(size));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { htmlHelper } from 'discourse/lib/helpers';
|
||||
import { htmlHelper } from 'discourse-common/lib/helpers';
|
||||
import { escapeExpression } from 'discourse/lib/utilities';
|
||||
|
||||
export default htmlHelper(str => escapeExpression(str).replace(/\n/g, "<br>"));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { registerUnbound } from 'discourse/lib/helpers';
|
||||
import { registerUnbound } from 'discourse-common/lib/helpers';
|
||||
|
||||
registerUnbound('value-at-tl', function(data, params) {
|
||||
var tl = parseInt(params.level, 10);
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { h } from 'virtual-dom';
|
||||
import { registerUnbound } from 'discourse/lib/helpers';
|
||||
import { registerUnbound } from 'discourse-common/lib/helpers';
|
||||
|
||||
function iconClasses(icon, params) {
|
||||
var classes = "fa fa-" + icon;
|
||||
export function iconClasses(icon, params) {
|
||||
let classes = "fa fa-" + icon;
|
||||
if (params.modifier) { classes += " fa-" + params.modifier; }
|
||||
if (params['class']) { classes += ' ' + params['class']; }
|
||||
return classes;
|
||||
|
@ -21,23 +20,6 @@ export function iconHTML(icon, params) {
|
|||
return html;
|
||||
}
|
||||
|
||||
export function iconNode(icon, params) {
|
||||
params = params || {};
|
||||
|
||||
const properties = {
|
||||
className: iconClasses(icon, params),
|
||||
attributes: { "aria-hidden": true }
|
||||
};
|
||||
|
||||
if (params.title) { properties.attributes.title = params.title; }
|
||||
|
||||
if (params.label) {
|
||||
return h('i', properties, h('span.sr-only', I18n.t(params.label)));
|
||||
} else {
|
||||
return h('i', properties);
|
||||
}
|
||||
}
|
||||
|
||||
registerUnbound('fa-icon', function(icon, params) {
|
||||
return new Handlebars.SafeString(iconHTML(icon, params));
|
||||
});
|
|
@ -1,3 +1,3 @@
|
|||
import { registerUnbound } from 'discourse/lib/helpers';
|
||||
import { registerUnbound } from 'discourse-common/lib/helpers';
|
||||
|
||||
registerUnbound('i18n', (key, params) => I18n.t(key, params));
|
|
@ -1,4 +1,4 @@
|
|||
import { get } from 'discourse/lib/raw-handlebars';
|
||||
import { get } from 'discourse-common/lib/raw-handlebars';
|
||||
|
||||
// `Ember.Helper` is only available in versions after 1.12
|
||||
export function htmlHelper(fn) {
|
218
app/assets/javascripts/discourse-common/resolver.js.es6
Normal file
218
app/assets/javascripts/discourse-common/resolver.js.es6
Normal file
|
@ -0,0 +1,218 @@
|
|||
/* global requirejs, require */
|
||||
|
||||
var classify = Ember.String.classify;
|
||||
var get = Ember.get;
|
||||
|
||||
var LOADING_WHITELIST = ['badges', 'userActivity', 'userPrivateMessages', 'admin', 'adminFlags',
|
||||
'user', 'preferences', 'adminEmail', 'adminUsersList'];
|
||||
var _dummyRoute;
|
||||
var _loadingView;
|
||||
|
||||
function loadingResolver(cb) {
|
||||
return function(parsedName) {
|
||||
var fullNameWithoutType = parsedName.fullNameWithoutType;
|
||||
|
||||
if (fullNameWithoutType.indexOf('Loading') >= 0) {
|
||||
fullNameWithoutType = fullNameWithoutType.replace('Loading', '');
|
||||
if (LOADING_WHITELIST.indexOf(fullNameWithoutType) !== -1) {
|
||||
return cb(fullNameWithoutType);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function parseName(fullName) {
|
||||
const nameParts = fullName.split(":"),
|
||||
type = nameParts[0], fullNameWithoutType = nameParts[1],
|
||||
name = fullNameWithoutType,
|
||||
namespace = get(this, 'namespace'),
|
||||
root = namespace;
|
||||
|
||||
return {
|
||||
fullName: fullName,
|
||||
type: type,
|
||||
fullNameWithoutType: fullNameWithoutType,
|
||||
name: name,
|
||||
root: root,
|
||||
resolveMethodName: "resolve" + classify(type)
|
||||
};
|
||||
}
|
||||
|
||||
export function buildResolver(baseName) {
|
||||
return Ember.DefaultResolver.extend({
|
||||
parseName,
|
||||
|
||||
resolveRouter(parsedName) {
|
||||
const routerPath = `${baseName}/router`;
|
||||
if (requirejs.entries[routerPath]) {
|
||||
const module = require(routerPath, null, null, true);
|
||||
return module.default;
|
||||
}
|
||||
return this._super(parsedName);
|
||||
},
|
||||
|
||||
normalize(fullName) {
|
||||
const split = fullName.split(':');
|
||||
if (split.length > 1) {
|
||||
const appBase = `${baseName}/${split[0]}s/`;
|
||||
const adminBase = 'admin/' + split[0] + 's/';
|
||||
|
||||
// Allow render 'admin/templates/xyz' too
|
||||
split[1] = split[1].replace('.templates', '').replace('/templates', '');
|
||||
|
||||
// Try slashes
|
||||
let dashed = Ember.String.dasherize(split[1].replace(/\./g, '/'));
|
||||
if (requirejs.entries[appBase + dashed] || requirejs.entries[adminBase + dashed]) {
|
||||
return split[0] + ":" + dashed;
|
||||
}
|
||||
|
||||
// Try with dashes instead of slashes
|
||||
dashed = Ember.String.dasherize(split[1].replace(/\./g, '-'));
|
||||
if (requirejs.entries[appBase + dashed] || requirejs.entries[adminBase + dashed]) {
|
||||
return split[0] + ":" + dashed;
|
||||
}
|
||||
}
|
||||
return this._super(fullName);
|
||||
},
|
||||
|
||||
customResolve(parsedName) {
|
||||
// If we end with the name we want, use it. This allows us to define components within plugins.
|
||||
const suffix = parsedName.type + 's/' + parsedName.fullNameWithoutType,
|
||||
dashed = Ember.String.dasherize(suffix),
|
||||
moduleName = Object.keys(requirejs.entries).find(function(e) {
|
||||
return (e.indexOf(suffix, e.length - suffix.length) !== -1) ||
|
||||
(e.indexOf(dashed, e.length - dashed.length) !== -1);
|
||||
});
|
||||
|
||||
var module;
|
||||
if (moduleName) {
|
||||
module = require(moduleName, null, null, true /* force sync */);
|
||||
if (module && module['default']) { module = module['default']; }
|
||||
}
|
||||
return module;
|
||||
},
|
||||
|
||||
resolveWidget(parsedName) {
|
||||
return this.customResolve(parsedName) || this._super(parsedName);
|
||||
},
|
||||
|
||||
resolveAdapter(parsedName) {
|
||||
return this.customResolve(parsedName) || this._super(parsedName);
|
||||
},
|
||||
|
||||
resolveModel(parsedName) {
|
||||
return this.customResolve(parsedName) || this._super(parsedName);
|
||||
},
|
||||
|
||||
resolveView(parsedName) {
|
||||
return this.findLoadingView(parsedName) || this.customResolve(parsedName) || this._super(parsedName);
|
||||
},
|
||||
|
||||
resolveHelper(parsedName) {
|
||||
return this.customResolve(parsedName) || this._super(parsedName);
|
||||
},
|
||||
|
||||
resolveController(parsedName) {
|
||||
return this.customResolve(parsedName) || this._super(parsedName);
|
||||
},
|
||||
|
||||
resolveComponent(parsedName) {
|
||||
return this.customResolve(parsedName) || this._super(parsedName);
|
||||
},
|
||||
|
||||
resolveRoute(parsedName) {
|
||||
return this.findLoadingRoute(parsedName) || this.customResolve(parsedName) || this._super(parsedName);
|
||||
},
|
||||
|
||||
resolveTemplate(parsedName) {
|
||||
return this.findPluginMobileTemplate(parsedName) ||
|
||||
this.findPluginTemplate(parsedName) ||
|
||||
this.findMobileTemplate(parsedName) ||
|
||||
this.findTemplate(parsedName) ||
|
||||
Ember.TEMPLATES.not_found;
|
||||
},
|
||||
|
||||
findLoadingRoute: loadingResolver(function() {
|
||||
_dummyRoute = _dummyRoute || Ember.Route.extend();
|
||||
return _dummyRoute;
|
||||
}),
|
||||
|
||||
findLoadingView: loadingResolver(function() {
|
||||
if (!_loadingView) {
|
||||
_loadingView = require('discourse/views/loading', null, null, true /* force sync */);
|
||||
if (_loadingView && _loadingView['default']) { _loadingView = _loadingView['default']; }
|
||||
}
|
||||
return _loadingView;
|
||||
}),
|
||||
|
||||
findPluginTemplate(parsedName) {
|
||||
var pluginParsedName = this.parseName(parsedName.fullName.replace("template:", "template:javascripts/"));
|
||||
return this.findTemplate(pluginParsedName);
|
||||
},
|
||||
|
||||
findPluginMobileTemplate(parsedName) {
|
||||
if (this.mobileView) {
|
||||
var pluginParsedName = this.parseName(parsedName.fullName.replace("template:", "template:javascripts/mobile/"));
|
||||
return this.findTemplate(pluginParsedName);
|
||||
}
|
||||
},
|
||||
|
||||
findMobileTemplate(parsedName) {
|
||||
if (this.mobileView) {
|
||||
var mobileParsedName = this.parseName(parsedName.fullName.replace("template:", "template:mobile/"));
|
||||
return this.findTemplate(mobileParsedName);
|
||||
}
|
||||
},
|
||||
|
||||
findTemplate(parsedName) {
|
||||
const withoutType = parsedName.fullNameWithoutType,
|
||||
slashedType = withoutType.replace(/\./g, '/'),
|
||||
decamelized = withoutType.decamelize(),
|
||||
dashed = decamelized.replace(/\./g, '-').replace(/\_/g, '-'),
|
||||
templates = Ember.TEMPLATES;
|
||||
|
||||
return this._super(parsedName) ||
|
||||
templates[slashedType] ||
|
||||
templates[withoutType] ||
|
||||
templates[dashed] ||
|
||||
templates[decamelized.replace(/\./, '/')] ||
|
||||
templates[decamelized.replace(/\_/, '/')] ||
|
||||
templates[`${baseName}/templates/${withoutType}`] ||
|
||||
this.findAdminTemplate(parsedName) ||
|
||||
this.findUnderscoredTemplate(parsedName);
|
||||
},
|
||||
|
||||
findUnderscoredTemplate(parsedName) {
|
||||
var decamelized = parsedName.fullNameWithoutType.decamelize();
|
||||
var underscored = decamelized.replace(/\-/g, "_");
|
||||
return Ember.TEMPLATES[underscored];
|
||||
},
|
||||
|
||||
// Try to find a template within a special admin namespace, e.g. adminEmail => admin/templates/email
|
||||
// (similar to how discourse lays out templates)
|
||||
findAdminTemplate(parsedName) {
|
||||
var decamelized = parsedName.fullNameWithoutType.decamelize();
|
||||
|
||||
if (decamelized.indexOf('components') === 0) {
|
||||
const compTemplate = Ember.TEMPLATES['admin/templates/' + decamelized];
|
||||
if (compTemplate) { return compTemplate; }
|
||||
}
|
||||
|
||||
if (decamelized === "javascripts/admin") {
|
||||
return Ember.TEMPLATES['admin/templates/admin'];
|
||||
}
|
||||
|
||||
if (decamelized.indexOf('admin') === 0 || decamelized.indexOf('javascripts/admin') === 0) {
|
||||
decamelized = decamelized.replace(/^admin\_/, 'admin/templates/');
|
||||
decamelized = decamelized.replace(/^admin\./, 'admin/templates/');
|
||||
decamelized = decamelized.replace(/\./g, '_');
|
||||
|
||||
const dashed = decamelized.replace(/_/g, '-');
|
||||
return Ember.TEMPLATES[decamelized] ||
|
||||
Ember.TEMPLATES[dashed] ||
|
||||
Ember.TEMPLATES[dashed.replace('admin-', 'admin/')];
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
import DiscourseResolver from 'discourse/ember/resolver';
|
||||
import { buildResolver } from 'discourse-common/resolver';
|
||||
import { default as computed, observes } from 'ember-addons/ember-computed-decorators';
|
||||
|
||||
const _pluginCallbacks = [];
|
||||
|
@ -31,7 +31,7 @@ const Discourse = Ember.Application.extend({
|
|||
return url;
|
||||
},
|
||||
|
||||
Resolver: DiscourseResolver,
|
||||
Resolver: buildResolver('discourse'),
|
||||
|
||||
@observes('_docTitle', 'hasFocus', 'notifyCount')
|
||||
_titleChanged() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { iconHTML } from 'discourse/helpers/fa-icon';
|
||||
import { iconHTML } from 'discourse-common/helpers/fa-icon';
|
||||
import DropdownButton from 'discourse/components/dropdown-button';
|
||||
import computed from "ember-addons/ember-computed-decorators";
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { iconHTML } from 'discourse/helpers/fa-icon';
|
||||
import { iconHTML } from 'discourse-common/helpers/fa-icon';
|
||||
import { default as computed, observes } from 'ember-addons/ember-computed-decorators';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import computed from 'ember-addons/ember-computed-decorators';
|
||||
import { iconHTML } from 'discourse/helpers/fa-icon';
|
||||
import { iconHTML } from 'discourse-common/helpers/fa-icon';
|
||||
import interceptClick from 'discourse/lib/intercept-click';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import StringBuffer from 'discourse/mixins/string-buffer';
|
||||
import { iconHTML } from 'discourse/helpers/fa-icon';
|
||||
import { iconHTML } from 'discourse-common/helpers/fa-icon';
|
||||
|
||||
export default Ember.Component.extend(StringBuffer, {
|
||||
tagName: 'th',
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { on } from 'ember-addons/ember-computed-decorators';
|
||||
import StringBuffer from 'discourse/mixins/string-buffer';
|
||||
import { iconHTML } from 'discourse/helpers/fa-icon';
|
||||
import { iconHTML } from 'discourse-common/helpers/fa-icon';
|
||||
import LogsNotice from 'discourse/services/logs-notice';
|
||||
|
||||
export default Ember.Component.extend(StringBuffer, {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import StringBuffer from 'discourse/mixins/string-buffer';
|
||||
import { iconHTML } from 'discourse/helpers/fa-icon';
|
||||
import { iconHTML } from 'discourse-common/helpers/fa-icon';
|
||||
|
||||
export default Ember.Component.extend(StringBuffer, {
|
||||
classNameBindings: [':tip', 'good', 'bad'],
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import DropdownButton from 'discourse/components/dropdown-button';
|
||||
import { allLevels, buttonDetails } from 'discourse/lib/notification-levels';
|
||||
import { iconHTML } from 'discourse/helpers/fa-icon';
|
||||
import { iconHTML } from 'discourse-common/helpers/fa-icon';
|
||||
import computed from 'ember-addons/ember-computed-decorators';
|
||||
|
||||
export default DropdownButton.extend({
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import StringBuffer from 'discourse/mixins/string-buffer';
|
||||
import { iconHTML } from 'discourse/helpers/fa-icon';
|
||||
import { iconHTML } from 'discourse-common/helpers/fa-icon';
|
||||
import { default as computed, observes } from 'ember-addons/ember-computed-decorators';
|
||||
|
||||
export default Ember.Component.extend(StringBuffer, {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { iconHTML } from 'discourse/helpers/fa-icon';
|
||||
import { iconHTML } from 'discourse-common/helpers/fa-icon';
|
||||
import DropdownButton from 'discourse/components/dropdown-button';
|
||||
import computed from "ember-addons/ember-computed-decorators";
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { iconHTML } from 'discourse/helpers/fa-icon';
|
||||
import { iconHTML } from 'discourse-common/helpers/fa-icon';
|
||||
import Combobox from 'discourse/components/combo-box';
|
||||
import { on, observes } from 'ember-addons/ember-computed-decorators';
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { iconHTML } from 'discourse/helpers/fa-icon';
|
||||
import { iconHTML } from 'discourse-common/helpers/fa-icon';
|
||||
import StringBuffer from 'discourse/mixins/string-buffer';
|
||||
import { escapeExpression } from 'discourse/lib/utilities';
|
||||
|
||||
|
|
|
@ -1,206 +0,0 @@
|
|||
/* global requirejs, require */
|
||||
|
||||
var classify = Ember.String.classify;
|
||||
var get = Ember.get;
|
||||
|
||||
var LOADING_WHITELIST = ['badges', 'userActivity', 'userPrivateMessages', 'admin', 'adminFlags',
|
||||
'user', 'preferences', 'adminEmail', 'adminUsersList'];
|
||||
var _dummyRoute;
|
||||
var _loadingView;
|
||||
|
||||
function loadingResolver(cb) {
|
||||
return function(parsedName) {
|
||||
var fullNameWithoutType = parsedName.fullNameWithoutType;
|
||||
|
||||
if (fullNameWithoutType.indexOf('Loading') >= 0) {
|
||||
fullNameWithoutType = fullNameWithoutType.replace('Loading', '');
|
||||
if (LOADING_WHITELIST.indexOf(fullNameWithoutType) !== -1) {
|
||||
return cb(fullNameWithoutType);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function parseName(fullName) {
|
||||
const nameParts = fullName.split(":"),
|
||||
type = nameParts[0], fullNameWithoutType = nameParts[1],
|
||||
name = fullNameWithoutType,
|
||||
namespace = get(this, 'namespace'),
|
||||
root = namespace;
|
||||
|
||||
return {
|
||||
fullName: fullName,
|
||||
type: type,
|
||||
fullNameWithoutType: fullNameWithoutType,
|
||||
name: name,
|
||||
root: root,
|
||||
resolveMethodName: "resolve" + classify(type)
|
||||
};
|
||||
}
|
||||
|
||||
export default Ember.DefaultResolver.extend({
|
||||
parseName: parseName,
|
||||
|
||||
normalize(fullName) {
|
||||
var split = fullName.split(':');
|
||||
if (split.length > 1) {
|
||||
var discourseBase = 'discourse/' + split[0] + 's/';
|
||||
var adminBase = 'admin/' + split[0] + 's/';
|
||||
|
||||
// Allow render 'admin/templates/xyz' too
|
||||
split[1] = split[1].replace('.templates', '').replace('/templates', '');
|
||||
|
||||
// Try slashes
|
||||
var dashed = Ember.String.dasherize(split[1].replace(/\./g, '/'));
|
||||
if (requirejs.entries[discourseBase + dashed] || requirejs.entries[adminBase + dashed]) {
|
||||
return split[0] + ":" + dashed;
|
||||
}
|
||||
|
||||
// Try with dashes instead of slashes
|
||||
dashed = Ember.String.dasherize(split[1].replace(/\./g, '-'));
|
||||
if (requirejs.entries[discourseBase + dashed] || requirejs.entries[adminBase + dashed]) {
|
||||
return split[0] + ":" + dashed;
|
||||
}
|
||||
}
|
||||
return this._super(fullName);
|
||||
},
|
||||
|
||||
customResolve(parsedName) {
|
||||
// If we end with the name we want, use it. This allows us to define components within plugins.
|
||||
const suffix = parsedName.type + 's/' + parsedName.fullNameWithoutType,
|
||||
dashed = Ember.String.dasherize(suffix),
|
||||
moduleName = Object.keys(requirejs.entries).find(function(e) {
|
||||
return (e.indexOf(suffix, e.length - suffix.length) !== -1) ||
|
||||
(e.indexOf(dashed, e.length - dashed.length) !== -1);
|
||||
});
|
||||
|
||||
var module;
|
||||
if (moduleName) {
|
||||
module = require(moduleName, null, null, true /* force sync */);
|
||||
if (module && module['default']) { module = module['default']; }
|
||||
}
|
||||
return module;
|
||||
},
|
||||
|
||||
resolveWidget(parsedName) {
|
||||
return this.customResolve(parsedName) || this._super(parsedName);
|
||||
},
|
||||
|
||||
resolveAdapter(parsedName) {
|
||||
return this.customResolve(parsedName) || this._super(parsedName);
|
||||
},
|
||||
|
||||
resolveModel(parsedName) {
|
||||
return this.customResolve(parsedName) || this._super(parsedName);
|
||||
},
|
||||
|
||||
resolveView(parsedName) {
|
||||
return this.findLoadingView(parsedName) || this.customResolve(parsedName) || this._super(parsedName);
|
||||
},
|
||||
|
||||
resolveHelper(parsedName) {
|
||||
return this.customResolve(parsedName) || this._super(parsedName);
|
||||
},
|
||||
|
||||
resolveController(parsedName) {
|
||||
return this.customResolve(parsedName) || this._super(parsedName);
|
||||
},
|
||||
|
||||
resolveComponent(parsedName) {
|
||||
return this.customResolve(parsedName) || this._super(parsedName);
|
||||
},
|
||||
|
||||
resolveRoute(parsedName) {
|
||||
return this.findLoadingRoute(parsedName) || this.customResolve(parsedName) || this._super(parsedName);
|
||||
},
|
||||
|
||||
resolveTemplate(parsedName) {
|
||||
return this.findPluginMobileTemplate(parsedName) ||
|
||||
this.findPluginTemplate(parsedName) ||
|
||||
this.findMobileTemplate(parsedName) ||
|
||||
this.findTemplate(parsedName) ||
|
||||
Ember.TEMPLATES.not_found;
|
||||
},
|
||||
|
||||
findLoadingRoute: loadingResolver(function() {
|
||||
_dummyRoute = _dummyRoute || Ember.Route.extend();
|
||||
return _dummyRoute;
|
||||
}),
|
||||
|
||||
findLoadingView: loadingResolver(function() {
|
||||
if (!_loadingView) {
|
||||
_loadingView = require('discourse/views/loading', null, null, true /* force sync */);
|
||||
if (_loadingView && _loadingView['default']) { _loadingView = _loadingView['default']; }
|
||||
}
|
||||
return _loadingView;
|
||||
}),
|
||||
|
||||
findPluginTemplate(parsedName) {
|
||||
var pluginParsedName = this.parseName(parsedName.fullName.replace("template:", "template:javascripts/"));
|
||||
return this.findTemplate(pluginParsedName);
|
||||
},
|
||||
|
||||
findPluginMobileTemplate(parsedName) {
|
||||
if (this.mobileView) {
|
||||
var pluginParsedName = this.parseName(parsedName.fullName.replace("template:", "template:javascripts/mobile/"));
|
||||
return this.findTemplate(pluginParsedName);
|
||||
}
|
||||
},
|
||||
|
||||
findMobileTemplate(parsedName) {
|
||||
if (this.mobileView) {
|
||||
var mobileParsedName = this.parseName(parsedName.fullName.replace("template:", "template:mobile/"));
|
||||
return this.findTemplate(mobileParsedName);
|
||||
}
|
||||
},
|
||||
|
||||
findTemplate(parsedName) {
|
||||
const withoutType = parsedName.fullNameWithoutType,
|
||||
slashedType = withoutType.replace(/\./g, '/'),
|
||||
decamelized = withoutType.decamelize(),
|
||||
dashed = decamelized.replace(/\./g, '-').replace(/\_/g, '-'),
|
||||
templates = Ember.TEMPLATES;
|
||||
|
||||
return this._super(parsedName) ||
|
||||
templates[slashedType] ||
|
||||
templates[withoutType] ||
|
||||
templates[dashed] ||
|
||||
templates[decamelized.replace(/\./, '/')] ||
|
||||
templates[decamelized.replace(/\_/, '/')] ||
|
||||
this.findAdminTemplate(parsedName) ||
|
||||
this.findUnderscoredTemplate(parsedName);
|
||||
},
|
||||
|
||||
findUnderscoredTemplate(parsedName) {
|
||||
var decamelized = parsedName.fullNameWithoutType.decamelize();
|
||||
var underscored = decamelized.replace(/\-/g, "_");
|
||||
return Ember.TEMPLATES[underscored];
|
||||
},
|
||||
|
||||
// Try to find a template within a special admin namespace, e.g. adminEmail => admin/templates/email
|
||||
// (similar to how discourse lays out templates)
|
||||
findAdminTemplate(parsedName) {
|
||||
var decamelized = parsedName.fullNameWithoutType.decamelize();
|
||||
|
||||
if (decamelized.indexOf('components') === 0) {
|
||||
const compTemplate = Ember.TEMPLATES['admin/templates/' + decamelized];
|
||||
if (compTemplate) { return compTemplate; }
|
||||
}
|
||||
|
||||
if (decamelized === "javascripts/admin") {
|
||||
return Ember.TEMPLATES['admin/templates/admin'];
|
||||
}
|
||||
|
||||
if (decamelized.indexOf('admin') === 0 || decamelized.indexOf('javascripts/admin') === 0) {
|
||||
decamelized = decamelized.replace(/^admin\_/, 'admin/templates/');
|
||||
decamelized = decamelized.replace(/^admin\./, 'admin/templates/');
|
||||
decamelized = decamelized.replace(/\./g, '_');
|
||||
|
||||
const dashed = decamelized.replace(/_/g, '-');
|
||||
return Ember.TEMPLATES[decamelized] ||
|
||||
Ember.TEMPLATES[dashed] ||
|
||||
Ember.TEMPLATES[dashed.replace('admin-', 'admin/')];
|
||||
}
|
||||
}
|
||||
|
||||
});
|
|
@ -1,4 +1,4 @@
|
|||
import { registerUnbound } from 'discourse/lib/helpers';
|
||||
import { registerUnbound } from 'discourse-common/lib/helpers';
|
||||
import { longDate, autoUpdatingRelativeAge, number } from 'discourse/lib/formatter';
|
||||
|
||||
const safe = Handlebars.SafeString;
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
import { htmlHelper } from 'discourse/lib/helpers';
|
||||
import { htmlHelper } from 'discourse-common/lib/helpers';
|
||||
|
||||
export default htmlHelper(color => `border-color: #${color}`);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { htmlHelper } from 'discourse/lib/helpers';
|
||||
import { htmlHelper } from 'discourse-common/lib/helpers';
|
||||
import { avatarImg } from 'discourse/lib/utilities';
|
||||
|
||||
export default htmlHelper((avatarTemplate, size) => avatarImg({ size, avatarTemplate }));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { htmlHelper } from 'discourse/lib/helpers';
|
||||
import { htmlHelper } from 'discourse-common/lib/helpers';
|
||||
import { avatarImg } from 'discourse/lib/utilities';
|
||||
|
||||
export default htmlHelper((user, size) => {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { htmlHelper } from 'discourse/lib/helpers';
|
||||
import { htmlHelper } from 'discourse-common/lib/helpers';
|
||||
import { categoryLinkHTML } from 'discourse/helpers/category-link';
|
||||
|
||||
export default htmlHelper(categoryLinkHTML);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { autoUpdatingRelativeAge } from 'discourse/lib/formatter';
|
||||
import { htmlHelper } from 'discourse/lib/helpers';
|
||||
import { htmlHelper } from 'discourse-common/lib/helpers';
|
||||
|
||||
export default htmlHelper(dt => autoUpdatingRelativeAge(new Date(dt), {format: 'medium', title: true }));
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
import { htmlHelper } from 'discourse/lib/helpers';
|
||||
import { htmlHelper } from 'discourse-common/lib/helpers';
|
||||
|
||||
export default htmlHelper(str => str[0].toUpperCase() + str.slice(1));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { categoryLinkHTML } from 'discourse/helpers/category-link';
|
||||
import { registerUnbound } from 'discourse/lib/helpers';
|
||||
import { registerUnbound } from 'discourse-common/lib/helpers';
|
||||
|
||||
registerUnbound('category-badge', function(cat, options) {
|
||||
options.link = false;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { registerUnbound } from 'discourse/lib/helpers';
|
||||
import { iconHTML } from 'discourse/helpers/fa-icon';
|
||||
import { registerUnbound } from 'discourse-common/lib/helpers';
|
||||
import { iconHTML } from 'discourse-common/helpers/fa-icon';
|
||||
|
||||
var get = Em.get,
|
||||
escapeExpression = Handlebars.Utils.escapeExpression;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { registerUnbound } from 'discourse/lib/helpers';
|
||||
import { registerUnbound } from 'discourse-common/lib/helpers';
|
||||
|
||||
function daysSinceEpoch(dt) {
|
||||
// 1000 * 60 * 60 * 24 = days since epoch
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { cook } from 'discourse/lib/text';
|
||||
import { registerUnbound } from 'discourse/lib/helpers';
|
||||
import { registerUnbound } from 'discourse-common/lib/helpers';
|
||||
|
||||
registerUnbound('cook-text', cook);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { registerHelper } from 'discourse/lib/helpers';
|
||||
import { registerHelper } from 'discourse-common/lib/helpers';
|
||||
import PreloadStore from 'preload-store';
|
||||
|
||||
const _customizations = {};
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
import { htmlHelper } from 'discourse/lib/helpers';
|
||||
import { htmlHelper } from 'discourse-common/lib/helpers';
|
||||
|
||||
export default htmlHelper(str => Ember.isEmpty(str) ? '—' : str);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { registerUnbound } from 'discourse/lib/helpers';
|
||||
import { registerUnbound } from 'discourse-common/lib/helpers';
|
||||
import renderTag from 'discourse/lib/render-tag';
|
||||
|
||||
export default registerUnbound('discourse-tag', function(name, params) {
|
||||
|
|
20
app/assets/javascripts/discourse/helpers/fa-icon-node.js.es6
Normal file
20
app/assets/javascripts/discourse/helpers/fa-icon-node.js.es6
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { h } from 'virtual-dom';
|
||||
import { iconClasses } from 'discourse-common/helpers/fa-icon';
|
||||
|
||||
export function iconNode(icon, params) {
|
||||
params = params || {};
|
||||
|
||||
const properties = {
|
||||
className: iconClasses(icon, params),
|
||||
attributes: { "aria-hidden": true }
|
||||
};
|
||||
|
||||
if (params.title) { properties.attributes.title = params.title; }
|
||||
|
||||
if (params.label) {
|
||||
return h('i', properties, h('span.sr-only', I18n.t(params.label)));
|
||||
} else {
|
||||
return h('i', properties);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import { autoUpdatingRelativeAge } from 'discourse/lib/formatter';
|
||||
import { registerUnbound } from 'discourse/lib/helpers';
|
||||
import { registerUnbound } from 'discourse-common/lib/helpers';
|
||||
|
||||
registerUnbound('format-age', function(dt) {
|
||||
dt = new Date(dt);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { registerUnbound } from 'discourse/lib/helpers';
|
||||
import { registerUnbound } from 'discourse-common/lib/helpers';
|
||||
import { autoUpdatingRelativeAge } from 'discourse/lib/formatter';
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { htmlHelper } from 'discourse/lib/helpers';
|
||||
import { htmlHelper } from 'discourse-common/lib/helpers';
|
||||
|
||||
export default htmlHelper(function(str) {
|
||||
if (Ember.isEmpty(str)) { return ""; }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { htmlHelper } from 'discourse/lib/helpers';
|
||||
import { htmlHelper } from 'discourse-common/lib/helpers';
|
||||
|
||||
function renderSpinner(cssClass) {
|
||||
var html = "<div class='spinner";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { registerUnbound } from 'discourse/lib/helpers';
|
||||
import { registerUnbound } from 'discourse-common/lib/helpers';
|
||||
|
||||
registerUnbound('max-usernames', function(usernames, params) {
|
||||
var maxLength = parseInt(params.max) || 3;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { htmlHelper } from 'discourse/lib/helpers';
|
||||
import { htmlHelper } from 'discourse-common/lib/helpers';
|
||||
|
||||
const TITLE_SUBS = {
|
||||
all: 'all_time',
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
The list of disabled plugins is returned via the `Site` singleton.
|
||||
|
||||
**/
|
||||
import { registerHelper } from 'discourse/lib/helpers';
|
||||
import { registerHelper } from 'discourse-common/lib/helpers';
|
||||
|
||||
let _connectorCache, _rawCache;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { registerUnbound } from 'discourse/lib/helpers';
|
||||
import { registerUnbound } from 'discourse-common/lib/helpers';
|
||||
|
||||
// see: https://github.com/emberjs/ember.js/issues/12634
|
||||
var missingViews = {};
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { registerUnbound } from 'discourse/lib/helpers';
|
||||
import { registerUnbound } from 'discourse-common/lib/helpers';
|
||||
import { emojiUnescape } from 'discourse/lib/text';
|
||||
|
||||
registerUnbound('i18n', (key, params) => I18n.t(key, params));
|
||||
registerUnbound('replace-emoji', text => new Handlebars.SafeString(emojiUnescape(text)));
|
|
@ -1,4 +1,4 @@
|
|||
import { registerUnbound } from 'discourse/lib/helpers';
|
||||
import { registerUnbound } from 'discourse-common/lib/helpers';
|
||||
|
||||
registerUnbound('shorten-url', function(url) {
|
||||
var matches = url.match(/\//g);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { registerUnbound } from 'discourse/lib/helpers';
|
||||
import { registerUnbound } from 'discourse-common/lib/helpers';
|
||||
|
||||
registerUnbound('topic-link', function(topic) {
|
||||
var title = topic.get('fancyTitle');
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { registerUnbound } from 'discourse/lib/helpers';
|
||||
import { registerUnbound } from 'discourse-common/lib/helpers';
|
||||
import { avatarImg } from 'discourse/lib/utilities';
|
||||
|
||||
function renderAvatar(user, options) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { iconHTML } from 'discourse/helpers/fa-icon';
|
||||
import { htmlHelper } from 'discourse/lib/helpers';
|
||||
import { iconHTML } from 'discourse-common/helpers/fa-icon';
|
||||
import { htmlHelper } from 'discourse-common/lib/helpers';
|
||||
import { escapeExpression } from 'discourse/lib/utilities';
|
||||
|
||||
export default htmlHelper((user, args) => {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { iconNode } from 'discourse/helpers/fa-icon';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon-node';
|
||||
import { addDecorator } from 'discourse/widgets/post-cooked';
|
||||
import ComposerEditor from 'discourse/components/composer-editor';
|
||||
import { addButton } from 'discourse/widgets/post-menu';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { mapRoutes } from 'discourse/router';
|
||||
import { mapRoutes } from 'discourse/mapping-router';
|
||||
|
||||
export default {
|
||||
name: "map-routes",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import ButtonView from 'discourse/views/button';
|
||||
import { iconHTML } from 'discourse/helpers/fa-icon';
|
||||
import { iconHTML } from 'discourse-common/helpers/fa-icon';
|
||||
|
||||
export default ButtonView.extend({
|
||||
classNames: ['bookmark'],
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import ButtonView from 'discourse/views/button';
|
||||
import { iconHTML } from 'discourse/helpers/fa-icon';
|
||||
import { iconHTML } from 'discourse-common/helpers/fa-icon';
|
||||
|
||||
export default ButtonView.extend({
|
||||
classNames: ['flag-topic'],
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import ButtonView from 'discourse/views/button';
|
||||
import { iconHTML } from 'discourse/helpers/fa-icon';
|
||||
import { iconHTML } from 'discourse-common/helpers/fa-icon';
|
||||
|
||||
export default ButtonView.extend({
|
||||
classNames: ['invite-topic'],
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import ButtonView from 'discourse/views/button';
|
||||
import { iconHTML } from 'discourse/helpers/fa-icon';
|
||||
import { iconHTML } from 'discourse-common/helpers/fa-icon';
|
||||
|
||||
export default ButtonView.extend({
|
||||
classNames: ['share'],
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { createWidget } from 'discourse/widgets/widget';
|
||||
import { avatarFor } from 'discourse/widgets/post';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon-node';
|
||||
import { h } from 'virtual-dom';
|
||||
import { dateNode } from 'discourse/helpers/node';
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { createWidget } from 'discourse/widgets/widget';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon-node';
|
||||
|
||||
export default createWidget('button', {
|
||||
tagName: 'button.widget-button',
|
||||
|
|
|
@ -2,7 +2,7 @@ import PostCooked from 'discourse/widgets/post-cooked';
|
|||
import DecoratorHelper from 'discourse/widgets/decorator-helper';
|
||||
import { createWidget } from 'discourse/widgets/widget';
|
||||
import { h } from 'virtual-dom';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon-node';
|
||||
import DiscourseURL from 'discourse/lib/url';
|
||||
|
||||
createWidget('post-link-arrow', {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { createWidget } from 'discourse/widgets/widget';
|
||||
import { h } from 'virtual-dom';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon-node';
|
||||
import DiscourseURL from 'discourse/lib/url';
|
||||
import RawHtml from 'discourse/widgets/raw-html';
|
||||
import { tagNode } from 'discourse/lib/render-tag';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { createWidget } from 'discourse/widgets/widget';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon-node';
|
||||
import { avatarImg } from 'discourse/widgets/post';
|
||||
import DiscourseURL from 'discourse/lib/url';
|
||||
import { wantsNewWindow } from 'discourse/lib/intercept-click';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { createWidget } from 'discourse/widgets/widget';
|
||||
import { h } from 'virtual-dom';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon-node';
|
||||
import { wantsNewWindow } from 'discourse/lib/intercept-click';
|
||||
import DiscourseURL from 'discourse/lib/url';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { wantsNewWindow } from 'discourse/lib/intercept-click';
|
||||
import { createWidget } from 'discourse/widgets/widget';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon-node';
|
||||
import { h } from 'virtual-dom';
|
||||
import DiscourseURL from 'discourse/lib/url';
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { iconNode } from 'discourse/helpers/fa-icon';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon-node';
|
||||
import { createWidget } from 'discourse/widgets/widget';
|
||||
import { h } from 'virtual-dom';
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { createWidget } from 'discourse/widgets/widget';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon-node';
|
||||
import { longDate } from 'discourse/lib/formatter';
|
||||
import { h } from 'virtual-dom';
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { iconNode } from 'discourse/helpers/fa-icon';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon-node';
|
||||
import { createWidget } from 'discourse/widgets/widget';
|
||||
import { h } from 'virtual-dom';
|
||||
import { replaceEmoji } from 'discourse/widgets/emoji';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { createWidget } from 'discourse/widgets/widget';
|
||||
import RawHtml from 'discourse/widgets/raw-html';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon-node';
|
||||
import { h } from 'virtual-dom';
|
||||
import { actionDescriptionHtml } from 'discourse/components/small-action';
|
||||
import { avatarFor } from 'discourse/widgets/post';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import PostCooked from 'discourse/widgets/post-cooked';
|
||||
import DecoratorHelper from 'discourse/widgets/decorator-helper';
|
||||
import { createWidget, applyDecorators } from 'discourse/widgets/widget';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon-node';
|
||||
import { transformBasicPost } from 'discourse/lib/transform-post';
|
||||
import { h } from 'virtual-dom';
|
||||
import DiscourseURL from 'discourse/lib/url';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { iconNode } from 'discourse/helpers/fa-icon';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon-node';
|
||||
import { createWidget } from 'discourse/widgets/widget';
|
||||
import { h } from 'virtual-dom';
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { iconNode } from 'discourse/helpers/fa-icon';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon-node';
|
||||
import { createWidget } from 'discourse/widgets/widget';
|
||||
import { h } from 'virtual-dom';
|
||||
import { avatarFor } from 'discourse/widgets/post';
|
||||
|
|
|
@ -3,7 +3,7 @@ import { dateNode } from 'discourse/helpers/node';
|
|||
import RawHtml from 'discourse/widgets/raw-html';
|
||||
import { createWidget } from 'discourse/widgets/widget';
|
||||
import { h } from 'virtual-dom';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon-node';
|
||||
|
||||
class Highlighted extends RawHtml {
|
||||
constructor(html, term) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { createWidget } from 'discourse/widgets/widget';
|
||||
import { h } from 'virtual-dom';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon-node';
|
||||
|
||||
function description(attrs) {
|
||||
const daysSince = attrs.daysSince;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { createWidget } from 'discourse/widgets/widget';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon-node';
|
||||
import { h } from 'virtual-dom';
|
||||
import { escapeExpression } from 'discourse/lib/utilities';
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { createWidget } from 'discourse/widgets/widget';
|
||||
import { h } from 'virtual-dom';
|
||||
import { relativeAge } from 'discourse/lib/formatter';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon';
|
||||
import { iconNode } from 'discourse/helpers/fa-icon-node';
|
||||
|
||||
const SCROLLAREA_HEIGHT = 300;
|
||||
const SCROLLER_HEIGHT = 50;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
//= require ./ember-addons/decorator-alias
|
||||
//= require ./ember-addons/macro-alias
|
||||
//= require ./ember-addons/ember-computed-decorators
|
||||
//= require_tree ./discourse-common
|
||||
//= require ./discourse
|
||||
//= require ./deprecated
|
||||
|
||||
|
@ -19,11 +20,6 @@
|
|||
//= require ./discourse/lib/debounce
|
||||
//= require ./discourse/lib/quote
|
||||
//= require ./discourse/lib/key-value-store
|
||||
//= require ./discourse/lib/helpers
|
||||
//= require ./discourse/helpers/i18n
|
||||
//= require ./discourse/helpers/fa-icon
|
||||
//= require ./discourse/lib/raw-handlebars
|
||||
//= require ./discourse/lib/helpers
|
||||
//= require ./discourse/lib/computed
|
||||
//= require ./discourse/lib/formatter
|
||||
//= require ./discourse/lib/eyeline
|
||||
|
@ -92,7 +88,7 @@
|
|||
//= require ./discourse/helpers/category-link
|
||||
//= require ./discourse/lib/export-result
|
||||
//= require_tree ./discourse/lib
|
||||
//= require ./discourse/router
|
||||
//= require ./discourse/mapping-router
|
||||
|
||||
//= require_tree ./discourse/controllers
|
||||
//= require_tree ./discourse/models
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
//= require ./ember-addons/decorator-alias
|
||||
//= require ./ember-addons/macro-alias
|
||||
//= require ./ember-addons/ember-computed-decorators
|
||||
//= require discourse/lib/raw-handlebars
|
||||
//= require discourse/lib/helpers
|
||||
//= require wizard/resolver
|
||||
//= require_tree ./discourse-common
|
||||
//= require wizard/router
|
||||
//= require wizard/wizard
|
||||
//= require_tree ./wizard/templates
|
||||
|
@ -14,5 +12,4 @@
|
|||
//= require_tree ./wizard/controllers
|
||||
//= require_tree ./wizard/lib
|
||||
//= require_tree ./wizard/mixins
|
||||
//= require_tree ./wizard/helpers
|
||||
//= require_tree ./wizard/initializers
|
||||
|
|
|
@ -20,4 +20,3 @@ export function findWizard() {
|
|||
return Wizard.create(wizard);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
function resolveType(parsedName) {
|
||||
const entries = requirejs.entries;
|
||||
|
||||
const named = `wizard/${parsedName.type}s/${parsedName.fullNameWithoutType}`;
|
||||
if (entries[named]) {
|
||||
const module = require(named, null, null, true /* force sync */);
|
||||
return module.default;
|
||||
}
|
||||
}
|
||||
|
||||
function customResolve(parsedName) {
|
||||
return resolveType(parsedName) || this._super(parsedName);
|
||||
}
|
||||
|
||||
export default Ember.DefaultResolver.extend({
|
||||
|
||||
resolveRoute: customResolve,
|
||||
resolveController: customResolve,
|
||||
resolveComponent: customResolve,
|
||||
|
||||
resolveTemplate(parsedName) {
|
||||
const templates = Ember.TEMPLATES;
|
||||
const withoutType = parsedName.fullNameWithoutType;
|
||||
return templates[`wizard/templates/${withoutType}`] || this._super(parsedName);
|
||||
}
|
||||
});
|
|
@ -1,4 +1,6 @@
|
|||
const Router = Ember.Router.extend();
|
||||
const Router = Ember.Router.extend({
|
||||
location: Ember.testing ? 'none': 'hash'
|
||||
});
|
||||
|
||||
Router.map(function () {
|
||||
this.route('step', { path: '/step/:step_id' });
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
{{#if showBackButton}}
|
||||
<button class='wizard-btn back' {{action "backStep"}} disabled={{saving}}>
|
||||
<i class='fa fa-chevron-left'></i>
|
||||
{{fa-icon "chevron-left"}}
|
||||
{{i18n "wizard.back"}}
|
||||
</button>
|
||||
{{/if}}
|
||||
|
@ -30,7 +30,7 @@
|
|||
{{#if showNextButton}}
|
||||
<button class='wizard-btn next' {{action "nextStep"}} disabled={{saving}}>
|
||||
{{i18n "wizard.next"}}
|
||||
<i class='fa fa-chevron-right'></i>
|
||||
{{fa-icon "chevron-right"}}
|
||||
</button>
|
||||
{{/if}}
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ QUnit.testDone(function() {
|
|||
var wizard = require('wizard/wizard').default.create({
|
||||
rootElement: '#ember-testing'
|
||||
});
|
||||
|
||||
wizard.setupForTesting();
|
||||
wizard.injectTestHelpers();
|
||||
wizard.start();
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
import Resolver from 'wizard/resolver';
|
||||
import Router from 'wizard/router';
|
||||
import { buildResolver } from 'discourse-common/resolver';
|
||||
|
||||
export default Ember.Application.extend({
|
||||
rootElement: '#wizard-main',
|
||||
Resolver,
|
||||
Router,
|
||||
Resolver: buildResolver('wizard'),
|
||||
|
||||
start() {
|
||||
Object.keys(requirejs._eak_seen).forEach(key => {
|
||||
|
|
|
@ -47,7 +47,7 @@ PLUGIN_API_JS
|
|||
name = node["name"] || node["data-template-name"] || "broken"
|
||||
precompiled =
|
||||
if name =~ /\.raw$/
|
||||
"require('discourse/lib/raw-handlebars').template(#{Barber::Precompiler.compile(node.inner_html)})"
|
||||
"require('discourse-common/lib/raw-handlebars').template(#{Barber::Precompiler.compile(node.inner_html)})"
|
||||
else
|
||||
"Ember.HTMLBars.template(#{Barber::Ember::Precompiler.compile(node.inner_html)})"
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ class Barber::Precompiler
|
|||
def precompiler
|
||||
if !@precompiler
|
||||
|
||||
source = File.read("#{Rails.root}/app/assets/javascripts/discourse/lib/raw-handlebars.js.es6")
|
||||
source = File.read("#{Rails.root}/app/assets/javascripts/discourse-common/lib/raw-handlebars.js.es6")
|
||||
template = Tilt::ES6ModuleTranspilerTemplate.new {}
|
||||
transpiled = template.babel_transpile(source)
|
||||
|
||||
|
@ -40,11 +40,11 @@ module Discourse
|
|||
module Handlebars
|
||||
module Helper
|
||||
def precompile_handlebars(string)
|
||||
"require('discourse/lib/raw-handlebars').template(#{Barber::Precompiler.compile(string)});"
|
||||
"require('discourse-common/lib/raw-handlebars').template(#{Barber::Precompiler.compile(string)});"
|
||||
end
|
||||
|
||||
def compile_handlebars(string)
|
||||
"require('discourse/lib/raw-handlebars').compile(#{indent(string).inspect});"
|
||||
"require('discourse-common/lib/raw-handlebars').compile(#{indent(string).inspect});"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import computed from 'ember-addons/ember-computed-decorators';
|
||||
import { iconHTML } from 'discourse/helpers/fa-icon';
|
||||
import { iconHTML } from 'discourse-common/helpers/fa-icon';
|
||||
|
||||
export default Em.Component.extend({
|
||||
tagName: "li",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import DiscourseResolver from 'discourse/ember/resolver';
|
||||
import { buildResolver } from 'discourse-common/resolver';
|
||||
|
||||
let originalTemplates;
|
||||
let resolver;
|
||||
|
@ -15,6 +15,8 @@ function setTemplates(lookupTemplateStrings) {
|
|||
});
|
||||
}
|
||||
|
||||
const DiscourseResolver = buildResolver('discourse');
|
||||
|
||||
module("lib:resolver", {
|
||||
setup: function() {
|
||||
originalTemplates = Ember.TEMPLATES;
|
||||
|
|
|
@ -2,10 +2,10 @@ import Store from "discourse/models/store";
|
|||
import RestAdapter from 'discourse/adapters/rest';
|
||||
import KeyValueStore from 'discourse/lib/key-value-store';
|
||||
import TopicTrackingState from 'discourse/models/topic-tracking-state';
|
||||
import Resolver from 'discourse/ember/resolver';
|
||||
import { buildResolver } from 'discourse-common/resolver';
|
||||
|
||||
export default function() {
|
||||
const resolver = Resolver.create();
|
||||
const resolver = buildResolver('discourse').create();
|
||||
return Store.create({
|
||||
container: {
|
||||
lookup(type) {
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
var resolver = require('discourse/ember/resolver').default;
|
||||
window.setResolver(resolver.create({ namespace: Discourse }));
|
||||
var buildResolver = require('discourse-common/resolver').buildResolver;
|
||||
window.setResolver(buildResolver('discourse').create({ namespace: Discourse }));
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
//= require helpers/qunit-helpers
|
||||
//= require helpers/assertions
|
||||
|
||||
//= require helpers/init-ember-qunit
|
||||
//= require_tree ./fixtures
|
||||
//= require_tree ./lib
|
||||
//= require_tree .
|
||||
|
|
Loading…
Reference in a new issue