aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/i18n_subsites/i18n_subsites.py39
-rw-r--r--plugins/i18n_subsites/implementing_language_buttons.rst2
2 files changed, 16 insertions, 25 deletions
diff --git a/plugins/i18n_subsites/i18n_subsites.py b/plugins/i18n_subsites/i18n_subsites.py
index 18481dd..2baec8b 100644
--- a/plugins/i18n_subsites/i18n_subsites.py
+++ b/plugins/i18n_subsites/i18n_subsites.py
@@ -12,10 +12,7 @@ import posixpath
from copy import copy
from itertools import chain
from operator import attrgetter
-try:
- from collections.abc import OrderedDict
-except ImportError:
- from collections import OrderedDict
+from collections import OrderedDict
from contextlib import contextmanager
from six.moves.urllib.parse import urlparse
@@ -25,10 +22,7 @@ import locale
from pelican import signals
from pelican.generators import ArticlesGenerator, PagesGenerator
from pelican.settings import configure_settings
-try:
- from pelican.contents import Draft
-except ImportError:
- from pelican.contents import Article as Draft
+from pelican.contents import Article
# Global vars
@@ -98,8 +92,9 @@ def prepare_site_db_and_overrides():
_MAIN_SETTINGS['CACHE_PATH'], lang)
if 'STATIC_PATHS' not in overrides:
overrides['STATIC_PATHS'] = []
- if ('THEME' not in overrides and 'THEME_STATIC_DIR' not in overrides and
- 'THEME_STATIC_PATHS' not in overrides):
+ if ('THEME' not in overrides and 'THEME_STATIC_DIR'
+ not in overrides and 'THEME_STATIC_PATHS'
+ not in overrides):
relpath = relpath_to_site(lang, _MAIN_LANG)
overrides['THEME_STATIC_DIR'] = posixpath.join(
relpath, _MAIN_SETTINGS['THEME_STATIC_DIR'])
@@ -157,9 +152,9 @@ def save_generator(generator):
def article2draft(article):
- '''Transform an Article to Draft'''
- draft = Draft(article._content, article.metadata, article.settings,
- article.source_path, article._context)
+ '''Set to draft the status of an article'''
+ draft = Article(article._content, article.metadata, article.settings,
+ article.source_path, article._context)
draft.status = 'draft'
return draft
@@ -254,10 +249,8 @@ def filter_contents_translations(generator):
hiding_func = inspector.hiding_function()
untrans_policy = inspector.untranslated_policy(default='hide')
for (contents, other_contents) in inspector.contents_list_pairs():
- # save any hidden native content first
- for content in other_contents:
- # in native lang
- if content.lang == current_lang:
+ for content in other_contents: # save any hidden native content first
+ if content.lang == current_lang: # in native lang
# save the native URL attr formatted in the current locale
_NATIVE_CONTENT_URL_DB[content.source_path] = content.url
# copy for removing in loop
@@ -367,19 +360,17 @@ def interlink_static_files(generator):
return
# minimize attr lookup
try:
- static_content = generator.context['static_content']
+ filenames = generator.context['static_content']
except KeyError:
- static_content = generator.context['filenames']
+ filenames = generator.context['filenames']
+ return # customized STATIC_PATHS
relpath = relpath_to_site(generator.settings['DEFAULT_LANG'], _MAIN_LANG)
for staticfile in _MAIN_STATIC_FILES:
- if staticfile.get_relative_source_path() not in static_content:
+ if staticfile.get_relative_source_path() not in filenames:
# prevent override in main site
staticfile = copy(staticfile)
staticfile.override_url = posixpath.join(relpath, staticfile.url)
- try:
- generator.add_source_path(staticfile, static=True)
- except TypeError:
- generator.add_source_path(staticfile)
+ generator.add_source_path(staticfile)
def save_main_static_files(static_generator):
diff --git a/plugins/i18n_subsites/implementing_language_buttons.rst b/plugins/i18n_subsites/implementing_language_buttons.rst
index 43f8bb3..55b7bf3 100644
--- a/plugins/i18n_subsites/implementing_language_buttons.rst
+++ b/plugins/i18n_subsites/implementing_language_buttons.rst
@@ -39,7 +39,7 @@ with local development when ``SITEURL == ''``.
Language buttons showing all available languages, current is active
...................................................................
-The ``extra_siteurls`` dictionary is a mapping of all languages to the
+The ``lang_subsites`` dictionary is a mapping of all languages to the
``SITEURL`` of the respective (sub-)sites. This template sets the
language of the current (sub-)site as active.