diff --git a/files/photos/README.md b/files/photos/README.md
index 118a7ff..4bc762a 100644
--- a/files/photos/README.md
+++ b/files/photos/README.md
@@ -1,3 +1,9 @@
# Hyperling.com - files/photos/
-Used by `http://localhost:8080/photos` to build albums for sharing.
+## index.html
+
+Used by `http://localhost:8080/photos` to build and show list of albums.
+
+## all.html
+
+Used by `http://localhost:8080/photos-all` to show all albums at once.
diff --git a/main.js b/main.js
index cef8888..f44b4de 100755
--- a/main.js
+++ b/main.js
@@ -141,6 +141,7 @@ async function main() {
/* AUTOMATIC METHOD BASED ON OBJECT/ARRAY OF WEB SCRIPTS
// Creates routes with the URL of the key and location of the value.
*/
+ // TBD/TODO would be great to log this as "DATE: ADDRESS hit ROUTER requesting RESOURCE"
for (let key in pages) {
console.log(" * Creating router for", key);
router.get("/" + key, function (req,res) {
@@ -182,6 +183,7 @@ async function main() {
`;
// Provide sitemap.xml file for "SEO".
+ // TBD/TODO would be great to log this as "DATE: ADDRESS hit ROUTER requesting RESOURCE"
console.log(" * Creating router for sitemap.xml");
router.get('/sitemap.xml', function (req, res) {
console.log("sitemap.xml being provided to", req.socket.remoteAddress)
@@ -190,6 +192,7 @@ async function main() {
});
// Provide human-usable sitemap links.
+ // TBD/TODO would be great to log this as "DATE: ADDRESS hit ROUTER requesting RESOURCE"
console.log(" * Creating router for sitemap*");
router.get('/sitemap*', function (req, res) {
console.log("sitemap.html being provided to", req.socket.remoteAddress)
@@ -197,6 +200,7 @@ async function main() {
});
// Return a resource from the files folder.
+ // TBD/TODO would be great to log this as "DATE: ADDRESS hit ROUTER requesting RESOURCE"
console.log(" * Creating router for files");
router.get('/files*', function (req, res) {
console.log("file response to", req.socket.remoteAddress, "asking for", req.url)
@@ -212,7 +216,8 @@ async function main() {
case "apk":
mime = "application/vnd.android.package-archive";
break;
- case "jpg" || "jpeg":
+ case "jpg":
+ case "jpeg":
mime = "image/jpeg";
break;
case "png":
@@ -224,7 +229,9 @@ async function main() {
case "zip":
mime = "application/zip";
break;
- case "txt" || "csv" || "md":
+ case "md":
+ case "txt":
+ case "csv":
mime = "text/*";
break;
default:
diff --git a/pages/about.php b/pages/about.php
index a626e30..0781d5a 100755
--- a/pages/about.php
+++ b/pages/about.php
@@ -1,5 +1,8 @@
#!/usr/bin/php
diff --git a/pages/apps.php b/pages/apps.php
index 97405c5..7b98f22 100755
--- a/pages/apps.php
+++ b/pages/apps.php
@@ -3,5 +3,8 @@
Synonym for home page.
-->
diff --git a/pages/contact.php b/pages/contact.php
index 40d4125..a315c8e 100755
--- a/pages/contact.php
+++ b/pages/contact.php
@@ -1,5 +1,8 @@
#!/usr/bin/php
diff --git a/pages/donate.php b/pages/donate.php
index 2aabe91..7304fc8 100755
--- a/pages/donate.php
+++ b/pages/donate.php
@@ -3,5 +3,8 @@
Alias for the support page with a more common name.
-->
diff --git a/pages/health.php b/pages/health.php
index 21e75c2..de0ec0d 100755
--- a/pages/health.php
+++ b/pages/health.php
@@ -4,6 +4,9 @@
-->
diff --git a/pages/helpers/header.php b/pages/helpers/header.php
index 352a717..4f2350b 100755
--- a/pages/helpers/header.php
+++ b/pages/helpers/header.php
@@ -1,8 +1,15 @@
#!/usr/bin/php
+
- Hyperling
+ Hyperling
diff --git a/pages/home.php b/pages/home.php
index 9d71f09..66631fc 100755
--- a/pages/home.php
+++ b/pages/home.php
@@ -3,6 +3,9 @@
Landing page, keeping it apps and development projects like old WordPress site.
-->
diff --git a/pages/journey.sh b/pages/journey.sh
index 23e01f2..b0db2f3 100755
--- a/pages/journey.sh
+++ b/pages/journey.sh
@@ -4,7 +4,7 @@
cd `dirname $0`
# Create the necessary HTML components for a web page.
-./helpers/body_open.php
+./helpers/body_open.php | sed -e 's/Hyperling/Hyperling: Journey/'
#Content for this page
cat << EOF
diff --git a/pages/lists.php b/pages/lists.php
index d8377ea..ec87496 100755
--- a/pages/lists.php
+++ b/pages/lists.php
@@ -3,6 +3,9 @@
Lists of items which I'd like to share such as gear and frequently used apps.
-->
diff --git a/pages/media.php b/pages/media.php
index 74112e7..4c91a82 100755
--- a/pages/media.php
+++ b/pages/media.php
@@ -3,6 +3,9 @@
Page for my video links.
-->
diff --git a/pages/photos-all.sh b/pages/photos-all.sh
new file mode 100755
index 0000000..68024a8
--- /dev/null
+++ b/pages/photos-all.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+# Alias for new All Photos feed.
+
+# Move to main directory.
+DIR=`dirname $0`
+cd $DIR/..
+
+# Locations of photo scripts.
+photos_all=./files/photos/all.html
+photos=./pages/photos.sh
+
+# If the all script does not exist,call the generator and ignore its output.
+if [[ ! -e $photos_all ]]; then
+ $photos > /dev/null
+fi
+
+## Main ##
+cat $photos_all
+
+exit 0
diff --git a/pages/photos.sh b/pages/photos.sh
index c094b7e..2924752 100755
--- a/pages/photos.sh
+++ b/pages/photos.sh
@@ -2,12 +2,11 @@
# 2024-01-21 Hyperling
# Transition away from PhotoPrism. Helps to save system resources and downsize.
-# Static Variables
+## Static Variables ##
DIR=`dirname $0`
-header="\n\t\n\t\tALBUM\n\t\n\t"
-footer="\n\t\n"
+a="a target='_blank' rel='noopener noreferrer'"
-# Functions
+## Functions ##
function remove_problem_strings {
file="$1"
sed -i -e 's/#!\/usr\/bin\/php//g' $file
@@ -20,6 +19,7 @@ cd $DIR/..
HELPER_DIR=./pages/helpers
PHOTOS_DIR=./files/photos
mainpage=$PHOTOS_DIR/index.html
+allpage=$PHOTOS_DIR/all.html
# Use the cached version if available.
if [[ -e $mainpage ]]; then
@@ -28,146 +28,273 @@ if [[ -e $mainpage ]]; then
exit 0
fi
-# Create the necessary HTML components for a web page.
-$HELPER_DIR/body_open.php > $mainpage
-echo "" >> $mainpage
+## Start the main /photos/ page. ##
+function start_main_page {
+ # Create the necessary HTML components for a web page.
+ $HELPER_DIR/body_open.php > $mainpage
+ sed -i -e 's/Hyperling/Hyperling: Photos/' $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//-/ }
+ # Give the page a description.
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
- 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
- # Add the container for the image and its text.
- echo -e "\t\t\t
" >> $subpage
-
- # End album listings on PHOTOS page.
+ 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
- # Add a final back button
- echo -en "\n\t\t
" >> $mainpage
-remove_problem_strings $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
+ sed -i -e "s/Hyperling/Hyperling: $album_name/" $subpage
+ echo "" >> $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
<$a href='/$photo'>$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
+ # Add the container for the image and its text.
+ echo -e "\t\t\t
" >> $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" >> $subpage
+ elif [[ $photo == *".md" || $photo == *".txt" ]]; then
+ echo -e "\t\t\t\t\t
`cat $photo`
" >> $subpage
+ else
+ echo -e "\t\t\t\t\t" >> $subpage
+ fi
+ # Check if it needs an extra descriptive detail.
+ echo -en "\t\t\t\t\t
$filename" >> $subpage
+ if [[ $photo == *".mp4" ]]; then
+ echo -en " [VIDEO]" >> $subpage
+ fi
+ # Close the image description and its link.
+ echo -e "
\n\t\t\t\t\n\t\t\t
" >> $subpage
+ # Close the row after an odd count.
+ if (( $count % 2 == 1 )); then
+ echo -e "\t\t
" >> $subpage
+
+ # Close out the ALBUM's page.
+ $HELPER_DIR/body_close.php >> $subpage
+ echo "" >> $subpage
+ remove_problem_strings $subpage
+ done
+}
+
+## Create an ALL page. ##
+function build_all_page {
+ # - Shows all photos in descending order, as an overall feed.
+ # - Four images wide.
+ # - Has 2 URLs below the image. One to the album, and one to the image.
+ # - Image is a URL to itself as with other pages.
+ # - Images are shown at maximum 500px or so vertical for quick scrolling.
+
+ # Create/overwrite file.
+ $HELPER_DIR/body_open.php > $allpage
+ sed -i -e 's/Hyperling/Hyperling: All Photos/' $allpage
+ echo "" >> $allpage
+
+ # Add header.
+ echo -e "\t\t
" >> $allpage
+ echo -e "\t\t\t
All Photo Feed
" >> $allpage
+ echo -e "\t\t
" >> $allpage
+
+ # Add images to the page
+ find $PHOTOS_DIR/ ! -name "*".html | sort -r | while read media_file; do
+ if [[ -d $media_file
+ || "$media_file" == *"/photos/README.md"
+ ]]; then
+ continue
+ fi
+
+ # 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=""
+
+ # Determine how to show the file.
+ if [[ $media_uri == *".mp4" ]]; then
+ media=""
+ media_name="$media_name [VIDEO]"
+ elif [[ $media_uri == *".md" || $media_uri == *".txt" ]]; then
+ media="
`cat $media_file`
"
+ fi
+
+ # Add a row if count has reset.
+ if [[ -z $count ]]; then
+ count=0
+ fi
+ if [[ $count == 0 ]]; then
+ echo -e "\t\t
" >> $allpage
+ fi
+
+ # Add a column.
+ echo -e "\t\t\t