dotfiles/.bin/website-add-image-to-gallery

47 lines
938 B
Plaintext
Raw Normal View History

2022-12-23 09:36:12 +01:00
#!/bin/sh
_imgpath="$(readlink -f "$1" || exit 2)"
_imgname="$(basename "$_imgpath")"
_imgnamenoext="${_imgname%%.*}"
cd $HOME/website/site/photos
gallerydir="$((echo NEW; find * -mindepth 0 -maxdepth 0 -type d; ) | fzf)"
if [ "$gallerydir" == "NEW" ]
then
echo -n "Add new gallery name ($(date +"%Y-%m-%d_")): "
read -r gallerydir
[ -z "$gallerydir" ] && exit 2
2022-12-23 19:19:15 +01:00
mkdir -p "$gallerydir"
2022-12-23 09:36:12 +01:00
echo -n "Add gallery description [y/N]: "
read -r gallerydescr
case $gallerydescr in
2022-12-23 19:19:15 +01:00
[yY]) vim "${gallerydir}/index.txt"; ;;
2022-12-23 09:36:12 +01:00
esac
fi
cp "$_imgpath" "$gallerydir/"
echo -n "Add image description? [y/N]: "
read -r imagedescr
case $imagedescr in
[yY]) vim "${gallerydir}/${_imgnamenoext}.txt"; ;;
esac
echo -n "Regenerate Website? [y/N]: "
read -r regen
case $regen in
[yY]) cd ~/website && make remote; ;;
esac
echo
echo "https://stefanhagen.de/photos/$gallerydir/${_imgnamenoext}.html"
echo