Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adding/extending signal handlers.
  • Loading branch information
felixfontein committed Dec 25, 2016
1 parent 6076df5 commit 7318d12
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions nikola/nikola.py
Expand Up @@ -2167,6 +2167,14 @@ def generic_page_renderer(self, lang, post, filters, context=None):
if post:
deps_dict['post_translations'] = post.translated_to

signal('render_post').send({
'site': self,
'post': post,
'lang': lang,
'context': context,
'deps_dict': deps_dict,
})

yield self.generic_renderer(lang, output_name, post.template_name, filters,
file_deps=deps,
uptodate_deps=uptodate_deps,
Expand Down
1 change: 1 addition & 0 deletions nikola/plugins/misc/taxonomies_classifier.py
Expand Up @@ -192,6 +192,7 @@ def create_hierarchy(hierarchy, parent=None, level=0):
taxonomy_outputs[lang][path] = (taxonomy.classification_name, classification, list(posts))
if quit:
sys.exit(1)
blinker.signal('taxonomies_classified').send(site)

def _get_filtered_list(self, taxonomy, classification, lang):
"""Return the filtered list of posts for this classification and language."""
Expand Down
18 changes: 18 additions & 0 deletions nikola/plugins/task/taxonomies.py
Expand Up @@ -27,6 +27,7 @@
"""Render the taxonomy overviews, classification pages and feeds."""

from __future__ import unicode_literals
import blinker
import os
import natsort
from copy import copy
Expand Down Expand Up @@ -118,6 +119,14 @@ def _render_classification_overview(self, classification_name, template, lang, c
if "pagekind" not in context:
context["pagekind"] = ["list", "tags_page"]
output_name = os.path.join(self.site.config['OUTPUT_FOLDER'], self.site.path('{}_index'.format(classification_name), None, lang))
blinker.signal('generate_classification_overview').send({
'site': self.site,
'classification_name': classification_name,
'lang': lang,
'context': context,
'kw': kw,
'output_name': output_name,
})
task = self.site.generic_post_list_renderer(
lang,
[],
Expand Down Expand Up @@ -322,6 +331,15 @@ def _generate_classification_page(self, taxonomy, classification, post_list, lan
kw["index_file"] = self.site.config['INDEX_FILE']
context = copy(context)
context["permalink"] = self.site.link(taxonomy.classification_name, classification, lang)
blinker.signal('generate_classification_page').send({
'site': self.site,
'taxonomy': taxonomy,
'classification': classification,
'lang': lang,
'posts': filtered_posts,
'context': context,
'kw': kw,
})
# Decide what to do
if taxonomy.has_hierarchy and taxonomy.show_list_as_subcategories_list:
# Determine whether there are subcategories
Expand Down
1 change: 1 addition & 0 deletions nikola/post.py
Expand Up @@ -552,6 +552,7 @@ def wrap_encrypt(path, password):
'source': self.translated_source_path(lang),
'dest': dest,
'post': self,
'lang': lang,
})

if self.meta('password'):
Expand Down

0 comments on commit 7318d12

Please sign in to comment.