plugins icon indicating copy to clipboard operation
plugins copied to clipboard

Surprising behaviour of plugin Medium and Devto (pseudo-boolean post options)

Open JesperDramsch opened this issue 4 years ago • 2 comments

I was a bit confused with the medium and devto plugins (not sure other plugins have this problem).

The documentation says:

At that point your posts with the "devto" metadata set to "yes" or "true" should be published.

But I have a hard time remembering all the keywords, so I set the standard keywords to

medium: False
devto: False

This will lead medium and devto to publish all articles, due to something that I'd say is unintuitive and should be changed to improve usability.

The code says: https://github.com/getnikola/plugins/blob/c9305572359263c719b19dc17bb6770521e08dee/v8/devto/devto_plugin.py#L67 https://github.com/getnikola/plugins/blob/c9305572359263c719b19dc17bb6770521e08dee/v8/medium/medium_plugin.py#L69

since post.meta('devto') is text, it will always be true, regardless of the value it was set. (Pseudo-)Boolean keywords like this should probably have an "off" switch.

Locally, I changed mine to:

to_post = [post for post in posts if post.title() not in devto_titles and (post.meta('devto').lower() in ["yes", "true"])]

I don't know if that's the best way to handle it. Happy to discuss solutions and make a pull request.

JesperDramsch avatar Jan 31 '22 14:01 JesperDramsch

Yeah, basically if it's set to anything it will be "True" ...

That change you made makes sense. Since there are not all that many users of these plugins I think it would be an acceptable thing.

ralsina avatar Jan 31 '22 16:01 ralsina

I could negate the command as

to_post = [post for post in posts if post.title() not in devto_titles and (post.meta('devto').lower() not in ["no", "false"])]

which would minimize surprising behaviour to anyone using it. I'll make a quick PR.

JesperDramsch avatar Jan 31 '22 17:01 JesperDramsch