Skip to content

Commit

Permalink
Renamed static_tagcloud to static_tag_cloud. Fixes #199.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Jan 7, 2017
1 parent 76e4828 commit 7843b51
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
File renamed without changes.
Expand Up @@ -12,7 +12,7 @@
# - output/assets/css/tagcloud-LANG-large.css # - output/assets/css/tagcloud-LANG-large.css
# - output/assets/css/catcloud-LANG-large.css # - output/assets/css/catcloud-LANG-large.css


RENDER_STATIC_TAGCLOUDS = { RENDER_STATIC_TAG_CLOUDS = {
'tag-small': { 'tag-small': {
# Tag cloud's name (used as CSS class). {0} will be replaced # Tag cloud's name (used as CSS class). {0} will be replaced
# by the language. # by the language.
Expand Down
@@ -1,6 +1,6 @@
[Core] [Core]
Name = render_static_tagcloud Name = render_static_tag_cloud
Module = static_tagcloud Module = static_tag_cloud


[Documentation] [Documentation]
Author = Felix Fontein Author = Felix Fontein
Expand Down
Expand Up @@ -34,7 +34,7 @@
import natsort import natsort
import os import os


_LOGGER = utils.get_logger('render_static_tagcloud', utils.STDERR_HANDLER) _LOGGER = utils.get_logger('render_static_tag_cloud', utils.STDERR_HANDLER)




_DEFAULT_CONFIG = { _DEFAULT_CONFIG = {
Expand Down Expand Up @@ -79,9 +79,9 @@
class StaticTagCloud(Task): class StaticTagCloud(Task):
"""Render tag clouds for various taxonomies.""" """Render tag clouds for various taxonomies."""


name = "render_static_tagcloud" name = "render_static_tag_cloud"


def _render_tagcloud_html(self, fn, tags, level_weights, config, lang, url_type): def _render_tag_cloud_html(self, fn, tags, level_weights, config, lang, url_type):
"""Create tag cloud HTML fragment.""" """Create tag cloud HTML fragment."""
assert fn.startswith(self.site.config["OUTPUT_FOLDER"]) assert fn.startswith(self.site.config["OUTPUT_FOLDER"])
# Create fragment # Create fragment
Expand All @@ -99,7 +99,7 @@ def _render_tagcloud_html(self, fn, tags, level_weights, config, lang, url_type)
with open(fn, "wb") as html_file: with open(fn, "wb") as html_file:
html_file.write(html) html_file.write(html)


def _render_tagcloud_css(self, css_fn, tags, level_weights, config): def _render_tag_cloud_css(self, css_fn, tags, level_weights, config):
"""Create tag cloud CSS.""" """Create tag cloud CSS."""
assert css_fn.startswith(self.site.config["OUTPUT_FOLDER"]) assert css_fn.startswith(self.site.config["OUTPUT_FOLDER"])


Expand All @@ -112,7 +112,7 @@ def _render_tagcloud_css(self, css_fn, tags, level_weights, config):
with open(css_fn, "wb") as css_file: with open(css_fn, "wb") as css_file:
css_file.write(css.encode('utf-8')) css_file.write(css.encode('utf-8'))


def _prepare_tagcloud(self, lang, config): def _prepare_tag_cloud(self, lang, config):
"""Create tag cloud task.""" """Create tag cloud task."""
# Collect information # Collect information
fn = os.path.join(self.site.config['OUTPUT_FOLDER'], config['filename']) fn = os.path.join(self.site.config['OUTPUT_FOLDER'], config['filename'])
Expand Down Expand Up @@ -143,19 +143,19 @@ def _prepare_tagcloud(self, lang, config):
'basename': self.name, 'basename': self.name,
'name': fn, 'name': fn,
'targets': [fn], 'targets': [fn],
'actions': [(self._render_tagcloud_html, [fn, tags, level_weights, config, lang, url_type])], 'actions': [(self._render_tag_cloud_html, [fn, tags, level_weights, config, lang, url_type])],
'clean': True, 'clean': True,
'uptodate': [utils.config_changed({1: tags, 2: level_weights}, 'nikola.plugins.render_tagcloud:tags'), utils.config_changed(config, 'nikola.plugins.render_tagcloud:config')] 'uptodate': [utils.config_changed({1: tags, 2: level_weights}, 'nikola.plugins.render_tag_cloud:tags'), utils.config_changed(config, 'nikola.plugins.render_tag_cloud:config')]
} }
yield utils.apply_filters(task, self.site.config["FILTERS"]) yield utils.apply_filters(task, self.site.config["FILTERS"])
# Create task for CSS # Create task for CSS
task = { task = {
'basename': self.name, 'basename': self.name,
'name': css_fn, 'name': css_fn,
'targets': [css_fn], 'targets': [css_fn],
'actions': [(self._render_tagcloud_css, [css_fn, tags, level_weights, config])], 'actions': [(self._render_tag_cloud_css, [css_fn, tags, level_weights, config])],
'clean': True, 'clean': True,
'uptodate': [utils.config_changed({1: tags, 2: level_weights}, 'nikola.plugins.render_tagcloud:tags'), utils.config_changed(config, 'nikola.plugins.render_tagcloud:config')] 'uptodate': [utils.config_changed({1: tags, 2: level_weights}, 'nikola.plugins.render_tag_cloud:tags'), utils.config_changed(config, 'nikola.plugins.render_tag_cloud:config')]
} }
yield utils.apply_filters(task, self.site.config["FILTERS"]) yield utils.apply_filters(task, self.site.config["FILTERS"])


Expand All @@ -165,7 +165,7 @@ def gen_tasks(self):
yield self.group_task() yield self.group_task()


# Create tag clouds # Create tag clouds
for name, config in self.site.config['RENDER_STATIC_TAGCLOUDS'].items(): for name, config in self.site.config['RENDER_STATIC_TAG_CLOUDS'].items():
try: try:
# Generic complete config # Generic complete config
generic_config = _DEFAULT_CONFIG.copy() generic_config = _DEFAULT_CONFIG.copy()
Expand All @@ -178,7 +178,7 @@ def gen_tasks(self):
config['filename'] = config['filename'].format(lang) config['filename'] = config['filename'].format(lang)
config['style_filename'] = config['style_filename'].format(lang) config['style_filename'] = config['style_filename'].format(lang)
# Generate tasks # Generate tasks
yield self._prepare_tagcloud(lang, config) yield self._prepare_tag_cloud(lang, config)
except Exception as e: except Exception as e:
_LOGGER.error("Error occured while creating tag cloud '{0}': {1}".format(name, e)) _LOGGER.error("Error occured while creating tag cloud '{0}': {1}".format(name, e))
raise e raise e

0 comments on commit 7843b51

Please sign in to comment.