diff options
author | rodri <rgl@antares-labs.eu> | 2023-08-19 18:23:17 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2023-08-19 18:23:17 +0000 |
commit | cdab944f806f94404b5f9bc0231ed1af43bcb888 (patch) | |
tree | 7605c692e5fcde4b2e550b610da87f5014d5f266 /mkgallery | |
parent | 9d48b7e5fcf840f710a7519800a3650fc7cf0aae (diff) | |
download | mkweb-cdab944f806f94404b5f9bc0231ed1af43bcb888.tar.gz mkweb-cdab944f806f94404b5f9bc0231ed1af43bcb888.tar.bz2 mkweb-cdab944f806f94404b5f9bc0231ed1af43bcb888.zip |
Diffstat (limited to 'mkgallery')
-rwxr-xr-x | mkgallery | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/mkgallery b/mkgallery new file mode 100755 index 0000000..6791a8f --- /dev/null +++ b/mkgallery @@ -0,0 +1,38 @@ +#!/bin/rc +rfork en + +fn entitle { + basename $1 | sed 's/-/ /g' | bin/capitalize +} + +fn usage { + echo usage: $0 path >[1=2] + exit usage +} + +if(! ~ $#* 1) + usage + +if(! test -d $1) + usage + +media=`{walk -f $1 | grep -i '\.(jpe?g|png|webp|mp4|webm)$'} + +>$1/index.html { + title=`{entitle $1 | sed 's/\./ /g'} + <tpl/head sed 's/(<title>[^<]*)/\1 - '^$"title^'/' + cat tpl/menu + echo '<h1>'^$"title^'</h1>' + echo '<div id="gallery">' + for(p in $media){ + if(~ $p *.mp4 *.webm) + echo -n '<video width="200px" height="auto" controls><source src="/'^$p^'"></video>' + if not { + echo -n '<a href="/'^$p^'" target="_blank">' + echo -n '<img src="/'^$p^'" width="200px" height="auto"></img>' + echo '</a>' + } + } + echo '</div>' + cat tpl/feet +} |