Skip to content
Permalink
Browse files

Merge pull request #2024 from getnikola/translatable-PATHS

Make TAG_PATH and CATEGORY_PATH translatable (part of #1914)
  • Loading branch information
Kwpolska committed Sep 5, 2015
2 parents 5964e52 + 4a2039a commit f3f855f9058c313ab94628b36470121e0cd2fbf4
Showing with 22 additions and 14 deletions.
  1. +4 −2 CHANGES.txt
  2. +2 −0 nikola/conf.py.in
  3. +6 −2 nikola/nikola.py
  4. +10 −10 nikola/plugins/task/tags.py
@@ -4,6 +4,8 @@ New in master
Features
--------

* Made TAG_PATH translatable (Issue #1914)
* Made CATEGORY_PATH translatable (Issue #1914)
* Display post counts for archive links (Issue #2011)
* Document link/path handlers (Issue #2008)

@@ -47,8 +49,8 @@ Bugfixes
* Make nikola tabcompletion work outside sites (Issue #1983)
* Fix display of categories list in bootstrap theme (Issue #2002)
* If webassets is not installed, use unbundled assets (Issue #1992)
* Check links in Atom and sitemap files (Issue #1993)
* Link checker should check all absolute URLs to self (Issue #1991)
* Check links in Atom and sitemap files (Issue #1993)
* Link checker should check all absolute URLs to self (Issue #1991)
* Check ``img|source[@srcset]`` as part of ``check -l`` (Issue #1989)
* Clean up translations for third party components
* ``pagekind["main_index"]`` set on the main indexes to differentiate
@@ -271,6 +271,7 @@ POSTS_SECTIONS = True
# output / TRANSLATION[lang] / TAG_PATH / index.html (list of tags)
# output / TRANSLATION[lang] / TAG_PATH / tag.html (list of posts for a tag)
# output / TRANSLATION[lang] / TAG_PATH / tag.xml (RSS feed for a tag)
# (translatable)
# TAG_PATH = "categories"

# If TAG_PAGES_ARE_INDEXES is set to True, each tag's page will contain
@@ -310,6 +311,7 @@ HIDDEN_TAGS = ['mathjax']
# output / TRANSLATION[lang] / CATEGORY_PATH / index.html (list of categories)
# output / TRANSLATION[lang] / CATEGORY_PATH / CATEGORY_PREFIX category.html (list of posts for a category)
# output / TRANSLATION[lang] / CATEGORY_PATH / CATEGORY_PREFIX category.xml (RSS feed for a category)
# (translatable)
# CATEGORY_PATH = "categories"
# CATEGORY_PREFIX = "cat_"

@@ -549,7 +549,11 @@ def __init__(self, **config):
'POSTS_SECTION_NAME',
'POSTS_SECTION_TITLE',
'INDEXES_PAGES',
'INDEXES_PRETTY_PAGE_URL',)
'INDEXES_PRETTY_PAGE_URL',
# PATH options (Issue #1914)
'TAG_PATH',
'CATEGORY_PATH',
)

self._GLOBAL_CONTEXT_TRANSLATABLE = ('blog_author',
'blog_title',
@@ -670,7 +674,7 @@ def __init__(self, **config):
if not self.config.get('COPY_SOURCES'):
self.config['SHOW_SOURCELINK'] = False

if self.config['CATEGORY_PATH'] is None:
if self.config['CATEGORY_PATH']._inp is None:
self.config['CATEGORY_PATH'] = self.config['TAG_PATH']
if self.config['CATEGORY_PAGES_ARE_INDEXES'] is None:
self.config['CATEGORY_PAGES_ARE_INDEXES'] = self.config['TAG_PAGES_ARE_INDEXES']
@@ -401,7 +401,7 @@ def tag_index_path(self, name, lang):
link://tag_index => /tags/index.html
"""
return [_f for _f in [self.site.config['TRANSLATIONS'][lang],
self.site.config['TAG_PATH'],
self.site.config['TAG_PATH'][lang],
self.site.config['INDEX_FILE']] if _f]

def category_index_path(self, name, lang):
@@ -412,7 +412,7 @@ def category_index_path(self, name, lang):
link://category_index => /categories/index.html
"""
return [_f for _f in [self.site.config['TRANSLATIONS'][lang],
self.site.config['CATEGORY_PATH'],
self.site.config['CATEGORY_PATH'][lang],
self.site.config['INDEX_FILE']] if _f]

def tag_path(self, name, lang):
@@ -425,13 +425,13 @@ def tag_path(self, name, lang):
if self.site.config['PRETTY_URLS']:
return [_f for _f in [
self.site.config['TRANSLATIONS'][lang],
self.site.config['TAG_PATH'],
self.site.config['TAG_PATH'][lang],
self.slugify_tag_name(name),
self.site.config['INDEX_FILE']] if _f]
else:
return [_f for _f in [
self.site.config['TRANSLATIONS'][lang],
self.site.config['TAG_PATH'],
self.site.config['TAG_PATH'][lang],
self.slugify_tag_name(name) + ".html"] if _f]

def tag_atom_path(self, name, lang):
@@ -442,7 +442,7 @@ def tag_atom_path(self, name, lang):
link://tag_atom/cats => /tags/cats.atom
"""
return [_f for _f in [self.site.config['TRANSLATIONS'][lang],
self.site.config['TAG_PATH'], self.slugify_tag_name(name) + ".atom"] if
self.site.config['TAG_PATH'][lang], self.slugify_tag_name(name) + ".atom"] if
_f]

def tag_rss_path(self, name, lang):
@@ -453,7 +453,7 @@ def tag_rss_path(self, name, lang):
link://tag_rss/cats => /tags/cats.xml
"""
return [_f for _f in [self.site.config['TRANSLATIONS'][lang],
self.site.config['TAG_PATH'], self.slugify_tag_name(name) + ".xml"] if
self.site.config['TAG_PATH'][lang], self.slugify_tag_name(name) + ".xml"] if
_f]

def slugify_category_name(self, name):
@@ -480,11 +480,11 @@ def category_path(self, name, lang):
"""
if self.site.config['PRETTY_URLS']:
return [_f for _f in [self.site.config['TRANSLATIONS'][lang],
self.site.config['CATEGORY_PATH']] if
self.site.config['CATEGORY_PATH'][lang]] if
_f] + self.slugify_category_name(name) + [self.site.config['INDEX_FILE']]
else:
return [_f for _f in [self.site.config['TRANSLATIONS'][lang],
self.site.config['CATEGORY_PATH']] if
self.site.config['CATEGORY_PATH'][lang]] if
_f] + self._add_extension(self.slugify_category_name(name), ".html")

def category_atom_path(self, name, lang):
@@ -495,7 +495,7 @@ def category_atom_path(self, name, lang):
link://category_atom/dogs => /categories/dogs.atom
"""
return [_f for _f in [self.site.config['TRANSLATIONS'][lang],
self.site.config['CATEGORY_PATH']] if
self.site.config['CATEGORY_PATH'][lang]] if
_f] + self._add_extension(self.slugify_category_name(name), ".atom")

def category_rss_path(self, name, lang):
@@ -506,5 +506,5 @@ def category_rss_path(self, name, lang):
link://category_rss/dogs => /categories/dogs.xml
"""
return [_f for _f in [self.site.config['TRANSLATIONS'][lang],
self.site.config['CATEGORY_PATH']] if
self.site.config['CATEGORY_PATH'][lang]] if
_f] + self._add_extension(self.slugify_category_name(name), ".xml")

0 comments on commit f3f855f

Please sign in to comment.