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) {
let url = "",
category = this.category;
if (category) {
url =
"/c/" +
Category.slugFor(category) +
(this.noSubcategories ? "/none" : "") +
"/l";
url = `/c/${Category.slugFor(category)}/${category.id}${
this.noSubcategories ? "/none" : ""
}/l`;
}
url += "/top/" + period;
return url;
},

View File

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

View File

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

View File

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

View File

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

View File

@ -84,7 +84,7 @@ export default ComboBoxComponent.extend(TagsMixin, {
let url = "/tags";
if (currentCategory) {
url += `/c/${Category.slugFor(currentCategory)}`;
url += `/c/${Category.slugFor(currentCategory)}/${currentCategory.id}`;
}
return Discourse.getURL(`${url}/none`);
@ -162,7 +162,9 @@ export default ComboBoxComponent.extend(TagsMixin, {
url = "/tags";
if (this.currentCategory) {
url += `/c/${Category.slugFor(this.currentCategory)}`;
url += `/c/${Category.slugFor(this.currentCategory)}/${
this.currentCategory.id
}`;
}
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: [
{ 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: [
{ 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: [
{ id: 1, username: "sam", avatar_template: "/images/avatar.png" },
{

View File

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