getnikola / plugins

Extra plugins for Nikola
https://plugins.getnikola.com/
MIT License
59 stars 95 forks source link

[WIP] Conversion plugin for Nikola's #2761: conversion plugin for pre-v8 tag-style metadata #271

Closed felixfontein closed 6 years ago

felixfontein commented 6 years ago

Companions #3068.

felixfontein commented 6 years ago

Ok, first working version.

felixfontein commented 6 years ago

(requires getnikola/nikola#3068 to work)

ralsina commented 6 years ago

+1, not familiar with the section killing, so going with Kw's opinion there.

felixfontein commented 6 years ago

Now the tests also no longer fail, thanks to 42d6e2b38bf01976b44af29480f4e1c09f42c230.

felixfontein commented 6 years ago

@Kwpolska how do you want to proceed with this one?

felixfontein commented 6 years ago

(I guess for a v8 beta, this one should be available.)

Kwpolska commented 6 years ago

Did you test this with YAML or other tricky edge cases?

felixfontein commented 6 years ago

Tags as list work now. What doesn't work are two-file posts, it seems. They don't work, because no extractor is stored for them. get_metadata_from_meta_file simply doesn't return it. Is this intentional?

felixfontein commented 6 years ago

(YAML and TOML work fine, at least outside two-files.)

Kwpolska commented 6 years ago

Fixed on master (getnikola/nikola@c2044a2e)

felixfontein commented 6 years ago

LOL, you were faster. I just pushed a branch for that :)

felixfontein commented 6 years ago

Now two-file posts work as well. METADATA_MAPPING support also seems to work.

felixfontein commented 6 years ago

I think it should be fine now.

Kwpolska commented 6 years ago

There were two bugs I found while fixing chriswarrick.com:

  1. saving as UTF-8 with BOM is evil
  2. posts without translations crash:
Traceback (most recent call last):
  File "/Users/kwpolska/virtualenvs/nikola/lib/python3.6/site-packages/doit/doit_cmd.py", line 172, in run
    return command.parse_execute(args)
  File "/Users/kwpolska/virtualenvs/nikola/lib/python3.6/site-packages/doit/cmd_base.py", line 127, in parse_execute
    return self.execute(params, args)
  File "/Users/kwpolska/git/nikola/nikola/plugin_categories.py", line 147, in execute
    return self._execute(options, args)
  File "/Users/kwpolska/website/plugins/upgrade_metadata_v8/upgrade_metadata_v8.py", line 105, in _execute
    with io.open(fname, "r", encoding="utf-8-sig") as meta_file:
FileNotFoundError: [Errno 2] No such file or directory: 'posts/2017/09/02/spawning-subprocesses-smartly-and-securely.pl.rst'

I fixed both in commit f79b5c5.

felixfontein commented 6 years ago

Ah, that's what -sig is for. I copied the open command from post.py (and changed it from read to write), and forgot to think about the encoding specified there... Sorry for that!

Thanks for fixing this.