FIX: Wizard didn't work with subfolders
This commit is contained in:
parent
92529cd409
commit
3d621767cc
|
@ -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')) {
|
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) {
|
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 computed from 'ember-addons/ember-computed-decorators';
|
||||||
import { getToken } from 'wizard/lib/ajax';
|
import { getToken } from 'wizard/lib/ajax';
|
||||||
|
|
||||||
|
@ -20,7 +21,7 @@ export default Ember.Component.extend({
|
||||||
const id = this.get('field.id');
|
const id = this.get('field.id');
|
||||||
|
|
||||||
$upload.fileupload({
|
$upload.fileupload({
|
||||||
url: "/uploads.json",
|
url: getUrl("/uploads.json"),
|
||||||
formData: { synchronous: true,
|
formData: { synchronous: true,
|
||||||
type: `wizard_${id}`,
|
type: `wizard_${id}`,
|
||||||
authenticity_token: getToken() },
|
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';
|
import { default as computed, observes } from 'ember-addons/ember-computed-decorators';
|
||||||
|
|
||||||
jQuery.fn.wiggle = function (times, duration) {
|
jQuery.fn.wiggle = function (times, duration) {
|
||||||
|
@ -37,7 +38,7 @@ export default Ember.Component.extend({
|
||||||
@computed('step.banner')
|
@computed('step.banner')
|
||||||
bannerImage(src) {
|
bannerImage(src) {
|
||||||
if (!src) { return; }
|
if (!src) { return; }
|
||||||
return `/images/wizard/${src}`;
|
return getUrl(`/images/wizard/${src}`);
|
||||||
},
|
},
|
||||||
|
|
||||||
@observes('step.id')
|
@observes('step.id')
|
||||||
|
@ -91,7 +92,7 @@ export default Ember.Component.extend({
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
quit() {
|
quit() {
|
||||||
document.location = "/";
|
document.location = getUrl("/");
|
||||||
},
|
},
|
||||||
|
|
||||||
backStep() {
|
backStep() {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import getUrl from 'discourse-common/lib/get-url';
|
||||||
|
|
||||||
export default Ember.Controller.extend({
|
export default Ember.Controller.extend({
|
||||||
wizard: null,
|
wizard: null,
|
||||||
step: null,
|
step: null,
|
||||||
|
@ -6,7 +8,7 @@ export default Ember.Controller.extend({
|
||||||
goNext(response) {
|
goNext(response) {
|
||||||
const next = this.get('step.next');
|
const next = this.get('step.next');
|
||||||
if (response.refresh_required) {
|
if (response.refresh_required) {
|
||||||
document.location = `/wizard/steps/${next}`;
|
document.location = getUrl(`/wizard/steps/${next}`);
|
||||||
} else {
|
} else {
|
||||||
this.transitionToRoute('step', next);
|
this.transitionToRoute('step', next);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import getUrl from 'discourse-common/lib/get-url';
|
||||||
|
|
||||||
let token;
|
let token;
|
||||||
|
|
||||||
|
@ -14,6 +15,7 @@ export function ajax(args) {
|
||||||
args.headers = { 'X-CSRF-Token': getToken() };
|
args.headers = { 'X-CSRF-Token': getToken() };
|
||||||
args.success = data => Ember.run(null, resolve, data);
|
args.success = data => Ember.run(null, resolve, data);
|
||||||
args.error = xhr => Ember.run(null, reject, xhr);
|
args.error = xhr => Ember.run(null, reject, xhr);
|
||||||
|
args.url = getUrl(args.url);
|
||||||
Ember.$.ajax(args);
|
Ember.$.ajax(args);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/*eslint no-bitwise:0 */
|
/*eslint no-bitwise:0 */
|
||||||
|
import getUrl from 'discourse-common/lib/get-url';
|
||||||
|
|
||||||
export const LOREM = `
|
export const LOREM = `
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||||
|
@ -190,8 +191,10 @@ export function createPreviewComponent(width, height, obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadImage(src) {
|
function loadImage(src) {
|
||||||
|
if (!src) { return Ember.RSVP.Promise.resolve(); }
|
||||||
|
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
img.src = src;
|
img.src = getUrl(src);
|
||||||
return new Ember.RSVP.Promise(resolve => img.onload = () => resolve(img));
|
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({
|
const Router = Ember.Router.extend({
|
||||||
rootURL: '/wizard',
|
rootURL: getUrl('/wizard'),
|
||||||
location: Ember.testing ? 'none': 'history'
|
location: Ember.testing ? 'none': 'history'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,6 @@
|
||||||
{{outlet}}
|
{{outlet}}
|
||||||
</div>
|
</div>
|
||||||
<div class='wizard-footer'>
|
<div class='wizard-footer'>
|
||||||
<img src="/images/wizard/discourse.png" class="logo">
|
<div class='discourse-logo'></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
body.wizard {
|
body.wizard {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
background-image: url('/images/wizard/bubbles.png');
|
background-image: asset-url('/images/wizard/bubbles.png');
|
||||||
background-repeat: repeat;
|
background-repeat: repeat;
|
||||||
background-position: left top;
|
background-position: left top;
|
||||||
|
|
||||||
|
@ -14,6 +14,14 @@ body.wizard {
|
||||||
line-height: 1.4em;
|
line-height: 1.4em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.discourse-logo {
|
||||||
|
background-image: asset-url('/images/wizard/discourse.png');
|
||||||
|
height: 30px;
|
||||||
|
width: 110px;
|
||||||
|
background-size: 110px 30px;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
.wizard-warning {
|
.wizard-warning {
|
||||||
font-family: sans-serif,
|
font-family: sans-serif,
|
||||||
|
|
||||||
|
@ -119,9 +127,6 @@ body.wizard {
|
||||||
border-top: 1px solid #ccc;
|
border-top: 1px solid #ccc;
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
padding: 0.5em;
|
padding: 0.5em;
|
||||||
img.logo {
|
|
||||||
height: 30px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.wizard-progress {
|
.wizard-progress {
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
<%= script "application" %>
|
<%= script "application" %>
|
||||||
|
|
||||||
<%- if staff? %>
|
<%- if staff? %>
|
||||||
<script src="/extra-locales/admin"></script>
|
<script src="<%= Discourse.base_uri %>/extra-locales/admin"></script>
|
||||||
<%= script "admin" %>
|
<%= script "admin" %>
|
||||||
<%- end %>
|
<%- end %>
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,11 @@
|
||||||
<%= script 'wizard-application' %>
|
<%= script 'wizard-application' %>
|
||||||
<%= script "locales/#{I18n.locale}" %>
|
<%= script "locales/#{I18n.locale}" %>
|
||||||
<%= render partial: "common/special_font_face" %>
|
<%= render partial: "common/special_font_face" %>
|
||||||
<script src="/extra-locales/wizard"></script>
|
<script src="<%= Discourse.base_uri %>/extra-locales/wizard"></script>
|
||||||
<%= csrf_meta_tags %>
|
<%= csrf_meta_tags %>
|
||||||
|
|
||||||
|
<meta name="discourse-base-uri" content="<%= Discourse.base_uri %>">
|
||||||
|
|
||||||
<%= render partial: "layouts/head" %>
|
<%= render partial: "layouts/head" %>
|
||||||
<title><%= t 'wizard.title' %></title>
|
<title><%= t 'wizard.title' %></title>
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -165,7 +165,7 @@ en:
|
||||||
|
|
||||||
topic_admin_menu: "topic admin actions"
|
topic_admin_menu: "topic admin actions"
|
||||||
|
|
||||||
wizard_required: "It's time to configure your forum! <a href='/wizard/' data-auto-route='true'>Start the Setup Wizard</a>!"
|
wizard_required: "It's time to configure your forum! <a href='%{url}' data-auto-route='true'>Start the Setup Wizard</a>!"
|
||||||
emails_are_disabled: "All outgoing email has been globally disabled by an administrator. No email notifications of any kind will be sent."
|
emails_are_disabled: "All outgoing email has been globally disabled by an administrator. No email notifications of any kind will be sent."
|
||||||
|
|
||||||
bootstrap_mode_enabled: "To make launching your new site easier, you are in bootstrap mode. All new users will be granted trust level 1 and have daily email digest updates enabled. This will be automatically turned off when total user count exceeds %{min_users} users."
|
bootstrap_mode_enabled: "To make launching your new site easier, you are in bootstrap mode. All new users will be granted trust level 1 and have daily email digest updates enabled. This will be automatically turned off when total user count exceeds %{min_users} users."
|
||||||
|
|
Loading…
Reference in New Issue