nikola icon indicating copy to clipboard operation
nikola copied to clipboard

Add/send a metadata signal.

Open vsajip opened this issue 4 years ago • 3 comments

Pull Request Checklist

  • [X] I’ve read the guidelines for contributing.
  • [ ] I updated AUTHORS.txt and CHANGES.txt (if the change is non-trivial) and documentation (if applicable).
  • [X] I tested my changes.

Description

Send a "metadata" signal to allow interested parties to make additions/changes to the metadata. One example use of this would be to set the "updated" time of a post to the actual modification time of the source file for the post.

vsajip avatar Aug 09 '21 06:08 vsajip

I don’t like the approach of mutating the meta dictionary in a signal. Perhaps a MetadataExtractor plugin would suit your needs better?

In any case, this should be documented in at least extending.rst

Kwpolska avatar Aug 09 '21 18:08 Kwpolska

I don’t like the approach of mutating the meta dictionary in a signal. Perhaps a MetadataExtractor plugin would suit your needs better?

I looked at that approach first. For my specific use case (setting the "updated" metadata for any post to the modification time of the source file) I couldn't see a way of doing it using MetadataExtractor, because extract_filename() is only called with filenames for paths which match FILE_METADATA_REGEXP. Since you can only have one such regexp, using it to match all posts would mean it couldn't be used with e.g. an actual regexp. https://github.com/getnikola/nikola/blob/650b954294ab01627ba9b45d81835293a5e02bb8/nikola/post.py#L1196-L1201

vsajip avatar Aug 09 '21 20:08 vsajip

In any case, this should be documented in at least extending.rst

If this functionality is going to be merged, I will happily update the documentation to cover it.

vsajip avatar Aug 09 '21 20:08 vsajip