eudicots / Cactus

Static site generator for designers. Uses Python and Django templates.
BSD 3-Clause "New" or "Revised" License
3.46k stars 314 forks source link

Makes full template power available to blog posts. #230

Closed blattms closed 8 years ago

blattms commented 8 years ago

Previously, I got weired errors when using e.g. {% url path %} in blog posts:

*** Error while building
'__CACTUS_SITE__'
Traceback (most recent call last):
...
File "/usr/local/lib/python2.7/dist-packages/Cactus-3.3.2-py2.7.egg/cactus/template_tags.py", line 52, in url
    site = context['__CACTUS_SITE__']
  File "/usr/local/lib/python2.7/dist-packages/Django-1.6.11-py2.7.egg/django/template/context.py", line 56, in __getitem__
    raise KeyError(key)
KeyError: '__CACTUS_SITE__'

It turns out that getNode needs the full site context to work probably. Therefore this commit creates the site context and adds it to all postContexts. Now I can use {% url path %} and the likes in my blog posts.

blattms commented 8 years ago

The problem that I experienced looks similar to the one described in #212. Therefore I guess merging this PR will close #212

ibarria0 commented 8 years ago

Hey blattms. I noticed you change the block name from "body to "postbody", any reason for this? Can I change it back to post to keep consistency with documentation?

blattms commented 8 years ago

Indeed, the change body->postbody is totally unrelated. I pushed a commit that reverts this change.

If you prefer I can squash the two commit into one.

ibarria0 commented 8 years ago

@blattms I noticed in this last commit that you are no longer using final_url and reverted to old behavior. Can you fix this up so I can merge it with your new behavior?

blattms commented 8 years ago

That change was never part of this PR but of #229. Both of them were based on master as of February 13.

Anyway, I will rebase this PR onto the current master and squash the two commits into one. Just wait a second.

blattms commented 8 years ago

Done with rebase and fixup.

ibarria0 commented 8 years ago

Tests are working locally but travis is failing for some reason. Im gonna look into this first before merging the PR.

blattms commented 8 years ago

BTW this seems like a system problem (python path?)

ibarria0 commented 8 years ago

Yes. I'm gonna merge anyways since tests pass.