Skip to content

Commit aa45a68

Browse files
authoredDec 7, 2016
Merge pull request #2584 from getnikola/translatable-url-pathnames
Making INDEX_PATH, RSS_PATH and AUTHOR_PATH translatable
2 parents d743c67 + 8fccc56 commit aa45a68

File tree

7 files changed

+24
-16
lines changed

7 files changed

+24
-16
lines changed
 

‎CHANGES.txt

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Features
3434
have been converted to the new system. (Issue #2107)
3535
* Added ``CATEGORIES_INDEX_PATH``, similar to ``TAGS_INDEX_PATH``.
3636
(Issue #2567)
37+
* Made ``INDEX_PATH``, ``RSS_PATH`` and ``AUTHOR_PATH`` translatable.
38+
(Issue #1914)
3739

3840
New in v7.8.1
3941
=============

‎nikola/conf.py.in

+7-4
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,11 @@ HIDDEN_CATEGORIES = []
385385
# author, author pages are generated.
386386
# ENABLE_AUTHOR_PAGES = True
387387

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

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

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

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

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

466469
# Slug the Tag URL. Easier for users to type, special characters are

‎nikola/nikola.py

+3
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,9 @@ def __init__(self, **config):
657657
'TAGS_INDEX_PATH',
658658
'CATEGORY_PATH',
659659
'CATEGORIES_INDEX_PATH',
660+
'INDEX_PATH',
661+
'RSS_PATH',
662+
'AUTHOR_PATH',
660663
'DATE_FORMAT',
661664
'JS_DATE_FORMAT',
662665
)

‎nikola/plugins/task/authors.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ def get_classification_friendly_name(self, author, lang, only_last_component=Fal
7373

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

7878
def get_path(self, author, lang, dest_type='page'):
7979
"""A path handler for the given classification."""
8080
if self.site.config['SLUG_AUTHOR_PATH']:
8181
slug = utils.slugify(author, lang)
8282
else:
8383
slug = author
84-
return [self.site.config['AUTHOR_PATH'], slug], 'auto'
84+
return [self.site.config['AUTHOR_PATH'](lang), slug], 'auto'
8585

8686
def provide_overview_context_and_uptodate(self, lang):
8787
"""Provide data for the context and the uptodate list for the list of all classifiations."""

‎nikola/plugins/task/categories.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ def get_classification_friendly_name(self, classification, lang, only_last_compo
7777

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

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

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

108108
def extract_hierarchy(self, classification):
109109
"""Given a classification, return a list of parts in the hierarchy."""

‎nikola/plugins/task/indexes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def get_classification_friendly_name(self, classification, lang, only_last_compo
6969
def get_path(self, classification, lang, dest_type='page'):
7070
"""A path handler for the given classification."""
7171
if dest_type == 'rss':
72-
return [self.site.config['RSS_PATH']], True
72+
return [self.site.config['RSS_PATH'](lang)], True
7373
# 'page' (index) or 'feed' (Atom)
7474
page_number = None
7575
if dest_type == 'page':
@@ -78,7 +78,7 @@ def get_path(self, classification, lang, dest_type='page'):
7878
page_number = int(classification)
7979
except:
8080
pass
81-
return [self.site.config['INDEX_PATH']], 'always', page_number
81+
return [self.site.config['INDEX_PATH'](lang)], 'always', page_number
8282

8383
def provide_context_and_uptodate(self, classification, lang, node=None):
8484
"""Provide data for the context and the uptodate list for the list of the given classifiation."""

‎nikola/plugins/task/tags.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ def slugify_tag_name(self, name, lang):
8181

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

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

9595
def provide_overview_context_and_uptodate(self, lang):

0 commit comments

Comments
 (0)
Please sign in to comment.