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