Update 2022-12-27 19:16 OpenBSD/amd64
This commit is contained in:
@@ -1,46 +1,103 @@
|
||||
#!/bin/sh
|
||||
|
||||
_imgpath="$(readlink -f "$1" || exit 2)"
|
||||
_imgpath="$(readlink -f "${*}")"
|
||||
_imgname="$(basename "$_imgpath")"
|
||||
_imgnamenoext="${_imgname%%.*}"
|
||||
|
||||
cd $HOME/website/site/photos
|
||||
edit_template() {
|
||||
[ ! -f "$1" ] \
|
||||
&& echo "<p></p>" > "$1"
|
||||
vim "$1"
|
||||
}
|
||||
|
||||
gallerydir="$((echo NEW; find * -mindepth 0 -maxdepth 0 -type d; ) | fzf)"
|
||||
error_exit() {
|
||||
echo "$1"
|
||||
read
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ "$gallerydir" == "NEW" ]
|
||||
if [ -z "${_imgpath}" ]
|
||||
then
|
||||
echo "Could not read image path: $1"
|
||||
read
|
||||
fi
|
||||
|
||||
_names="\
|
||||
$(exiftool -q -q -p '$modifyDate' -p '$createDate' -p '$dateTimeOriginal' "${_imgpath}" | tr ':' '-' | tr ' ' '_')
|
||||
$(basename "$(dirname "${_imgpath}")")
|
||||
${_imgname%%.*}
|
||||
_custom
|
||||
$(date +"%Y-%m-%d_%H-%M-%S")"
|
||||
|
||||
_name="$( echo "$_names" \
|
||||
| sort -u \
|
||||
| fzf --prompt="Filename> " \
|
||||
|| error_exit "fzf on name selection failed")"
|
||||
|
||||
if [ "${_name}" == "_custom" ]
|
||||
then
|
||||
echo "$_names"
|
||||
echo -n "Filename (without extension): "
|
||||
read -r _name
|
||||
fi
|
||||
|
||||
[ -z "${_name}" ] \
|
||||
&& error_exit "Filename not set"
|
||||
|
||||
cd "${HOME}/website/site/photos"
|
||||
|
||||
gallerydir="$((echo NEW; find * -mindepth 0 -maxdepth 0 -type d; ) \
|
||||
| fzf --prompt "Directory> " \
|
||||
|| error_exit "Directory not set after fzf")"
|
||||
|
||||
if [ "${gallerydir}" == "NEW" ]
|
||||
then
|
||||
|
||||
echo -n "Add new gallery name ($(date +"%Y-%m-%d_")): "
|
||||
read -r gallerydir
|
||||
|
||||
[ -z "$gallerydir" ] && exit 2
|
||||
mkdir -p "$gallerydir"
|
||||
[ -z "${gallerydir}" ] \
|
||||
&& error_exit "New directory requested, but not set"
|
||||
|
||||
mkdir -p "${gallerydir}"
|
||||
|
||||
echo -n "Add gallery description [y/N]: "
|
||||
read -r gallerydescr
|
||||
case $gallerydescr in
|
||||
[yY]) vim "${gallerydir}/index.txt"; ;;
|
||||
|
||||
case "${gallerydescr}" in
|
||||
[yY]) edit_template "${gallerydir}/index.txt"; ;;
|
||||
esac
|
||||
|
||||
fi
|
||||
|
||||
cp "$_imgpath" "$gallerydir/"
|
||||
[ -z "${gallerydir}" ] \
|
||||
&& error_exit "Directory not set"
|
||||
|
||||
_mime="$(file -ib "${_imgpath}")"
|
||||
if [ "${_mime}" == "image/jpeg" ]
|
||||
then
|
||||
cp "${_imgpath}" "${gallerydir}/${_name}.jpg"
|
||||
else
|
||||
convert "${_imgpath}" "${gallerydir}/${_name}.jpg"
|
||||
fi
|
||||
|
||||
jpegoptim -w 12 --all-progressive --strip-all "$gallerydir/${_name}.jpg"
|
||||
|
||||
echo -n "Add image description? [y/N]: "
|
||||
read -r imagedescr
|
||||
|
||||
case $imagedescr in
|
||||
[yY]) vim "${gallerydir}/${_imgnamenoext}.txt"; ;;
|
||||
case "$imagedescr" in
|
||||
[yY]) edit_template "${gallerydir}/${_name}.txt"; ;;
|
||||
esac
|
||||
|
||||
echo -n "Regenerate Website? [y/N]: "
|
||||
read -r regen
|
||||
|
||||
case $regen in
|
||||
[yY]) cd ~/website && make remote; ;;
|
||||
[yY]) cd ~/website && make; ;;
|
||||
esac
|
||||
|
||||
echo
|
||||
echo "https://stefanhagen.de/photos/$gallerydir/${_imgnamenoext}.html"
|
||||
echo "https://stefanhagen.de/photos/${gallerydir}/${_name}.html"
|
||||
echo
|
||||
|
||||
read
|
||||
|
||||
Reference in New Issue
Block a user