Finish the all
page! Even easier than expected and works GREAT!
This commit is contained in:
parent
474c258a83
commit
c6fd3f4786
@ -6,6 +6,7 @@
|
||||
DIR=`dirname $0`
|
||||
header="<html>\n\t<header>\n\t\t<title>ALBUM</title>\n\t</header>\n\t<body>"
|
||||
footer="\n\t</body>\n</html>"
|
||||
a="a target='_blank' rel='noopener noreferrer'"
|
||||
|
||||
## Functions ##
|
||||
function remove_problem_strings {
|
||||
@ -48,6 +49,12 @@ function start_main_page {
|
||||
echo -e "video name to pull up the full resolution for download.</p>" >> $mainpage
|
||||
echo -e "\t\t\t</div>" >> $mainpage
|
||||
echo -e "\t\t</div>" >> $mainpage
|
||||
|
||||
echo -e "\t\t<div class='row'>" >> $mainpage
|
||||
echo -e "\t\t\t<$a href='/files/photos/all/index.html'" >> $mainpage
|
||||
echo -e "\t\t\t\tclass='col-12 header'>Click Here for the Full Image Feed" >> $mainpage
|
||||
echo -e "\t\t\t</a>" >> $mainpage
|
||||
echo -e "\t\t</div>" >> $mainpage
|
||||
}
|
||||
|
||||
## Close out the main page after the sub pages are done being added. ##
|
||||
@ -63,7 +70,7 @@ function build_album_pages {
|
||||
# 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
|
||||
if [[ ! -d "$PHOTOS_DIR/$album" || "$album" == "all" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
@ -73,8 +80,8 @@ function build_album_pages {
|
||||
album_name=${album_name//-/ }
|
||||
echo -e "\t\t<div class='row'>" >> $mainpage
|
||||
echo -en "\t\t\t<h2 class='col-12 title'>" >> $mainpage
|
||||
echo -en "<a href='/files/photos/$album/index.html' " >> $mainpage
|
||||
echo -e "target='_blank' rel='noopener noreferrer'>$album_name</a></h2>" >> $mainpage
|
||||
echo -en "<$a href='/files/photos/$album/index.html'>" >> $mainpage
|
||||
echo -e "$album_name</a></h2>" >> $mainpage
|
||||
echo -e "\t\t</div>" >> $mainpage
|
||||
|
||||
# Catch all the upcoming photo records.
|
||||
@ -115,8 +122,7 @@ function build_album_pages {
|
||||
echo -e "\t\t\t\t<p>`cat $photo`</p>" >> $mainpage
|
||||
else
|
||||
# Otherwise put in the PHOTOS page list.
|
||||
echo -en "\t\t\t\t<li class='indent'><a href=/$photo target='_blank' " >> $mainpage
|
||||
echo -en "rel='noopener noreferrer'>$filename" >> $mainpage
|
||||
echo -en "\t\t\t\t<li class='indent'><$a href='/$photo'>$filename" >> $mainpage
|
||||
if [[ $photo == *".mp4" ]]; then
|
||||
echo -en " [VIDEO]" >> $mainpage
|
||||
fi
|
||||
@ -134,8 +140,7 @@ function build_album_pages {
|
||||
fi
|
||||
# Add the container for the image and its text.
|
||||
echo -e "\t\t\t<div class='col-6 center'>" >> $subpage
|
||||
echo -en "\t\t\t\t<a href=/$photo target='_blank' " >> $subpage
|
||||
echo -e "rel='noopener noreferrer'>" >> $subpage
|
||||
echo -en "\t\t\t\t<$a href='/$photo'>" >> $subpage
|
||||
# Determine what type of media it is, and how to display it.
|
||||
if [[ $photo == *".mp4" ]]; then
|
||||
echo -e "\t\t\t\t\t<video width='320px' controls>" >> $subpage
|
||||
@ -145,7 +150,7 @@ function build_album_pages {
|
||||
elif [[ $photo == *".md" || $photo == *".txt" ]]; then
|
||||
echo -e "\t\t\t\t\t<p>`cat $photo`</p>" >> $subpage
|
||||
else
|
||||
echo -e "\t\t\t\t\t<img src='/$photo'/ alt="">" >> $subpage
|
||||
echo -e "\t\t\t\t\t<img src='/$photo' alt=''>" >> $subpage
|
||||
fi
|
||||
# Check if it needs an extra descriptive detail.
|
||||
echo -en "\t\t\t\t\t<p>$filename" >> $subpage
|
||||
@ -196,18 +201,45 @@ function build_all_page {
|
||||
|
||||
# Add images to the page
|
||||
find $PHOTOS_DIR/ ! -name "*".html | sort -r | while read media_file; do
|
||||
media_name="`basename $media_file`"
|
||||
dir_name="`dirname $media_file`"
|
||||
if [[ -d $media_file
|
||||
|| "$media_file" == *"/photos/README.md"
|
||||
|| "$media_file" == *"/all/README.md"
|
||||
]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
media="<img src='/$media_file'/ alt="">"
|
||||
# Remove the initial '.' from the URI.
|
||||
media_uri="${media_file//\.\//\/}"
|
||||
|
||||
# Path to the image home.
|
||||
dir_uri="`dirname $media_uri`"
|
||||
|
||||
# Prepare variables which will be used throughout the loop.
|
||||
media_name="`basename $media_uri`"
|
||||
dir_name="`basename $dir_uri`"
|
||||
|
||||
# This must be after the dir_name has been pulled.
|
||||
dir_uri="$dir_uri/index.html"
|
||||
|
||||
# Do not show the file extension for the filename.
|
||||
media_name="${media_name%%.*}"
|
||||
|
||||
# Change underscores and dashes to be spaces for better overflow.
|
||||
media_name="${media_name//_/ }"
|
||||
media_name="${media_name//-/ }"
|
||||
dir_name="${dir_name//_/ }"
|
||||
dir_name="${dir_name//-/ }"
|
||||
|
||||
media="<img src='$media_uri' alt='' style='width:100%'>"
|
||||
|
||||
# Determine how to show the file.
|
||||
if [[ $media_name == *".mp4" ]]; then
|
||||
media="<video width='320px' controls>"
|
||||
media="${media}<source src='/$media_file' type=video/mp4>"
|
||||
if [[ $media_uri == *".mp4" ]]; then
|
||||
media="<video controls style='width:100%'>"
|
||||
media="${media}<source src='$media_uri' type=video/mp4>"
|
||||
media="${media}Your browser does not support videos."
|
||||
media="${media}</video>"
|
||||
elif [[ $media_name == *".md" || $media_name == *".txt" ]]; then
|
||||
media_name="$media_name [VIDEO]"
|
||||
elif [[ $media_uri == *".md" || $media_uri == *".txt" ]]; then
|
||||
media="<p>`cat $media_file`</p>"
|
||||
fi
|
||||
|
||||
@ -216,26 +248,34 @@ function build_all_page {
|
||||
count=0
|
||||
fi
|
||||
if [[ $count == 0 ]]; then
|
||||
echo "<div class=row text>" >> $allpage
|
||||
echo -e "\t\t<div class=row text>" >> $allpage
|
||||
fi
|
||||
|
||||
# Add a column.
|
||||
echo "<div class=col-3 center>" >> $allpage
|
||||
echo -e "\t\t\t<div class=col-3>" >> $allpage
|
||||
|
||||
# Add the image.
|
||||
echo "<a href='$media_file'>$media</a>" >> $allpage
|
||||
echo -e "\t\t\t\t<div class=center>" >> $allpage
|
||||
echo -e "\t\t\t\t\t<$a href='$media_uri'>$media</a>" >> $allpage
|
||||
echo -e "\t\t\t\t</div>" >> $allpage
|
||||
|
||||
# Add the URLs.
|
||||
echo "<a href='$dir_name>$dir_name</a>" >> $allpage
|
||||
echo "<a href='$media_file>$media_name</a>" >> $allpage
|
||||
echo -e "\t\t\t\t<div class=center>" >> $allpage
|
||||
echo -e "\t\t\t\t\t<p><$a href='$dir_uri'>$dir_name</a></p>" >> $allpage
|
||||
echo -e "\t\t\t\t</div>" >> $allpage
|
||||
echo -e "\t\t\t\t<div class=center>" >> $allpage
|
||||
echo -e "\t\t\t\t\t<p><$a href='$media_uri'>$media_name</a></p>" >> $allpage
|
||||
echo -e "\t\t\t\t</div>" >> $allpage
|
||||
|
||||
# Close the column.
|
||||
echo "</div>" >> $allpage
|
||||
echo -e "\t\t\t</div>" >> $allpage
|
||||
|
||||
# Close the row and reset the the count if full.
|
||||
if [[ $count == 3 ]]; then
|
||||
echo "</div>" >> $allpage
|
||||
echo -e "\t\t</div>" >> $allpage
|
||||
count=0
|
||||
else
|
||||
count=$(( count + 1 ))
|
||||
fi
|
||||
done
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user