added ability to register a function that will add extra information to ... #18

Open
wants to merge 1 commit into from

3 participants

@meantheory

...page meta

It would be nice to be able to register a function with Flask-Flatpages that adds information to the Page Metadata. This function will parse information out of some meaningful file name.

Providing a means to register a function allows the developer to choose what type of file naming convention best suits there project (or none at all).

Several static site generators use naming conventions and it is a handy feature in my mind. When you have a lot of posts in one directory, naming conventions can give you a predictable time based order when sorted by characters.

I am trying to port my blog efforts from a static site generator that uses this type of naming convention methodology and I do not want to have to port the date information in the naming convention into the yaml metadata.

This method is an idea for allowing users of Flask-Flatpages to easily adapt naming convention information into the page meta.

@playpauseandstop
Collaborator

Interesting proposition, will think about in few next days

@fhirschmann

I'm not quite sure what you're trying to achieve, but does something like this work for you?

pages = FlatPages(app)

for page in pages:
    page.meta["moddate"] = datetime.utcfromtimestamp(os.path.getmtime(
        os.path.join(FLATPAGES_ROOT,
                     *os.path.split(page.path + FLATPAGES_EXTENSION))))

This merely illustrates how to add something to a Page's meta information. I'm however uncertain if this is something that should be done to a cached property.

@playpauseandstop
Collaborator

Moved to 1.0 milestone as not sure about exact way to implement this in 0.6

@playpauseandstop playpauseandstop modified the milestone: 1.0, 0.6 Feb 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment