FIX: Wizard didn't work with subfolders
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
let baseUri;
|
||||
|
||||
export default function getURL(url) {
|
||||
if (!url) return url;
|
||||
|
||||
if (!baseUri) {
|
||||
baseUri = $('meta[name="discourse-base-uri"]').attr('content') || '';
|
||||
}
|
||||
|
||||
// if it's a non relative URL, return it.
|
||||
if (url !== '/' && !/^\/[^\/]/.test(url)) return url;
|
||||
|
||||
const found = url.indexOf(baseUri);
|
||||
|
||||
if (found >= 0 && found < 3) return url;
|
||||
if (url[0] !== "/") url = "/" + url;
|
||||
|
||||
return baseUri + url;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@ export default Ember.Component.extend(StringBuffer, {
|
||||
}
|
||||
|
||||
if (this.site.get('wizard_required')) {
|
||||
notices.push([I18n.t('wizard_required'), 'alert-wizard']);
|
||||
const requiredText = I18n.t('wizard_required', {url: Discourse.getURL('/wizard')});
|
||||
notices.push([requiredText, 'alert-wizard']);
|
||||
}
|
||||
|
||||
if (this.currentUser && this.currentUser.get('staff') && this.siteSettings.bootstrap_mode_enabled) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import getUrl from 'discourse-common/lib/get-url';
|
||||
import computed from 'ember-addons/ember-computed-decorators';
|
||||
import { getToken } from 'wizard/lib/ajax';
|
||||
|
||||
@@ -20,7 +21,7 @@ export default Ember.Component.extend({
|
||||
const id = this.get('field.id');
|
||||
|
||||
$upload.fileupload({
|
||||
url: "/uploads.json",
|
||||
url: getUrl("/uploads.json"),
|
||||
formData: { synchronous: true,
|
||||
type: `wizard_${id}`,
|
||||
authenticity_token: getToken() },
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import getUrl from 'discourse-common/lib/get-url';
|
||||
import { default as computed, observes } from 'ember-addons/ember-computed-decorators';
|
||||
|
||||
jQuery.fn.wiggle = function (times, duration) {
|
||||
@@ -37,7 +38,7 @@ export default Ember.Component.extend({
|
||||
@computed('step.banner')
|
||||
bannerImage(src) {
|
||||
if (!src) { return; }
|
||||
return `/images/wizard/${src}`;
|
||||
return getUrl(`/images/wizard/${src}`);
|
||||
},
|
||||
|
||||
@observes('step.id')
|
||||
@@ -91,7 +92,7 @@ export default Ember.Component.extend({
|
||||
|
||||
actions: {
|
||||
quit() {
|
||||
document.location = "/";
|
||||
document.location = getUrl("/");
|
||||
},
|
||||
|
||||
backStep() {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import getUrl from 'discourse-common/lib/get-url';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
wizard: null,
|
||||
step: null,
|
||||
@@ -6,7 +8,7 @@ export default Ember.Controller.extend({
|
||||
goNext(response) {
|
||||
const next = this.get('step.next');
|
||||
if (response.refresh_required) {
|
||||
document.location = `/wizard/steps/${next}`;
|
||||
document.location = getUrl(`/wizard/steps/${next}`);
|
||||
} else {
|
||||
this.transitionToRoute('step', next);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import getUrl from 'discourse-common/lib/get-url';
|
||||
|
||||
let token;
|
||||
|
||||
@@ -14,6 +15,7 @@ export function ajax(args) {
|
||||
args.headers = { 'X-CSRF-Token': getToken() };
|
||||
args.success = data => Ember.run(null, resolve, data);
|
||||
args.error = xhr => Ember.run(null, reject, xhr);
|
||||
args.url = getUrl(args.url);
|
||||
Ember.$.ajax(args);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*eslint no-bitwise:0 */
|
||||
import getUrl from 'discourse-common/lib/get-url';
|
||||
|
||||
export const LOREM = `
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
@@ -190,8 +191,10 @@ export function createPreviewComponent(width, height, obj) {
|
||||
}
|
||||
|
||||
function loadImage(src) {
|
||||
if (!src) { return Ember.RSVP.Promise.resolve(); }
|
||||
|
||||
const img = new Image();
|
||||
img.src = src;
|
||||
img.src = getUrl(src);
|
||||
return new Ember.RSVP.Promise(resolve => img.onload = () => resolve(img));
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import getUrl from 'discourse-common/lib/get-url';
|
||||
|
||||
const Router = Ember.Router.extend({
|
||||
rootURL: '/wizard',
|
||||
rootURL: getUrl('/wizard'),
|
||||
location: Ember.testing ? 'none': 'history'
|
||||
});
|
||||
|
||||
|
||||
@@ -7,6 +7,6 @@
|
||||
{{outlet}}
|
||||
</div>
|
||||
<div class='wizard-footer'>
|
||||
<img src="/images/wizard/discourse.png" class="logo">
|
||||
<div class='discourse-logo'></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user