-
Notifications
You must be signed in to change notification settings - Fork 964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A Fix for the permalinks in #1136 #1142
Conversation
The test failures seem legit? |
they were, I had forgotten to run the entire test suite rather than just the ones for the taxonomy, that's my bad. The point is that the taxonomy names now get saved slightly differently to detect the collisions where necessary. The only change necessary was to add |
Can you do a separate PR with some failing tests for the permalinks? I can have a look as well. |
…erged (#1136) reimplement taxonomy deduping
I think I found a solution that works and doesn't require moddifications to the templates to pass all tests. If you're happy about the changes I'll try and clean up the history before you merge the request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ok to me. Do you think there are enough tests covering that or should we add more?
@@ -121,8 +138,23 @@ impl Taxonomy { | |||
for (name, pages) in items { | |||
sorted_items.push(TaxonomyItem::new(&name, &kind, config, pages, library)); | |||
} | |||
sorted_items.sort_by(|a, b| a.name.cmp(&b.name)); | |||
// make sure we have stabel sorting when slugs are equal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you mean that you prefer the original bit since that is already stable, which is fine, I'll revert it when I make the change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edit, sorry I just realised sorting by slug first is actually necessary since the deduping otherwise fails. Tests fail with the original sorting
Thanks for the feedback. I added tests for all cases that I could think of that would result in the same permalink (added whitespace, inconsistent capitalisation and substituting spaces for hyphens) so unless you can think of something on top of that I think it should be okay? The only thing that is perhaps left untested is how this all interacts with Unicode, but I thought that valid URLs are limited to ASCII, so I didn't add anything for that. I don't actually know enough to make a definitive comment on that so I'll defer to your judgement on that |
They get escaped but you can get URL outside of ASCII: https://fr.wikipedia.org/wiki/%C3%89cole (eg École). |
I've added two tests to cover those two cases |
Thanks! |
Code changes
When taking another look at my PR #1136 I noticed that it didn't actually solve the problem because it didn't merge the permalinks properly. apologies for that. I checked that Also, my git fu is not amazing but I've tried to keep the commit history as clean as possible, I hope it's okay like this.
Checklist
next
branch?