pelican-plugins / series

Series is a Pelican plugin that joins multiple posts into a series
11 stars 4 forks source link

Draft articles break pelican if the series is referenced in the article theme #18

Closed antonmosich closed 2 years ago

antonmosich commented 2 years ago

If you have an article that has both a Series tag as well as the Status: draft set, and the article.html makes use of e.g. article.series.all, pelican will throw an error:

UndefinedError: 'str object' has no attribute 'all'

That happens even though I used the {% if article.series %} that is used in the README. That is mostly a documentation problem in my opinion, as you could just change the template to {% if article.series and article.series.all %} or any variation of that.

lgiordani commented 2 years ago

Anton, thanks for the issue, I will look into it as soon as possible! Have a good day

lgiordani commented 2 years ago

Hi @antonmosich, a question just to clarify the use case. Shall the blog contain only 1 article (the draft one) or is it enough to have one of the articles with that specific combination of features? Thanks

antonmosich commented 2 years ago

It should work with any blog containing an article which is a draft and has a series tag.

lgiordani commented 2 years ago

@antonmosich I'm sorry but I can't reproduce it. I took a series of 5 posts and marked the 5th post with Status: draft. I put in the template the following code

<p>{{ article.series.all }}</p>

and I got the error

[16:29:07] WARNING  Caught exception:                                                                                                                                                                                                                                           log.py:91
                    "'pelican.contents.Article object' has no attribute 'series'".                                                                                                                                                                                                       

which is why I suggested using {% if article.series %}. Can you please provide a minimal reproducible example? Thanks

antonmosich commented 2 years ago

You're right. I couldn't reproduce the issue either, which confuses me a lot, as I had that problem while setting up my blog. Sadly I did not use a VCS while setting that up, so I can't reproduce the state my blog was at while encountering the issue exactly... I don't know the exactly how pelican works internally, could it be that another plugin interfered with series, causing the series tag to be accessible as a string for jinja? I'm sorry. I should've better documented my issue when I had it :(

lgiordani commented 2 years ago

Do not worry! I'm not sure if another plugin might produce that effect. I will test a bit more with a fresh blog and see if I can reproduce the problem.

lgiordani commented 2 years ago

@antonmosich I tried different configurations but wasn't able to reproduce this. For now I will close it, feel free to reopen it if you manage to find the configuration that produces the bug. Thanks!