mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 19:01:27 +08:00
Add baseUri to site model
This commit is contained in:
@ -81,6 +81,7 @@ const DiscourseURL = Ember.Object.extend({
|
|||||||
const holderId = `#post_${postNumber}`;
|
const holderId = `#post_${postNumber}`;
|
||||||
|
|
||||||
_transitioning = postNumber > 1;
|
_transitioning = postNumber > 1;
|
||||||
|
|
||||||
Ember.run.schedule('afterRender', () => {
|
Ember.run.schedule('afterRender', () => {
|
||||||
let elementId;
|
let elementId;
|
||||||
let holder;
|
let holder;
|
||||||
@ -107,7 +108,7 @@ const DiscourseURL = Ember.Object.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (holder.length > 0 && opts && opts.skipIfOnScreen){
|
if (holder.length > 0 && opts && opts.skipIfOnScreen) {
|
||||||
const elementTop = lockon.elementTop();
|
const elementTop = lockon.elementTop();
|
||||||
const scrollTop = $(window).scrollTop();
|
const scrollTop = $(window).scrollTop();
|
||||||
const windowHeight = $(window).height() - offsetCalculator();
|
const windowHeight = $(window).height() - offsetCalculator();
|
||||||
@ -172,7 +173,7 @@ const DiscourseURL = Ember.Object.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const pathname = path.replace(/(https?\:)?\/\/[^\/]+/, '');
|
const pathname = path.replace(/(https?\:)?\/\/[^\/]+/, '');
|
||||||
let baseUri = Discourse.BaseUri;
|
const baseUri = Discourse.BaseUri;
|
||||||
|
|
||||||
// If we have a baseUri and an absolute URL, make sure the baseUri
|
// If we have a baseUri and an absolute URL, make sure the baseUri
|
||||||
// is the same. Otherwise we could be switching forums.
|
// is the same. Otherwise we could be switching forums.
|
||||||
@ -217,18 +218,18 @@ const DiscourseURL = Ember.Object.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handle prefixes
|
// handle prefixes
|
||||||
if (path.match(/^\//)) {
|
if (path.indexOf("/") === 0) {
|
||||||
let rootURL = (baseUri === undefined ? "/" : baseUri);
|
const rootURL = (baseUri === undefined ? "/" : baseUri).replace(/\/$/, "");
|
||||||
rootURL = rootURL.replace(/\/$/, '');
|
path = path.replace(rootURL, "");
|
||||||
path = path.replace(rootURL, '');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
path = rewritePath(path);
|
path = rewritePath(path);
|
||||||
|
|
||||||
if (this.navigatedToPost(oldPath, path, opts)) { return; }
|
if (this.navigatedToPost(oldPath, path, opts)) { return; }
|
||||||
|
|
||||||
if (oldPath === path) {
|
if (oldPath === path) {
|
||||||
// If navigating to the same path send an app event. Views can watch it
|
// If navigating to the same path send an app event.
|
||||||
// and tell their controllers to refresh
|
// Views can watch it and tell their controllers to refresh
|
||||||
this.appEvents.trigger('url:refresh');
|
this.appEvents.trigger('url:refresh');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +54,11 @@ const Site = RestModel.extend({
|
|||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@computed
|
||||||
|
baseUri() {
|
||||||
|
return Discourse.baseUri;
|
||||||
|
},
|
||||||
|
|
||||||
// Returns it in the correct order, by setting
|
// Returns it in the correct order, by setting
|
||||||
@computed
|
@computed
|
||||||
categoriesList() {
|
categoriesList() {
|
||||||
|
Reference in New Issue
Block a user