pyvec / naucse.python.cz

Website with learning materials / Stránka s učebními materiály
https://naucse.python.cz
Other
321 stars 118 forks source link

404 errors for fast-track http #338

Closed hroncok closed 6 years ago

hroncok commented 6 years ago

http://naucse.python.cz/2018/pyknihovny-jaro/intro/requests/ -> a link there goes to http://naucse.python.cz/2018/pyknihovny-jaro/fast-track/http/ :+1: 200 OK

http://naucse.python.cz/course/mi-pyt/intro/requests/ -> a link there goes to http://naucse.python.cz/course/mi-pyt/fast-track/http/ :-1: 404 Not Found

http://naucse.python.cz/2017/mipyt-kam/intro/requests/ -> a link there goes to http://naucse.python.cz/2017/mipyt-kam/fast-track/http/ :-1: 404 Not Found

http://naucse.python.cz/2017/mipyt-zima/intro/requests/ -> a link there goes to http://naucse.python.cz/2017/mipyt-zima/fast-track/http/ :-1: 404 Not Found

IMHO this is related to the way the link is generated from [...](../../fast-track/http/) added in 27f5ce9dd3d5a433bce3e8752c24a7950d2554bf

It is not picked up by the freezer if it's not part of that course/run (that's why the first thing works, because it was added in 1dc4efaab19c0a4971fbf7323e2bdfa4ec574e0f).

This works when not freezing but serving instead. If I examine the HTML, the link there is relative:

<a href="../../fast-track/http/">shrnutí pro začátečníky</a>

It was not converted to url_for, hence not picked up by the freezer.

hroncok commented 6 years ago

I had an impression that relative links are somehow converted (like we did it in https://github.com/pyvec/naucse.python.cz/pull/100 for static files). However, this is apparently not true. All the relative links so far worked only by accident :man_facepalming:

We need to either convert relative links to url_fors or register them to the freezer while doing markdown conversion. Or use lesson_url etc, which makes it ugly.

mikicz commented 6 years ago

Yes, it is related to the way the link is generated from [...](../../fast-track/http/). It should be something like [...]({{ lesson_url('fast-track/http') }}).

The relative links work, but only if there's a link to the same URL somewhere else that's generated via lesson_url (or just url_for)

There were only about five relative links in the lessons when I last checked, I think.

hroncok commented 6 years ago

Fun fact: The PR that uncovered this problem adds the following to Flask lecture:

https://github.com/pyvec/naucse.python.cz/pull/337/files#diff-2463deae0fb1d109ac8d9c868773c2e0R186 https://github.com/pyvec/naucse.python.cz/pull/337/files#diff-2463deae0fb1d109ac8d9c868773c2e0R188

encukou commented 6 years ago

Oh dear. Sorry for breaking things :( Thanks for the PR solving the immediate issue. I filed https://github.com/pyvec/naucse.python.cz/issues/341 so I remember to think about this more later.