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

felixfontein commented Jan 6, 2017

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;

This comment has been minimized.

Copy link
@Kwpolska

Kwpolska Jan 6, 2017

Member

with*

This comment has been minimized.

Copy link
@felixfontein

felixfontein Jan 6, 2017

Author Contributor

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)]),

This comment has been minimized.

Copy link
@Kwpolska

Kwpolska Jan 6, 2017

Member

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)

This comment has been minimized.

Copy link
@felixfontein

felixfontein Jan 6, 2017

Author Contributor

Done.


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

This comment has been minimized.

Copy link
@Kwpolska

Kwpolska Jan 6, 2017

Member

.inc.html looks better to me (but feel free to ignore that)

This comment has been minimized.

Copy link
@felixfontein

felixfontein Jan 6, 2017

Author Contributor

Changed that.



def _get_hex_color(color):
def myHex(i, digits):

This comment has been minimized.

Copy link
@Kwpolska

Kwpolska Jan 6, 2017

Member

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)

This comment has been minimized.

Copy link
@felixfontein

felixfontein Jan 6, 2017

Author Contributor

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

felixfontein commented Jan 6, 2017

Ok, thanks!

@felixfontein felixfontein merged commit 68e3f3c into master Jan 6, 2017
0 of 2 checks passed
0 of 2 checks passed
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/travis-ci/push The Travis CI build is in progress
Details
@felixfontein felixfontein deleted the static_tagcloud branch Jan 6, 2017
@felixfontein
Copy link
Contributor Author

felixfontein commented Jan 7, 2017

@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

felixfontein commented Jan 7, 2017

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

felixfontein commented Jan 7, 2017

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

felixfontein commented Jan 7, 2017

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

felixfontein commented Jan 7, 2017

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

felixfontein commented Jan 7, 2017

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

felixfontein commented Jan 7, 2017

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

felixfontein commented Jan 7, 2017

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

felixfontein commented Jan 7, 2017

Where does it expects the plugin repository to be?

@felixfontein
Copy link
Contributor Author

felixfontein commented Jan 7, 2017

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

felixfontein commented Jan 7, 2017

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

@felixfontein
Copy link
Contributor Author

felixfontein commented Jan 7, 2017

(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

felixfontein commented Jan 7, 2017

Ok, thanks!

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

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.