Skip to content
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

Merged
merged 4 commits into from Jan 6, 2017
Merged

Added static tagcloud plugin. #197

merged 4 commits into from Jan 6, 2017

Conversation

felixfontein
Copy link
Contributor

Allows to create HTML fragments and CSS for tag clouds which can be included in the blog via JavaScript or some post-processing.

@@ -0,0 +1,90 @@
# Renders two tag clouds for tags and one for categories:
# - a small one wiht at most 40 tags;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with*

Copy link
Contributor Author

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)]),
Copy link
Member

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)

Copy link
Contributor Author

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',
Copy link
Member

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)

Copy link
Contributor Author

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):
Copy link
Member

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea.

@Kwpolska
Copy link
Member

Kwpolska commented Jan 6, 2017

Merge at will, the site will (or at least, should) update itself on midnight UTC.

@felixfontein
Copy link
Contributor Author

Ok, thanks!

@felixfontein felixfontein merged commit 68e3f3c into master Jan 6, 2017
@felixfontein felixfontein deleted the static_tagcloud branch January 6, 2017 20:13
@felixfontein
Copy link
Contributor Author

@Kwpolska: it looks like the plugin site didn't update (correctly).

@Kwpolska
Copy link
Member

Kwpolska commented Jan 7, 2017

What went wrong?

@felixfontein
Copy link
Contributor Author

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).

@Kwpolska
Copy link
Member

Kwpolska commented Jan 7, 2017

I can see it, force a reload (Ctrl+Shift+R) and blame our single-page architecture.

@felixfontein
Copy link
Contributor Author

Now both vanished for me...

@Kwpolska
Copy link
Member

Kwpolska commented Jan 7, 2017

Try refreshing the JS file or using incognito mode?

@felixfontein
Copy link
Contributor Author

It's really strange. If I load the JS file via wget or open it in a new tab, I can see sidebar and static_tagcloud in there. But when I check out via inspector what the browser is using on the pages, it uses an old version. Forcing reload or using incognito mode in Chromium (I'm testing both Firefox and Chromium) doesn't help, the same thing is happening there. Also, clearing the cache has the same result, which I find even more strange!

@felixfontein
Copy link
Contributor Author

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.

@felixfontein
Copy link
Contributor Author

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 plugin_data.js.

@Kwpolska
Copy link
Member

Kwpolska commented Jan 7, 2017

I tried nuking that file from cache. I should probably get going on the JS-less version of that site.

@felixfontein
Copy link
Contributor Author

https://github.com/Kwpolska/nikola-plugins-v2 is going to be the JS-less version, right?

@Kwpolska
Copy link
Member

Kwpolska commented Jan 7, 2017

Yes.

@felixfontein
Copy link
Contributor Author

Can I help with that?

@Kwpolska
Copy link
Member

Kwpolska commented Jan 7, 2017

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 v7 from this repo into the root directory.

@felixfontein
Copy link
Contributor Author

Where does it expects the plugin repository to be?

@felixfontein
Copy link
Contributor Author

Ah. I tried that, but now I get an exception. Looks like one of the plugins is missing a Nikola section in the config.

@felixfontein
Copy link
Contributor Author

Actually, that's v7/notebook_shortcode/notebook_shortcode.plugin.

@felixfontein
Copy link
Contributor Author

(And is there a better place to discuss this then here?)

@Kwpolska
Copy link
Member

Kwpolska commented Jan 7, 2017

getnikola/nikola#2482

I fixed notebook_shortcode.plugin.

@felixfontein
Copy link
Contributor Author

Ok, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants