Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

my retarded tumblog

View atomize
1 2 3 4 5 6 7 8 9
#!/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
View atomize
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
#!/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
View atomize
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
#!/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
View atomize
1 2 3
#!/usr/bin/env ruby
require "rdiscount"
puts RDiscount.new(STDIN.read).to_html.gsub!(/h1>/, "h2")
View atomize
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/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
Something went wrong with that request. Please try again.