shithub: img

ref: 08f0b154171793f440928929fbca6e49ac085738
dir: /mkyearidx.rc/

View raw version
#!/bin/rc

this=`{basename `{pwd}}

months=(January February March April May June July August September October November December)

cat <<EOF
<!DOCTYPE html>
<html>
<head>
<title>$1</title>
<style>
body{
	background-color: black;
	text-align: center;
}
div>p, a{
	color: white;
}
div{
	float: left;
	text-align: center;
	padding: 0.25cm;
	width: 200px;
	height: 200px;
}
div.bordered{
	float: none;
	display: inline-block;
	width: 160px;
	height: 160px;
	padding: 0px;
	border: 1px solid white;
}
img{
	width: 160px;
	height: 160px;
}
.disabled{
	color: grey;
}
</style>
</head>
<body>
<p>
EOF

fn findnext{
	@{
		for(i in `{seq `{echo $1 $2 | bc} $2 $3}){
			if(test -d ../^$i){
				echo $i
				exit
			}
		}
	}
}

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

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

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

for(m in `{seq -w 1 12}){
	if(test -d $m)
		echo '<div><a href="'^$m^'/index.html"><img src="'^$m^'/montage.jpg"/><p>'^$months($m)^'</p></a></div>'
	if not
		echo '<div><div class="bordered"></div><p>'^$months($m)^'</p></div>'
}

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