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
Conversation
There seems to be something wrong with the tests @Kwpolska (related to the |
|
||
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. |
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.
I’d prefer to add html
and markdown
. Also, remove ipynb
because that’s going too far.
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.
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)?
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.
Comments are meant to be small and simple, they do not need shortcodes, notebooks, or other magic. Just make it basic HTML passthrough.
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.
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.
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.
Sure, go ahead with markdown
.
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.
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 """ |
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 what?
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.
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! |
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.
May not* and who provides compile_to_string?
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.
Fixed.
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.
Who provides compile_to_string and why is that distinct from compile_string
?
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.
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> |
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.
How would that work? Does this plugin require manual messages customization?
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.
Yes, it does. I'll mention that in the instructions.
LGTM. My blogs still compile and produce the same output. |
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.
👍 but please don’t merge this yet so I don’t have to fight with merge conflicts.
Sure, fine for me. Merge whenever you are done. |
A plugin which allows to add static comments which don't require JavaScript. Needs theme support to actually show the comments.