meeb / django-distill

Minimal configuration static site generator for Django
MIT License
441 stars 35 forks source link

Workaround for a possible bug when rendering URLs with parameters #59

Closed FranckBoyer closed 2 years ago

FranckBoyer commented 2 years ago

Suppose you have the following URL pattern in the urls.py distill_path('blog/<int:pk>/', detail_view, distill_func=lambda : [1,2]) I suppose that the distill-local command should create two different files blog/1/index.html and blog/2/index.html but this is not the case.

It simply overwrites the file blog/1/index.html for each value of the pk :

Rendering page: blog/1/index.html -> /home/fboyer/temp/test_distill/output/blog/1/index.html ["text/html; charset=utf-8", 63 bytes]  (renamed from "/blog/1/")
Rendering page: blog/1/index.html -> /home/fboyer/temp/test_distill/output/blog/1/index.html ["text/html; charset=utf-8", 64 bytes]  (renamed from "/blog/2/")

With the PR I propose it seems to work the way it should :

Rendering page: blog/1/index.html -> /home/fboyer/temp/test_distill/output/blog/1/index.html ["text/html; charset=utf-8", 63 bytes]  (renamed from "/blog/1/")
Rendering page: blog/2/index.html -> /home/fboyer/temp/test_distill/output/blog/2/index.html ["text/html; charset=utf-8", 64 bytes]  (renamed from "/blog/2/")

Thanks for this very nice package !

meeb commented 2 years ago

Thanks! This does certainly look like a bug so nice catch. I'm going to write a test to catch this before merging your PR so it doesn't regress in the future.

meeb commented 2 years ago

Thanks, all looks good. Merged in and I'll bundle this into the next release.

imbev commented 1 month ago

@meeb This bug has regressed.

https://quay.io/repository/heliumos/website/build/bba0dd5b-2224-4598-9759-2222f40095d4

Rendering page: blog/post/heliumos-v9-alpha-is-available-for-downlaod/index.html -> /build/dist/blog/post/heliumos-v9-alpha-is-available-for-downlaod/index.html ["text/html; charset=utf-8", 8604 bytes] (renamed from "/blog/post/heliumos-v9-alpha-is-available-for-downlaod/")

Rendering page: blog/post/heliumos-v9-alpha-is-available-for-downlaod/index.html -> /build/dist/blog/post/heliumos-v9-alpha-is-available-for-downlaod/index.html ["text/html; charset=utf-8", 9910 bytes] (renamed from "/blog/post/this-month-in-heliumos-august-2024/")

This is under the "make build" step of the CI build.

imbev commented 1 month ago

The bug is present in 3.0.0 but not 2.10.2

meeb commented 1 month ago

Thanks I'll take a look at what changes impacted this. Does your original example trigger this again?

Edit: your quay.io link requires authentication to see the content.

Edit edit: you've typo'd "downlaod" in your blog post URL :)

imbev commented 1 month ago

Here's another link to the logs: https://privatebin.net/?d8fa26309e96ba99#Bhqr2Qh4A4z2hWzg1r7hjyT7DCeY5AukLzQR5GDum1wf

You can reproduce by building the Containerfile at this commit https://codeberg.org/HeliumOS/website/src/commit/43d23d5bcbd23b65dc56a930dacb22f400678130

My latest commit uses 2.10.2 and works, but django-distill is pinned to 3.0.0 in this commit.

you've typo'd "downlaod" in your blog post URL :)

I corrected the title, but I had already shared links with "downlaod" in the url. Thank you :)

meeb commented 1 month ago

Before I spend any time debugging this, 3.0.0 is over 2 years old. Can you try the latest 3.2.7 release?

imbev commented 1 month ago

It is not present with 3.2.7

I'm sorry for the false alarm.

meeb commented 1 month ago

No problem!