nicolas-van / pygreen

A micro web framework/static web site generator.

Home Page:https://nicolas-van.github.io/pygreen/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A few suggestions: adding more context to rendering

ialbert opened this issue · comments

First of all thanks for this amazing tool. It is simple and elegant, I love it.

Not really an issue but a suggestion, I am exploring the following small extensions to pass more context into the templates. For example the list of all files as pygreen.files attribute will be available in the template, this helps with designing navigation bars and table of contents.

The other is to allow optional importing of a settings module that may be placed in the folder. This is optional and again is to expose whatever more complex functionality one might want inside a template via the pygreen.settings.

Finally I am adding a series of demo sites, mostly as helper/cookbook, to remind myself how things are supposed to work.

The full change is here: https://github.com/ialbert/pygreen/commit/ba6c69e8b055dd933999730f9c13b4d6541755ea

below are just the relevant changes, and thanks again for this superfun mini blog generator:

@property
def settings(self):
    m = __import__('settings', globals(), locals(), [], -1)
    reload(m)
    return m

@property
def files(self):
    """
    Collects all files that will be parsed. Will also be available in main context.
    """
    files = []
    for l in self.file_listers:
        files += l()
    return files

Why close it? I didn't had time to take a look at it yet.

in the meantime I have created a standalone fork called PyBlue and I have been adding a lot more functionality to it here:

https://github.com/ialbert/pyblue

the changes that I am adding are like to be outside the main focus of the tool as it will target a specific use case, that of bioinformatics. I should have mentioned this in my previous comment.