Created
February 19, 2009 20:20
-
-
Save sr/67101 to your computer and use it in GitHub Desktop.
my retarded tumblog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
cat <<EOF | |
<entry> | |
<title>Omnifaria $1</title> | |
<published>$(date --utc)</published> | |
<updated>$(date --utc)</updated> | |
<content type="xhtml"><div>$(cat | ./src/markdown)</div></content> | |
</entry> | |
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
usage() { | |
echo "Usage: $0 directory" | |
exit 1 | |
} | |
[ -z $1 ] && usage | |
[ -d $1 ] || usage | |
pushd $1 > /dev/null | |
page () { | |
echo "$(basename $1 | sed 's/\.mkd$//g')" | |
} | |
rm feed.atom || true | |
cat <<EOF > feed.atom | |
<feed> | |
<title>Omnifaria</title> | |
<updated>$(date --utc)</updated> | |
<author> | |
<name>Simon Rozet</name> | |
<uri>http://purl.org/net/sr/</uri> | |
<email>simon@rozet.name</email> | |
</author> | |
EOF | |
let i=0 | |
list=$(dir *.mkd | sort -ru) | |
count=$(echo $list | wc -l) | |
for file in $list; do | |
# TODO: preserve old pages | |
echo "$(cat $file | src/htmlize $(page $file) $count)" > $(page $file).html | |
let i=($i+1) | |
if [ $i -lt 10 ]; then # atom | |
echo "$(cat $file | src/atomize $(page $file))" >> feed.atom | |
fi | |
if [ $i -eq $count ]; then # index | |
cp $(page $file).html index.html | |
fi | |
done | |
echo "</feed>" >> feed.atom | |
popd > /dev/null | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
cat <<EOF | |
<!DOCTYPE> | |
<html> | |
<head> | |
<title>Omnifaria, page $1</title> | |
<style type="text/css"> | |
html { background: #fff; padding: 3em; width: 40%;} | |
body { font: small Arial, sans-serif; margin: 0;} | |
h1 a { text-decoration: none; } | |
h2 { display: none; } | |
ul { padding: 0; list-style-type: none; } | |
#nav { position: absolute; top: 0; bottom: -5px; } | |
#nav a { text-decoration: none; font-size: larger;} | |
blockquote { padding-left: 0; margin-left: 2em;} | |
blockquote p { font-style: italic;} | |
cite { font-style: normal; font-size: smaller;} | |
cite:before { content: "— ";} | |
address { font-size: x-small; text-align: center;} | |
address:before { content: "— ";} | |
</style> | |
</head> | |
<body> | |
<h1>Omnifaria <small>($1)</small></h1> | |
<p id="nav"> | |
EOF | |
if [ $1 -gt 1 ]; then | |
n=$(($1 - 1)) | |
echo "<a href=\"/omnifaria/$n\">←</a>" | |
fi | |
if [ $1 -eq 1 ]; then | |
echo "<a href=\"/omnifaria/2\">→</a>" | |
elif [ $1 -lt $2 ]; then | |
echo "<a href=\"/omnifaria/$(($i + 1))\">→</a>" | |
fi | |
echo "</p>" | |
cat | ./src/markdown | |
cat <<EOF | |
<address>Simon Rozet</address> | |
</body> | |
</html> | |
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "rdiscount" | |
puts RDiscount.new(STDIN.read).to_html.gsub!(/h1>/, "h2") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
dir="/home/simon/web/atonie.org/omnifaria" | |
next="$(ls $dir/*.mkd | wc -l)" | |
page="$dir/$next.mkd" | |
if [ $next -eq 0 ]; then | |
page="$dir/1.mkd" | |
elif [ -e $page ]; then | |
if [ $(cat $page | grep "^# \d*" | wc -l) -eq 10 ]; then | |
page="$dir/$(($next + 1)).mkd" | |
fi | |
fi | |
echo "# $(date -R)" >> $page | |
vim +10000 -c "setfiletype mkd" $page |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment