~chambln/cosine.blue

22d4376cd39fdaadd9927019c023fa7ab87c55e1 — Gregory Chamberlain 2 months ago 3e993a9
Add photo gallery

Imagemagick’s convert(1) command is now required to build the site in
order to generate the thumbnails.

Use the photos-import script to import new photos into the repo.  They
will be resized and added to the gallery.  Example usage:

    contrib/photos-import ~/Pictures/*
M bin/make => bin/make +6 -0
@@ 142,4 142,10 @@ for src in src/* src/*/*; do [ -f "$src" ] && (
        *.html) html < "$src" > www/"$bn" ;;
        *) cp -f "$src" www
    esac
    case $src in
        src/photos/*)
            mkdir -p www/thumbnail
            convert "$src" -resize 480x www/thumbnail/"$bn"
            ;;
    esac
) done

A contrib/photos-import => contrib/photos-import +13 -0
@@ 0,0 1,13 @@
#!/bin/sh -e

[ -d src ]
mkdir -p src/photos
for img; do
    output_file=src/photos/${img##*/}

    # Skip $img if it’s already been imported.
    [ -e "$output_file" ] && continue

    # Copy $img into the repo, shrinking it if it’s too big.
    convert "$img" -resize '1500x>' "$output_file"
done

A env/photos.html.sh.sh => env/photos.html.sh.sh +1 -0
@@ 0,0 1,1 @@
title=Photos

M share/style.css => share/style.css +7 -0
@@ 136,11 136,18 @@
    }
}

@media (min-width: 480px) {
    #photos {
        column-count: 2;
    }
}

small {
    color: var(--fg-faded);
}

img, figure {
    width: 100%;
    max-width: 100%;
    margin: 0;
}

M src/index.html.sh => src/index.html.sh +2 -3
@@ 22,9 22,8 @@
. share/lib.sh

cmark <<EOF
*New:* [Recommended Hardware And Software].

  [Recommended Hardware And Software]: /recommended.html
- [Recommended Hardware And Software](/recommended.html)
- [Photos](/photos.html)
EOF

x h2 Recently

A src/photos.html.sh => src/photos.html.sh +16 -0
@@ 0,0 1,16 @@
. share/lib.sh

cmark <<EOF
Here are some of the photos I’ve taken.  They are all Creative
Commons—see [licence](/licence.html) for more details.  Higher
resolution copies are available on request (up to 5184 x 3456).  Just
[send me an email] specifying which image(s) you would like.

  [send me an email]: mailto:greg@cosine.blue
EOF

for img in src/photos/*; do
    [ -e "$img" ] || continue
    img=${img##*/}
    printf '<a href="%s"><figure><img src="%s"></figure></a>' /"$img" /thumbnail/"$img"
done | x 'section id="photos""'

A src/photos/IMG_0340.JPG => src/photos/IMG_0340.JPG +0 -0
A src/photos/IMG_0341.JPG => src/photos/IMG_0341.JPG +0 -0
A src/photos/IMG_0370.JPG => src/photos/IMG_0370.JPG +0 -0
A src/photos/IMG_0374.JPG => src/photos/IMG_0374.JPG +0 -0
A src/photos/IMG_0388.JPG => src/photos/IMG_0388.JPG +0 -0
A src/photos/IMG_0390.JPG => src/photos/IMG_0390.JPG +0 -0
A src/photos/IMG_0397.JPG => src/photos/IMG_0397.JPG +0 -0
A src/photos/IMG_0405.JPG => src/photos/IMG_0405.JPG +0 -0
A src/photos/IMG_0409.JPG => src/photos/IMG_0409.JPG +0 -0
A src/photos/IMG_0416.JPG => src/photos/IMG_0416.JPG +0 -0
A src/photos/IMG_0423.JPG => src/photos/IMG_0423.JPG +0 -0
A src/photos/IMG_0433.JPG => src/photos/IMG_0433.JPG +0 -0
A src/photos/IMG_0438.JPG => src/photos/IMG_0438.JPG +0 -0
A src/photos/IMG_0449.JPG => src/photos/IMG_0449.JPG +0 -0
A src/photos/IMG_0457.JPG => src/photos/IMG_0457.JPG +0 -0
A src/photos/IMG_0462.JPG => src/photos/IMG_0462.JPG +0 -0