posativ / acrylamid

(unmaintained) static blog generator in python with incremental rendering ⛺
http://posativ.org/acrylamid/
Other
277 stars 40 forks source link

Implement Jinja2 multiple location on the templatefileloader #224

Closed andreamoro closed 9 years ago

andreamoro commented 9 years ago

Jinja2 API allows multiple locations to be passed to the loader, thus allowing templates to be also in folder different than the "theme" one (which has been set as a default).

This can be extremely useful to import one or more files whose "static" content should be edited from the "web site editor" and sit in a different folder than the theme one. By allowing the inclusion of a file in the content folder, it would be possible to achieve the complete abstraction between the theme and the content itself (though this means sacrifice the versioning).

To implement this feature, something like this is required

loader=jinja2.FileSystemLoader(
   [os.path.join(os.path.dirname(__file__),"root/theme/"),
    os.path.join(os.path.dirname(__file__),"root/content")])

To make the feature more scalable, a global variable can be included thus allowing the end user to specify any local path.

posativ commented 9 years ago

Done, needs testing though. You can't use multiple directories if you use webassets (only the first is honored). To add multiple directory, write something like

THEME = ['foo', 'bar']

to your conf.py.

andreamoro commented 9 years ago

Not sure why the webassets doesn't work. Having a second theme folder, I believe can make this a bit confusing? How am I supposed to "import" files in this way? An example could be great to start the testing, as well as some instructions on how to upgrade (would a pip acrylamid update suffice)?

Thanks Andrea

posativ commented 9 years ago

Webassets only supports a single root folder and I didn't have the time to circumvent this limitation. Webassets still work (I specifically mean this feature: http://posativ.org/~tmp/acrylamid/assets.html#webassets-integration), but only for the first theme directory.

You can upgrade Acrylamid via pip:

$ pip install -U https://github.com/posativ/acrylamid/archive/master.zip
andreamoro commented 9 years ago

This seems to work, but as an unexpected behavior all the files in the second theme are copied in the output folder.

posativ commented 9 years ago

That is always the case, if a template is not used. You can ignore certain files to be copied to the output folder, though.