-
Notifications
You must be signed in to change notification settings - Fork 458
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
Add section path 2738 #2746
Add section path 2738 #2746
Conversation
It looks like your commit was misattributed. Please add the e-mail address you used for this commit to your GitHub profile so your commits will appear as yours. |
nikola/conf.py.in
Outdated
@@ -243,6 +243,12 @@ POSTS_SECTIONS = True | |||
# are the default and will apply GENERATE_ATOM if set. | |||
# POSTS_SECTIONS_ARE_INDEXES = True | |||
|
|||
# Final locations are: | |||
# output / TRANSLATION[lang] / SECTION_PATH / SECTION_NAME / index.html (list of posts for a section) | |||
# output / TRANSLATION[lang] / SECTION_PATH / rss.xml (RSS feed for a section) |
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.
That doesn’t make much sense. Did you mean SECTION_PATH / SECTION_NAME / rss.xml
? (Otherwise, there would be only one RSS file for all sections)
nikola/plugins/task/sections.py
Outdated
@@ -98,7 +98,7 @@ def get_classification_friendly_name(self, section, lang, only_last_component=Fa | |||
|
|||
def get_path(self, section, lang, dest_type='page'): | |||
"""Return a path for the given classification.""" | |||
result = [_f for _f in [section] if _f] | |||
result = [_f for _f in [self.site.config['SECTION_PATH'] + section] if _f] |
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.
Don’t concatenate, make it a list of two elements.
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.
You need to write self.site.config['SECTION_PATH'](lang)
to make it translatable.
You can take a look at tags.py
to see how this could be done correctly:
def get_path(self, classification, lang, dest_type='page'):
"""Return a path for the given classification."""
return [_f for _f in [
self.site.config['TAG_PATH'](lang),
self.slugify_tag_name(classification, lang)] if _f], 'auto'
So it should be:
result = [_f for _f in [self.site.config['SECTION_PATH'](lang), section] if _f]
nikola/conf.py.in
Outdated
# Final locations are: | ||
# output / TRANSLATION[lang] / SECTION_PATH / SECTION_NAME / index.html (list of posts for a section) | ||
# output / TRANSLATION[lang] / SECTION_PATH / rss.xml (RSS feed for a section) | ||
# (translatable) |
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.
SECTION_PATH
is not translatable in your implementation. You need to add it to nikola/nikola.py
, both to the default config and to TRANSLATABLE_SETTINGS
. Then, when you use it, you have to provide the language (see comment below). (Search for TAG_PATH
in nikola.py
to see how it is done.)
nikola/plugins/task/sections.py
Outdated
@@ -98,7 +98,7 @@ def get_classification_friendly_name(self, section, lang, only_last_component=Fa | |||
|
|||
def get_path(self, section, lang, dest_type='page'): | |||
"""Return a path for the given classification.""" | |||
result = [_f for _f in [section] if _f] | |||
result = [_f for _f in [self.site.config['SECTION_PATH'] + section] if _f] |
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.
You need to write self.site.config['SECTION_PATH'](lang)
to make it translatable.
You can take a look at tags.py
to see how this could be done correctly:
def get_path(self, classification, lang, dest_type='page'):
"""Return a path for the given classification."""
return [_f for _f in [
self.site.config['TAG_PATH'](lang),
self.slugify_tag_name(classification, lang)] if _f], 'auto'
So it should be:
result = [_f for _f in [self.site.config['SECTION_PATH'](lang), section] if _f]
Also, you need to update |
Weird, I had that fixed at one point. But should be fixed now. Thanks.
I didn't because it was such a minor change, but okay.
Yes, that was a typo. I'll fix that. |
If you'd fix a typo or a small bug, it might be too minor, but this is a new feature after all, even if somewhat minor :) |
Okay, I believe I've addressed the comments. |
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!
LGTM too! |
@@ -120,3 +120,4 @@ | |||
* `Yaşar Arabacı <https://github.com/yasar11732>`_ | |||
* `Zhaojun Meng <https://github.com/zhaojunmeng>`_ | |||
* `小明 <https://github.com/dongweiming>`_ | |||
* `h4ckninja <https://github.com/h4ckninja>`_ |
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.
Ok, one little thing: you should put yourself at the correct (alphabetically sorted) place ;-) But we (or at least Kwpolska) can do that during merging.
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.
Fixed that.
Thanks for contributing to Nikola! 🎉 |
Pull Request Checklist
Description
Fixes #2738.