shithub: img

ref: 186ec93c43fb4be482679dce0728aa70621a1c32
dir: /mkpages.rc/

View raw version
#!/bin/rc

yflag=()

while(~ $1 -*){
	switch($1){
	case -y
		yflag=1
	}
}

month=`{basename `{pwd}}
year=`{basename `{dirname `{pwd}}}

fn mkpage{
	echo '<!DOCTYPE html>
<html>
<head>
<style>
body{
	background-color: black;
	text-align: center;
}
a{
	color: white;
}
.disabled{
	color: grey;
}
</style>
</head>
<body>
<p>'
if(! ~ $3 '')
	echo '<a href="'^$3^'.html">prev</a>'
if not
	echo '<span class="disabled">prev</span>'
if(~ $yflag 1)
	echo ' | <a href="../../'^$year^/^$month^'/index.html">'^$year^/^$month^'</a> | '
if not
	echo ' | <a href=".">up</a> | '
if(! ~ $4 '')
	echo '<a href="'^$4^'.html">next</a>'
if not
	echo '<span class="disabled">next</span>'
echo '</p>
<p><a href="'^$2^'"><img src="'^$1^'"/></a></p>
</body>
</html>'
}

ls *.full.* | sed 's/\.full\.[A-Z]\+$//' | awk '{
	if (buf){
		i = NR - 1
		p = i - 1
		if(p < 1)
			p = ""
		n = i + 1
		printf "mkpage %s.big.JPG %s.full.* ''%s'' ''%s'' >%d.html\n", buf, buf, p, n, i
	}
	buf = $0
}
END{
	i = NR
	p = i - 1
	printf "mkpage %s.big.JPG %s.full.* ''%s'' '''' >%d.html\n", buf, buf, p, i
}' | rc