mirror of
https://github.com/vale981/ablog
synced 2025-03-06 01:31:39 -05:00
Keeping not JSON serializable objects out of html context (#47)
ABlog objects are not JSON serializable. They are used for creating archive pages, and work fine with HTML builders. When json builder is used, it pickles HTML context along with HTML, and this causes serialization issues. So ABlog objects (functions, Catalog, Blog instance, etc.) are avoided when builder is not one of html/dirhtml.
This commit is contained in:
parent
aa36f76552
commit
698eaea6e0
2 changed files with 10 additions and 3 deletions
|
@ -22,6 +22,7 @@ def anchor(post):
|
|||
|
||||
def html_page_context(app, pagename, templatename, context, doctree):
|
||||
|
||||
if app.builder.name in {'html', 'dirhtml'}:
|
||||
context['ablog'] = Blog(app)
|
||||
context['anchor'] = anchor
|
||||
|
||||
|
|
|
@ -361,7 +361,7 @@ def process_postlist(app, doctree, docname):
|
|||
"""Replace `PostList` nodes with lists of posts. Also, register all posts
|
||||
if they have not been registered yet."""
|
||||
|
||||
blog = Blog()
|
||||
blog = Blog(app)
|
||||
if not blog:
|
||||
register_posts(app)
|
||||
|
||||
|
@ -480,6 +480,9 @@ def generate_archive_pages(app):
|
|||
"""Generate archive pages for all posts, categories, tags, authors, and
|
||||
drafts."""
|
||||
|
||||
if app.builder.name not in {'html', 'dirhtml'}:
|
||||
return
|
||||
|
||||
blog = Blog(app)
|
||||
for post in blog.posts:
|
||||
for redirect in post.redirect:
|
||||
|
@ -559,6 +562,9 @@ def generate_atom_feeds(app):
|
|||
"""Generate archive pages for all posts, categories, tags, authors, and
|
||||
drafts."""
|
||||
|
||||
if app.builder.name not in {'html', 'dirhtml'}:
|
||||
return
|
||||
|
||||
blog = Blog(app)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue