ref: b24df14003cf4b8e6c6a5725531b859ba93c2303
author: Alex Musolino <musolinoa@gmail.com>
date: Sun Nov 22 10:19:31 EST 2020
initial commit
--- /dev/null
+++ b/album.mk
@@ -1,0 +1,60 @@
+MKSHELL=rc
+
+fullsize=`{ls *.full.JPG >[2]/dev/null}
+bigs=`{ls *.full.JPG | sed 's/\.full\.JPG/.big.JPG/'}
+mediums=`{ls *.full.JPG | sed 's/\.full\.JPG/.medium.JPG/'}
+smalls=`{ls *.full.JPG | sed 's/\.full\.JPG/.small.JPG/'}
+thumbs=`{ls *.full.JPG | sed 's/\.full\.JPG/.thumb.JPG/'}
+n=`{ls *.full.JPG | wc -l}
+pages=`{seq 1 $n | sed 's/$/.html/'}
+
+cflags=-auto-orient
+
+all:V: bigs mediums smalls thumbs html montage.jpg
+bigs:V: $bigs
+mediums:V: $mediums
+smalls:V: $smalls
+thumbs:V: $thumbs
+
+%.big.JPG: %.full.JPG
+ convert $prereq -resize 1024 -auto-orient $target
+
+%.medium.JPG: %.big.JPG
+ convert $prereq -resize 512 -auto-orient $target
+
+%.small.JPG: %.medium.JPG
+ convert $prereq -resize 256 -auto-orient $target
+
+%.thumb.JPG: %.small.JPG
+ convert $prereq -resize 128 -auto-orient $target
+
+montage.jpg: smalls
+ $HOME/img/mkmontage.rc
+
+html:V: index.html $pages
+
+index.html: $thumbs $HOME/img/mkalbumindex.rc
+ $HOME/img/mkalbumindex.rc >$target
+
+$pages: $HOME/img/mkpages.rc
+ $HOME/img/mkpages.rc
+
+clean.html:V:
+ rm -f *.html
+
+clean.bigs:V:
+ rm -f *.big.JPG
+
+clean.mediums:V:
+ rm -f *.medium.JPG
+
+clean.smalls:V:
+ rm -f *.small.JPG
+
+clean.thumbs:V:
+ rm -f *.thumb.JPG
+
+clean.imgs:V: clean.bigs clean.mediums clean.smalls clean.thumbs
+ rm -f montage.jpg
+
+clean:V: clean.html clean.imgs
--- /dev/null
+++ b/mkalbumindex.rc
@@ -1,0 +1,48 @@
+#!/bin/rc
+
+this=`{basename `{pwd}}
+prev=`{echo $this - 1 | bc | sed 's/^.$/0&/'}
+next=`{echo $this + 1 | bc | sed 's/^.$/0&/'}
+
+cat <<EOF
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+body{
+ background-color: black;
+ text-align: center;
+}
+img{
+ width: 128px;
+ height: 96px;
+}
+a{
+ color: white;
+}
+.disabled{
+ color: grey;
+}
+</style>
+</head>
+<body>
+<p>
+EOF
+
+if(test -d ../^$"prev)
+ echo '<a href="../'^$"prev^'/index.html">prev</a>'
+if not
+ echo '<span class="disabled">prev</span>'
+echo ' | <a href="../index.html">up</a> | '
+if(test -d ../^$"next)
+ echo '<a href="../'^$next^'/index.html">next</a>'
+if not
+ echo '<span class="disabled">next</span>'
+echo '</p>'
+
+ls *.thumb.JPG | awk '{ printf "<a href=\"%d.html\"><img src=\"%s\"/></a>\n", NR, $0 }'
+
+cat <<EOF
+</body>
+</html>
+EOF
--- /dev/null
+++ b/mkfile
@@ -1,0 +1,46 @@
+MKSHELL=/bin/rc
+
+years=\
+ 2008\
+ 2009\
+ 2013\
+ 2014\
+ 2015\
+ 2018\
+ 2019\
+ 2020\
+
+dirs=\
+ moto\
+ guns\
+ sssc\
+ group-shoot\
+
+fullsize=`{find $years $dirs -type f -name '*.full.*'}
+
+montages=`{echo $years/^montage.jpg $dirs/^montage.jpg}
+
+index.html:D: $montages ./mkindex.rc ./mkfile
+ ./mkindex.rc $years $dirs >index.html
+
+%/montage.jpg: subdirs
+
+subdirs:V:
+ for(d in $years)@{
+ cd $d
+ mk -f ../year.mk
+ }
+ for(d in $dirs)@{
+ cd $d
+ mk -f ../album.mk
+ }
+
+html clean nuke:V:
+ for(d in $years)@{
+ cd $d
+ mk -f ../year.mk $target
+ }
+ for(d in $dirs)@{
+ cd $d
+ mk -f ../album.mk $target
+ }
--- /dev/null
+++ b/mkindex.rc
@@ -1,0 +1,38 @@
+#!/bin/rc
+
+cat <<EOF
+<!DOCTYPE html>
+<html>
+<head>
+<title></title>
+<meta http-equiv="content-type" content="text/html; charset=utf-8">
+<style>
+body{
+ background-color: black;
+}
+a{
+ color: white;
+}
+div{
+ float: left;
+ text-align: center;
+ padding: 0.25cm;
+ width: 400px;
+ height: 400px;
+}
+img{
+ width: 320px;
+ height: 320px;
+}
+</style>
+</head>
+<body>
+EOF
+
+for(d)
+ echo '<div><a href="'^$d^'/index.html"><img src="'^$d^'/montage.jpg"/><p>'^$d^'</p></a></div>'
+
+cat <<EOF
+</body>
+</html>
+EOF
--- /dev/null
+++ b/mkmontage.rc
@@ -1,0 +1,22 @@
+#!/bin/rc
+
+fn mkmontage{
+ imgs=`{find -name '*.small.JPG' >[2]/dev/null | shuffle >[2]/dev/null | sed $2^q}
+ if(! ~ $#imgs $2){
+ status='not enough images'
+ }
+ if not{
+ n=`{echo 320/$1 | bc}
+ montage -gravity Center -crop $n^x^$n+0+0 +repage $imgs -geometry $n^x^$n -thumbnail $n^x^$n -mode Concatenate -tile $1^x^$1 montage.jpg
+ }
+}
+
+if(! mkmontage 5 25
+&& ! mkmontage 4 16
+&& ! mkmontage 3 9
+&& ! mkmontage 2 4
+&& ! mkmontage 1 1){
+ echo 'E: failed to make montage for '^$1 >[1=2]
+ exit 1
+}
+exit 0
--- /dev/null
+++ b/mkpages.rc
@@ -1,0 +1,52 @@
+#!/bin/rc
+
+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>'
+echo ' | <a href="index.html">index</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.JPG | sed 's/\.full\.JPG//' | awk '{
+ if (buf){
+ i = NR - 1
+ p = i - 1
+ if(p < 1)
+ p = ""
+ n = i + 1
+ printf "mkpage %s.big.JPG %s.full.JPG ''%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.JPG ''%s'' '''' >%d.html\n", buf, buf, p, i
+}' | rc
--- /dev/null
+++ b/mkyearidx.rc
@@ -1,0 +1,61 @@
+#!/bin/rc
+
+this=`{basename `{pwd}}
+prev=`{echo $this - 1 | bc}
+next=`{echo $this + 1 | bc}
+
+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;
+}
+a{
+ color: white;
+}
+div{
+ float: left;
+ text-align: center;
+ padding: 0.25cm;
+ width: 400px;
+ height: 400px;
+}
+img{
+ width: 320px;
+ height: 320px;
+}
+.disabled{
+ color: grey;
+}
+</style>
+</head>
+<body>
+<p>
+EOF
+
+if(test -d ../^$"prev)
+ echo '<a href="../'^$"prev^'/index.html">prev</a>'
+if not
+ echo '<span class="disabled">prev</span>'
+echo ' | <a href="../index.html">up</a> | '
+if(test -d ../^$"next)
+ echo '<a href="../'^$next^'/index.html">next</a>'
+if not
+ echo '<span class="disabled">next</span>'
+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>'
+}
+
+cat <<EOF
+</body>
+</html>
+EOF
--- /dev/null
+++ b/sdrip/archive.rc
@@ -1,0 +1,12 @@
+#!/bin/rc
+
+ls *.JPG | awk -F_ '{
+ year=substr($1, 1, 4)
+ month=substr($1, 5, 2)
+ dirs[sprintf("%s/%s", year, month)] = 1
+ printf "mv -n %s /home/alex/img/%s/%s/%s\n", $0, year, month, $0
+}
+END{
+ for(d in dirs)
+ printf "mkdir -p /home/alex/img/%s\n", d
+}' | tac
--- /dev/null
+++ b/sdrip/rename.rc
@@ -1,0 +1,15 @@
+#!/bin/rc -e
+
+rename jpg JPG *.jpg >[2]/dev/null || {}
+exiv2 --verbose --Force -t rename *.JPG
+
+sha1sum *.JPG *.jpg >[2]/dev/null | awk '
+function quote(s){
+ gsub("''", "''''", s)
+ return sprintf("%s", s)
+}
+{
+ hash=substr($1, 1, 8)
+ date=substr($2, 1, 15)
+ printf "mv %s %s.%s.full.JPG\n", quote($2), date, hash
+}' | rc
--- /dev/null
+++ b/year.mk
@@ -1,0 +1,55 @@
+MKSHELL=rc
+
+months=\
+ 01\
+ 02\
+ 03\
+ 04\
+ 05\
+ 06\
+ 07\
+ 08\
+ 09\
+ 10\
+ 11\
+ 12\
+
+months=`{ls -d $months >[2]/dev/null}
+montages=`{ls -d $months | sed 's,$,/montage.jpg,'}
+
+all:V: $montages index.html montage.jpg
+
+[0-9]+/montage\.jpg:RQ:
+ for(d in $months)@{
+ if(test -d $d){
+ cd $d
+ mk -f ../../album.mk
+ }
+ if not
+ status=()
+ }
+
+html:V: index.html
+ for(d in $months)@{
+ cd $d
+ mk -f ../../album.mk $target
+ }
+
+index.html: $HOME/img/mkyearidx.rc $montages
+ $HOME/img/mkyearidx.rc >index.html
+
+montage.jpg: $HOME/img/mkmontage.rc $montages
+ $HOME/img/mkmontage.rc
+
+clean:V:
+ rm *.html
+ for(d in $months)@{
+ cd $d
+ mk -f ../../album.mk $target
+ }
+
+nuke:V: clean
+ for(d in $months)@{
+ cd $d
+ mk -f ../../album.mk $target
+ }