Mercurial > hg > decoupage
changeset 33:e384d4569ac3
include components necessary to make decoupage feel almost like a framework
author | k0s <k0scist@gmail.com> |
---|---|
date | Mon, 08 Feb 2010 11:40:57 -0500 |
parents | 983c13e1b71f |
children | 527ccb76d043 |
files | decoupage/formatters.py decoupage/templates/index.html decoupage/web.py setup.py |
diffstat | 4 files changed, 33 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/decoupage/formatters.py Mon Feb 08 11:10:54 2010 -0500 +++ b/decoupage/formatters.py Mon Feb 08 11:40:57 2010 -0500 @@ -143,6 +143,22 @@ def __call__(self, request, data): data['css'] = self.css +class JavaScript(object): + """specify JS for the page""" + + def __init__(self, arg): + self.scripts = arg.split() + def __call__(self, request, data): + data['scripts'] = self.scripts + +class Favicon(object): + """specify favicons for the page""" + + def __init__(self, icon): + self.icon = icon + def __call__(self, request, data): + data['icon'] = self.icon + class Include(object): """include a file at the top of the body"""
--- a/decoupage/templates/index.html Mon Feb 08 11:10:54 2010 -0500 +++ b/decoupage/templates/index.html Mon Feb 08 11:40:57 2010 -0500 @@ -6,7 +6,10 @@ xmlns:xi="http://www.w3.org/2001/XInclude"> <head> <title>${title or path}</title> + <link py:if="icon" rel="icon" href="${icon}"/> <link py:for="sheet in css" rel="stylesheet" type="text/css" href="${sheet}"/> + <script py:for="script in scripts" src="${script}"></script> + </head> <body> <xi:include py:if="include" href="${include}"/> @@ -17,10 +20,11 @@ <a href="${f['path']}"> ${f.get('title', f['description']) or f['name']}</a><span py:if="'title' in f and f['description']">: ${f['description']} </span> - <span py:if="'links' in f" py:for="link in f['links']" - class="link"> - <a href="link['link']">${link['text']}</a> + <py:if test="'links' in f"> + <span py:for="link in f['links']" class="link"> + <a href="${link['link']}">${link['text']}</a> </span> + </py:if> </li> </ul> </body>
--- a/decoupage/web.py Mon Feb 08 11:10:54 2010 -0500 +++ b/decoupage/web.py Mon Feb 08 11:40:57 2010 -0500 @@ -1,5 +1,5 @@ """ -decoupage: a view with webob +decoupage: a view with webob to index and serve static content """ import os @@ -102,13 +102,17 @@ # get the configuraton conf = self.conf(path) - # build data dictionary + ### build data dictionary files = self.filedata(path, directory, conf) data = {'path': path, 'files': files, 'request': request } + + # defaults; TODO: make this better data['title'] = conf.get('/title') data['directory'] = directory data['include'] = None data['css'] = () + data['scripts'] = () + data['icon'] = None # apply formatters # XXX this should be cached if not self.auto_reload
--- a/setup.py Mon Feb 08 11:10:54 2010 -0500 +++ b/setup.py Mon Feb 08 11:40:57 2010 -0500 @@ -6,7 +6,7 @@ except IOError: description = '' -version = '0.5.2' +version = '0.6' setup(name='decoupage', version=version, @@ -42,11 +42,13 @@ all = decoupage.formatters:All css = decoupage.formatters:CSS describe = decoupage.formatters:FilenameDescription + icon = decoupage.formatters:Favicon ignore = decoupage.formatters:Ignore include = decoupage.formatters:Include links = decoupage.formatters:Links + scripts = decoupage.formatter:JavaScript + sort = decoupage.formatters:Sort title = decoupage.formatters:TitleDescription - sort = decoupage.formatters:Sort """, )