fix i18n_subsites with pelican 4.0.0
This commit is contained in:
parent
b49d21c984
commit
08d9b22103
@ -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,8 +152,8 @@ def save_generator(generator):
|
||||
|
||||
|
||||
def article2draft(article):
|
||||
'''Transform an Article to Draft'''
|
||||
draft = Draft(article._content, article.metadata, article.settings,
|
||||
'''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,18 +360,16 @@ 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)
|
||||
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user