mini newsletter framework
This commit is contained in:
parent
0ba16344d6
commit
a9503a9dc6
|
@ -1,17 +1,3 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
|
||||
<style>
|
||||
body {
|
||||
width: 600px;
|
||||
padding-left: 40px;
|
||||
}
|
||||
a {
|
||||
color: #00e;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div><p class="MsoNormal"><b><span style="font-size: 14pt; font-family: Arial;" lang="EN-GB">Pad.ma
|
||||
Newsletter I<br>
|
||||
</span></b><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB"><a href="http://pad.ma/newsletter" target="_blank">http://pad.ma/newsletter</a></span></p><p class="MsoNormal"><br><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB">
|
3
footer.html
Normal file
3
footer.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
</body>
|
||||
</html>
|
||||
|
8
header.html
Normal file
8
header.html
Normal file
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
|
||||
<link rel="stylesheet" type="text/css" href="newsletter.css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
|
@ -1 +1 @@
|
|||
2010-03-15.html
|
||||
2010-04-15.html
|
29
newsletter.css
Normal file
29
newsletter.css
Normal file
|
@ -0,0 +1,29 @@
|
|||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 10pt;
|
||||
font-family: Arial;
|
||||
}
|
||||
#nav {
|
||||
position: fixed;
|
||||
left: 16px;
|
||||
top: 16px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
#nav li {
|
||||
display: linline;
|
||||
list-style-type:none;
|
||||
}
|
||||
.title {
|
||||
font-weight: bold;
|
||||
}
|
||||
#content {
|
||||
width: 600px;
|
||||
padding-top: 16px;
|
||||
padding-left: 168px;
|
||||
}
|
||||
a {
|
||||
color: #00e;
|
||||
}
|
||||
|
46
update.py
Normal file
46
update.py
Normal file
|
@ -0,0 +1,46 @@
|
|||
#!/bin/python
|
||||
import os
|
||||
import sys
|
||||
from glob import glob
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
with open('header.html') as f:
|
||||
header = f.read().decode('utf-8')
|
||||
with open('footer.html') as f:
|
||||
footer = f.read().decode('utf-8')
|
||||
|
||||
mails = sorted(glob('*.raw'))
|
||||
latest = None
|
||||
|
||||
def format_title(name):
|
||||
return datetime.strptime(name, '%Y-%m-%d').strftime('%B') + ' Newsletter'
|
||||
|
||||
navigation = u'<ul id="nav">'
|
||||
navigation += u'<li><span class="title">Pad.ma Newsletter</span></li>'
|
||||
for mail in reversed(mails):
|
||||
name = mail[:-4]
|
||||
navigation += u'<li><a href="%s.html">%s</a></li>' % (name, format_title(name))
|
||||
if not latest:
|
||||
latest = "%s.html" % name
|
||||
|
||||
navigation += u'</ul>'
|
||||
|
||||
for mail in reversed(mails):
|
||||
name = mail[:-4]
|
||||
print name
|
||||
title = format_title(name)
|
||||
nav = navigation.replace(u'<li><a href="%s.html">%s</a></li>' % (name, title), u'<li>%s</li>' % title)
|
||||
|
||||
with open(mail) as f:
|
||||
body = f.read().decode('utf-8')
|
||||
body = '<div id="content">' + body + '</div>'
|
||||
with open('%s.html' % name, 'w') as f:
|
||||
f.write(header.encode('utf-8'))
|
||||
f.write(nav.encode('utf-8'))
|
||||
f.write(body.encode('utf-8'))
|
||||
f.write(footer.encode('utf-8'))
|
||||
|
||||
os.system('ln -sf "%s" index.html' % latest)
|
||||
|
Loading…
Reference in New Issue
Block a user