Merge pull request 'Page Titles & All Photos Page' (#5) from dev into main
Reviewed-on: #5
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
# Hyperling.com - files/photos/
|
# 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.
|
||||||
|
11
main.js
11
main.js
@ -141,6 +141,7 @@ async function main() {
|
|||||||
/* AUTOMATIC METHOD BASED ON OBJECT/ARRAY OF WEB SCRIPTS
|
/* AUTOMATIC METHOD BASED ON OBJECT/ARRAY OF WEB SCRIPTS
|
||||||
// Creates routes with the URL of the key and location of the value.
|
// 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) {
|
for (let key in pages) {
|
||||||
console.log(" * Creating router for", key);
|
console.log(" * Creating router for", key);
|
||||||
router.get("/" + key, function (req,res) {
|
router.get("/" + key, function (req,res) {
|
||||||
@ -182,6 +183,7 @@ async function main() {
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
// Provide sitemap.xml file for "SEO".
|
// 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");
|
console.log(" * Creating router for sitemap.xml");
|
||||||
router.get('/sitemap.xml', function (req, res) {
|
router.get('/sitemap.xml', function (req, res) {
|
||||||
console.log("sitemap.xml being provided to", req.socket.remoteAddress)
|
console.log("sitemap.xml being provided to", req.socket.remoteAddress)
|
||||||
@ -190,6 +192,7 @@ async function main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Provide human-usable sitemap links.
|
// 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*");
|
console.log(" * Creating router for sitemap*");
|
||||||
router.get('/sitemap*', function (req, res) {
|
router.get('/sitemap*', function (req, res) {
|
||||||
console.log("sitemap.html being provided to", req.socket.remoteAddress)
|
console.log("sitemap.html being provided to", req.socket.remoteAddress)
|
||||||
@ -197,6 +200,7 @@ async function main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Return a resource from the files folder.
|
// 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");
|
console.log(" * Creating router for files");
|
||||||
router.get('/files*', function (req, res) {
|
router.get('/files*', function (req, res) {
|
||||||
console.log("file response to", req.socket.remoteAddress, "asking for", req.url)
|
console.log("file response to", req.socket.remoteAddress, "asking for", req.url)
|
||||||
@ -212,7 +216,8 @@ async function main() {
|
|||||||
case "apk":
|
case "apk":
|
||||||
mime = "application/vnd.android.package-archive";
|
mime = "application/vnd.android.package-archive";
|
||||||
break;
|
break;
|
||||||
case "jpg" || "jpeg":
|
case "jpg":
|
||||||
|
case "jpeg":
|
||||||
mime = "image/jpeg";
|
mime = "image/jpeg";
|
||||||
break;
|
break;
|
||||||
case "png":
|
case "png":
|
||||||
@ -224,7 +229,9 @@ async function main() {
|
|||||||
case "zip":
|
case "zip":
|
||||||
mime = "application/zip";
|
mime = "application/zip";
|
||||||
break;
|
break;
|
||||||
case "txt" || "csv" || "md":
|
case "md":
|
||||||
|
case "txt":
|
||||||
|
case "csv":
|
||||||
mime = "text/*";
|
mime = "text/*";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
#!/usr/bin/php
|
#!/usr/bin/php
|
||||||
<?php
|
<?php
|
||||||
|
if (!isset($GLOBALS["HEADER_TITLE"])) {
|
||||||
|
$GLOBALS["HEADER_TITLE"] = "About";
|
||||||
|
}
|
||||||
include "helpers/body_open.php";
|
include "helpers/body_open.php";
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
@ -3,5 +3,8 @@
|
|||||||
Synonym for home page.
|
Synonym for home page.
|
||||||
-->
|
-->
|
||||||
<?php
|
<?php
|
||||||
|
if (!isset($GLOBALS["HEADER_TITLE"])) {
|
||||||
|
$GLOBALS["HEADER_TITLE"] = "Apps";
|
||||||
|
}
|
||||||
include "home.php";
|
include "home.php";
|
||||||
?>
|
?>
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
#!/usr/bin/php
|
#!/usr/bin/php
|
||||||
<?php
|
<?php
|
||||||
|
if (!isset($GLOBALS["HEADER_TITLE"])) {
|
||||||
|
$GLOBALS["HEADER_TITLE"] = "Contact";
|
||||||
|
}
|
||||||
include "helpers/body_open.php";
|
include "helpers/body_open.php";
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
@ -3,5 +3,8 @@
|
|||||||
Alias for the support page with a more common name.
|
Alias for the support page with a more common name.
|
||||||
-->
|
-->
|
||||||
<?php
|
<?php
|
||||||
|
if (!isset($GLOBALS["HEADER_TITLE"])) {
|
||||||
|
$GLOBALS["HEADER_TITLE"] = "Donate";
|
||||||
|
}
|
||||||
include "support.php";
|
include "support.php";
|
||||||
?>
|
?>
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
-->
|
-->
|
||||||
<?php
|
<?php
|
||||||
$GLOBALS["ADVISORY"] = false;
|
$GLOBALS["ADVISORY"] = false;
|
||||||
|
if (!isset($GLOBALS["HEADER_TITLE"])) {
|
||||||
|
$GLOBALS["HEADER_TITLE"] = "Health";
|
||||||
|
}
|
||||||
include "helpers/body_open.php";
|
include "helpers/body_open.php";
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
@ -1,8 +1,15 @@
|
|||||||
#!/usr/bin/php
|
#!/usr/bin/php
|
||||||
|
<?php
|
||||||
|
if (!isset($GLOBALS["HEADER_TITLE"])) {
|
||||||
|
$GLOBALS["HEADER_TITLE"] = "";
|
||||||
|
} else {
|
||||||
|
$GLOBALS["HEADER_TITLE"] = ": " . $GLOBALS["HEADER_TITLE"];
|
||||||
|
}
|
||||||
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>Hyperling</title>
|
<title>Hyperling<?php echo($GLOBALS["HEADER_TITLE"]); ?></title>
|
||||||
<link rel="icon" sizes="32x32"
|
<link rel="icon" sizes="32x32"
|
||||||
href="/files/media/icons/favicon.ico"
|
href="/files/media/icons/favicon.ico"
|
||||||
>
|
>
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
Landing page, keeping it apps and development projects like old WordPress site.
|
Landing page, keeping it apps and development projects like old WordPress site.
|
||||||
-->
|
-->
|
||||||
<?php
|
<?php
|
||||||
|
if (!isset($GLOBALS["HEADER_TITLE"])) {
|
||||||
|
$GLOBALS["HEADER_TITLE"] = "Home";
|
||||||
|
}
|
||||||
include "helpers/body_open.php";
|
include "helpers/body_open.php";
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
cd `dirname $0`
|
cd `dirname $0`
|
||||||
|
|
||||||
# Create the necessary HTML components for a web page.
|
# 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
|
#Content for this page
|
||||||
cat << EOF
|
cat << EOF
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
Lists of items which I'd like to share such as gear and frequently used apps.
|
Lists of items which I'd like to share such as gear and frequently used apps.
|
||||||
-->
|
-->
|
||||||
<?php
|
<?php
|
||||||
|
if (!isset($GLOBALS["HEADER_TITLE"])) {
|
||||||
|
$GLOBALS["HEADER_TITLE"] = "Lists";
|
||||||
|
}
|
||||||
include "helpers/body_open.php";
|
include "helpers/body_open.php";
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
Page for my video links.
|
Page for my video links.
|
||||||
-->
|
-->
|
||||||
<?php
|
<?php
|
||||||
|
if (!isset($GLOBALS["HEADER_TITLE"])) {
|
||||||
|
$GLOBALS["HEADER_TITLE"] = "Media";
|
||||||
|
}
|
||||||
include "helpers/body_open.php";
|
include "helpers/body_open.php";
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
20
pages/photos-all.sh
Executable file
20
pages/photos-all.sh
Executable file
@ -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
|
393
pages/photos.sh
393
pages/photos.sh
@ -2,12 +2,11 @@
|
|||||||
# 2024-01-21 Hyperling
|
# 2024-01-21 Hyperling
|
||||||
# Transition away from PhotoPrism. Helps to save system resources and downsize.
|
# Transition away from PhotoPrism. Helps to save system resources and downsize.
|
||||||
|
|
||||||
# Static Variables
|
## Static Variables ##
|
||||||
DIR=`dirname $0`
|
DIR=`dirname $0`
|
||||||
header="<html>\n\t<header>\n\t\t<title>ALBUM</title>\n\t</header>\n\t<body>"
|
a="a target='_blank' rel='noopener noreferrer'"
|
||||||
footer="\n\t</body>\n</html>"
|
|
||||||
|
|
||||||
# Functions
|
## Functions ##
|
||||||
function remove_problem_strings {
|
function remove_problem_strings {
|
||||||
file="$1"
|
file="$1"
|
||||||
sed -i -e 's/#!\/usr\/bin\/php//g' $file
|
sed -i -e 's/#!\/usr\/bin\/php//g' $file
|
||||||
@ -20,6 +19,7 @@ cd $DIR/..
|
|||||||
HELPER_DIR=./pages/helpers
|
HELPER_DIR=./pages/helpers
|
||||||
PHOTOS_DIR=./files/photos
|
PHOTOS_DIR=./files/photos
|
||||||
mainpage=$PHOTOS_DIR/index.html
|
mainpage=$PHOTOS_DIR/index.html
|
||||||
|
allpage=$PHOTOS_DIR/all.html
|
||||||
|
|
||||||
# Use the cached version if available.
|
# Use the cached version if available.
|
||||||
if [[ -e $mainpage ]]; then
|
if [[ -e $mainpage ]]; then
|
||||||
@ -28,146 +28,273 @@ if [[ -e $mainpage ]]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create the necessary HTML components for a web page.
|
## Start the main /photos/ page. ##
|
||||||
$HELPER_DIR/body_open.php > $mainpage
|
function start_main_page {
|
||||||
echo "" >> $mainpage
|
# 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.
|
# Give the page a description.
|
||||||
echo -e "\t\t<div class='row'>" >> $mainpage
|
|
||||||
echo -e "\t\t\t<h1 class='col-12 title'>Albums</h1>" >> $mainpage
|
|
||||||
echo -e "\t\t</div>" >> $mainpage
|
|
||||||
|
|
||||||
echo -e "\t\t<div class='row'>" >> $mainpage
|
|
||||||
echo -e "\t\t\t<div class='col-12 text'>" >> $mainpage
|
|
||||||
echo -en "\t\t\t\t<p>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.</p>" >> $mainpage
|
|
||||||
echo -e "\t\t\t</div>" >> $mainpage
|
|
||||||
echo -e "\t\t</div>" >> $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<div class='row'>" >> $mainpage
|
echo -e "\t\t<div class='row'>" >> $mainpage
|
||||||
echo -en "\t\t\t<h2 class='col-12 title'>" >> $mainpage
|
echo -e "\t\t\t<h1 class='col-12 title'>Albums</h1>" >> $mainpage
|
||||||
echo -en "<a href='/files/photos/$album/index.html' " >> $mainpage
|
|
||||||
echo -e "target='_blank' rel='noopener noreferrer'>$album_name</a></h2>" >> $mainpage
|
|
||||||
echo -e "\t\t</div>" >> $mainpage
|
echo -e "\t\t</div>" >> $mainpage
|
||||||
|
|
||||||
# Catch all the upcoming photo records.
|
echo -e "\t\t<div class='row'>" >> $mainpage
|
||||||
echo -e "\t\t<div class='row'>\n\t\t\t<div class='col-12 text'>" >> $mainpage
|
echo -e "\t\t\t<div class='col-12 text'>" >> $mainpage
|
||||||
|
echo -en "\t\t\t\t<p>You may click on an album name to " >> $mainpage
|
||||||
# Create index page for each photo ALBUM based on its contents.
|
echo -en "view all of its files, or click on a specific image to bring up the " >> $mainpage
|
||||||
page=""
|
echo -en "full resolution. On the album pages you may also click an image or " >> $mainpage
|
||||||
subpage="$PHOTOS_DIR/$album/index.html"
|
echo -e "video name to pull up the full resolution for download.</p>" >> $mainpage
|
||||||
$HELPER_DIR/body_open.php > $subpage
|
|
||||||
|
|
||||||
# Add a back button
|
|
||||||
echo -en "\n\t\t<div class='row'>\n\t\t\t<a href='/photos'>" >> $subpage
|
|
||||||
echo -e "<h3 class='col-12 title'>Back</h3></a>\n\t\t</div>" >> $subpage
|
|
||||||
|
|
||||||
# Build the ALBUM page.
|
|
||||||
echo -e "\t\t<div class='row'>" >> $subpage
|
|
||||||
echo -e "\t\t\t<h1 class='col-12 title'>$album_name</h1>" >> $subpage
|
|
||||||
echo -e "\t\t</div>" >> $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<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
|
|
||||||
if [[ $photo == *".mp4" ]]; then
|
|
||||||
echo -en " [VIDEO]" >> $mainpage
|
|
||||||
fi
|
|
||||||
echo -e "</a></li>" >> $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<div class='row text'>" >> $subpage
|
|
||||||
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
|
|
||||||
# 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
|
|
||||||
echo -e "\t\t\t\t\t\t<source src='/$photo' type=video/mp4>" >> $subpage
|
|
||||||
echo -e "\t\t\t\t\t\tYour browser does not support videos." >> $subpage
|
|
||||||
echo -e "\t\t\t\t\t</video>" >> $subpage
|
|
||||||
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
|
|
||||||
fi
|
|
||||||
# Check if it needs an extra descriptive detail.
|
|
||||||
echo -en "\t\t\t\t\t<p>$filename" >> $subpage
|
|
||||||
if [[ $photo == *".mp4" ]]; then
|
|
||||||
echo -en " [VIDEO]" >> $subpage
|
|
||||||
fi
|
|
||||||
# Close the image description and its link.
|
|
||||||
echo -e "</p>\n\t\t\t\t</a>\n\t\t\t</div>" >> $subpage
|
|
||||||
# Close the row after an odd count.
|
|
||||||
if (( $count % 2 == 1 )); then
|
|
||||||
echo -e "\t\t</div>" >> $subpage
|
|
||||||
fi
|
|
||||||
count=$(( count + 1 ))
|
|
||||||
done
|
|
||||||
echo -e "\t\t</div>" >> $subpage
|
|
||||||
|
|
||||||
# End album listings on PHOTOS page.
|
|
||||||
echo -e "\t\t\t</div>" >> $mainpage
|
echo -e "\t\t\t</div>" >> $mainpage
|
||||||
echo -e "\t\t</div>" >> $mainpage
|
echo -e "\t\t</div>" >> $mainpage
|
||||||
|
|
||||||
# Add a final back button
|
echo -e "\t\t<div class='row'>" >> $mainpage
|
||||||
echo -en "\n\t\t<div class='row'>\n\t\t\t<a href='/photos'>" >> $subpage
|
echo -e "\t\t\t<$a href='/photos-all'" >> $mainpage
|
||||||
echo -e "<h3 class='col-12 title'>Back</h3></a>\n\t\t</div>" >> $subpage
|
echo -e "\t\t\t\tclass='col-12 header'>Click Here for the Full Photo Feed" >> $mainpage
|
||||||
|
echo -e "\t\t\t</a>" >> $mainpage
|
||||||
|
echo -e "\t\t</div>" >> $mainpage
|
||||||
|
}
|
||||||
|
|
||||||
# Close out the ALBUM's page.
|
## Close out the main page after the sub pages are done being added. ##
|
||||||
$HELPER_DIR/body_close.php >> $subpage
|
function end_main_page {
|
||||||
echo "<!-- Built on `date`. -->" >> $subpage
|
# Finish the main /photos/ page.
|
||||||
|
$HELPER_DIR/body_close.php >> $mainpage
|
||||||
|
echo "<!-- Built on `date`. -->" >> $mainpage
|
||||||
|
remove_problem_strings $mainpage
|
||||||
|
}
|
||||||
|
|
||||||
remove_problem_strings $subpage
|
## Create the album pages. ##
|
||||||
done
|
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" || "$album" == "all" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
# Finish the web page.
|
# Clean album name.
|
||||||
$HELPER_DIR/body_close.php >> $mainpage
|
album_name=${album}
|
||||||
echo "<!-- Built on `date`. -->" >> $mainpage
|
album_name=${album_name//_/ }
|
||||||
|
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 "$album_name</a></h2>" >> $mainpage
|
||||||
|
echo -e "\t\t</div>" >> $mainpage
|
||||||
|
|
||||||
remove_problem_strings $mainpage
|
# Catch all the upcoming photo records.
|
||||||
|
echo -e "\t\t<div class='row'>\n\t\t\t<div class='col-12 text'>" >> $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<div class='row'>\n\t\t\t<a href='/photos'>" >> $subpage
|
||||||
|
echo -e "<h3 class='col-12 title'>Back</h3></a>\n\t\t</div>" >> $subpage
|
||||||
|
|
||||||
|
# Build the ALBUM page.
|
||||||
|
echo -e "\t\t<div class='row'>" >> $subpage
|
||||||
|
echo -e "\t\t\t<h1 class='col-12 title'>$album_name</h1>" >> $subpage
|
||||||
|
echo -e "\t\t</div>" >> $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<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'>$filename" >> $mainpage
|
||||||
|
if [[ $photo == *".mp4" ]]; then
|
||||||
|
echo -en " [VIDEO]" >> $mainpage
|
||||||
|
fi
|
||||||
|
echo -e "</a></li>" >> $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<div class='row text'>" >> $subpage
|
||||||
|
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'>" >> $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
|
||||||
|
echo -e "\t\t\t\t\t\t<source src='/$photo' type=video/mp4>" >> $subpage
|
||||||
|
echo -e "\t\t\t\t\t\tYour browser does not support videos." >> $subpage
|
||||||
|
echo -e "\t\t\t\t\t</video>" >> $subpage
|
||||||
|
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
|
||||||
|
fi
|
||||||
|
# Check if it needs an extra descriptive detail.
|
||||||
|
echo -en "\t\t\t\t\t<p>$filename" >> $subpage
|
||||||
|
if [[ $photo == *".mp4" ]]; then
|
||||||
|
echo -en " [VIDEO]" >> $subpage
|
||||||
|
fi
|
||||||
|
# Close the image description and its link.
|
||||||
|
echo -e "</p>\n\t\t\t\t</a>\n\t\t\t</div>" >> $subpage
|
||||||
|
# Close the row after an odd count.
|
||||||
|
if (( $count % 2 == 1 )); then
|
||||||
|
echo -e "\t\t</div>" >> $subpage
|
||||||
|
fi
|
||||||
|
count=$(( count + 1 ))
|
||||||
|
done
|
||||||
|
echo -e "\t\t</div>" >> $subpage
|
||||||
|
|
||||||
|
# End album listings on PHOTOS page.
|
||||||
|
echo -e "\t\t\t</div>" >> $mainpage
|
||||||
|
echo -e "\t\t</div>" >> $mainpage
|
||||||
|
|
||||||
|
# Add a final back button
|
||||||
|
echo -en "\n\t\t<div class='row'>\n\t\t\t<a href='/photos'>" >> $subpage
|
||||||
|
echo -e "<h3 class='col-12 title'>Back</h3></a>\n\t\t</div>" >> $subpage
|
||||||
|
|
||||||
|
# Close out the ALBUM's page.
|
||||||
|
$HELPER_DIR/body_close.php >> $subpage
|
||||||
|
echo "<!-- Built on `date`. -->" >> $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<div class='row'>" >> $allpage
|
||||||
|
echo -e "\t\t\t<h1 class='col-12 title'>All Photo Feed</h1>" >> $allpage
|
||||||
|
echo -e "\t\t</div>" >> $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="<img src='$media_uri' alt='' style='width:100%'>"
|
||||||
|
|
||||||
|
# Determine how to show the file.
|
||||||
|
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>"
|
||||||
|
media_name="$media_name [VIDEO]"
|
||||||
|
elif [[ $media_uri == *".md" || $media_uri == *".txt" ]]; then
|
||||||
|
media="<p>`cat $media_file`</p>"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add a row if count has reset.
|
||||||
|
if [[ -z $count ]]; then
|
||||||
|
count=0
|
||||||
|
fi
|
||||||
|
if [[ $count == 0 ]]; then
|
||||||
|
echo -e "\t\t<div class=row text>" >> $allpage
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add a column.
|
||||||
|
echo -e "\t\t\t<div class=col-3>" >> $allpage
|
||||||
|
|
||||||
|
# Add the image.
|
||||||
|
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 -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 -e "\t\t\t</div>" >> $allpage
|
||||||
|
|
||||||
|
# Close the row and reset the the count if full.
|
||||||
|
if [[ $count == 3 ]]; then
|
||||||
|
echo -e "\t\t</div>" >> $allpage
|
||||||
|
count=0
|
||||||
|
else
|
||||||
|
count=$(( count + 1 ))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Add a final back button.
|
||||||
|
echo -en "\n\t\t<div class='row'>\n\t\t\t<a href='/photos'>" >> $allpage
|
||||||
|
echo -e "<h3 class='col-12 title'>Back</h3></a>\n\t\t</div>" >> $allpage
|
||||||
|
|
||||||
|
# Finish the ALL page.
|
||||||
|
$HELPER_DIR/body_close.php >> $allpage
|
||||||
|
echo "<!-- Built on `date`. -->" >> $allpage
|
||||||
|
remove_problem_strings $allpage
|
||||||
|
}
|
||||||
|
|
||||||
|
## Main ##
|
||||||
|
start_main_page
|
||||||
|
build_album_pages
|
||||||
|
build_all_page
|
||||||
|
end_main_page
|
||||||
|
|
||||||
cat $mainpage
|
cat $mainpage
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
Page for my resume and work skill links.
|
Page for my resume and work skill links.
|
||||||
-->
|
-->
|
||||||
<?php
|
<?php
|
||||||
|
if (!isset($GLOBALS["HEADER_TITLE"])) {
|
||||||
|
$GLOBALS["HEADER_TITLE"] = "Resume";
|
||||||
|
}
|
||||||
include "helpers/body_open.php";
|
include "helpers/body_open.php";
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
Page to provide ways people can support me.
|
Page to provide ways people can support me.
|
||||||
-->
|
-->
|
||||||
<?php
|
<?php
|
||||||
|
if (!isset($GLOBALS["HEADER_TITLE"])) {
|
||||||
|
$GLOBALS["HEADER_TITLE"] = "Support";
|
||||||
|
}
|
||||||
include "helpers/body_open.php";
|
include "helpers/body_open.php";
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
@ -4,27 +4,33 @@
|
|||||||
cd `dirname $0`
|
cd `dirname $0`
|
||||||
|
|
||||||
# Create the necessary HTML components for a web page.
|
# Create the necessary HTML components for a web page.
|
||||||
./helpers/body_open.php
|
./helpers/body_open.php | sed -e 's/Hyperling/Hyperling: Test Page!/'
|
||||||
echo -e "\t\t<h1>This is a web page written in BASH!!!</h1>"
|
echo -e "\t\t<div class='row'>"
|
||||||
|
echo -e "\t\t\t<h1 class='col-12 title'>This is a web page written in BASH!!!</h1>"
|
||||||
|
|
||||||
cat << EOF
|
cat << EOF
|
||||||
<p>
|
<p class="col-12 text">
|
||||||
Look at all the fancy things we can do!
|
Look at all the fancy things we can do!
|
||||||
</p>
|
</p>
|
||||||
<h2>Current Time</h2>
|
|
||||||
<p>
|
<h2 class="col-12 header">Current Time</h2>
|
||||||
We can use the date command to spit out the time!
|
<div class="col-12 text">
|
||||||
</p>
|
<p>
|
||||||
<p>
|
We can use the date command to spit out the time!
|
||||||
`date`
|
</p>
|
||||||
</p>
|
<p>
|
||||||
|
`date`
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Create a subsection
|
# Create a subsection
|
||||||
echo -e "\t\t<h2>Server Neofetch</h2>"
|
echo -e "\t\t\t<h2 class='col-12 header'>Server Neofetch</h2>"
|
||||||
echo -e "\t\t<p>"
|
echo -en "\t\t\t<p class='col-12 text'>"
|
||||||
#neofetch --stdout
|
#neofetch --stdout | sed -e 's/\n/<br>/g'
|
||||||
echo "jk lol"
|
echo -n "jk lol"
|
||||||
echo -e "\t\t</p>"
|
echo -e "</p>"
|
||||||
|
echo -e "\t\t</div>"
|
||||||
|
|
||||||
# Finish the web page
|
# Finish the web page
|
||||||
./helpers/body_close.php
|
./helpers/body_close.php
|
||||||
|
@ -4,5 +4,8 @@
|
|||||||
Deprecated 2024-03-06 for /media.
|
Deprecated 2024-03-06 for /media.
|
||||||
-->
|
-->
|
||||||
<?php
|
<?php
|
||||||
|
if (!isset($GLOBALS["HEADER_TITLE"])) {
|
||||||
|
$GLOBALS["HEADER_TITLE"] = "Videos";
|
||||||
|
}
|
||||||
include "media.php";
|
include "media.php";
|
||||||
?>
|
?>
|
||||||
|
45
run.sh
45
run.sh
@ -21,6 +21,11 @@ function usage {
|
|||||||
exit $1
|
exit $1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function log {
|
||||||
|
message="$1"
|
||||||
|
echo -e "`date` - $message"
|
||||||
|
}
|
||||||
|
|
||||||
## Parameters ##
|
## Parameters ##
|
||||||
|
|
||||||
while getopts ':p:h' opt; do
|
while getopts ':p:h' opt; do
|
||||||
@ -36,6 +41,10 @@ while getopts ':p:h' opt; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ -z $ports ]]; then
|
||||||
|
ports=8080
|
||||||
|
fi
|
||||||
|
|
||||||
## Build Environment ##
|
## Build Environment ##
|
||||||
|
|
||||||
# Ensure we are executing from this file's directory.
|
# Ensure we are executing from this file's directory.
|
||||||
@ -43,11 +52,11 @@ cd $DIR
|
|||||||
|
|
||||||
sudo=""
|
sudo=""
|
||||||
if [[ $LOGNAME != "root" ]]; then
|
if [[ $LOGNAME != "root" ]]; then
|
||||||
echo "`date` - Using sudo since user is '$LOGNAME'."
|
log "Using sudo since user is '$LOGNAME'."
|
||||||
sudo="sudo"
|
sudo="sudo"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "`date` - Check if any system dependencies need installed."
|
log "Check if any system dependencies need installed."
|
||||||
if [[ ! `which php` ]]; then
|
if [[ ! `which php` ]]; then
|
||||||
echo "- Installing PHP"
|
echo "- Installing PHP"
|
||||||
$sudo apt-get install -y php-cli
|
$sudo apt-get install -y php-cli
|
||||||
@ -62,7 +71,7 @@ if [[ ! `which npm` ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Directories and allowed page types are executable, others are not.
|
# Directories and allowed page types are executable, others are not.
|
||||||
echo "`date` - Fix any strange file permissions."
|
log "Fix any strange file permissions."
|
||||||
find ./pages/ | while read file; do
|
find ./pages/ | while read file; do
|
||||||
if [[ $file == *".php" || $file == *".sh" || -d $file ]]; then
|
if [[ $file == *".php" || $file == *".sh" || -d $file ]]; then
|
||||||
mode=755
|
mode=755
|
||||||
@ -72,16 +81,40 @@ find ./pages/ | while read file; do
|
|||||||
chmod -c $mode $file
|
chmod -c $mode $file
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "`date` - Check if any node modules need updated/installed."
|
log "Check if any node modules need updated/installed."
|
||||||
npm install
|
npm install
|
||||||
|
|
||||||
|
# Reset generated index files.
|
||||||
|
log "Removing old index files."
|
||||||
|
find files/photos/ -name "*".html -print -delete
|
||||||
|
{
|
||||||
|
count=1
|
||||||
|
http_code=0
|
||||||
|
port="${ports%% *}"
|
||||||
|
photos_uri=":$port/photos/"
|
||||||
|
while [[ $http_code != "200" ]]; do
|
||||||
|
log "Sleeping for '$count' while waiting for $photos_uri to come up."
|
||||||
|
sleep $count
|
||||||
|
log "Checking if $photos_uri is available."
|
||||||
|
http_code="`curl --silent --fail --w '\n%{http_code}' localhost$photos_uri | tail -n 1`"
|
||||||
|
log "Check for $photos_uri responded with '$http_code'."
|
||||||
|
if (( $count >= 10 )); then
|
||||||
|
log "Giving up on loading $photos_uri after '$count' attempts."
|
||||||
|
break
|
||||||
|
else
|
||||||
|
count=$(( count + 1 ))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
log "Finished checking for /photos/."
|
||||||
|
} &
|
||||||
|
|
||||||
## Main ##
|
## Main ##
|
||||||
|
|
||||||
echo "`date` - Start website API."
|
log "Start website API."
|
||||||
node ./main.js $ports
|
node ./main.js $ports
|
||||||
status=$?
|
status=$?
|
||||||
|
|
||||||
## Finish ##
|
## Finish ##
|
||||||
|
|
||||||
echo "`date` - Exiting with status '$status'."
|
log "Exiting with status '$status'."
|
||||||
exit $status
|
exit $status
|
||||||
|
Reference in New Issue
Block a user