diff --git a/nikola/plugins/misc/taxonomies_classifier.py b/nikola/plugins/misc/taxonomies_classifier.py index 33063fd120..919756396b 100644 --- a/nikola/plugins/misc/taxonomies_classifier.py +++ b/nikola/plugins/misc/taxonomies_classifier.py @@ -160,34 +160,36 @@ def create_hierarchy(hierarchy, parent=None, level=0): for lang in site.config['TRANSLATIONS'].keys(): if not taxonomy.is_enabled(lang): continue - for tlang in site.config['TRANSLATIONS'].keys(): - if lang != tlang: + for classification, posts in site.posts_per_classification[taxonomy.classification_name][lang].items(): + # Do we actually generate this classification page? + filtered_posts = [x for x in posts if self.site.config["SHOW_UNTRANSLATED_POSTS"] or x.is_translation_available(lang)] + generate_list = taxonomy.should_generate_classification_page(classification, filtered_posts, lang) + if not generate_list: continue - for classification, posts in site.posts_per_classification[taxonomy.classification_name][tlang].items(): - # Obtain path as tuple - path = site.path_handlers[taxonomy.classification_name](classification, lang) - # Check that path is OK - for path_element in path: - if len(path_element) == 0: - utils.LOGGER.error("{0} {1} yields invalid path '{2}'!".format(taxonomy.classification_name.title(), classification, '/'.join(path))) - quit = True - # Combine path - path = os.path.join(*[os.path.normpath(p) for p in path if p != '.']) - # Determine collisions - if path in taxonomy_outputs[lang]: - other_classification_name, other_classification, other_posts = taxonomy_outputs[lang][path] - if other_classification_name == taxonomy.classification_name and other_classification == classification: - taxonomy_outputs[lang][path][2].extend(posts) - else: - utils.LOGGER.error('You have classifications that are too similar: {0} "{1}" and {2} "{3}" both result in output path {4} for language {5}.'.format( - taxonomy.classification_name, classification, other_classification_name, other_classification, path, lang)) - utils.LOGGER.error('{0} {1} is used in: {2}'.format( - taxonomy.classification_name.title(), classification, ', '.join(sorted([p.source_path for p in posts])))) - utils.LOGGER.error('{0} {1} is used in: {2}'.format( - other_classification_name.title(), other_classification, ', '.join(sorted([p.source_path for p in other_posts])))) - quit = True + # Obtain path as tuple + path = site.path_handlers[taxonomy.classification_name](classification, lang) + # Check that path is OK + for path_element in path: + if len(path_element) == 0: + utils.LOGGER.error("{0} {1} yields invalid path '{2}'!".format(taxonomy.classification_name.title(), classification, '/'.join(path))) + quit = True + # Combine path + path = os.path.join(*[os.path.normpath(p) for p in path if p != '.']) + # Determine collisions + if path in taxonomy_outputs[lang]: + other_classification_name, other_classification, other_posts = taxonomy_outputs[lang][path] + if other_classification_name == taxonomy.classification_name and other_classification == classification: + taxonomy_outputs[lang][path][2].extend(filtered_posts) else: - taxonomy_outputs[lang][path] = (taxonomy.classification_name, classification, list(posts)) + utils.LOGGER.error('You have classifications that are too similar: {0} "{1}" and {2} "{3}" both result in output path {4} for language {5}.'.format( + taxonomy.classification_name, classification, other_classification_name, other_classification, path, lang)) + utils.LOGGER.error('{0} "{1}" is used in: {2}'.format( + taxonomy.classification_name.title(), classification, ', '.join(sorted([p.source_path for p in filtered_posts])))) + utils.LOGGER.error('{0} "{1}" is used in: {2}'.format( + other_classification_name.title(), other_classification, ', '.join(sorted([p.source_path for p in other_posts])))) + quit = True + else: + taxonomy_outputs[lang][path] = (taxonomy.classification_name, classification, list(posts)) if quit: sys.exit(1) blinker.signal('taxonomies_classified').send(site) diff --git a/nikola/plugins/task/taxonomies.py b/nikola/plugins/task/taxonomies.py index f763f4b903..76424cb463 100644 --- a/nikola/plugins/task/taxonomies.py +++ b/nikola/plugins/task/taxonomies.py @@ -423,13 +423,8 @@ def gen_tasks(self): for taxonomy in self.site.taxonomy_plugins.values(): plpl = {} for lang in self.site.config["TRANSLATIONS"]: - classifications = {} - for tlang, posts_per_classification in self.site.posts_per_classification[taxonomy.classification_name].items(): - if lang != tlang: - continue - classifications.update(posts_per_classification) result = {} - for classification, posts in classifications.items(): + for classification, posts in self.site.posts_per_classification[taxonomy.classification_name][lang].items(): # Filter list filtered_posts = self._filter_list(posts, lang) if len(filtered_posts) == 0 and taxonomy.omit_empty_classifications: