REFACTOR: Remove `Discourse.SiteSettings` from more lib-like helpers
This commit is contained in:
parent
3d7c81149e
commit
656abe22c7
|
@ -1,4 +1,6 @@
|
|||
import { helperContext } from "discourse-common/lib/helpers";
|
||||
import I18n from "I18n";
|
||||
|
||||
export function shortDate(date) {
|
||||
return moment(date).format(I18n.t("dates.medium.date_year"));
|
||||
}
|
||||
|
@ -170,6 +172,9 @@ function relativeAgeTiny(date, ageOpts) {
|
|||
return ageOpts && ageOpts.addAgo ? wrapAgo(result) : result;
|
||||
};
|
||||
|
||||
// This file is in lib but it's used as a helper
|
||||
let siteSettings = helperContext().siteSettings;
|
||||
|
||||
switch (true) {
|
||||
case distanceInMinutes >= 0 && distanceInMinutes <= 44:
|
||||
formatted = t("x_minutes", { count: distanceInMinutes });
|
||||
|
@ -182,7 +187,7 @@ function relativeAgeTiny(date, ageOpts) {
|
|||
count: Math.round(distanceInMinutes / 60.0)
|
||||
});
|
||||
break;
|
||||
case Discourse.SiteSettings.relative_date_duration === 0 &&
|
||||
case siteSettings.relative_date_duration === 0 &&
|
||||
distanceInMinutes <= 525599:
|
||||
formatted = shortDateNoYear(date);
|
||||
break;
|
||||
|
@ -190,8 +195,7 @@ function relativeAgeTiny(date, ageOpts) {
|
|||
formatted = t("x_days", { count: 1 });
|
||||
break;
|
||||
case distanceInMinutes >= 2520 &&
|
||||
distanceInMinutes <=
|
||||
(Discourse.SiteSettings.relative_date_duration || 14) * 1440:
|
||||
distanceInMinutes <= (siteSettings.relative_date_duration || 14) * 1440:
|
||||
formatted = t("x_days", {
|
||||
count: Math.round(distanceInMinutes / 1440.0)
|
||||
});
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import getURL from "discourse-common/lib/get-url";
|
||||
import User from "discourse/models/user";
|
||||
import { escapeExpression } from "discourse/lib/utilities";
|
||||
import { helperContext } from "discourse-common/lib/helpers";
|
||||
|
||||
let _renderer = defaultRenderTag;
|
||||
|
||||
|
@ -9,6 +10,9 @@ export function replaceTagRenderer(fn) {
|
|||
}
|
||||
|
||||
export function defaultRenderTag(tag, params) {
|
||||
// This file is in lib but it's used as a helper
|
||||
let siteSettings = helperContext().siteSettings;
|
||||
|
||||
params = params || {};
|
||||
const visibleName = escapeExpression(tag);
|
||||
tag = visibleName.toLowerCase();
|
||||
|
@ -27,8 +31,8 @@ export function defaultRenderTag(tag, params) {
|
|||
}
|
||||
const href = path ? ` href='${getURL(path)}' ` : "";
|
||||
|
||||
if (Discourse.SiteSettings.tag_style || params.style) {
|
||||
classes.push(params.style || Discourse.SiteSettings.tag_style);
|
||||
if (siteSettings.tag_style || params.style) {
|
||||
classes.push(params.style || siteSettings.tag_style);
|
||||
}
|
||||
if (params.size) {
|
||||
classes.push(params.size);
|
||||
|
|
Loading…
Reference in New Issue