shithub: img

ref: ab3a209ed97ea6d9e085a32bf806fd9395615ade
dir: /mkalbumindex.rc/

View raw version
#!/bin/rc

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

cat <<EOF
<!DOCTYPE html>
<html>
<head>
<style>
body{
	background-color: black;
	text-align: center;
}
img{
	height: 96px;
}
a{
	color: white;
}
.disabled{
	color: grey;
}
</style>
</head>
<body>
<p>
EOF

fn findnext1{
	for(i in `{seq $2 $3 $4 | sed 's/^.$/0&/'}){
		if(test -d ../../$1/^$i){
			echo $1/$i
			exit
		}
	}
}

fn findnext{
	@{
		findnext1 $1 `{echo $2 $3 | bc} $3 $4

		end=1990
		ms=12
		me=1
		if(~ $3 +1){
			end=`{date '+%Y'}
			ms=1
			me=12
		}

		for(y in `{seq `{echo $1 $3 | bc} $3 $end}){
			if(test -d ../../^$y)
				findnext1 $y $ms $3 $me
		}
	}
}

prev=`{findnext $year $this -1 1}
if(~ $#prev 0)
	echo '<span class="disabled">prev</span>'
if not
	echo '<a href="../../'^$"prev^'/index.html">prev</a>'

echo ' | <a href="../index.html">'^$year^'</a> | '

next=`{findnext $year $this +1 12}
if(~ $#next 0)
	echo '<span class="disabled">next</span>'
if not
	echo '<a href="../../'^$next^'/index.html">next</a>'
echo '</p>'

ls *.thumb.JPG | awk '{ printf "<a href=\"%d.html\"><img src=\"%s\"/></a>\n", NR, $0 }'

cat <<EOF
</body>
</html>
EOF