Skip to content
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

Making INDEX_PATH, RSS_PATH and AUTHOR_PATH translatable #2584

Merged
merged 4 commits into from
Dec 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Features
have been converted to the new system. (Issue #2107)
* Added ``CATEGORIES_INDEX_PATH``, similar to ``TAGS_INDEX_PATH``.
(Issue #2567)
* Made ``INDEX_PATH``, ``RSS_PATH`` and ``AUTHOR_PATH`` translatable.
(Issue #1914)

New in v7.8.1
=============
Expand Down
11 changes: 7 additions & 4 deletions nikola/conf.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,11 @@ HIDDEN_CATEGORIES = []
# author, author pages are generated.
# ENABLE_AUTHOR_PAGES = True

# Final locations are:
# output / TRANSLATION[lang] / AUTHOR_PATH / index.html (list of tags)
# output / TRANSLATION[lang] / AUTHOR_PATH / author.html (list of posts for a tag)
# output / TRANSLATION[lang] / AUTHOR_PATH / author.xml (RSS feed for a tag)
# Path to author pages. Final locations are:
# output / TRANSLATION[lang] / AUTHOR_PATH / index.html (list of authors)
# output / TRANSLATION[lang] / AUTHOR_PATH / author.html (list of posts by an author)
# output / TRANSLATION[lang] / AUTHOR_PATH / author.xml (RSS feed for an author)
# (translatable)
# AUTHOR_PATH = "authors"

# If AUTHOR_PAGES_ARE_INDEXES is set to True, each author's page will contain
Expand All @@ -413,6 +414,7 @@ HIDDEN_AUTHORS = ['Guest']

# Final location for the main blog page and sibling paginated pages is
# output / TRANSLATION[lang] / INDEX_PATH / index-*.html
# (translatable)
# INDEX_PATH = ""

# Optional HTML that displayed on “main” blog index.html files.
Expand Down Expand Up @@ -461,6 +463,7 @@ USE_BASE_TAG = False

# Final location for the blog main RSS feed is:
# output / TRANSLATION[lang] / RSS_PATH / rss.xml
# (translatable)
# RSS_PATH = ""

# Slug the Tag URL. Easier for users to type, special characters are
Expand Down
3 changes: 3 additions & 0 deletions nikola/nikola.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,9 @@ def __init__(self, **config):
'TAGS_INDEX_PATH',
'CATEGORY_PATH',
'CATEGORIES_INDEX_PATH',
'INDEX_PATH',
'RSS_PATH',
'AUTHOR_PATH',
'DATE_FORMAT',
'JS_DATE_FORMAT',
)
Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/task/authors.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ def get_classification_friendly_name(self, author, lang, only_last_component=Fal

def get_overview_path(self, lang, dest_type='page'):
"""A path handler for the list of all classifications."""
return [self.site.config['AUTHOR_PATH']], 'always'
return [self.site.config['AUTHOR_PATH'](lang)], 'always'

def get_path(self, author, lang, dest_type='page'):
"""A path handler for the given classification."""
if self.site.config['SLUG_AUTHOR_PATH']:
slug = utils.slugify(author, lang)
else:
slug = author
return [self.site.config['AUTHOR_PATH'], slug], 'auto'
return [self.site.config['AUTHOR_PATH'](lang), slug], 'auto'

def provide_overview_context_and_uptodate(self, lang):
"""Provide data for the context and the uptodate list for the list of all classifiations."""
Expand Down
8 changes: 4 additions & 4 deletions nikola/plugins/task/categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ def get_classification_friendly_name(self, classification, lang, only_last_compo

def get_overview_path(self, lang, dest_type='page'):
"""A path handler for the list of all classifications."""
if self.site.config['CATEGORIES_INDEX_PATH'][lang]:
return [_f for _f in [self.site.config['CATEGORIES_INDEX_PATH'][lang]] if _f], 'never'
if self.site.config['CATEGORIES_INDEX_PATH'](lang):
return [_f for _f in [self.site.config['CATEGORIES_INDEX_PATH'](lang)] if _f], 'never'
else:
return [_f for _f in [self.site.config['CATEGORY_PATH'][lang]] if _f], 'always'
return [_f for _f in [self.site.config['CATEGORY_PATH'](lang)] if _f], 'always'

def slugify_tag_name(self, name, lang):
"""Slugify a tag name."""
Expand All @@ -103,7 +103,7 @@ def slugify_category_name(self, path, lang):

def get_path(self, classification, lang, dest_type='page'):
"""A path handler for the given classification."""
return ([_f for _f in [self.site.config['CATEGORY_PATH'][lang]] if _f] + self.slugify_category_name(classification, lang), 'auto')
return ([_f for _f in [self.site.config['CATEGORY_PATH'](lang)] if _f] + self.slugify_category_name(classification, lang), 'auto')

def extract_hierarchy(self, classification):
"""Given a classification, return a list of parts in the hierarchy."""
Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/task/indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def get_classification_friendly_name(self, classification, lang, only_last_compo
def get_path(self, classification, lang, dest_type='page'):
"""A path handler for the given classification."""
if dest_type == 'rss':
return [self.site.config['RSS_PATH']], True
return [self.site.config['RSS_PATH'](lang)], True
# 'page' (index) or 'feed' (Atom)
page_number = None
if dest_type == 'page':
Expand All @@ -78,7 +78,7 @@ def get_path(self, classification, lang, dest_type='page'):
page_number = int(classification)
except:
pass
return [self.site.config['INDEX_PATH']], 'always', page_number
return [self.site.config['INDEX_PATH'](lang)], 'always', page_number

def provide_context_and_uptodate(self, classification, lang, node=None):
"""Provide data for the context and the uptodate list for the list of the given classifiation."""
Expand Down
8 changes: 4 additions & 4 deletions nikola/plugins/task/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ def slugify_tag_name(self, name, lang):

def get_overview_path(self, lang, dest_type='page'):
"""A path handler for the list of all classifications."""
if self.site.config['TAGS_INDEX_PATH'][lang]:
return [_f for _f in [self.site.config['TAGS_INDEX_PATH'][lang]] if _f], 'never'
if self.site.config['TAGS_INDEX_PATH'](lang):
return [_f for _f in [self.site.config['TAGS_INDEX_PATH'](lang)] if _f], 'never'
else:
return [_f for _f in [self.site.config['TAG_PATH'][lang]] if _f], 'always'
return [_f for _f in [self.site.config['TAG_PATH'](lang)] if _f], 'always'

def get_path(self, classification, lang, dest_type='page'):
"""A path handler for the given classification."""
return [_f for _f in [
self.site.config['TAG_PATH'][lang],
self.site.config['TAG_PATH'](lang),
self.slugify_tag_name(classification, lang)] if _f], 'auto'

def provide_overview_context_and_uptodate(self, lang):
Expand Down