Skip to content
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

Slugify Collectives and Pages #1424

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Koc
Copy link
Contributor

@Koc Koc commented Aug 18, 2024

📝 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

  • resolve updater issue
  • update previewer
  • add/fix tests

🏁 Checklist

  • Code is properly formatted (npm run lint / npm run stylelint / composer run cs:check)
  • Sign-off message is added to all commits
  • Tests (unit, integration and/or end-to-end) passing and the changes are covered with tests
  • Documentation (README or documentation) has been updated or is not required

Sorry, something went wrong.

@juliusknorr juliusknorr requested a review from mejo- August 19, 2024 07:15
@juliusknorr juliusknorr added enhancement New feature or request 2. developing labels Aug 19, 2024
@Koc Koc force-pushed the feature/slugify-collectives-and-pages branch 4 times, most recently from 1cc11f7 to e179382 Compare August 19, 2024 23:42
@mejo-
Copy link
Member

mejo- commented Aug 28, 2024

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?

@Koc
Copy link
Contributor Author

Koc commented Aug 30, 2024

@mejo- we have a lot of pages in collectives, so I would like to reduce amount of runtime operations to speedup backend endpoints.

@Koc Koc self-assigned this Sep 1, 2024
@Koc Koc force-pushed the feature/slugify-collectives-and-pages branch 5 times, most recently from 24eca7a to 6eb5ed6 Compare September 1, 2024 15:16
@Koc Koc marked this pull request as ready for review September 1, 2024 15:20
@Koc
Copy link
Contributor Author

Koc commented Sep 1, 2024

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

Copy link
Contributor

github-actions bot commented Sep 2, 2024

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

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.)

@Koc Koc requested review from juliusknorr and skjnldsv September 2, 2024 10:23
@skjnldsv skjnldsv removed their request for review September 3, 2024 07:21
@Koc Koc force-pushed the feature/slugify-collectives-and-pages branch 2 times, most recently from 4941808 to f8372d7 Compare September 11, 2024 23:35
@Koc
Copy link
Contributor Author

Koc commented Sep 11, 2024

@mejo- there is one more reason to persist slug in the database: we can make it editable in upcoming PRs. Sometimes page titles can be long, so we can give possibility to our users shorten them

@Koc Koc force-pushed the feature/slugify-collectives-and-pages branch 2 times, most recently from 4f66821 to 122a2b3 Compare September 28, 2024 00:09
@Koc

This comment was marked as outdated.

@Koc Koc force-pushed the feature/slugify-collectives-and-pages branch 2 times, most recently from c9fd222 to 7d50cb3 Compare October 5, 2024 23:29
@Koc Koc force-pushed the feature/slugify-collectives-and-pages branch 3 times, most recently from 21ca8b9 to 1a4c573 Compare December 20, 2024 14:56
@Koc
Copy link
Contributor Author

Koc commented Dec 20, 2024

hey @mejo- !

It seems like ./occ migrations:migrate collectives works in a different way comparing to ./occ upgrade. Here some interesting scenario:

  1. Truncate all collectives/pages
  2. Create few collectives with few pages. No need to delete anything.
  3. Run ./occ migrations:migrate collectives
  4. Migrations migrated, slugs were successfully generated ✔️
  5. Drop columns/migration records
  6. Bump module version
  7. Run ./occ upgrade 💥 . There an error that collectives folder /myCurrentUserName/files/Collectives/myCollectiveName not exists

It doesn't matter have I removed collectives/pages or not. The fact is the same code works fine with migrations:migrate but not works with upgrade. I've try to debug it but no luck.

That's why I've moved slugs generation into separate console command. So, after upgrade old pages/collectives would have same urls like before.

Details

string(29) "/admin/files/Collectives/aaaa"  <---- exception message with path + collective name

#0 /var/www/html/lib/private/Files/Node/Folder.php(107): OC\Files\Node\Root->get()
#1 /var/www/html/apps/collectives/lib/Service/PageService.php(100): OC\Files\Node\Folder->get() <--- why collective folder not available? Only 1 page was trashed, not whole collective
#2 /var/www/html/apps/collectives/lib/Service/PageService.php(498): OCA\Collectives\Service\PageService->getCollectiveFolder()
#3 /var/www/html/apps/collectives/lib/Migration/Version021500Date20240820000001.php(78): OCA\Collectives\Service\PageService->findAll()
#4 /var/www/html/lib/private/DB/MigrationService.php(522): OCA\Collectives\Migration\Version021500Date20240820000001->postSchemaChange()
#5 /var/www/html/lib/private/DB/MigrationService.php(395): OC\DB\MigrationService->executeStep()
#6 /var/www/html/lib/private/legacy/OC_App.php(694): OC\DB\MigrationService->migrate()
#7 /var/www/html/lib/private/Updater.php(325): OC_App::updateApp()
#8 /var/www/html/lib/private/Updater.php(236): OC\Updater->doAppUpgrade()
#9 /var/www/html/lib/private/Updater.php(100): OC\Updater->doUpgrade()
#10 /var/www/html/core/Command/Upgrade.php(190): OC\Updater->upgrade()
#11 /var/www/html/3rdparty/symfony/console/Command/Command.php(326): OC\Core\Command\Upgrade->execute()
#12 /var/www/html/3rdparty/symfony/console/Application.php(1078): Symfony\Component\Console\Command\Command->run()
#13 /var/www/html/3rdparty/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand()
#14 /var/www/html/3rdparty/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun()
#15 /var/www/html/lib/private/Console/Application.php(187): Symfony\Component\Console\Application->run()
#16 /var/www/html/console.php(87): OC\Console\Application->run()
#17 /var/www/html/occ(11): require_once('...')
#18 {main}

@Koc Koc force-pushed the feature/slugify-collectives-and-pages branch 4 times, most recently from ca439ad to ddcb0c4 Compare December 20, 2024 15:47
@Koc Koc force-pushed the feature/slugify-collectives-and-pages branch 4 times, most recently from f6201fd to 074f66b Compare January 2, 2025 18:25
@Koc
Copy link
Contributor Author

Koc commented Jan 3, 2025

I don't know why cypress is failing with 401: Unauthorized error 😕

@juliusknorr
Copy link
Member

Cypress failures were unrelated, should be fixed after a rebase to latest main by #1623

@Koc
Copy link
Contributor Author

Koc commented Jan 3, 2025

@juliusknorr I've already rebased few times 😄. Mentioned PR fixes Behat tests but not Cypress.

@juliusknorr
Copy link
Member

Ah sorry, seems I mixed up repos and have not pushed a fix for collectives yet. We'll need to adapt nextcloud/text#6819 for this repo as well then

@Koc Koc force-pushed the feature/slugify-collectives-and-pages branch from 1f3e553 to dd350b2 Compare January 3, 2025 17:14
@Koc
Copy link
Contributor Author

Koc commented Jan 3, 2025

@juliusknorr I've opened PR with backport: #1625.

But now there is another error 🤷‍♂️ :

Could not download app contacts

Koc added 2 commits January 4, 2025 00:44

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
…onsole command)

Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
@Koc Koc force-pushed the feature/slugify-collectives-and-pages branch from dd350b2 to 893a5c8 Compare January 3, 2025 23:44
@Koc Koc requested a review from mejo- January 3, 2025 23:45
Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
@Koc Koc force-pushed the feature/slugify-collectives-and-pages branch 5 times, most recently from 8cae6e6 to 408616e Compare January 4, 2025 19:49
Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
@Koc Koc force-pushed the feature/slugify-collectives-and-pages branch from 408616e to dffe309 Compare January 6, 2025 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

None yet

5 participants