DEV: Use category ids in URLs preferentially

This commit is contained in:
Daniel Waterworth 2019-11-29 15:47:17 +00:00
parent 9251065768
commit 374534f00e
8 changed files with 20 additions and 18 deletions

View File

@ -23,13 +23,13 @@ export default Controller.extend({
showMoreUrl(period) { showMoreUrl(period) {
let url = "", let url = "",
category = this.category; category = this.category;
if (category) { if (category) {
url = url = `/c/${Category.slugFor(category)}/${category.id}${
"/c/" + this.noSubcategories ? "/none" : ""
Category.slugFor(category) + }/l`;
(this.noSubcategories ? "/none" : "") +
"/l";
} }
url += "/top/" + period; url += "/top/" + period;
return url; return url;
}, },

View File

@ -120,7 +120,7 @@ NavItem.reopenClass({
if (context.category) { if (context.category) {
includesCategoryContext = true; includesCategoryContext = true;
path += `/c/${Category.slugFor(context.category)}`; path += `/c/${Category.slugFor(context.category)}/${context.category.id}`;
if (context.noSubcategories) { if (context.noSubcategories) {
path += "/none"; path += "/none";

View File

@ -102,9 +102,9 @@ export default (filterArg, params) => {
}, },
_retrieveTopicList(category, transition) { _retrieveTopicList(category, transition) {
const listFilter = `c/${Category.slugFor(category)}/l/${this.filter( const listFilter = `c/${Category.slugFor(category)}/${
category category.id
)}`, }/l/${this.filter(category)}`,
findOpts = filterQueryParams(transition.to.queryParams, params), findOpts = filterQueryParams(transition.to.queryParams, params),
extras = { cached: this.isPoppedState(transition) }; extras = { cached: this.isPoppedState(transition) };

View File

@ -69,7 +69,7 @@ export default DiscourseRoute.extend(FilterModeMixin, {
if (category) { if (category) {
category.setupGroupsAndPermissions(); category.setupGroupsAndPermissions();
this.set("category", category); this.set("category", category);
filter = `tags/c/${Category.slugFor(category)}`; filter = `tags/c/${Category.slugFor(category)}/${category.id}`;
if (this.noSubcategories) { if (this.noSubcategories) {
filter += "/none"; filter += "/none";

View File

@ -144,7 +144,7 @@ export default ComboBoxComponent.extend({
} else { } else {
const category = Category.findById(parseInt(categoryId, 10)); const category = Category.findById(parseInt(categoryId, 10));
const slug = Category.slugFor(category); const slug = Category.slugFor(category);
categoryURL = Discourse.getURL("/c/") + slug; categoryURL = Discourse.getURL(`/c/${slug}/${categoryId}`);
} }
DiscourseURL.routeTo(categoryURL); DiscourseURL.routeTo(categoryURL);

View File

@ -84,7 +84,7 @@ export default ComboBoxComponent.extend(TagsMixin, {
let url = "/tags"; let url = "/tags";
if (currentCategory) { if (currentCategory) {
url += `/c/${Category.slugFor(currentCategory)}`; url += `/c/${Category.slugFor(currentCategory)}/${currentCategory.id}`;
} }
return Discourse.getURL(`${url}/none`); return Discourse.getURL(`${url}/none`);
@ -162,7 +162,9 @@ export default ComboBoxComponent.extend(TagsMixin, {
url = "/tags"; url = "/tags";
if (this.currentCategory) { if (this.currentCategory) {
url += `/c/${Category.slugFor(this.currentCategory)}`; url += `/c/${Category.slugFor(this.currentCategory)}/${
this.currentCategory.id
}`;
} }
url = Discourse.getURL(`${url}/${tagId.toLowerCase()}`); url = Discourse.getURL(`${url}/${tagId.toLowerCase()}`);

View File

@ -2683,7 +2683,7 @@ export default {
] ]
} }
}, },
"/c/bug/l/latest.json": { "/c/bug/1/l/latest.json": {
users: [ users: [
{ id: 1, username: "sam", avatar_template: "/images/avatar.png" }, { id: 1, username: "sam", avatar_template: "/images/avatar.png" },
{ {
@ -3863,7 +3863,7 @@ export default {
] ]
} }
}, },
"/c/feature/l/latest.json": { "/c/feature/2/l/latest.json": {
users: [ users: [
{ id: 1, username: "sam", avatar_template: "/images/avatar.png" }, { id: 1, username: "sam", avatar_template: "/images/avatar.png" },
{ {
@ -4935,7 +4935,7 @@ export default {
] ]
} }
}, },
"/c/dev/l/latest.json": { "/c/dev/7/l/latest.json": {
users: [ users: [
{ id: 1, username: "sam", avatar_template: "/images/avatar.png" }, { id: 1, username: "sam", avatar_template: "/images/avatar.png" },
{ {

View File

@ -64,8 +64,8 @@ export default function() {
return response(json); return response(json);
}); });
this.get("/c/bug/l/latest.json", () => { this.get("/c/bug/1/l/latest.json", () => {
const json = fixturesByUrl["/c/bug/l/latest.json"]; const json = fixturesByUrl["/c/bug/1/l/latest.json"];
if (loggedIn()) { if (loggedIn()) {
// Stuff to let us post // Stuff to let us post