Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: getnikola/plugins
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: fba2e8aef110
Choose a base ref
...
head repository: getnikola/plugins
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9f76c9e03a86
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Jan 6, 2017

  1. Copy the full SHA
    5fbfdb9 View commit details
  2. Copy the full SHA
    c992e34 View commit details
  3. Copy the full SHA
    9f76c9e View commit details
Showing with 8 additions and 17 deletions.
  1. +5 −5 v7/static_tagcloud/conf.py.sample
  2. +2 −5 v7/static_tagcloud/static_tagcloud/__init__.py
  3. +1 −7 v7/static_tagcloud/static_tagcloud/engine.py
10 changes: 5 additions & 5 deletions v7/static_tagcloud/conf.py.sample
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Renders two tag clouds for tags and one for categories:
# - a small one wiht at most 40 tags;
# - a small one with at most 40 tags;
# - a large one with all tags;
# - a large one with all categories.
#
# The generated files are
# - output/tagcloud-LANG.inc
# - output/tagcloud-LANG-large.inc
# - output/catcloud-LANG.inc
# - output/tagcloud-LANG.inc.html
# - output/tagcloud-LANG-large.inc.html
# - output/catcloud-LANG.inc.html
# and
# - output/assets/css/tagcloud-LANG-small.css
# - output/assets/css/tagcloud-LANG-large.css
@@ -20,7 +20,7 @@ RENDER_STATIC_TAGCLOUDS = {

# Filename for the HTML fragment. {0} will be replaced by the
# language.
'filename': 'tagcloud-{0}.inc',
'filename': 'tagcloud-{0}.inc.html',

# The taxonomy type to obtain the classification ("tags")
# from.
7 changes: 2 additions & 5 deletions v7/static_tagcloud/static_tagcloud/__init__.py
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@
'name': 'tc-{0}',
# Filename for the HTML fragment. {0} will be replaced by the
# language.
'filename': 'tagcloud-{0}.inc',
'filename': 'tagcloud-{0}.inc.html',
# The taxonomy type to obtain the classification ("tags")
# from.
'taxonomy_type': 'tag',
@@ -122,14 +122,11 @@ def _prepare_tagcloud(self, lang, config):
taxonomy = self.site.taxonomy_plugins[taxonomy_type]

# Compose list of tags, their post count and links
def acceptor(post):
return True if self.site.config['SHOW_UNTRANSLATED_POSTS'] else post.is_translation_available(lang)

tag_count_url_list = []
for tag in natsort.humansorted(list(posts_per_tag.keys())):
tag_count_url_list.append((
taxonomy.get_classification_friendly_name(tag, lang),
len([post for post in posts_per_tag[tag] if acceptor(post)]),
len([post for post in posts_per_tag[tag] if self.site.config['SHOW_UNTRANSLATED_POSTS'] or post.is_translation_available(lang)]),
self.site.link(taxonomy_type, tag, lang)
))

8 changes: 1 addition & 7 deletions v7/static_tagcloud/static_tagcloud/engine.py
Original file line number Diff line number Diff line change
@@ -129,13 +129,7 @@ def create_tag_cloud_data(tags, max_number_of_levels=10, max_tags=-1, minimal_nu


def _get_hex_color(color):
def myHex(i, digits):
s = hex(i)[2:]
while len(s) < digits:
s = '0' + s
return s

return '#' + ''.join([myHex(int(round(c * 255)), 2) for c in color])
return '#' + ''.join('{:02x}'.format(int(round(c * 255))) for c in color)


def create_tag_cloud_css(tag_cloud_name, level_weights, colors=((0.4, 0.4, 0.4), (1.0, 1.0, 1.0)), background_colors=((0.133, 0.133, 0.133), ), border_colors=((0.2, 0.2, 0.2), ), font_sizes=(6, 20), round_factor=0.6):