Skip to content
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

series breaks on draft articles #31

Open
mpounsett opened this issue Sep 6, 2023 · 1 comment
Open

series breaks on draft articles #31

mpounsett opened this issue Sep 6, 2023 · 1 comment

Comments

@mpounsett
Copy link

mpounsett commented Sep 6, 2023

This is similar to #18, although the specifics I'm seeing are slightly different than what was described there.

I've got a draft article with my first series in it.. and just added series support to my theme. My pelicanconf.py defines DEFAULT_METADATA of "status": "published" for development purposes, and publishconf.py sets that default to draft. This is the setup I use so that the devserver will show me draft articles as they will appear once published. My uses of pelican-series worked fine in this setup until I tried to do a producton publish of a new article, while the unfinished series article is still in drafts.

When Pelican's make publish target hits that draft article, it fails. The first encountered error is a reference to article.series.previous.url:

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

The error comes from this bit of template in my article.html:

{% if article.series.previous is not none %}
    <a class="series-footer text-muted"
       href="{{ SITEURL }}/{{ article.series.previous.url }}">
        <i class="fa fa-angles-left"></i>
        Previous Article
    </a>
{% else %}
    <i class="fa fa-angles-left"></i>
    Previous Article
{% endif %}

That block is itself wrapped in an if to check whether the article is part of a series:

{% if SHOW_SERIES and article.series is defined %}

The draft in question is the first and only article in the series, so article.series.next and article.series.previous should both be None. I've done some strategic commenting-out of bits of the template and inserting values as comments to determine that article.series.previous actually references article.series.name in a draft, rather than article.series.all_previous[-1], as it does when the article is published.

Oddly, article.series.index and article.series.name both seem to be empty string when the document is a draft, but work as expected when the document is published.

Relevant software version info from my virtualenv:

% python --version
Python 3.10.9

% pip freeze
blinker==1.5
commonmark==0.9.1
docutils==0.19
feedgenerator==2.0.0
Jinja2==3.1.2
MarkupSafe==2.1.1
pelican==4.8.0
pelican-i18n-subsites==0.9.0
pelican-series==2.1.0
pelican-youtube==0.2.1
Pygments==2.13.0
python-dateutil==2.8.2
pytz==2022.7
rich==13.0.0
six==1.16.0
smartypants==2.0.1
typogrify==2.0.7
Unidecode==1.3.6
@lgiordani
Copy link
Collaborator

@mpounsett I'm so sorry I ignored this error for so long. Would you be able to provide a GH repo with a minimal example of the situation? This way it will be very easy to debug. Thanks, and again so sorry for the delay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants