#!/bin/bash # 2024-01-21 Hyperling # Transition away from PhotoPrism. Helps to save system resources and downsize. # Static Variables header="\n\t
\n\t\tALBUM\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\t

Photo Albums

" echo -en "\t\t

You 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

" echo -en "$album_name

" echo -e "\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 echo -en "\t\t\t> $subpage echo -e "rel='noopener noreferrer'>" >> $subpage if [[ $photo == *".mp4" ]]; then echo -e "\t\t\t\t" >> $subpage elif [[ $photo == *".md" || $photo == *".txt" ]]; then echo -e "\t\t\t\t

    `cat $photo`

    " >> $subpage else echo -e "\t\t\t\t" >> $subpage fi # Add a descriptive link. echo -en "\t\t\t\t

    $filename" >> $subpage if [[ $photo == *".mp4" ]]; then echo -en " [VIDEO]" >> $subpage fi echo -e "

    \n\t\t\t
    \n\t\t
    " >> $subpage done # End album on PHOTOS page. echo -e "\t\t
    " # Add a final back button echo -en "\t\t" >> $subpage echo -e "

    Back

    " >> $subpage # Close out the ALBUM's page. $HELPER_DIR/body_close.php >> $subpage done # Finish the web page. $HELPER_DIR/body_close.php