Skip to content
Permalink
Browse files

Merge pull request #2584 from getnikola/translatable-url-pathnames

Making INDEX_PATH, RSS_PATH and AUTHOR_PATH translatable
  • Loading branch information
felixfontein committed Dec 7, 2016
2 parents d743c67 + 8fccc56 commit aa45a6811084bc44713dc20e4b44a85232cc4b5b
@@ -34,6 +34,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
=============
@@ -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
@@ -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.
@@ -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
@@ -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',
)
@@ -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."""
@@ -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."""
@@ -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."""
@@ -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':
@@ -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."""
@@ -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):

0 comments on commit aa45a68

Please sign in to comment.
You can’t perform that action at this time.