willkg / douglas

DEAD PROJECT: File based static rendering blog system
Other
2 stars 3 forks source link

fix plugins to work with jinja2 renderer #4

Closed willkg closed 10 years ago

willkg commented 10 years ago

The jinja2 renderer doesn't do cb_head, cb_foot, cb_story, ... callbacks. Many of the plugins require these to work properly.

They should be updated to add things (variables, functions, ...) to the context so that they can be used in templates.

willkg commented 10 years ago

Breaking this down into steps:

  1. remove all the cb_head, cb_foot, cb_story, ... stuff.
  2. create a cb_context_processor callback that lets plugins add functions and variables to the Jinja2 environment.
  3. rewrite plugins that use the old blosxom callbacks to use the new context_processor callback.
  4. document new context_processor callback.

This has some interesting ramifications on how plugins work.

For example, the tags plugin used cb_head and cb_foot and added a variable that built a list of all the tags for the blog. Instead, it can add an object to the context that has:

  1. a list of (tag, tag url, count) tuples for all tags on the blog 2.. a function that generates HTML for a generic tags list which probably covers most peoples' needs
  2. a function that generates HTML for a tag cloud
  3. a function that takes an entry and returns the tags for that entry as a list of (tag, tag url) tuples
  4. a function that takes an entry and generates HTML for a generic tags list which probably covers most peoples' needs
willkg commented 10 years ago

I like the new system a lot better.

Plugins to rewrite

willkg commented 10 years ago

For clarification, I folded the interesting bits of readmore into rst_parser and ditched the readmore plugin.

willkg commented 10 years ago

The last one to rewrite is archives. I'm going to close this issue out and open a new issue to merge archives and yeararchives into a datearchives plugin.

willkg commented 10 years ago

Done! Yay!