Added Django template handler for Planet Venus
This commit is contained in:
parent
bc33615ced
commit
81d10e1f5c
30
planet/shell/dj.py
Normal file
30
planet/shell/dj.py
Normal file
@ -0,0 +1,30 @@
|
||||
import os.path
|
||||
import urlparse
|
||||
|
||||
from planet import config
|
||||
from tmpl import template_info
|
||||
|
||||
def run(script, doc, output_file=None, options={}):
|
||||
"""process a Django template file """
|
||||
|
||||
# this is needed to use the Django template system as standalone
|
||||
# I need to re-import the settings at every call because I have to
|
||||
# set the TEMPLATE_DIRS variable programmatically
|
||||
from django.conf import settings
|
||||
settings.configure(
|
||||
DEBUG=True, TEMPLATE_DEBUG=True,
|
||||
TEMPLATE_DIRS=(os.path.dirname(script),)
|
||||
)
|
||||
from django.template import Context
|
||||
from django.template.loader import get_template
|
||||
|
||||
context = Context()
|
||||
context.update(template_info(doc))
|
||||
|
||||
reluri = os.path.splitext(os.path.basename(output_file))[0]
|
||||
context['url'] = urlparse.urljoin(config.link(),reluri)
|
||||
|
||||
t = get_template(script)
|
||||
f = open(output_file, 'w')
|
||||
f.write(t.render(context))
|
||||
f.close()
|
39
themes/django/bland.css
Normal file
39
themes/django/bland.css
Normal file
@ -0,0 +1,39 @@
|
||||
body {
|
||||
margin: 50px 60px;
|
||||
font-family: Georgia, Times New Roman, serif;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font: normal 4em Georgia, serif;
|
||||
color: #900;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
.updated, .entry-tools {
|
||||
font: .8em Verdana, Arial, sans-serif;
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
|
||||
#channels {
|
||||
float: right;
|
||||
width: 30%;
|
||||
padding: 20px;
|
||||
margin: 20px;
|
||||
margin-top: 0px;
|
||||
border: 1px solid #FC6;
|
||||
background: #FFC;
|
||||
}
|
||||
|
||||
#channels h2 {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
#channels ul {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
.entry {
|
||||
border-top: 1px solid #CCC;
|
||||
padding-top: 1em;
|
||||
}
|
||||
|
11
themes/django/config.ini
Normal file
11
themes/django/config.ini
Normal file
@ -0,0 +1,11 @@
|
||||
# This theme is an example Planet Venus theme using the
|
||||
# Django template engine.
|
||||
|
||||
[Planet]
|
||||
template_files:
|
||||
index.html.dj
|
||||
|
||||
template_directories:
|
||||
|
||||
bill_of_materials:
|
||||
bland.css
|
49
themes/django/index.html.dj
Normal file
49
themes/django/index.html.dj
Normal file
@ -0,0 +1,49 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title>{{ name }}</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<link rel="stylesheet" href="bland.css" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h1>{{ name }}</h1>
|
||||
|
||||
<p class="updated">
|
||||
last updated by <a href="http://intertwingly.net/code/venus/">Venus</a>
|
||||
on {{ date }} on behalf of {{ author_name }}
|
||||
</p>
|
||||
|
||||
<div id="channels">
|
||||
<h2>Feeds</h2>
|
||||
|
||||
<ul>
|
||||
{% for channel in Channels %}
|
||||
<li>{{ channel.title }} by {{ channel.author_name }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{% for item in Items %}
|
||||
{% ifchanged item.channel_name %}
|
||||
<h3>{{ item.channel_name }}</h3>
|
||||
{% endifchanged %}
|
||||
|
||||
<div class="entry">
|
||||
{% if item.title %}<h4>{{ item.title }}</h4>{% endif %}
|
||||
|
||||
{{ item.content }}
|
||||
|
||||
<p class="entry-tools">
|
||||
by {{ item.channel_author }} on
|
||||
{{ item.date }} ·
|
||||
<a href="{{ item.id }}">permalink</a>
|
||||
</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user