#!/bin/bash
# 2024-01-21 Hyperling
# Transition away from PhotoPrism. Helps to save system resources and downsize.
# Static Variables
header="\n\t\n\t
"
footer="\n\t\n"
HELPER_DIR=./pages/helpers
# Move to the main project directory.
cd `dirname $0`/..
# Create the necessary HTML components for a web page.
$HELPER_DIR/body_open.php
# Give the page a description.
echo -e "\n\t\tYou may click on an album name to view "
echo -en "all of its files, or click on a specific image to bring up the full "
echo -en "resolution. On the album pages you may also click an image or video "
echo -e "name to pull up the full resolution for download.
"
# Display the album names descending.
ls files/photos/ | sort -r | while read album; do
# Clean album name.
album_name=${album}
album_name=${album_name//_/ }
album_name=${album_name//-/ }
echo -en "\t\t"
# Create index page for each photo ALBUM based on its contents.
page=""
subpage="files/photos/$album/index.html"
$HELPER_DIR/body_open.php > $subpage
# Add a back button
echo -en "\n\t\t
" >> $subpage
echo -e "Back
" >> $subpage
# Build the ALBUM page.
echo -e "\t\t
$album_name
" >> $subpage
ls files/photos/$album/* | sort | while read photo; do
# Do not include the index page.
if [[ $photo == *"index.html" ]]; then
continue
fi
# Clean filename to be a little more presentable.
# Going with CAPSLOCK. ;)
typeset -u filename
filename="`basename $photo`"
# Remove extension.
filename="${filename%%.*}"
# Remove special characters for spaces.
filename="${filename//_/ }"
filename="${filename//-/ }"
if [[ $photo == *"/README.md" || $photo == *"/README.txt" ]]; then
# If there is a README, show it on the PHOTOS page without a link.
echo -e "\t\t\t
`cat $photo`
"
else
# Otherwise put in the PHOTOS page list.
echo -en "\t\t\t
$filename"
if [[ $photo == *".mp4" ]]; then
echo -en " [VIDEO]"
fi
echo -e ""
fi
# Put in the subpage HTML.
echo -e "\t\t
" >> $subpage
done
# End album on PHOTOS page.
echo -e "\t\t
"
# Add a final back button
echo -en "\t\t