mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 01:31:35 +08:00
DEV: Remove Discourse.Site in favor of import (#8344)
* DEV: Remove Discourse.Site in favor of importing Site * Ran prettier
This commit is contained in:

committed by
Robin Ward

parent
d2b3ac1282
commit
3c5df82590
@ -6,6 +6,7 @@ import {
|
|||||||
default as discourseComputed,
|
default as discourseComputed,
|
||||||
observes
|
observes
|
||||||
} from "discourse-common/utils/decorators";
|
} from "discourse-common/utils/decorators";
|
||||||
|
import Site from "discourse/models/site";
|
||||||
|
|
||||||
export default RestModel.extend({
|
export default RestModel.extend({
|
||||||
content_type: 1, // json
|
content_type: 1, // json
|
||||||
@ -36,7 +37,7 @@ export default RestModel.extend({
|
|||||||
const groupIds = this.group_ids;
|
const groupIds = this.group_ids;
|
||||||
this.set(
|
this.set(
|
||||||
"groupsFilterInName",
|
"groupsFilterInName",
|
||||||
Discourse.Site.currentProp("groups").reduce((groupNames, g) => {
|
Site.currentProp("groups").reduce((groupNames, g) => {
|
||||||
if (groupIds.includes(g.id)) {
|
if (groupIds.includes(g.id)) {
|
||||||
groupNames.push(g.name);
|
groupNames.push(g.name);
|
||||||
}
|
}
|
||||||
@ -87,7 +88,7 @@ export default RestModel.extend({
|
|||||||
group_ids:
|
group_ids:
|
||||||
isEmpty(groupNames) || isEmpty(groupNames[0])
|
isEmpty(groupNames) || isEmpty(groupNames[0])
|
||||||
? [null]
|
? [null]
|
||||||
: Discourse.Site.currentProp("groups").reduce((groupIds, g) => {
|
: Site.currentProp("groups").reduce((groupIds, g) => {
|
||||||
if (groupNames.includes(g.name)) {
|
if (groupNames.includes(g.name)) {
|
||||||
groupIds.push(g.id);
|
groupIds.push(g.id);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ import { get } from "@ember/object";
|
|||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { categoryBadgeHTML } from "discourse/helpers/category-link";
|
import { categoryBadgeHTML } from "discourse/helpers/category-link";
|
||||||
import { iconHTML } from "discourse-common/lib/icon-library";
|
import { iconHTML } from "discourse-common/lib/icon-library";
|
||||||
|
import Site from "discourse/models/site";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
elementId: "suggested-topics",
|
elementId: "suggested-topics",
|
||||||
@ -36,8 +37,7 @@ export default Component.extend({
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
category &&
|
category &&
|
||||||
get(category, "id") ===
|
get(category, "id") === Site.currentProp("uncategorized_category_id")
|
||||||
Discourse.Site.currentProp("uncategorized_category_id")
|
|
||||||
) {
|
) {
|
||||||
category = null;
|
category = null;
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,14 @@ import {
|
|||||||
customNavItemHref
|
customNavItemHref
|
||||||
} from "discourse/models/nav-item";
|
} from "discourse/models/nav-item";
|
||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
|
import Site from "discourse/models/site";
|
||||||
|
|
||||||
if (customNavItemHref) {
|
if (customNavItemHref) {
|
||||||
customNavItemHref(function(navItem) {
|
customNavItemHref(function(navItem) {
|
||||||
if (navItem.get("tagId")) {
|
if (navItem.get("tagId")) {
|
||||||
const name = navItem.get("name");
|
const name = navItem.get("name");
|
||||||
|
|
||||||
if (!Discourse.Site.currentProp("filters").includes(name)) {
|
if (!Site.currentProp("filters").includes(name)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ import { registerUnbound } from "discourse-common/lib/helpers";
|
|||||||
import { isRTL } from "discourse/lib/text-direction";
|
import { isRTL } from "discourse/lib/text-direction";
|
||||||
import { iconHTML } from "discourse-common/lib/icon-library";
|
import { iconHTML } from "discourse-common/lib/icon-library";
|
||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
|
import Site from "discourse/models/site";
|
||||||
|
|
||||||
let escapeExpression = Handlebars.Utils.escapeExpression;
|
let escapeExpression = Handlebars.Utils.escapeExpression;
|
||||||
let _renderer = defaultCategoryLinkRenderer;
|
let _renderer = defaultCategoryLinkRenderer;
|
||||||
@ -32,8 +33,7 @@ export function categoryBadgeHTML(category, opts) {
|
|||||||
if (
|
if (
|
||||||
!category ||
|
!category ||
|
||||||
(!opts.allowUncategorized &&
|
(!opts.allowUncategorized &&
|
||||||
get(category, "id") ===
|
get(category, "id") === Site.currentProp("uncategorized_category_id") &&
|
||||||
Discourse.Site.currentProp("uncategorized_category_id") &&
|
|
||||||
Discourse.SiteSettings.suppress_uncategorized_badge)
|
Discourse.SiteSettings.suppress_uncategorized_badge)
|
||||||
)
|
)
|
||||||
return "";
|
return "";
|
||||||
|
@ -3,6 +3,7 @@ import pageVisible from "discourse/lib/page-visible";
|
|||||||
import logout from "discourse/lib/logout";
|
import logout from "discourse/lib/logout";
|
||||||
import Session from "discourse/models/session";
|
import Session from "discourse/models/session";
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
|
import Site from "discourse/models/site";
|
||||||
|
|
||||||
let _trackView = false;
|
let _trackView = false;
|
||||||
let _transientHeader = null;
|
let _transientHeader = null;
|
||||||
@ -100,7 +101,7 @@ export function ajax() {
|
|||||||
handleLogoff(xhr);
|
handleLogoff(xhr);
|
||||||
|
|
||||||
run(() => {
|
run(() => {
|
||||||
Discourse.Site.currentProp(
|
Site.currentProp(
|
||||||
"isReadOnly",
|
"isReadOnly",
|
||||||
!!xhr.getResponseHeader("Discourse-Readonly")
|
!!xhr.getResponseHeader("Discourse-Readonly")
|
||||||
);
|
);
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
import { cancel } from "@ember/runloop";
|
import { cancel } from "@ember/runloop";
|
||||||
import { later } from "@ember/runloop";
|
import { later } from "@ember/runloop";
|
||||||
|
import { iconHTML } from "discourse-common/lib/icon-library";
|
||||||
|
import { setCaretPosition, caretPosition } from "discourse/lib/utilities";
|
||||||
|
import Site from "discourse/models/site";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This is a jQuery plugin to support autocompleting values in our text fields.
|
This is a jQuery plugin to support autocompleting values in our text fields.
|
||||||
|
|
||||||
@module $.fn.autocomplete
|
@module $.fn.autocomplete
|
||||||
**/
|
**/
|
||||||
import { iconHTML } from "discourse-common/lib/icon-library";
|
|
||||||
export const CANCELLED_STATUS = "__CANCELLED";
|
|
||||||
import { setCaretPosition, caretPosition } from "discourse/lib/utilities";
|
|
||||||
|
|
||||||
|
export const CANCELLED_STATUS = "__CANCELLED";
|
||||||
const allowedLettersRegex = /[\s\t\[\{\(\/]/;
|
const allowedLettersRegex = /[\s\t\[\{\(\/]/;
|
||||||
|
|
||||||
const keys = {
|
const keys = {
|
||||||
@ -319,7 +321,7 @@ export default function(options) {
|
|||||||
vOffset = BELOW;
|
vOffset = BELOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Discourse.Site.currentProp("mobileView")) {
|
if (Site.currentProp("mobileView")) {
|
||||||
if (me.height() / 2 >= pos.top) {
|
if (me.height() / 2 >= pos.top) {
|
||||||
vOffset = BELOW;
|
vOffset = BELOW;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ import DiscourseURL from "discourse/lib/url";
|
|||||||
import KeyValueStore from "discourse/lib/key-value-store";
|
import KeyValueStore from "discourse/lib/key-value-store";
|
||||||
import { formatUsername } from "discourse/lib/utilities";
|
import { formatUsername } from "discourse/lib/utilities";
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
|
import Site from "discourse/models/site";
|
||||||
|
|
||||||
let primaryTab = false;
|
let primaryTab = false;
|
||||||
let liveEnabled = false;
|
let liveEnabled = false;
|
||||||
@ -213,7 +214,7 @@ function requestPermission() {
|
|||||||
function i18nKey(notification_type) {
|
function i18nKey(notification_type) {
|
||||||
return (
|
return (
|
||||||
"notifications.popup." +
|
"notifications.popup." +
|
||||||
Discourse.Site.current().get("notificationLookup")[notification_type]
|
Site.current().get("notificationLookup")[notification_type]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import Site from "discourse/models/site";
|
||||||
|
|
||||||
let _connectorCache;
|
let _connectorCache;
|
||||||
let _rawConnectorCache;
|
let _rawConnectorCache;
|
||||||
let _extraConnectorClasses = {};
|
let _extraConnectorClasses = {};
|
||||||
@ -22,7 +24,7 @@ const DefaultConnectorClass = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function findOutlets(collection, callback) {
|
function findOutlets(collection, callback) {
|
||||||
const disabledPlugins = Discourse.Site.currentProp("disabled_plugins") || [];
|
const disabledPlugins = Site.currentProp("disabled_plugins") || [];
|
||||||
|
|
||||||
Object.keys(collection).forEach(function(res) {
|
Object.keys(collection).forEach(function(res) {
|
||||||
if (res.indexOf("/connectors/") !== -1) {
|
if (res.indexOf("/connectors/") !== -1) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { defaultHomepage } from "discourse/lib/utilities";
|
import { defaultHomepage } from "discourse/lib/utilities";
|
||||||
import { rewritePath } from "discourse/lib/url";
|
import { rewritePath } from "discourse/lib/url";
|
||||||
import ENV from "discourse-common/config/environment";
|
import ENV from "discourse-common/config/environment";
|
||||||
|
import Site from "discourse/models/site";
|
||||||
|
|
||||||
const rootURL = Discourse.BaseUri;
|
const rootURL = Discourse.BaseUri;
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ class RouteNode {
|
|||||||
this.children = [];
|
this.children = [];
|
||||||
this.childrenByName = {};
|
this.childrenByName = {};
|
||||||
this.paths = {};
|
this.paths = {};
|
||||||
this.site = Discourse.Site.current();
|
this.site = Site.current();
|
||||||
|
|
||||||
if (!opts.path) {
|
if (!opts.path) {
|
||||||
opts.path = name;
|
opts.path = name;
|
||||||
|
@ -19,6 +19,7 @@ import { propertyNotEqual } from "discourse/lib/computed";
|
|||||||
import { throttle } from "@ember/runloop";
|
import { throttle } from "@ember/runloop";
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
import { set } from "@ember/object";
|
import { set } from "@ember/object";
|
||||||
|
import Site from "discourse/models/site";
|
||||||
|
|
||||||
// The actions the composer can take
|
// The actions the composer can take
|
||||||
export const CREATE_TOPIC = "createTopic",
|
export const CREATE_TOPIC = "createTopic",
|
||||||
@ -1146,7 +1147,7 @@ Composer.reopenClass({
|
|||||||
create(args) {
|
create(args) {
|
||||||
args = args || {};
|
args = args || {};
|
||||||
args.user = args.user || Discourse.User.current();
|
args.user = args.user || Discourse.User.current();
|
||||||
args.site = args.site || Discourse.Site.current();
|
args.site = args.site || Site.current();
|
||||||
args.siteSettings = args.siteSettings || Discourse.SiteSettings;
|
args.siteSettings = args.siteSettings || Discourse.SiteSettings;
|
||||||
return this._super(args);
|
return this._super(args);
|
||||||
},
|
},
|
||||||
|
@ -3,6 +3,7 @@ import EmberObject from "@ember/object";
|
|||||||
import { updateCsrfToken } from "discourse/lib/ajax";
|
import { updateCsrfToken } from "discourse/lib/ajax";
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
import Session from "discourse/models/session";
|
import Session from "discourse/models/session";
|
||||||
|
import Site from "discourse/models/site";
|
||||||
|
|
||||||
const LoginMethod = EmberObject.extend({
|
const LoginMethod = EmberObject.extend({
|
||||||
@discourseComputed
|
@discourseComputed
|
||||||
@ -70,7 +71,7 @@ export function findAll() {
|
|||||||
|
|
||||||
methods = [];
|
methods = [];
|
||||||
|
|
||||||
Discourse.Site.currentProp("auth_providers").forEach(provider =>
|
Site.currentProp("auth_providers").forEach(provider =>
|
||||||
methods.pushObject(LoginMethod.create(provider))
|
methods.pushObject(LoginMethod.create(provider))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ import { emojiUnescape } from "discourse/lib/text";
|
|||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
||||||
import deprecated from "discourse-common/lib/deprecated";
|
import deprecated from "discourse-common/lib/deprecated";
|
||||||
|
import Site from "discourse/models/site";
|
||||||
|
|
||||||
const NavItem = EmberObject.extend({
|
const NavItem = EmberObject.extend({
|
||||||
@discourseComputed("name")
|
@discourseComputed("name")
|
||||||
@ -18,7 +19,7 @@ const NavItem = EmberObject.extend({
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
name === "latest" &&
|
name === "latest" &&
|
||||||
(!Discourse.Site.currentProp("mobileView") || this.tagId !== undefined)
|
(!Site.currentProp("mobileView") || this.tagId !== undefined)
|
||||||
) {
|
) {
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
@ -106,13 +107,12 @@ NavItem.reopenClass({
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
anonymous &&
|
anonymous &&
|
||||||
!Discourse.Site.currentProp("anonymous_top_menu_items").includes(testName)
|
!Site.currentProp("anonymous_top_menu_items").includes(testName)
|
||||||
)
|
)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (!Category.list() && testName === "categories") return null;
|
if (!Category.list() && testName === "categories") return null;
|
||||||
if (!Discourse.Site.currentProp("top_menu_items").includes(testName))
|
if (!Site.currentProp("top_menu_items").includes(testName)) return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
var args = { name: text, hasIcon: text === "unread" };
|
var args = { name: text, hasIcon: text === "unread" };
|
||||||
if (opts.category) {
|
if (opts.category) {
|
||||||
|
@ -14,6 +14,7 @@ import { cookAsync } from "discourse/lib/text";
|
|||||||
import { userPath } from "discourse/lib/url";
|
import { userPath } from "discourse/lib/url";
|
||||||
import Composer from "discourse/models/composer";
|
import Composer from "discourse/models/composer";
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
|
import Site from "discourse/models/site";
|
||||||
|
|
||||||
const Post = RestModel.extend({
|
const Post = RestModel.extend({
|
||||||
// TODO: Remove this once one instantiate all `Discourse.Post` models via the store.
|
// TODO: Remove this once one instantiate all `Discourse.Post` models via the store.
|
||||||
@ -355,7 +356,7 @@ Post.reopenClass({
|
|||||||
|
|
||||||
// this area should be optimized, it is creating way too many objects per post
|
// this area should be optimized, it is creating way too many objects per post
|
||||||
json.actions_summary = json.actions_summary.map(a => {
|
json.actions_summary = json.actions_summary.map(a => {
|
||||||
a.actionType = Discourse.Site.current().postActionTypeById(a.id);
|
a.actionType = Site.current().postActionTypeById(a.id);
|
||||||
a.count = a.count || 0;
|
a.count = a.count || 0;
|
||||||
const actionSummary = ActionSummary.create(a);
|
const actionSummary = ActionSummary.create(a);
|
||||||
lookup[a.actionType.name_key] = actionSummary;
|
lookup[a.actionType.name_key] = actionSummary;
|
||||||
|
@ -9,6 +9,7 @@ import { defaultHomepage } from "discourse/lib/utilities";
|
|||||||
import PreloadStore from "preload-store";
|
import PreloadStore from "preload-store";
|
||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
||||||
|
import Site from "discourse/models/site";
|
||||||
|
|
||||||
function isNew(topic) {
|
function isNew(topic) {
|
||||||
return (
|
return (
|
||||||
@ -145,7 +146,7 @@ const TopicTrackingState = EmberObject.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (filter === defaultHomepage()) {
|
if (filter === defaultHomepage()) {
|
||||||
const suppressed_from_latest_category_ids = Discourse.Site.currentProp(
|
const suppressed_from_latest_category_ids = Site.currentProp(
|
||||||
"suppressed_from_latest_category_ids"
|
"suppressed_from_latest_category_ids"
|
||||||
);
|
);
|
||||||
if (
|
if (
|
||||||
|
@ -21,6 +21,7 @@ import {
|
|||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
import Session from "discourse/models/session";
|
import Session from "discourse/models/session";
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
|
import Site from "discourse/models/site";
|
||||||
|
|
||||||
export function loadTopicView(topic, args) {
|
export function loadTopicView(topic, args) {
|
||||||
const data = _.merge({}, args);
|
const data = _.merge({}, args);
|
||||||
@ -102,7 +103,7 @@ const Topic = RestModel.extend({
|
|||||||
fancyTitle(title) {
|
fancyTitle(title) {
|
||||||
let fancyTitle = censor(
|
let fancyTitle = censor(
|
||||||
emojiUnescape(title || ""),
|
emojiUnescape(title || ""),
|
||||||
Discourse.Site.currentProp("censored_regexp")
|
Site.currentProp("censored_regexp")
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Discourse.SiteSettings.support_mixed_text_direction) {
|
if (Discourse.SiteSettings.support_mixed_text_direction) {
|
||||||
@ -338,7 +339,7 @@ const Topic = RestModel.extend({
|
|||||||
|
|
||||||
@discourseComputed("archetype")
|
@discourseComputed("archetype")
|
||||||
archetypeObject(archetype) {
|
archetypeObject(archetype) {
|
||||||
return Discourse.Site.currentProp("archetypes").findBy("id", archetype);
|
return Site.currentProp("archetypes").findBy("id", archetype);
|
||||||
},
|
},
|
||||||
|
|
||||||
isPrivateMessage: equal("archetype", "private_message"),
|
isPrivateMessage: equal("archetype", "private_message"),
|
||||||
@ -641,7 +642,7 @@ Topic.reopenClass({
|
|||||||
const lookup = EmberObject.create();
|
const lookup = EmberObject.create();
|
||||||
result.actions_summary = result.actions_summary.map(a => {
|
result.actions_summary = result.actions_summary.map(a => {
|
||||||
a.post = result;
|
a.post = result;
|
||||||
a.actionType = Discourse.Site.current().postActionTypeById(a.id);
|
a.actionType = Site.current().postActionTypeById(a.id);
|
||||||
const actionSummary = ActionSummary.create(a);
|
const actionSummary = ActionSummary.create(a);
|
||||||
lookup.set(a.actionType.get("name_key"), actionSummary);
|
lookup.set(a.actionType.get("name_key"), actionSummary);
|
||||||
return actionSummary;
|
return actionSummary;
|
||||||
|
@ -26,6 +26,7 @@ import Category from "discourse/models/category";
|
|||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
import { getProperties } from "@ember/object";
|
import { getProperties } from "@ember/object";
|
||||||
import deprecated from "discourse-common/lib/deprecated";
|
import deprecated from "discourse-common/lib/deprecated";
|
||||||
|
import Site from "discourse/models/site";
|
||||||
|
|
||||||
export const SECOND_FACTOR_METHODS = {
|
export const SECOND_FACTOR_METHODS = {
|
||||||
TOTP: 1,
|
TOTP: 1,
|
||||||
@ -200,7 +201,7 @@ const User = RestModel.extend({
|
|||||||
|
|
||||||
@discourseComputed("trust_level")
|
@discourseComputed("trust_level")
|
||||||
trustLevel(trustLevel) {
|
trustLevel(trustLevel) {
|
||||||
return Discourse.Site.currentProp("trustLevels").findBy(
|
return Site.currentProp("trustLevels").findBy(
|
||||||
"id",
|
"id",
|
||||||
parseInt(trustLevel, 10)
|
parseInt(trustLevel, 10)
|
||||||
);
|
);
|
||||||
|
@ -2,6 +2,7 @@ import buildCategoryRoute from "discourse/routes/build-category-route";
|
|||||||
import buildTopicRoute from "discourse/routes/build-topic-route";
|
import buildTopicRoute from "discourse/routes/build-topic-route";
|
||||||
import DiscoverySortableController from "discourse/controllers/discovery-sortable";
|
import DiscoverySortableController from "discourse/controllers/discovery-sortable";
|
||||||
import TagsShowRoute from "discourse/routes/tags-show";
|
import TagsShowRoute from "discourse/routes/tags-show";
|
||||||
|
import Site from "discourse/models/site";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
after: "inject-discourse-objects",
|
after: "inject-discourse-objects",
|
||||||
@ -19,7 +20,7 @@ export default {
|
|||||||
no_subcategories: true
|
no_subcategories: true
|
||||||
});
|
});
|
||||||
|
|
||||||
const site = Discourse.Site.current();
|
const site = Site.current();
|
||||||
site.get("filters").forEach(filter => {
|
site.get("filters").forEach(filter => {
|
||||||
const filterCapitalized = filter.capitalize();
|
const filterCapitalized = filter.capitalize();
|
||||||
app[
|
app[
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import Site from "discourse/models/site";
|
||||||
|
|
||||||
export default function() {
|
export default function() {
|
||||||
// Error page
|
// Error page
|
||||||
this.route("exception", { path: "/exception" });
|
this.route("exception", { path: "/exception" });
|
||||||
@ -27,7 +29,7 @@ export default function() {
|
|||||||
this.route("topCategory", { path: "/c/:parentSlug/:slug/l/top" });
|
this.route("topCategory", { path: "/c/:parentSlug/:slug/l/top" });
|
||||||
|
|
||||||
// top by periods
|
// top by periods
|
||||||
Discourse.Site.currentProp("periods").forEach(period => {
|
Site.currentProp("periods").forEach(period => {
|
||||||
const top = "top" + period.capitalize();
|
const top = "top" + period.capitalize();
|
||||||
this.route(top, { path: "/top/" + period });
|
this.route(top, { path: "/top/" + period });
|
||||||
this.route(top + "ParentCategory", { path: "/c/:slug/l/top/" + period });
|
this.route(top + "ParentCategory", { path: "/c/:slug/l/top/" + period });
|
||||||
@ -40,7 +42,7 @@ export default function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// filters
|
// filters
|
||||||
Discourse.Site.currentProp("filters").forEach(filter => {
|
Site.currentProp("filters").forEach(filter => {
|
||||||
this.route(filter, { path: "/" + filter });
|
this.route(filter, { path: "/" + filter });
|
||||||
this.route(filter + "ParentCategory", { path: "/c/:slug/l/" + filter });
|
this.route(filter + "ParentCategory", { path: "/c/:slug/l/" + filter });
|
||||||
this.route(filter + "CategoryNone", {
|
this.route(filter + "CategoryNone", {
|
||||||
@ -204,7 +206,7 @@ export default function() {
|
|||||||
path: "/c/:parent_category/:category/:tag_id"
|
path: "/c/:parent_category/:category/:tag_id"
|
||||||
});
|
});
|
||||||
|
|
||||||
Discourse.Site.currentProp("filters").forEach(filter => {
|
Site.currentProp("filters").forEach(filter => {
|
||||||
this.route("show" + filter.capitalize(), {
|
this.route("show" + filter.capitalize(), {
|
||||||
path: "/:tag_id/l/" + filter
|
path: "/:tag_id/l/" + filter
|
||||||
});
|
});
|
||||||
|
@ -3,6 +3,7 @@ import { queryParams } from "discourse/controllers/discovery-sortable";
|
|||||||
import { defaultHomepage } from "discourse/lib/utilities";
|
import { defaultHomepage } from "discourse/lib/utilities";
|
||||||
import Session from "discourse/models/session";
|
import Session from "discourse/models/session";
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
|
import Site from "discourse/models/site";
|
||||||
|
|
||||||
// A helper to build a topic route for a filter
|
// A helper to build a topic route for a filter
|
||||||
function filterQueryParams(params, defaultParams) {
|
function filterQueryParams(params, defaultParams) {
|
||||||
@ -66,7 +67,7 @@ function findTopicList(store, tracking, filter, filterParams, extras) {
|
|||||||
}
|
}
|
||||||
Session.currentProp("topicList", list);
|
Session.currentProp("topicList", list);
|
||||||
if (list.topic_list && list.topic_list.top_tags) {
|
if (list.topic_list && list.topic_list.top_tags) {
|
||||||
Discourse.Site.currentProp("top_tags", list.topic_list.top_tags);
|
Site.currentProp("top_tags", list.topic_list.top_tags);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
});
|
});
|
||||||
|
@ -4,6 +4,8 @@ import DiscourseURL from "discourse/lib/url";
|
|||||||
import { default as discourseComputed } from "discourse-common/utils/decorators";
|
import { default as discourseComputed } from "discourse-common/utils/decorators";
|
||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
import { categoryBadgeHTML } from "discourse/helpers/category-link";
|
import { categoryBadgeHTML } from "discourse/helpers/category-link";
|
||||||
|
import Site from "discourse/models/site";
|
||||||
|
|
||||||
const { isEmpty } = Ember;
|
const { isEmpty } = Ember;
|
||||||
|
|
||||||
export default ComboBoxComponent.extend({
|
export default ComboBoxComponent.extend({
|
||||||
@ -168,10 +170,7 @@ export default ComboBoxComponent.extend({
|
|||||||
|
|
||||||
if (!this.siteSettings.allow_uncategorized_topics) {
|
if (!this.siteSettings.allow_uncategorized_topics) {
|
||||||
results = results.filter(result => {
|
results = results.filter(result => {
|
||||||
return (
|
return result.id !== Site.currentProp("uncategorized_category_id");
|
||||||
result.id !==
|
|
||||||
Discourse.Site.currentProp("uncategorized_category_id")
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user