aboutsummaryrefslogtreecommitdiffstats
path: root/nikola/plugins/misc/scan_posts.py
diff options
context:
space:
mode:
Diffstat (limited to 'nikola/plugins/misc/scan_posts.py')
-rw-r--r--nikola/plugins/misc/scan_posts.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/nikola/plugins/misc/scan_posts.py b/nikola/plugins/misc/scan_posts.py
index f584a05..8812779 100644
--- a/nikola/plugins/misc/scan_posts.py
+++ b/nikola/plugins/misc/scan_posts.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2016 Roberto Alsina and others.
+# Copyright © 2012-2020 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
@@ -26,7 +26,6 @@
"""The default post scanner."""
-from __future__ import unicode_literals, print_function
import glob
import os
import sys
@@ -35,7 +34,7 @@ from nikola.plugin_categories import PostScanner
from nikola import utils
from nikola.post import Post
-LOGGER = utils.get_logger('scan_posts', utils.STDERR_HANDLER)
+LOGGER = utils.get_logger('scan_posts')
class ScanPosts(PostScanner):
@@ -55,10 +54,10 @@ class ScanPosts(PostScanner):
self.site.config['post_pages']:
if not self.site.quiet:
print(".", end='', file=sys.stderr)
+ destination_translatable = utils.TranslatableSetting('destination', destination, self.site.config['TRANSLATIONS'])
dirname = os.path.dirname(wildcard)
for dirpath, _, _ in os.walk(dirname, followlinks=True):
- dest_dir = os.path.normpath(os.path.join(destination,
- os.path.relpath(dirpath, dirname))) # output/destination/foo/
+ rel_dest_dir = os.path.relpath(dirpath, dirname)
# Get all the untranslated paths
dir_glob = os.path.join(dirpath, os.path.basename(wildcard)) # posts/foo/*.rst
untranslated = glob.glob(dir_glob)
@@ -84,24 +83,30 @@ class ScanPosts(PostScanner):
if not any([x.startswith('.')
for x in p.split(os.sep)])]
- for base_path in full_list:
+ for base_path in sorted(full_list):
if base_path in seen:
continue
- else:
- seen.add(base_path)
try:
post = Post(
base_path,
self.site.config,
- dest_dir,
+ rel_dest_dir,
use_in_feeds,
self.site.MESSAGES,
template_name,
- self.site.get_compiler(base_path)
+ self.site.get_compiler(base_path),
+ destination_base=destination_translatable,
+ metadata_extractors_by=self.site.metadata_extractors_by
)
+ for lang in post.translated_to:
+ seen.add(post.translated_source_path(lang))
timeline.append(post)
- except Exception as err:
+ except Exception:
LOGGER.error('Error reading post {}'.format(base_path))
- raise err
+ raise
return timeline
+
+ def supported_extensions(self):
+ """Return a list of supported file extensions, or None if such a list isn't known beforehand."""
+ return list({os.path.splitext(x[0])[1] for x in self.site.config['post_pages']})