DEV: Remove more `Discourse.` globals
This commit is contained in:
parent
4cf3dbe3db
commit
279835f603
|
@ -17,7 +17,6 @@ const Discourse = Application.extend(FocusEvent, {
|
|||
|
||||
reset() {
|
||||
this._super(...arguments);
|
||||
|
||||
Mousetrap.reset();
|
||||
},
|
||||
|
||||
|
@ -28,18 +27,18 @@ const Discourse = Application.extend(FocusEvent, {
|
|||
if (url !== "/" && !/^\/[^\/]/.test(url)) return url;
|
||||
|
||||
if (url[0] !== "/") url = "/" + url;
|
||||
if (url.startsWith(Discourse.BaseUri)) return url;
|
||||
if (url.startsWith(this.BaseUri)) return url;
|
||||
|
||||
return Discourse.BaseUri + url;
|
||||
return this.BaseUri + url;
|
||||
},
|
||||
|
||||
getURLWithCDN(url) {
|
||||
url = Discourse.getURL(url);
|
||||
url = this.getURL(url);
|
||||
// only relative urls
|
||||
if (Discourse.CDN && /^\/[^\/]/.test(url)) {
|
||||
url = Discourse.CDN + url;
|
||||
} else if (Discourse.S3CDN) {
|
||||
url = url.replace(Discourse.S3BaseUrl, Discourse.S3CDN);
|
||||
if (this.CDN && /^\/[^\/]/.test(url)) {
|
||||
url = this.CDN + url;
|
||||
} else if (this.S3CDN) {
|
||||
url = url.replace(this.S3BaseUrl, this.S3CDN);
|
||||
}
|
||||
return url;
|
||||
},
|
||||
|
@ -48,7 +47,7 @@ const Discourse = Application.extend(FocusEvent, {
|
|||
|
||||
@observes("_docTitle", "hasFocus", "contextCount", "notificationCount")
|
||||
_titleChanged() {
|
||||
let title = this._docTitle || Discourse.SiteSettings.title;
|
||||
let title = this._docTitle || this.SiteSettings.title;
|
||||
|
||||
let displayCount = this.displayCount;
|
||||
let dynamicFavicon = this.currentUser && this.currentUser.dynamic_favicon;
|
||||
|
@ -70,13 +69,13 @@ const Discourse = Application.extend(FocusEvent, {
|
|||
@observes("contextCount", "notificationCount")
|
||||
faviconChanged() {
|
||||
if (this.currentUser && this.currentUser.get("dynamic_favicon")) {
|
||||
let url = Discourse.SiteSettings.site_favicon_url;
|
||||
let url = this.SiteSettings.site_favicon_url;
|
||||
|
||||
// Since the favicon is cached on the browser for a really long time, we
|
||||
// append the favicon_url as query params to the path so that the cache
|
||||
// is not used when the favicon changes.
|
||||
if (/^http/.test(url)) {
|
||||
url = Discourse.getURL("/favicon/proxied?" + encodeURIComponent(url));
|
||||
url = this.getURL("/favicon/proxied?" + encodeURIComponent(url));
|
||||
}
|
||||
|
||||
var displayCount = this.displayCount;
|
||||
|
@ -116,7 +115,7 @@ const Discourse = Application.extend(FocusEvent, {
|
|||
|
||||
authenticationComplete(options) {
|
||||
// TODO, how to dispatch this to the controller without the container?
|
||||
const loginController = Discourse.__container__.lookup("controller:login");
|
||||
const loginController = this.__container__.lookup("controller:login");
|
||||
return loginController.authenticationComplete(options);
|
||||
},
|
||||
|
||||
|
|
|
@ -7,13 +7,15 @@ import { formatUsername } from "discourse/lib/utilities";
|
|||
import { Promise } from "rsvp";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
|
||||
const getURLWithCDN = url => Discourse.getURLWithCDN(url);
|
||||
|
||||
function getOpts(opts) {
|
||||
const siteSettings = Discourse.__container__.lookup("site-settings:main"),
|
||||
site = Discourse.__container__.lookup("site:main");
|
||||
|
||||
opts = _.merge(
|
||||
{
|
||||
getURL: Discourse.getURLWithCDN,
|
||||
getURL: getURLWithCDN,
|
||||
currentUser: Discourse.__container__.lookup("current-user:main"),
|
||||
censoredRegexp: site.censored_regexp,
|
||||
siteSettings,
|
||||
|
@ -67,7 +69,7 @@ function emojiOptions() {
|
|||
}
|
||||
|
||||
return {
|
||||
getURL: Discourse.getURLWithCDN,
|
||||
getURL: url => getURLWithCDN(url),
|
||||
emojiSet: Discourse.SiteSettings.emoji_set,
|
||||
enableEmojiShortcuts: Discourse.SiteSettings.enable_emoji_shortcuts,
|
||||
inlineEmoji: Discourse.SiteSettings.enable_inline_emoji_translation
|
||||
|
|
|
@ -54,8 +54,10 @@ export function getRawSize(size) {
|
|||
return size * Math.min(3, Math.max(1, Math.round(pixelRatio)));
|
||||
}
|
||||
|
||||
const getURLWithCDN = url => Discourse.getURLWithCDN(url);
|
||||
|
||||
export function avatarImg(options, getURL) {
|
||||
getURL = getURL || Discourse.getURLWithCDN;
|
||||
getURL = getURL || getURLWithCDN;
|
||||
|
||||
const size = translateSize(options.size);
|
||||
const url = avatarUrl(options.avatarTemplate, size);
|
||||
|
|
Loading…
Reference in New Issue