-
Notifications
You must be signed in to change notification settings - Fork 29
Slugify Collectives and Pages (fork-based) #1424
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
Conversation
1cc11f7 to
e179382
Compare
|
Hey @Koc, thanks for looking into this. Definitely a good idea to slugify collectives and page titles for cleaner URLs. Without looking into all the details, I wonder if we could implement this in a way that doesn't need the sluggified string to be persisted in the database. Why not make calculate the slug of titles/names on demand in the backend and add them as attribute to the collectives and pages in the API responses? Then the frontend could always check for name/title match first and for slug match second. What do you think about this approach? |
|
@mejo- we have a lot of pages in collectives, so I would like to reduce amount of runtime operations to speedup backend endpoints. |
24eca7a to
6eb5ed6
Compare
|
I've achieved some progress. Now it more or less works, we have even redirects if slugs have been renamed. You can observe how it works in the video that attached to PR description |
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
4941808 to
f8372d7
Compare
|
@mejo- there is one more reason to persist |
4f66821 to
122a2b3
Compare
This comment was marked as outdated.
This comment was marked as outdated.
c9fd222 to
7d50cb3
Compare
0a0bb08 to
285f5de
Compare
|
I'm currently looking into the page-links cypress test. I noticed two things: Use of the old page formatWhen clicking a page on the sidebar it opens the old subroute for me: Old paths are not converted to new pathsThe cypress test clicks on a number of links in a document that still have the old format. I think that's a good thing to still have around. When visiting such a link the url stays in the old format leading to a failing assertion. I'm not sure - but I think we should rewrite urls to have the new format on visiting the old format. For one this will hopefully make the test pass... and it will also use the shorter nicer urls more often. |
| return $this->slugger->slug($name)->toString() . '-' . $collectiveId; | ||
| } | ||
|
|
||
| public function generatePageSlug(string $title): string { |
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.
@Koc I don't understand why the collective slug contains the collectiveId and the page slug doesn't contain the pageId.
Looking at the frontend router changes it seems to me that the slug is expected to be separate from the IDs, which makes sense to me. So maybe generateCollectiveSlug() should not add -${collectiveId} either, right?
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.
no, we need ids for both pages and collectives. This is needed because collective/page can be renamed but we want to make it possible content using old URLs.
At the same time I can't remember why we can't store fileId inside slug on BE side (PR was opened almost year ago). I guess it's because of routing stuff - we need to distinguish old and new routes
| this.selectVersion(null) | ||
| const routerParams = this.$router.currentRoute.params | ||
| // If the current page is not the one we are supposed to be on, redirect |
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 have to admit that I don't fully understand the purpose of this code. When is this expected to happen? Is the idea to redirect to the slugified URL when the old URL is opened?
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.
yeah, exactly. The only one thing: it stopped work after one of latest rebases. I'm investigating it
| component: CollectiveView, | ||
| props: (route) => route.params, | ||
| children: [ | ||
| { path: 'page-:pageId(\\d+)-:pageSlug' }, |
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 think it's confusing to use <slug>-<id> for the collective URL part and page-<id>-<slug> for the page URL part. Why not use <slug>-<id> for the page as well?
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.
This was added as a prefix for some edge cases when generated slug/old file path contains digits and dash at the beginning
@Koc seems like the CI job runs into a rate limit of the app store. I wonder whether this is because the base branch for this PR lives in your Github realm and not in |
|
Dear @Koc, do you plan to continue working on this PR in the near future? Or would you prefer us to take over work on it? Both options are perfectly fine for us and there's no urgency or need to rush. I just wanted to check in with you. |
c169728 to
a1706e5
Compare
|
hey @mejo- ! I will try to do next things:
And after that I will disappear 😄 . I don't know how to fix Cypress tests |
Thanks so much @Koc, much appreciated! Let me know when you want us to take over or when you have questions. Don't mind the upgrade app test failures, they're unrelated and will be fixed after the next app release. Regarding creating the slugs initially, I think the best would be to implement a |
Sorry @Koc, I just merged another larger PR that created rebase/merge conflicts for this PR one more time. They should be easy to fix this time though. Maybe you can open a new PR based on a branch in this repo soon, then I can do the manual rebase myself next time 🫣 |
b83f81c to
cda0a23
Compare
Signed-off-by: Kostiantyn Miakshyn <[email protected]>
cda0a23 to
c21559e
Compare
|
So, here we go. I did rebase one more time and fixed few things.
Here reopened PR #1802 created from original Nextcloud repo instead of my own fork. Please don't abandon it 🙏 , I spent really too much time on such functionality cc @mejo- |



📝 Summary
This is a very beginning of my PR to slugify urls for Collectives and Pages. For now urls are too long and hard to understand if using cyrylic in this entities.
Here an example of some of them:
http://localhost/index.php/apps/collectives/%D0%A3%D0%BA%D1%80%D0%B0%D1%97%D0%BD%D1%81%D1%8C%D0%BA%D1%96%20%D1%84%D1%83%D1%82%D0%B1%D0%BE%D0%BB%D1%96%D1%81%D1%82%D0%B8/%D0%AF%D1%80%D0%BC%D0%BE%D0%BB%D0%B5%D0%BD%D0%BA%D0%BE%20%D0%90%D0%BD%D0%B4%D1%80%D1%96%D0%B9%20%D0%9C%D0%B8%D0%BA%D0%BE%D0%BB%D0%B0%D0%B9%D0%BE%D0%B2%D0%B8%D1%87?fileId=187. Just compare it with slugified version:http://localhost/index-php/apps/collectives/ukrayinski-futbolisti-1/page-1-yurchenko-andriy-mykolayovich. Easy to read, 3 times shorter.🖼️ Video
Screencast.from.2024-09-01.17-18-46.webm
🚧 TODO
🏁 Checklist
npm run lint/npm run stylelint/composer run cs:check)