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
Allow plugins to provide metadata #1603
Conversation
@@ -136,6 +136,9 @@ def __init__( | |||
self._dependency_uptodate_page = defaultdict(list) | |||
|
|||
default_metadata, self.newstylemeta = get_meta(self, self.config['FILE_METADATA_REGEXP'], self.config['UNSLUGIFY_TITLES']) | |||
compiler_meta = self.compiler.read_metadata(self, self.config['FILE_METADATA_REGEXP'], self.config['UNSLUGIFY_TITLES']) |
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.
IMO, you should integrate this into get_meta
instead.
Sorry for the time to respond, comment should be addressed. |
So what? |
738080d
to
6cd634c
Compare
No, i just ment that passing self as first argument just felt unnatural to me, I was thus thinking that from inside I've also forgot to push the cleanup commit that remove my debugs, and comments. |
@@ -928,6 +928,8 @@ def get_meta(post, file_metadata_regexp=None, unslugify_titles=False, lang=None) | |||
meta.update(_) | |||
|
|||
if meta: | |||
compiler_meta = post.compiler.read_metadata(post, file_metadata_regexp, unslugify_titles, 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.
why is this still there?
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.
Still ? You asked me to move it in it's in get_meta
which I did. Though get_meta
return in two places, so if the post.compiler.read_metadata
want to have an effect in all casses, I need to call it before each of the return
s. Which explain why the call still appear twice in the diff.
|
Will do. |
I recommend replacing the if not meta:
post.is_two_file = False and then putting the |
This allow plugins to provide a way to extract metadata from file the way they wish to. Metadata will be search first from the default value of as before this PR. Metadata extracted by the plugin will then be merged into the metadata dict, which in turn will be extended by the value in the `.meta` file if present.
Squashed, comment taken into account. |
@@ -374,6 +374,10 @@ They must provide: | |||
If the compiler produces something other than HTML files, it should also implement ``extension`` which | |||
returns the preferred extension for the output file. | |||
|
|||
These plugin can also be used to extract metadata from file. To do so, the |
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.
These plugins*
a dict containing the metadata*
Allow plugins to provide metadata
Code looks good, only needs some typo fixes in the documentation. Will fix myself. Thanks for contributing! |
(PS. I forgot to tell you squashing commits is unnecessary; we don’t really care.) |
Thanks for maintaining Nikola and guiding me through the codebase ! |
This allow plugins to provide a way to extract metadata from file the way
they wish to.
Metadata will be search first from the default value of as before this
PR. Metadata extracted by the plugin will then be merged into the
metadata dict, which in turn will be extended by the value in the
.meta
file if present.See start of discussion from #1602
I tried to get the api to extract metadata by way of plugins, as close as possible as other
get_meta
calls.I also implement this for 1 plugin (
.ipynb
) the one I'm interested in.This should not change current behavior for reading metadata from other places.