Deliverance: Theming Decoupled ============================== :author: Ian Bicking :organization: `The Open Planning Project `_ :site: http://deliverance.openplans.org Outline Of This Talk -------------------- 1. A demonstration of what Deliverance does 2. Why Deliverance 3. How Deliverance Works (from the outside) Installation ------------ * Installation: - "Quickstart" on deliverance.openplans.org - Uses pyinstall/pybundles - Regular snapshots, but not automated paster startup -------------- :: $ pyinstall.py -E DelivTest Deliverance-snapshot-latest.pybundle $ cd DelivTest $ source bin/activate $ paster create -t deliverance_plone . Demo ---- See the demo... Why Deliverance? ---------------- Why Do *I* Work With Deliverance? --------------------------------- * I've been through a lot of frameworks * Using a new framework, platform, or existing application shouldn't be a repudiation of any other system Why Do *I* Work With Deliverance? --------------------------------- * This lets me do things with Plone without poking around in the internals * It is built on technologies I **know** will stay relevant: - HTTP - HTML Why Should *You* Care? ---------------------- * Theming with no (visible) Python * Rules and content are entirely separate (vs. Page Templates) * Aggregation is relatively straight-forward Why Should *You* Care? ---------------------- * Clear path for creating exceptions (e.g., ``class="sphinx"``) * Everything is based on visible information: URLs and markup Why You Should Want Heterogeneity --------------------------------- * Plone, the community, can't be everything to everyone - For example, Plone will never have the best blog * Without heterogeneity, every platform and specialization of a platform creates smaller and smaller audiences Heterogeneous Stacks Are Hard ----------------------------- (I'm not going to deny it) How Deliverance Works --------------------- Moving Boxes Around ------------------- * Deliverance moves boxes around between the content and theme, and some external resources (like the sidebar) * Deliverance produces no content itself * Deliverance doesn't care how the content was produced From Content To Theme --------------------- * "Content" is the response that was generated for the request -- what you'd see if there was no Deliverance and no theming * "Theme" is the theme you've created From Content To Theme --------------------- * The response starts with the theme page * Rules move stuff from the content into the theme * If there were no rules, every response would be the identical theme page The Rules --------- Four rules: * ```` * ```` * ```` * ```` replace, append, prepend ------------------------ ````: Remove some stuff from the theme, and replace it with stuff from the content ````: Take some stuff from the content and put it right after some stuff in the theme ````: Like ``append``, but prepend Rules ----- ```` looks like:: Rules ----- ```` looks like:: Replace all the children of ``#content`` in the theme, with the children of ``#content`` in the content. Selectors --------- * Selectors can be CSS selectors (``#content``) or XPath (``//*[@id='content']``) * Selectors select *elements* * Modifiers make it more clear what you want to do Selectors (modifiers) --------------------- ``element:...``: Selects the element ``children:...``: Selects the children of the element ``tag:...``: Selects the *tag*, but not its children Selectors (modifiers) --------------------- ``attributes:...``: Selects the attributes of the elmeent ``attributes(class):...``: Selects just the ``class`` attribute of the element drop ---- Mostly to fix up problems: ````: Remove some stuff from the theme ````: Remove some stuff from the content (only meaningful if you have later rules) Examples -------- :: * Take the elements from the content with the class ``.content`` * The target is ``children:#content`` -- the element with the id ``content`` (e.g., ``
`` * Because the target is ``children``, it will be appended *inside* the ``
`` tag Examples -------- :: (continued...) * It will also preserve the children of that div; if you don't want to preserve that content (e.g., it looks like ``
content goes here
`` use ```` Examples -------- :: * This will remove the ```` tags, but *not* their children (will just clean the content) Examples -------- :: * This will move the ``class`` attribute from ```` in the content, into ```` in the theme. * With ```` the *content* attributes get priority, with ```` the *theme* attributes get priority Examples -------- :: * This adds the element ``