diff --git a/.gitignore b/.gitignore
index 2b31a12..2eb32ec 100644
--- a/.gitignore
+++ b/.gitignore
@@ -105,3 +105,4 @@ dist
## Above is Github's recommendations for Node.js. Below are my additions. ##
package-lock.json
+files/*
diff --git a/README.md b/README.md
index 9827b7a..be95674 100644
--- a/README.md
+++ b/README.md
@@ -14,25 +14,29 @@ All content is formatted so that the page source is readible.
# How To Run
-The install script is currently only set up for apt, and the package names only tested on Ubuntu.
+The install script is currently only set up for apt, and the package names only
+tested on Ubuntu and Debian.
-`git clone https://github.com/Hyperling/www www`
+```
+git clone https://github.com/Hyperling/website www
+cd www
+./run.sh
+```
-`cd www`
-
-`./run.sh`
-
-Then in a web browser, navigate to `your_machines_ip_address:8080`.
+Then in a web browser, navigate to `localhost:8080`.
## TODO
All goals are currently completed.
+- ~~Add support for Let's Encrypt without using `nginx` or `apache`.~~
+ - Going to continue using a reverse proxy, but may still be nice someday.
+
## Inspiration
-- [https://liquorix.net/]
+- [Liquorix Kernel](https://liquorix.net/)
- The linux-zen kernel, a really great one if you're running FOSS OS's!
-- [https://cahlen.org/]
+- [Cahlen.org](https://cahlen.org/)
- Also has really interesting and important content, it is highly recommended.
-- [https://merkinvineyardsosteria.com/]
+- [Merkin Vineyards Osteria](https://merkinvineyardsosteria.com/)
- A winery website for MJ Keenan.
diff --git a/files/README.md b/files/README.md
new file mode 100644
index 0000000..b781cd7
--- /dev/null
+++ b/files/README.md
@@ -0,0 +1,9 @@
+# Hyperling.com - Files
+
+Place files into this folder which should be used as static resources.
+Examples would be APKs, zip files, images, text files, etc.
+
+For example, if `test.jpg` was placed here, it could be accessed via
+`http://localhost:8080/files/test.jpg`. Depending on the file type the MIME type
+may be detected automatically, otherwise it will be assumed a text file and
+most likely ask to be downloaded by the browser.
diff --git a/main.js b/main.js
index 37bc194..5bc061d 100755
--- a/main.js
+++ b/main.js
@@ -25,7 +25,18 @@ const pages_dir = "./pages/";
const file_types = ["php", "sh"];
let ports = [];
-ports.push(8080);
+// Check parameters for numeric port numbers.
+process.argv.forEach(function (val, index, array) {
+ console.log("Parameter", index + ':', val, !isNaN(val));
+ if (!isNaN(val)) {
+ console.log("Adding Port", val)
+ ports.push(val);
+ }
+});
+// Default port if none were passed.
+if (ports.length === 0) {
+ ports.push(8080);
+}
//// Functions ////
@@ -116,7 +127,7 @@ async function main() {
console.log("...Adding Routes...");
let router = express.Router();
- /* 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.
*/
for (let key in pages) {
@@ -170,6 +181,48 @@ async function main() {
res.send(sitemap_html);
});
+ // Return a resource from the files folder.
+ console.log(" * Creating router for files");
+ router.get('/files*', function (req, res) {
+ console.log("file response to", req.socket.remoteAddress, "asking for", req.url)
+
+ // Build variables.
+ const file = "." + req.path;
+ const extensions = req.path.split(".");
+ const extension = extensions[extensions.length-1];
+
+ // Check extension and guess a MIME type.
+ let mime;
+ switch (extension) {
+ case "apk":
+ mime = "application/vnd.android.package-archive";
+ break;
+ case "jpg" || "jpeg":
+ mime = "image/jpeg";
+ break;
+ case "png":
+ mime = "image/png";
+ break;
+ case "html":
+ mime = "text/html";
+ break;
+ default:
+ mime = "text/*";
+ break;
+ }
+ console.log("- Extension", extension, "led to MIME", mime);
+
+ // Return the file
+ res.contentType(mime);
+ let f = fs.createReadStream(file)
+ .on("error", function(e) {
+ res.contentType("text/plain");
+ res.send(404, "File Not Found");
+ })
+ .pipe(res)
+ ;
+ });
+
// Originally a test, now a catch-all redirection to Home!
console.log(" * Creating router for redirection");
router.get('/*', function (req, res) {
diff --git a/pages/photos.sh b/pages/photos.sh
new file mode 100755
index 0000000..2760e33
--- /dev/null
+++ b/pages/photos.sh
@@ -0,0 +1,99 @@
+#!/bin/bash
+# 2024-01-21 Hyperling
+# Transition away from PhotoPrism. Helps to save system resources and downsize.
+
+# Static Variables
+header="\n\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`cat $photo`
" + else + # Otherwise put in the PHOTOS page list. + echo -en "\t\t\t