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_comments plugin. #201

Merged
merged 10 commits into from Jan 8, 2017
Merged

Added static_comments plugin. #201

merged 10 commits into from Jan 8, 2017

Conversation

felixfontein
Copy link
Contributor

A plugin which allows to add static comments which don't require JavaScript. Needs theme support to actually show the comments.

@felixfontein
Copy link
Contributor Author

There seems to be something wrong with the tests @Kwpolska (related to the helloworld plugin)'; I guess this is a result of moving the v6 plugins to the v7 folder.


the content spans the rest of the file.

Most header fields are optional. `compiler` must specify a page compiler which allows to compile a content given as a string to a string; these are currently the restructured text compiler (`rest`), the `ipynb` compiler, and the [WordPress](https://plugins.getnikola.com/#wordpress_compiler) (`wordpress`) compiler. Comments can form a hierarchy; `parent_id` must be the comment ID of the parent comment, or left away if there's no parent.
Copy link
Member

Choose a reason for hiding this comment

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

I’d prefer to add html and markdown. Also, remove ipynb because that’s going too far.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, ipynb is one of the two default plugins providing such a function. Markdown isn't (yet). With html, do you mean "just treat the content as HTML", or do you want the content to be processed by the html page compiler plugin (which also processes shortcodes)?

Copy link
Member

Choose a reason for hiding this comment

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

Comments are meant to be small and simple, they do not need shortcodes, notebooks, or other magic. Just make it basic HTML passthrough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, it should be up to the blog admin to decide which page compiler he/she whats to use for which comments. If for whatever reason they want to use ipynb, they can do so because that plugin supports compiling from a string to a string.

I'll add passthrough support for html.

I can also add such a function to the markdown plugin in Nikola core to enable using markdown as a comment compiler.

Copy link
Member

Choose a reason for hiding this comment

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

Sure, go ahead with markdown.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I just noticed I didn't look at the ipynb plugin close enough. The compile_string function wants a file name, not the content.

_header_regex = re.compile('^\.\. (.*?): (.*)')

def _compile_content(self, compiler_name, content, filename):
"""Compile comment content with """
Copy link
Member

Choose a reason for hiding this comment

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

with what?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

return compiler.compile_string(content)
else:
try:
return compiler.compile_to_string(content) # this is a non-standard function! must not be available with any page compiler!
Copy link
Member

Choose a reason for hiding this comment

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

May not* and who provides compile_to_string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Member

Choose a reason for hiding this comment

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

Who provides compile_to_string and why is that distinct from compile_string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The WordPress compiler provides compile_to_string, while rest and ipynb provide compile_string (though rest doesn't simply return a string, but a tuple).


{% macro add_static_comments(static_comment_list, lang) %}
{%if static_comment_list|length == 0 %}
<div class="no-comments">{{ messages("No comments.", lang) }}</div>
Copy link
Member

Choose a reason for hiding this comment

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

How would that work? Does this plugin require manual messages customization?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it does. I'll mention that in the instructions.

@felixfontein
Copy link
Contributor Author

LGTM. My blogs still compile and produce the same output.

Copy link
Member

@Kwpolska Kwpolska left a comment

Choose a reason for hiding this comment

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

👍 but please don’t merge this yet so I don’t have to fight with merge conflicts.

@felixfontein
Copy link
Contributor Author

Sure, fine for me. Merge whenever you are done.

@Kwpolska Kwpolska merged commit 8586402 into master Jan 8, 2017
@Kwpolska Kwpolska deleted the static_comments branch January 8, 2017 14:24
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