#!/bin/bash # 2024-01-21 Hyperling # Transition away from PhotoPrism. Helps to save system resources and downsize. # Static Variables DIR=`dirname $0` header="\n\t
\n\t\tALBUM\n\t
\n\t" footer="\n\t\n" # Move to the main directory. cd $DIR/.. # Where resources are from the main directory. HELPER_DIR=./pages/helpers PHOTOS_DIR=./files/photos mainpage=$PHOTOS_DIR/index.html # Use the cached version if available. if [[ -e $mainpage ]]; then cat $mainpage echo "" exit 0 fi # Create the necessary HTML components for a web page. $HELPER_DIR/body_open.php > $mainpage echo "" >> $mainpage # Give the page a description. echo -e "\t\t
" >> $mainpage echo -e "\t\t\t

Albums

" >> $mainpage echo -e "\t\t
" >> $mainpage echo -e "\t\t
" >> $mainpage echo -e "\t\t\t
" >> $mainpage echo -en "\t\t\t\t

You may click on an album name to " >> $mainpage echo -en "view all of its files, or click on a specific image to bring up the " >> $mainpage echo -en "full resolution. On the album pages you may also click an image or " >> $mainpage echo -e "video name to pull up the full resolution for download.

" >> $mainpage echo -e "\t\t\t
" >> $mainpage echo -e "\t\t
" >> $mainpage # Display the album names descending. ls $PHOTOS_DIR/ | sort -r | while read album; do # Skip files, only read directories. if [[ ! -d $PHOTOS_DIR/$album ]]; then continue fi # Clean album name. album_name=${album} album_name=${album_name//_/ } album_name=${album_name//-/ } echo -e "\t\t
" >> $mainpage echo -en "\t\t\t

" >> $mainpage echo -en "> $mainpage echo -e "target='_blank' rel='noopener noreferrer'>$album_name

" >> $mainpage echo -e "\t\t
" >> $mainpage # Catch all the upcoming photo records. echo -e "\t\t
\n\t\t\t
" >> $mainpage # Create index page for each photo ALBUM based on its contents. page="" subpage="$PHOTOS_DIR/$album/index.html" $HELPER_DIR/body_open.php > $subpage # Add a back button echo -en "\n\t\t" >> $subpage # Build the ALBUM page. echo -e "\t\t
" >> $subpage echo -e "\t\t\t

$album_name

" >> $subpage echo -e "\t\t
" >> $subpage ls $PHOTOS_DIR/$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\t

`cat $photo`

" >> $mainpage else # Otherwise put in the PHOTOS page list. echo -en "\t\t\t\t
  • > $mainpage echo -en "rel='noopener noreferrer'>$filename" >> $mainpage if [[ $photo == *".mp4" ]]; then echo -en " [VIDEO]" >> $mainpage fi echo -e "
  • " >> $mainpage fi ## Put in the subpage HTML ## # Set the count if this is the first loop. if [[ -z $count ]]; then count=0 fi # Add a row for the next 2 images. if (( $count % 2 == 0 )); then echo -e "\t\t" >> $subpage fi count=$(( count + 1 )) done echo -e "\t\t
    " >> $subpage # End album listings on PHOTOS page. echo -e "\t\t\t
    " >> $mainpage echo -e "\t\t" >> $mainpage # Add a final back button echo -en "\n\t\t
    \n\t\t\t" >> $subpage echo -e "

    Back

    \n\t\t
    " >> $subpage # Close out the ALBUM's page. $HELPER_DIR/body_close.php >> $subpage echo "" >> $subpage done # Finish the web page. $HELPER_DIR/body_close.php >> $mainpage echo "" >> $mainpage cat $mainpage exit 0