#!/bin/sh
trap 'rm -f /tmp/flog$$' 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
ID=$(date +t%s)
MONTH=$(date +%Y-%m)
echo "<div class=\"post\" id=\"$ID\">" >> body
echo -n "<h1>On <a href=\"http://d8uv.org/flog/$MONTH#$ID\"" >> body
echo ">$(date +"%B %d, %Y at %l:%M %P")...</a></h1>" >> body
nano /tmp/flog$$; markdown </tmp/flog$$ >> body
echo "</div>" >> body
echo "" >> body
./rebuild
#!/bin/sh
MONTH=$(date +%Y-%m)
./header > $MONTH.html
cat body >> $MONTH.html
cat footer >> $MONTH.html
./genfeed > feed.xml
# this is for me and not for you
# ~/genindex > ~/www/index.html
./header (v1.0.0)
#!/bin/sh
echo "<!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\">
<head>
<title>The Flog for $(date +"%B %Y")</title>
<link rel=\"stylesheet\" type=\"text/css\" href=\"a.css\" />
</head>
<body>
<div id=\"header\">
<a href=\"index\"><img src=\"flog.jpg\" alt=\"Back to the Flog index\" /></a>
<p>$(date +"%B %Y")</p>
</div>
"
#!/usr/bin/env python
"""
feed.cgi - The Flog Feed
Author: Sean B. Palmer, inamidst.com
"""
import cgitb
cgitb.enable()
import re, glob
r_post = re.compile(r'(?i)<div[^>]+id=[\'"]t([^\'"]+)[\'"]')
def months():
for fn in reversed(sorted(glob.glob('*-*.html'))):
yield fn
def days():
import time
today = time.strftime('%Y-%m-%d', time.gmtime())
wait = True
for month in months():
floglets = []
f = open(month)
for line in f:
m = r_post.match(line)
if m:
date = int(m.group(1))
updated = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(date))
floglets.append([updated, [line]])
wait = False
elif floglets and (not wait):
floglets[-1][1].append(line)
if line.startswith('</div>'):
wait = True
f.close()
day = []
old = False
for note in reversed(floglets):
new, lines = note
if not old:
old = new[:10]
elif new[:10] != old:
if day[0] != today:
yield day
day = []
old = new[:10]
if not day: day.append(new)
day.extend(lines)
if day[0] != today:
yield day
def main():
print """\
<feed xmlns="http://www.w3.org/2005/Atom">
<title>The Flog</title>
<subtitle>Almost an entirely normal web blog.</subtitle>
<link href="http://d8uv.org/flog/" />
<link rel="self" href="http://d8uv.org/flog/feed" />
<logo>http://d8uv.org/flog/flog.jpg</logo>
<id>tag:d8uv.org,2006:flog</id>
"""
for i, day in enumerate(days()):
if i > 10: break
updated, lines = day[0], day[1:]
day = updated[:10]
content = ''.join(lines).replace(']]>', ']]>]]><![CDATA[')
if i == 0:
print " <updated>%s</updated>" % updated
print
print """\
<entry>
<id>tag:d8uv.org,2006:flog:%s</id>
<link rel="alternate" type="text/html"
href="http://d8uv.org/flog/%s" />
<title>%s</title>
<updated>%s</updated>
<author>
<name>Cody Woodard</name>
</author>
<content type="html" xml:base="http://d8uv.org/flog/%s">
<![CDATA[\n%s]]>
</content>
</entry>
""" % (day, day[:7], day, updated, day[:7], content)
print '</feed>'
if __name__ == '__main__':
main()
#!/bin/sh
trap rm -f /tmp/flog$$ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
ID=$(date +t%s)
MONTH=$(date +%Y-%m)
echo "<div class=\"post\" id=\"$ID\">" >> body
echo "<h1>On <a href=\"http://d8uv.org/flog/$MONTH#$ID\">$(date +"%B %d, %Y at %l:%M %P")...</a></h1>" >> body
nano /tmp/flog$$; markdown </tmp/flog$$ >> body
echo "</div>" >> body
echo "" >> body
./header > $MONTH.html
cat body >> $MONTH.html
cat footer >> $MONTH.html
#!/bin/sh
ID=$(date --iso-8601=second -u)
MONTH=$(date +%Y-%m)
echo "<div class=\"post\" id=\"$ID\">" >> body
echo "<h1>On <a href=\"#$ID\">$(date +'%B %d, %Y at %l:%M %P')...</a></h1>" >> body
markdown >> body
echo "</div>" >> body
echo "" >> body
./header > $MONTH.html
cat body >> $MONTH.html
cat footer >> $MONTH.html