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
Make PAGE_INDEX work with PRETTY_URLS #2705
Conversation
If you replace Also, we shouldn't use |
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
Also simplifies the removal code with str.rstrip() — it’s always index.html. h/t @felixfontein Signed-off-by: Chris Warrick <kwpolska@gmail.com>
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
208188d
to
3230953
Compare
Done. @felixfontein, @ralsina: reviews welcome. I’d like to get this out in a release soon. |
nikola/plugins/task/page_index.py
Outdated
@@ -64,6 +64,8 @@ def is_enabled(self, lang=None): | |||
def classify(self, post, lang): | |||
"""Classify the given post for the given language.""" | |||
destpath = post.destination_path(lang, sep='/') | |||
if post._has_pretty_url(lang): | |||
destpath = destpath.rstrip('/index.html') |
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.
If, for whatever obscure reason, your path happens to be https://example.com/something/index.html/index.html/index.html
, this will not result in what you want ;-)
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.
Actually, rstrip
is not a good idea here at all: it removes all letters from the right of the string which are contained in /index.html
. So also /end/html/nix.html
would be removed, for example.
nikola/plugins/task/page_index.py
Outdated
@@ -64,6 +64,8 @@ def is_enabled(self, lang=None): | |||
def classify(self, post, lang): | |||
"""Classify the given post for the given language.""" | |||
destpath = post.destination_path(lang, sep='/') | |||
if post._has_pretty_url(lang): |
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.
Should we maybe turn this in a version not prefixed by _
?
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.
Can do.
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.
Cool, thanks!
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.
LGTM, except the use of rstrip
.
h/t @felixfontein Signed-off-by: Chris Warrick <kwpolska@gmail.com>
d774e62
to
1731f0c
Compare
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
1731f0c
to
6faa834
Compare
This should end the PAGE_INDEX saga for good. PRETTY_URLS and some corner cases, including
.php
are supported (and I also unearthed a bug in #2706).