FEATURE: add clean support for running Discourse in a subfolder

To setup set DISCOURSE_RELATIVE_URL_ROOT to the folder you wish
This commit is contained in:
Sam
2015-03-09 11:45:36 +11:00
parent 4c4183228f
commit f5af4768eb
27 changed files with 81 additions and 34 deletions

View File

@ -5,6 +5,10 @@ window.Discourse = Ember.Application.createWithMixins(Discourse.Ajax, {
rootElement: '#main',
_docTitle: document.title,
script: function(url) {
return $LAB.script(this.getURL(url));
},
getURL: function(url) {
if (!url) { return url; }
@ -16,6 +20,12 @@ window.Discourse = Ember.Application.createWithMixins(Discourse.Ajax, {
u = u.substring(0, u.length-1);
}
if (url.indexOf(u) !== -1) return url;
if(u.length > 0 && url[0] !== "/") {
// we got to root this
url = "/" + url;
}
return u + url;
},