-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added static tagcloud plugin. #197
Conversation
@@ -0,0 +1,90 @@ | |||
# Renders two tag clouds for tags and one for categories: | |||
# - a small one wiht at most 40 tags; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
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)]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can easily replace acceptor
with the inlined logic, which can be simplified to
self.site.config['SHOW_UNTRANSLATED_POSTS'] or post.is_translation_available(lang)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
# Filename for the HTML fragment. {0} will be replaced by the | ||
# language. | ||
'filename': 'tagcloud-{0}.inc', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.inc.html
looks better to me (but feel free to ignore that)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed that.
|
||
|
||
def _get_hex_color(color): | ||
def myHex(i, digits): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String formatting would work better for that, and str.join
can take a generator expression:
def _get_hex_color(color):
return '#' + ''.join('{:02x}'.format(int(round(c * 255))) for c in color)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea.
Merge at will, the site will (or at least, should) update itself on midnight UTC. |
Ok, thanks! |
@Kwpolska: it looks like the plugin site didn't update (correctly). |
What went wrong? |
The page for sidebar (https://plugins.getnikola.com/#sidebar) still has the broken ReST-style link, and the page for static_tagcloud doesn't seem to exist (https://plugins.getnikola.com/#static_tagcloud). |
I can see it, force a reload (Ctrl+Shift+R) and blame our single-page architecture. |
Now both vanished for me... |
Try refreshing the JS file or using incognito mode? |
It's really strange. If I load the JS file via |
Hmm, maybe this is all related to CloudFlare? They seem to convert JavaScript to "rocketscript", and their rocket scripts are doing the actual loading, so this could be completely independent from what the browser is doing. |
I guess I get the content from another CloudFlare server than you do, and the one I get the content from serves an outdated version of |
I tried nuking that file from cache. I should probably get going on the JS-less version of that site. |
https://github.com/Kwpolska/nikola-plugins-v2 is going to be the JS-less version, right? |
Yes. |
Can I help with that? |
Sure, I just invited you to that project. I think there isn’t that much to do, and to run it, you need to copy |
Where does it expects the plugin repository to be? |
Ah. I tried that, but now I get an exception. Looks like one of the plugins is missing a |
Actually, that's |
(And is there a better place to discuss this then here?) |
I fixed |
Ok, thanks! |
Allows to create HTML fragments and CSS for tag clouds which can be included in the blog via JavaScript or some post-processing.