Skip to content

Commit

Permalink
Add section path #2738 (#2746)
Browse files Browse the repository at this point in the history
* PR for #2738 - add in a section path for controlling output location

fixes #2738
  • Loading branch information
h4ckninja authored and Kwpolska committed May 8, 2017
1 parent 5b91084 commit 0c77090
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS.txt
Expand Up @@ -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>`_
2 changes: 2 additions & 0 deletions CHANGES.txt
Expand Up @@ -13,6 +13,8 @@ Math support changes
Features
--------

* Add ``SECTION_PATH`` support to move the section indexes to a
user-defined location (Issue #2738)
* Add a list of template variables to documentation (Issues #2328,
#2712, #2259) and update the theming reference (Issue #2259)
* Add ``{post_title}`` tag for Read More links (Issue #2709)
Expand Down
6 changes: 6 additions & 0 deletions nikola/conf.py.in
Expand Up @@ -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 / SECTION_NAME / rss.xml (RSS feed for a section)
# (translatable)
# SECTION_PATH = ""

# Each post and section page will have an associated color that can be used
# to style them with a recognizable color detail across your site. A color
# is assigned to each section based on shifting the hue of your THEME_COLOR
Expand Down
2 changes: 2 additions & 0 deletions nikola/nikola.py
Expand Up @@ -584,6 +584,7 @@ def __init__(self, **config):
'SOCIAL_BUTTONS_CODE': '',
'SITE_URL': 'https://example.com/',
'PAGE_INDEX': False,
'SECTION_PATH': '',
'STRIP_INDEXES': False,
'SITEMAP_INCLUDE_FILELESS_DIRS': True,
'TAG_PATH': 'categories',
Expand Down Expand Up @@ -673,6 +674,7 @@ def __init__(self, **config):
'TAGS_INDEX_PATH',
'CATEGORY_PATH',
'CATEGORIES_INDEX_PATH',
'SECTION_PATH',
'INDEX_PATH',
'RSS_PATH',
'AUTHOR_PATH',
Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/task/sections.py
Expand Up @@ -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'](lang), section] if _f]
if dest_type == 'rss':
return result + ['rss.xml'], 'never'
return result, 'always'
Expand Down

0 comments on commit 0c77090

Please sign in to comment.