2022-12-23 09:36:12 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2022-12-27 19:16:20 +01:00
|
|
|
_imgpath="$(readlink -f "${*}")"
|
2022-12-23 09:36:12 +01:00
|
|
|
_imgname="$(basename "$_imgpath")"
|
|
|
|
|
2022-12-27 19:16:20 +01:00
|
|
|
edit_template() {
|
|
|
|
[ ! -f "$1" ] \
|
|
|
|
&& echo "<p></p>" > "$1"
|
|
|
|
vim "$1"
|
|
|
|
}
|
2022-12-23 09:36:12 +01:00
|
|
|
|
2022-12-27 19:16:20 +01:00
|
|
|
error_exit() {
|
|
|
|
echo "$1"
|
|
|
|
read
|
|
|
|
exit 1
|
|
|
|
}
|
2022-12-23 09:36:12 +01:00
|
|
|
|
2022-12-27 19:16:20 +01:00
|
|
|
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"
|
|
|
|
|
2023-01-01 10:16:54 +01:00
|
|
|
cd "${HOME}/website/photos"
|
2022-12-27 19:16:20 +01:00
|
|
|
|
|
|
|
gallerydir="$((echo NEW; find * -mindepth 0 -maxdepth 0 -type d; ) \
|
|
|
|
| fzf --prompt "Directory> " \
|
|
|
|
|| error_exit "Directory not set after fzf")"
|
|
|
|
|
|
|
|
if [ "${gallerydir}" == "NEW" ]
|
2022-12-23 09:36:12 +01:00
|
|
|
then
|
|
|
|
|
|
|
|
echo -n "Add new gallery name ($(date +"%Y-%m-%d_")): "
|
|
|
|
read -r gallerydir
|
|
|
|
|
2022-12-27 19:16:20 +01:00
|
|
|
[ -z "${gallerydir}" ] \
|
|
|
|
&& error_exit "New directory requested, but not set"
|
|
|
|
|
|
|
|
mkdir -p "${gallerydir}"
|
2022-12-23 09:36:12 +01:00
|
|
|
|
|
|
|
echo -n "Add gallery description [y/N]: "
|
|
|
|
read -r gallerydescr
|
2022-12-27 19:16:20 +01:00
|
|
|
|
|
|
|
case "${gallerydescr}" in
|
|
|
|
[yY]) edit_template "${gallerydir}/index.txt"; ;;
|
2022-12-23 09:36:12 +01:00
|
|
|
esac
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
2022-12-27 19:16:20 +01:00
|
|
|
[ -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
|
|
|
|
|
2023-01-01 10:16:54 +01:00
|
|
|
jhead -q -autorot "${gallerydir}/${_name}.jpg"
|
2022-12-27 19:16:20 +01:00
|
|
|
jpegoptim -w 12 --all-progressive --strip-all "$gallerydir/${_name}.jpg"
|
2022-12-23 09:36:12 +01:00
|
|
|
|
|
|
|
echo -n "Add image description? [y/N]: "
|
|
|
|
read -r imagedescr
|
|
|
|
|
2022-12-27 19:16:20 +01:00
|
|
|
case "$imagedescr" in
|
|
|
|
[yY]) edit_template "${gallerydir}/${_name}.txt"; ;;
|
2022-12-23 09:36:12 +01:00
|
|
|
esac
|
|
|
|
|
2023-01-07 15:07:46 +01:00
|
|
|
cd "${HOME}/website/photos"
|
|
|
|
git pull
|
|
|
|
find . -type f \
|
|
|
|
-not -name "*.html" \
|
|
|
|
-not -path "*/mid/*" \
|
|
|
|
-not -path "*/thm/*" \
|
|
|
|
-exec git add {} +
|
|
|
|
git commit -m "Adding ${_name} to ${gallerydir}"
|
|
|
|
git push
|
|
|
|
|
2022-12-23 09:36:12 +01:00
|
|
|
echo -n "Regenerate Website? [y/N]: "
|
|
|
|
read -r regen
|
|
|
|
|
|
|
|
case $regen in
|
2022-12-27 19:16:20 +01:00
|
|
|
[yY]) cd ~/website && make; ;;
|
2022-12-23 09:36:12 +01:00
|
|
|
esac
|
|
|
|
|
|
|
|
echo
|
2022-12-27 19:16:20 +01:00
|
|
|
echo "https://stefanhagen.de/photos/${gallerydir}/${_name}.html"
|
2022-12-23 09:36:12 +01:00
|
|
|
echo
|
2022-12-27 19:16:20 +01:00
|
|
|
|
|
|
|
read
|