Compare commits
25 Commits
fb55bfa42a
...
feat/termi
| Author | SHA1 | Date | |
|---|---|---|---|
|
d46f2ed40d
|
|||
|
687e7af91b
|
|||
|
f97e362192
|
|||
|
6c7242b167
|
|||
|
0fdcf435e1
|
|||
|
27517ad857
|
|||
|
6657151f81
|
|||
|
c43e453d05
|
|||
|
91950e5a78
|
|||
|
2a42378ad7
|
|||
|
4ae6f7bb99
|
|||
|
d4d6b47225
|
|||
|
9809fe0695
|
|||
|
3522389422
|
|||
|
2979d3c4de
|
|||
|
a8b2c02164
|
|||
|
372ba908b8
|
|||
|
1145b9205c
|
|||
|
a71c5b6663
|
|||
|
724e800201
|
|||
|
abcaa9283d
|
|||
|
e175f68d25
|
|||
|
80b6a9bf46
|
|||
|
b089b8c0a8
|
|||
|
8f774ba8f0
|
@@ -1,4 +1,4 @@
|
||||
FROM --platform=$BUILDPLATFORM python:3.10-alpine AS builder
|
||||
FROM --platform=$BUILDPLATFORM python:3.13-alpine AS builder
|
||||
|
||||
RUN apk add curl
|
||||
WORKDIR /app
|
||||
|
||||
@@ -4,9 +4,10 @@ import datetime
|
||||
import requests
|
||||
import re
|
||||
from mail import sendEmail
|
||||
from tools import getClientIP, getGitCommit, json_response, parse_date
|
||||
from tools import getClientIP, getGitCommit, json_response, parse_date, get_tools_data
|
||||
from blueprints.sol import sol_bp
|
||||
from dateutil import parser as date_parser
|
||||
from blueprints.spotify import get_spotify_track
|
||||
|
||||
# Constants
|
||||
HTTP_OK = 200
|
||||
@@ -43,6 +44,8 @@ def help():
|
||||
"/project": "Get the current project from git",
|
||||
"/version": "Get the current version of the website",
|
||||
"/page_date?url=URL&verbose=BOOL": "Get the last modified date of a webpage (verbose is optional, default false)",
|
||||
"/tools": "Get a list of tools used by Nathan Woodburn",
|
||||
"/playing": "Get the currently playing Spotify track",
|
||||
"/status": "Just check if the site is up",
|
||||
"/ping": "Just check if the site is up",
|
||||
"/help": "Get this help message"
|
||||
@@ -164,6 +167,29 @@ def project():
|
||||
"status": HTTP_OK
|
||||
})
|
||||
|
||||
@api_bp.route("/tools")
|
||||
def tools():
|
||||
"""Get a list of tools used by Nathan Woodburn."""
|
||||
try:
|
||||
tools = get_tools_data()
|
||||
except Exception as e:
|
||||
print(f"Error getting tools data: {e}")
|
||||
return json_response(request, "500 Internal Server Error", HTTP_SERVER_ERROR)
|
||||
|
||||
# Remove demo and move demo_url to demo
|
||||
for tool in tools:
|
||||
if "demo_url" in tool:
|
||||
tool["demo"] = tool.pop("demo_url")
|
||||
|
||||
return json_response(request, {"tools": tools}, HTTP_OK)
|
||||
|
||||
@api_bp.route("/playing")
|
||||
def playing():
|
||||
"""Get the currently playing Spotify track."""
|
||||
track_info = get_spotify_track()
|
||||
if "error" in track_info:
|
||||
return json_response(request, track_info, HTTP_OK)
|
||||
return json_response(request, {"spotify": track_info}, HTTP_OK)
|
||||
|
||||
@api_bp.route("/page_date")
|
||||
def page_date():
|
||||
|
||||
@@ -10,6 +10,10 @@ blog_bp = Blueprint('blog', __name__)
|
||||
|
||||
def list_page_files():
|
||||
blog_pages = os.listdir("data/blog")
|
||||
# Sort pages by modified time, newest first
|
||||
blog_pages.sort(
|
||||
key=lambda x: os.path.getmtime(os.path.join("data/blog", x)), reverse=True)
|
||||
|
||||
# Remove .md extension
|
||||
blog_pages = [page.removesuffix(".md")
|
||||
for page in blog_pages if page.endswith(".md")]
|
||||
|
||||
148
blueprints/spotify.py
Normal file
148
blueprints/spotify.py
Normal file
@@ -0,0 +1,148 @@
|
||||
from flask import redirect, request, Blueprint, url_for
|
||||
from tools import json_response
|
||||
import os
|
||||
import requests
|
||||
import time
|
||||
import base64
|
||||
|
||||
spotify_bp = Blueprint('spotify', __name__)
|
||||
|
||||
CLIENT_ID = os.getenv("SPOTIFY_CLIENT_ID")
|
||||
CLIENT_SECRET = os.getenv("SPOTIFY_CLIENT_SECRET")
|
||||
ALLOWED_SPOTIFY_USER_ID = os.getenv("SPOTIFY_USER_ID")
|
||||
|
||||
SPOTIFY_AUTH_URL = "https://accounts.spotify.com/authorize"
|
||||
SPOTIFY_TOKEN_URL = "https://accounts.spotify.com/api/token"
|
||||
SPOTIFY_CURRENTLY_PLAYING_URL = "https://api.spotify.com/v1/me/player/currently-playing"
|
||||
|
||||
SCOPE = "user-read-currently-playing user-read-playback-state"
|
||||
|
||||
ACCESS_TOKEN = None
|
||||
REFRESH_TOKEN = os.getenv("SPOTIFY_REFRESH_TOKEN")
|
||||
TOKEN_EXPIRES = 0
|
||||
|
||||
def refresh_access_token():
|
||||
"""Refresh Spotify access token when expired."""
|
||||
global ACCESS_TOKEN, TOKEN_EXPIRES
|
||||
|
||||
# If still valid, reuse it
|
||||
if ACCESS_TOKEN and time.time() < TOKEN_EXPIRES - 60:
|
||||
return ACCESS_TOKEN
|
||||
|
||||
auth_str = f"{CLIENT_ID}:{CLIENT_SECRET}"
|
||||
b64_auth = base64.b64encode(auth_str.encode()).decode()
|
||||
|
||||
data = {
|
||||
"grant_type": "refresh_token",
|
||||
"refresh_token": REFRESH_TOKEN,
|
||||
}
|
||||
headers = {"Authorization": f"Basic {b64_auth}"}
|
||||
|
||||
response = requests.post(SPOTIFY_TOKEN_URL, data=data, headers=headers)
|
||||
if response.status_code != 200:
|
||||
print("Failed to refresh token:", response.text)
|
||||
return None
|
||||
|
||||
token_info = response.json()
|
||||
ACCESS_TOKEN = token_info["access_token"]
|
||||
TOKEN_EXPIRES = time.time() + token_info.get("expires_in", 3600)
|
||||
return ACCESS_TOKEN
|
||||
|
||||
@spotify_bp.route("/login")
|
||||
def login():
|
||||
auth_query = (
|
||||
f"{SPOTIFY_AUTH_URL}?response_type=code&client_id={CLIENT_ID}"
|
||||
f"&redirect_uri={url_for('spotify.callback', _external=True)}&scope={SCOPE}"
|
||||
)
|
||||
return redirect(auth_query)
|
||||
|
||||
@spotify_bp.route("/callback")
|
||||
def callback():
|
||||
code = request.args.get("code")
|
||||
if not code:
|
||||
return "Authorization failed.", 400
|
||||
|
||||
data = {
|
||||
"grant_type": "authorization_code",
|
||||
"code": code,
|
||||
"redirect_uri": url_for("spotify.callback", _external=True),
|
||||
"client_id": CLIENT_ID,
|
||||
"client_secret": CLIENT_SECRET,
|
||||
}
|
||||
response = requests.post(SPOTIFY_TOKEN_URL, data=data)
|
||||
token_info = response.json()
|
||||
if "access_token" not in token_info:
|
||||
return json_response(request, {"error": "Failed to obtain token", "details": token_info}, 400)
|
||||
|
||||
access_token = token_info["access_token"]
|
||||
me = requests.get(
|
||||
"https://api.spotify.com/v1/me",
|
||||
headers={"Authorization": f"Bearer {access_token}"}
|
||||
).json()
|
||||
|
||||
if me.get("id") != ALLOWED_SPOTIFY_USER_ID:
|
||||
return json_response(request, {"error": "Unauthorized user"}, 403)
|
||||
|
||||
global REFRESH_TOKEN
|
||||
REFRESH_TOKEN = token_info.get("refresh_token")
|
||||
print("Spotify authorization successful.")
|
||||
print("Refresh Token:", REFRESH_TOKEN)
|
||||
return redirect(url_for("spotify.currently_playing"))
|
||||
|
||||
@spotify_bp.route("/")
|
||||
@spotify_bp.route("/currently-playing")
|
||||
def currently_playing():
|
||||
"""Public endpoint showing your current track."""
|
||||
token = refresh_access_token()
|
||||
if not token:
|
||||
return json_response(request, {"error": "Failed to refresh access token"}, 500)
|
||||
|
||||
headers = {"Authorization": f"Bearer {token}"}
|
||||
response = requests.get(SPOTIFY_CURRENTLY_PLAYING_URL, headers=headers)
|
||||
|
||||
if response.status_code == 204:
|
||||
return json_response(request, {"message": "Nothing is currently playing."}, 200)
|
||||
elif response.status_code != 200:
|
||||
return json_response(request, {"error": "Spotify API error", "status": response.status_code}, response.status_code)
|
||||
|
||||
data = response.json()
|
||||
if not data.get("item"):
|
||||
return json_response(request, {"message": "Nothing is currently playing."}, 200)
|
||||
|
||||
|
||||
track = {
|
||||
"song_name": data["item"]["name"],
|
||||
"artist": ", ".join([artist["name"] for artist in data["item"]["artists"]]),
|
||||
"album_name": data["item"]["album"]["name"],
|
||||
"album_art": data["item"]["album"]["images"][0]["url"],
|
||||
"is_playing": data["is_playing"]
|
||||
}
|
||||
return json_response(request, {"spotify":track}, 200)
|
||||
|
||||
def get_spotify_track():
|
||||
"""Internal function to get current playing track without HTTP context."""
|
||||
token = refresh_access_token()
|
||||
if not token:
|
||||
return json_response(request, {"error": "Failed to refresh access token"}, 500)
|
||||
|
||||
headers = {"Authorization": f"Bearer {token}"}
|
||||
response = requests.get(SPOTIFY_CURRENTLY_PLAYING_URL, headers=headers)
|
||||
|
||||
if response.status_code == 204:
|
||||
return {"error": "Nothing is currently playing."}
|
||||
elif response.status_code != 200:
|
||||
return {"error": "Spotify API error", "status": response.status_code}
|
||||
|
||||
data = response.json()
|
||||
if not data.get("item"):
|
||||
return {"error": "Nothing is currently playing."}
|
||||
|
||||
|
||||
track = {
|
||||
"song_name": data["item"]["name"],
|
||||
"artist": ", ".join([artist["name"] for artist in data["item"]["artists"]]),
|
||||
"album_name": data["item"]["album"]["name"],
|
||||
"album_art": data["item"]["album"]["images"][0]["url"],
|
||||
"is_playing": data["is_playing"]
|
||||
}
|
||||
return track
|
||||
9
blueprints/template.py
Normal file
9
blueprints/template.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from flask import Blueprint, request
|
||||
from tools import json_response
|
||||
|
||||
template_bp = Blueprint('template', __name__)
|
||||
|
||||
|
||||
@template_bp.route("/")
|
||||
def index():
|
||||
return json_response(request, "Success", 200)
|
||||
665
blueprints/terminal.py
Normal file
665
blueprints/terminal.py
Normal file
@@ -0,0 +1,665 @@
|
||||
from flask import Blueprint, request, render_template, session
|
||||
from tools import json_response, getClientIP
|
||||
from datetime import datetime
|
||||
|
||||
terminal_bp = Blueprint('terminal', __name__)
|
||||
|
||||
|
||||
@terminal_bp.route("/terminal")
|
||||
def index():
|
||||
return render_template("terminal.html", user=getClientIP(request))
|
||||
|
||||
|
||||
COMMANDS = {
|
||||
"help": "Show this help message",
|
||||
"about": "About this terminal",
|
||||
"clear": "Clear the terminal",
|
||||
"echo [text]": "Echo text back",
|
||||
"whoami": "Display the current user",
|
||||
"ls": "List directory contents",
|
||||
"pwd": "Print working directory",
|
||||
"date": "Show current date and time with optional format",
|
||||
"cd [path]": "Change directory to path",
|
||||
"cat [file]": "Display file contents",
|
||||
"rm [file]": "Remove a file",
|
||||
"tree [path]": "Display directory tree",
|
||||
"touch [file]": "Create a new empty file",
|
||||
"nano [file]": "Edit a file",
|
||||
"reset": "Reset the terminal session",
|
||||
"exit": "Exit the terminal session",
|
||||
}
|
||||
|
||||
BOOT_FILES = [
|
||||
"amd-ucode.img",
|
||||
"EFI",
|
||||
"initramfs-linux-fallback.img",
|
||||
"initramfs-linux.img",
|
||||
"initramfs-linux-lts-fallback.img",
|
||||
"initramfs-linux-lts.img",
|
||||
"intel-ucode.img",
|
||||
"loader",
|
||||
"vmlinuz-linux",
|
||||
"vmlinuz-linux-lts"
|
||||
]
|
||||
|
||||
|
||||
def get_nodes_in_directory(path: str) -> list[str]:
|
||||
"""Simulate getting files in a directory for the terminal."""
|
||||
# If path is valid, get files from session
|
||||
if session.get("paths", None) is None:
|
||||
setup_path_session()
|
||||
|
||||
# Split path into parts
|
||||
parts = path.strip("/").split("/")
|
||||
if not parts or parts == [""]:
|
||||
return session["paths"]
|
||||
|
||||
current_level = session["paths"]
|
||||
for part in parts:
|
||||
found = False
|
||||
for item in current_level:
|
||||
if item["name"] == part and item["type"] == 0:
|
||||
current_level = item.get("children", [])
|
||||
found = True
|
||||
break
|
||||
if not found:
|
||||
return []
|
||||
|
||||
return current_level
|
||||
|
||||
|
||||
def setup_path_session():
|
||||
"""Initialize the session path variables if not already set."""
|
||||
if "pwd" not in session:
|
||||
session["pwd"] = f"/home/{getClientIP(request)}"
|
||||
if "paths" not in session:
|
||||
binaries = []
|
||||
for cmd in COMMANDS.keys():
|
||||
binaries.append({"name": cmd.split()[0], "type": 2, "content": "", "permissions": 1})
|
||||
boot_files = []
|
||||
for bin_file in BOOT_FILES:
|
||||
boot_files.append({"name": bin_file, "type": 1, "content": "", "permissions": 1})
|
||||
|
||||
session["paths"] = [
|
||||
{"name": "home", "type": 0, "children": [
|
||||
{"name": str(getClientIP(request)), "type": 0, "children": [
|
||||
{"name": "Readme.txt", "type": 1, "content": "This is a README file.", "permissions": 2},
|
||||
], "permissions": 2}
|
||||
], "permissions": 1},
|
||||
{"name": "bin", "type": 0, "children": binaries, "permissions": 1},
|
||||
{"name": "boot", "type": 0, "children": boot_files, "permissions": 1},
|
||||
{"name": "dev", "type": 0, "children": [], "permissions": 1},
|
||||
{"name": "etc", "type": 0, "children": [], "permissions": 1},
|
||||
{"name": "lib", "type": 0, "children": [], "permissions": 1},
|
||||
{"name": "lib64", "type": 0, "children": [], "permissions": 1},
|
||||
{"name": "opt", "type": 0, "children": [], "permissions": 1},
|
||||
{"name": "proc", "type": 0, "children": [], "permissions": 1},
|
||||
{"name": "root", "type": 0, "children": [], "permissions": 1},
|
||||
{"name": "run", "type": 0, "children": [], "permissions": 1},
|
||||
{"name": "sbin", "type": 0, "children": [], "permissions": 1},
|
||||
{"name": "srv", "type": 0, "children": [], "permissions": 1},
|
||||
{"name": "sys", "type": 0, "children": [], "permissions": 1},
|
||||
{"name": "tmp", "type": 0, "children": [], "permissions": 1},
|
||||
{"name": "usr", "type": 0, "children": [], "permissions": 1},
|
||||
{"name": "var", "type": 0, "children": [], "permissions": 1},
|
||||
]
|
||||
|
||||
|
||||
def is_valid_path(path: str) -> bool:
|
||||
"""Check if the given path is valid in the simulated terminal."""
|
||||
if session.get("paths", None) is None:
|
||||
setup_path_session()
|
||||
|
||||
# Split path into parts
|
||||
parts = path.strip("/").split("/")
|
||||
if not parts or parts == [""]:
|
||||
return True # Root path is valid
|
||||
|
||||
current_level = session["paths"]
|
||||
for part in parts:
|
||||
found = False
|
||||
for item in current_level:
|
||||
if item["name"] == part and item["type"] == 0:
|
||||
current_level = item.get("children", [])
|
||||
found = True
|
||||
break
|
||||
if not found:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def is_valid_file(path: str) -> bool:
|
||||
"""Check if the given file exists in the current directory."""
|
||||
if session.get("paths", None) is None:
|
||||
setup_path_session()
|
||||
|
||||
# Get path parts
|
||||
parts = path.split("/")
|
||||
# Get files in the directory
|
||||
if is_valid_path("/".join(parts[:-1])):
|
||||
files = get_nodes_in_directory("/".join(parts[:-1]))
|
||||
for item in files:
|
||||
if item["name"] == parts[-1] and item["type"] == 1:
|
||||
return True
|
||||
return False
|
||||
|
||||
def is_valid_binary(path: str) -> bool:
|
||||
"""Check if the given file exists in the current directory."""
|
||||
if session.get("paths", None) is None:
|
||||
setup_path_session()
|
||||
|
||||
# Get path parts
|
||||
parts = path.split("/")
|
||||
# Get files in the directory
|
||||
if is_valid_path("/".join(parts[:-1])):
|
||||
files = get_nodes_in_directory("/".join(parts[:-1]))
|
||||
for item in files:
|
||||
if item["name"] == parts[-1] and item["type"] == 2:
|
||||
return True
|
||||
return False
|
||||
|
||||
def get_node(path: str) -> dict:
|
||||
"""Get the node (file or directory) at the given path."""
|
||||
if session.get("paths", None) is None:
|
||||
setup_path_session()
|
||||
|
||||
parts = path.strip("/").split("/")
|
||||
current_level = session["paths"]
|
||||
for part in parts:
|
||||
for item in current_level:
|
||||
if item["name"] == part:
|
||||
if part == parts[-1]:
|
||||
return item
|
||||
else:
|
||||
current_level = item.get("children", [])
|
||||
break
|
||||
return {}
|
||||
|
||||
def build_tree(path: str, prefix: str = "") -> str:
|
||||
output = ""
|
||||
files = get_nodes_in_directory(path)
|
||||
for i, item in enumerate(files):
|
||||
connector = "└── " if i == len(files) - 1 else "├── "
|
||||
output += f"{prefix}{connector}{item['name']}\n"
|
||||
if item["type"] == 0: # Directory
|
||||
extension = " " if i == len(files) - 1 else "│ "
|
||||
output += build_tree(sanitize_path(path + "/" + item["name"]), prefix + extension)
|
||||
return output
|
||||
|
||||
def sanitize_path(path: str) -> str:
|
||||
"""Sanitize the given path to prevent directory traversal."""
|
||||
parts = path.strip("/").split("/")
|
||||
sanitized_parts = []
|
||||
for part in parts:
|
||||
if part == "" or part == ".":
|
||||
continue
|
||||
elif part == "..":
|
||||
if sanitized_parts:
|
||||
sanitized_parts.pop()
|
||||
else:
|
||||
sanitized_parts.append(part)
|
||||
return "/" + "/".join(sanitized_parts)
|
||||
|
||||
def remove_node(path: str) -> bool:
|
||||
"""Remove the node (file or directory) at the given path."""
|
||||
if session.get("paths", None) is None:
|
||||
setup_path_session()
|
||||
|
||||
parts = path.strip("/").split("/")
|
||||
current_level = session["paths"]
|
||||
for i, part in enumerate(parts):
|
||||
for j, item in enumerate(current_level):
|
||||
if item["name"] == part:
|
||||
if i == len(parts) - 1:
|
||||
# Remove the item
|
||||
del current_level[j]
|
||||
|
||||
# Update the session paths
|
||||
session["paths"] = session["paths"]
|
||||
|
||||
return True
|
||||
else:
|
||||
current_level = item.get("children", [])
|
||||
break
|
||||
return False
|
||||
|
||||
|
||||
@terminal_bp.route("/terminal/execute/ls", methods=["POST"])
|
||||
def ls():
|
||||
data = request.get_json() or {}
|
||||
args = data.get("args", "")
|
||||
args = args.split()
|
||||
# Check if -a flag is provided
|
||||
# Pop if -a flag from args
|
||||
all_files = False
|
||||
if "-a" in args:
|
||||
all_files = True
|
||||
args.remove("-a")
|
||||
elif "--all" in args:
|
||||
all_files = True
|
||||
args.remove("--all")
|
||||
|
||||
long_format = False
|
||||
if "-l" in args:
|
||||
long_format = True
|
||||
args.remove("-l")
|
||||
elif "--long" in args:
|
||||
long_format = True
|
||||
args.remove("--long")
|
||||
|
||||
for arg in args:
|
||||
if arg.startswith("-") and not arg.startswith("--"):
|
||||
if "l" in arg:
|
||||
long_format = True
|
||||
if "a" in arg:
|
||||
all_files = True
|
||||
args.remove(arg)
|
||||
|
||||
|
||||
ip = getClientIP(request)
|
||||
path = session.get("pwd", f"/home/{ip}")
|
||||
if args:
|
||||
path = args[0]
|
||||
if not path.startswith("/"):
|
||||
# Relative path
|
||||
path = sanitize_path(session.get("pwd", f"/home/{ip}") + "/" + path)
|
||||
if not is_valid_path(path):
|
||||
# If it is a file or binary, return it
|
||||
if is_valid_file(path) or is_valid_binary(path):
|
||||
if long_format:
|
||||
node = get_node(path)
|
||||
permissions = node.get("permissions", 0)
|
||||
perm_str = ""
|
||||
perm_str += "r" if permissions > 0 else "-"
|
||||
perm_str += "w" if permissions > 1 else "-"
|
||||
perm_str += "x" if (node.get("type", 0) == 2 and permissions > 1) else "-"
|
||||
user = f"{ip}" if path.startswith(f"/home/{ip}") else "root"
|
||||
output = f"{perm_str} {user} {user} {path.split('/')[-1]}"
|
||||
return json_response(request, {"output": output}, 200)
|
||||
return json_response(request, {"output": path.split("/")[-1]}, 200)
|
||||
|
||||
return json_response(request, {"output": f"ls: cannot access '{path}': No such file or directory"}, 200)
|
||||
|
||||
files = get_nodes_in_directory(path)
|
||||
output = []
|
||||
if long_format:
|
||||
for f in files:
|
||||
permissions = f.get("permissions", 0)
|
||||
perm_str = ""
|
||||
perm_str += "r" if permissions > 0 else "-"
|
||||
perm_str += "w" if permissions > 1 else "-"
|
||||
perm_str += "x" if (f.get("type", 0) == 2 and permissions >= 1) else "-"
|
||||
user = f"{ip}" if path.startswith(f"/home/{ip}") else "root"
|
||||
output.append(f"{perm_str} {user} {user} {f['name']}")
|
||||
else:
|
||||
output = [f["name"] for f in files]
|
||||
if all_files:
|
||||
output.insert(0, ".")
|
||||
output.insert(1, "..")
|
||||
else:
|
||||
output = [file for file in output if not file.startswith(".")]
|
||||
if long_format:
|
||||
output = "\n".join(output)
|
||||
else:
|
||||
output = " ".join(output)
|
||||
|
||||
return json_response(request, {"output": output}, 200)
|
||||
|
||||
|
||||
@terminal_bp.route("/terminal/pwd")
|
||||
def pwd():
|
||||
if "pwd" not in session:
|
||||
session["pwd"] = f"/home/{getClientIP(request)}"
|
||||
pwd = session["pwd"]
|
||||
if pwd == "/home/" + getClientIP(request):
|
||||
pwd = "~"
|
||||
return json_response(request, {"output": pwd, "raw": session["pwd"]}, 200)
|
||||
|
||||
|
||||
@terminal_bp.route("/terminal/execute/cd", methods=["POST"])
|
||||
def cd():
|
||||
data = request.get_json() or {}
|
||||
args = data.get("args", "")
|
||||
args = args.split()
|
||||
|
||||
if not args:
|
||||
# No path provided, go to home
|
||||
session["pwd"] = f"/home/{getClientIP(request)}"
|
||||
output = ""
|
||||
else:
|
||||
path = args[0]
|
||||
# Simulate changing directory
|
||||
if path == "~":
|
||||
session["pwd"] = f"/home/{getClientIP(request)}"
|
||||
output = ""
|
||||
|
||||
if not path.startswith("/"):
|
||||
path = sanitize_path(session.get("pwd", f"/home/{getClientIP(request)}") + "/" + path)
|
||||
|
||||
if is_valid_path(path):
|
||||
session["pwd"] = sanitize_path(path)
|
||||
output = ""
|
||||
else:
|
||||
output = f"bash: cd: {path}: No such file or directory"
|
||||
|
||||
return json_response(request, {"output": output}, 200)
|
||||
|
||||
def can_write_to_path(path: str) -> bool:
|
||||
"""Check if the user can write to the given path (must be in their home directory)."""
|
||||
user_home = f"/home/{getClientIP(request)}"
|
||||
normalized_path = sanitize_path(path)
|
||||
return normalized_path.startswith(user_home)
|
||||
|
||||
def create_file(path: str, content: str = "") -> bool:
|
||||
"""Create a new file at the given path."""
|
||||
if session.get("paths", None) is None:
|
||||
setup_path_session()
|
||||
|
||||
parts = path.strip("/").split("/")
|
||||
filename = parts[-1]
|
||||
dir_path = "/".join(parts[:-1])
|
||||
|
||||
# Get the directory
|
||||
if not is_valid_path("/" + dir_path):
|
||||
return False
|
||||
|
||||
# Get nodes in directory
|
||||
dir_parts = dir_path.strip("/").split("/")
|
||||
current_level = session["paths"]
|
||||
|
||||
for part in dir_parts:
|
||||
if part == "":
|
||||
continue
|
||||
for item in current_level:
|
||||
if item["name"] == part and item["type"] == 0:
|
||||
current_level = item.get("children", [])
|
||||
break
|
||||
|
||||
# Check if file already exists
|
||||
for item in current_level:
|
||||
if item["name"] == filename:
|
||||
# Update existing file
|
||||
item["content"] = content
|
||||
session.modified = True
|
||||
return True
|
||||
|
||||
# Create new file
|
||||
new_file = {
|
||||
"name": filename,
|
||||
"type": 1,
|
||||
"content": content,
|
||||
"permissions": 2
|
||||
}
|
||||
current_level.append(new_file)
|
||||
session.modified = True
|
||||
return True
|
||||
|
||||
def update_file_content(path: str, content: str) -> bool:
|
||||
"""Update the content of an existing file."""
|
||||
if session.get("paths", None) is None:
|
||||
setup_path_session()
|
||||
|
||||
parts = path.strip("/").split("/")
|
||||
current_level = session["paths"]
|
||||
|
||||
for i, part in enumerate(parts):
|
||||
for item in current_level:
|
||||
if item["name"] == part:
|
||||
if i == len(parts) - 1:
|
||||
# Update the file content
|
||||
if item["type"] == 1:
|
||||
item["content"] = content
|
||||
session.modified = True
|
||||
return True
|
||||
return False
|
||||
else:
|
||||
current_level = item.get("children", [])
|
||||
break
|
||||
return False
|
||||
|
||||
@terminal_bp.route("/terminal/execute/touch", methods=["POST"])
|
||||
def touch():
|
||||
try:
|
||||
data = request.get_json() or {}
|
||||
args = data.get("args", "")
|
||||
args = args.split()
|
||||
|
||||
if not args:
|
||||
return json_response(request, {"output": "touch: missing file operand"}, 200)
|
||||
|
||||
path = args[0]
|
||||
if not path.startswith("/"):
|
||||
path = sanitize_path(session.get("pwd", f"/home/{getClientIP(request)}") + "/" + path)
|
||||
|
||||
# Check if user can write to this path
|
||||
if not can_write_to_path(path):
|
||||
return json_response(request, {"output": f"touch: cannot touch '{path}': Permission denied"}, 200)
|
||||
|
||||
# Check if file already exists
|
||||
if is_valid_file(path):
|
||||
return json_response(request, {"output": f"touch: '{path}': File already exists"}, 200)
|
||||
|
||||
# Create the file
|
||||
if create_file(path, ""):
|
||||
output = ""
|
||||
else:
|
||||
output = f"touch: cannot create '{path}': No such file or directory"
|
||||
|
||||
return json_response(request, {"output": output}, 200)
|
||||
except Exception as e:
|
||||
return json_response(request, {"output": f"touch: {str(e)}"}, 200)
|
||||
|
||||
@terminal_bp.route("/terminal/execute/nano", methods=["POST"])
|
||||
def nano():
|
||||
try:
|
||||
data = request.get_json() or {}
|
||||
args = data.get("args", "")
|
||||
|
||||
# Parse args - format: filename CONTENT content here
|
||||
parts = args.split(" CONTENT ", 1)
|
||||
if len(parts) != 2:
|
||||
return json_response(request, {"output": "Usage: nano [file] CONTENT [text]\nExample: nano test.txt CONTENT Hello World"}, 200)
|
||||
|
||||
path = parts[0].strip()
|
||||
content = parts[1]
|
||||
|
||||
if not path.startswith("/"):
|
||||
path = sanitize_path(session.get("pwd", f"/home/{getClientIP(request)}") + "/" + path)
|
||||
|
||||
# Check if user can write to this path
|
||||
if not can_write_to_path(path):
|
||||
return json_response(request, {"output": f"nano: cannot write to '{path}': Permission denied"}, 200)
|
||||
|
||||
# Check if file exists
|
||||
if is_valid_file(path):
|
||||
# Update existing file
|
||||
node = get_node(path)
|
||||
if node.get("permissions", 0) < 2:
|
||||
return json_response(request, {"output": f"nano: cannot write to '{path}': Permission denied"}, 200)
|
||||
|
||||
if update_file_content(path, content):
|
||||
output = ""
|
||||
else:
|
||||
output = f"nano: failed to update '{path}'"
|
||||
else:
|
||||
# Create new file
|
||||
if create_file(path, content):
|
||||
output = f"File '{path}' created successfully"
|
||||
else:
|
||||
output = f"nano: cannot create '{path}': No such file or directory"
|
||||
|
||||
return json_response(request, {"output": output}, 200)
|
||||
except Exception as e:
|
||||
return json_response(request, {"output": f"nano: {str(e)}"}, 200)
|
||||
|
||||
@terminal_bp.route("/terminal/execute/cat", methods=["POST"])
|
||||
def cat():
|
||||
try:
|
||||
data = request.get_json() or {}
|
||||
args = data.get("args", "")
|
||||
args = args.split()
|
||||
|
||||
if not args:
|
||||
return json_response(request, {"output": "cat: missing file operand"}, 200)
|
||||
|
||||
path = args[0]
|
||||
if not path.startswith("/"):
|
||||
path = sanitize_path(session.get("pwd", f"/home/{getClientIP(request)}") + "/" + path)
|
||||
|
||||
# Check if path is valid
|
||||
if not is_valid_file(path):
|
||||
# Check if it is a binary
|
||||
if is_valid_binary(path):
|
||||
return json_response(request, {"output": f"cat: {path}: Binary file"}, 200)
|
||||
return json_response(request, {"output": f"cat: {path}: No such file or directory"}, 200)
|
||||
|
||||
output = get_node(path).get("content", "")
|
||||
|
||||
return json_response(request, {"output": output}, 200)
|
||||
except Exception as e:
|
||||
return json_response(request, {"output": f"cat: {str(e)}"}, 200)
|
||||
|
||||
@terminal_bp.route("/terminal/execute/echo", methods=["POST"])
|
||||
def echo():
|
||||
try:
|
||||
data = request.get_json() or {}
|
||||
args = data.get("args", "")
|
||||
return json_response(request, {"output": args}, 200)
|
||||
except Exception as e:
|
||||
return json_response(request, {"output": f"echo: {str(e)}"}, 200)
|
||||
|
||||
@terminal_bp.route("/terminal/execute/date", methods=["POST"])
|
||||
def date():
|
||||
try:
|
||||
# See if any args are passed
|
||||
data = request.get_json() or {}
|
||||
args = data.get("args", "")
|
||||
|
||||
# Use arguments to format date if needed
|
||||
if args:
|
||||
# If args if --help or -h, show help message
|
||||
if args in ("--help", "-h"):
|
||||
output = (
|
||||
"Usage: date [FORMAT]\n\n"
|
||||
"Display the current date and time.\n\n"
|
||||
"FORMAT controls the output. Some common format specifiers:\n"
|
||||
" %a Abbreviated weekday name (e.g., 'Mon')\n"
|
||||
" %b Abbreviated month name (e.g., 'Jan')\n"
|
||||
" %d Day of the month (01 to 31)\n"
|
||||
" %H Hour (00 to 23)\n"
|
||||
" %M Minute (00 to 59)\n"
|
||||
" %S Second (00 to 60)\n"
|
||||
" %Y Year with century (e.g., 2024)\n\n"
|
||||
"Example: date '%Y-%m-%d %H:%M:%S'"
|
||||
)
|
||||
return json_response(request, {"output": output}, 200)
|
||||
|
||||
try:
|
||||
output = datetime.now().strftime(args)
|
||||
except Exception:
|
||||
output = "Invalid date format."
|
||||
else:
|
||||
output = datetime.now().strftime("%a %b %d %H:%M:%S %Z %Y")
|
||||
return json_response(request, {"output": output}, 200)
|
||||
except Exception as e:
|
||||
return json_response(request, {"output": f"date: {str(e)}"}, 200)
|
||||
|
||||
@terminal_bp.route("/terminal/execute/rm", methods=["POST"])
|
||||
def rm():
|
||||
try:
|
||||
data = request.get_json() or {}
|
||||
args = data.get("args", "")
|
||||
args = args.split()
|
||||
|
||||
if not args:
|
||||
return json_response(request, {"output": "rm: missing operand"}, 200)
|
||||
|
||||
path = args[0]
|
||||
if not path.startswith("/"):
|
||||
path = sanitize_path(session.get("pwd", f"/home/{getClientIP(request)}") + "/" + path)
|
||||
|
||||
# Check if user can write to this path
|
||||
if not can_write_to_path(path):
|
||||
return json_response(request, {"output": f"rm: cannot remove '{path}': Permission denied"}, 200)
|
||||
|
||||
# Check if path is valid
|
||||
if not is_valid_file(path) and not is_valid_binary(path):
|
||||
return json_response(request, {"output": f"rm: cannot remove '{path}': No such file"}, 200)
|
||||
|
||||
# Get the node
|
||||
node = get_node(path)
|
||||
# Only let user delete files if the permission is >1 (writable)
|
||||
if node.get("permissions", 0) < 2:
|
||||
return json_response(request, {"output": f"rm: cannot remove '{path}': Permission denied"}, 200)
|
||||
|
||||
# Only let the user remove files
|
||||
if node.get("type", 1) != 1:
|
||||
return json_response(request, {"output": f"rm: cannot remove '{path}': Is a directory"}, 200)
|
||||
|
||||
# Remove the file from session paths
|
||||
if remove_node(path):
|
||||
output = f"Removed '{path}'"
|
||||
else:
|
||||
output = f"Failed to remove '{path}'"
|
||||
|
||||
return json_response(request, {"output": output}, 200)
|
||||
except Exception as e:
|
||||
return json_response(request, {"output": f"rm: {str(e)}"}, 200)
|
||||
|
||||
@terminal_bp.route("/terminal/execute/tree", methods=["POST"])
|
||||
def tree():
|
||||
try:
|
||||
data = request.get_json() or {}
|
||||
args = data.get("args", "")
|
||||
path = session.get("pwd", f"/home/{getClientIP(request)}")
|
||||
if args:
|
||||
path = args
|
||||
if not path.startswith("/"):
|
||||
path = sanitize_path(session.get("pwd", f"/home/{getClientIP(request)}") + "/" + path)
|
||||
if not is_valid_path(path):
|
||||
return json_response(request, {"output": f"tree: cannot access '{path}': No such file or directory"}, 200)
|
||||
|
||||
output = build_tree(path).rstrip()
|
||||
return json_response(request, {"output": output}, 200)
|
||||
except Exception as e:
|
||||
return json_response(request, {"output": f"tree: {str(e)}"}, 200)
|
||||
|
||||
@terminal_bp.route("/terminal/execute/<command>", methods=["POST"])
|
||||
def execute_catch(command):
|
||||
try:
|
||||
# Basic command processing
|
||||
if command == "help":
|
||||
output = "Available commands:\n" + \
|
||||
"\n".join(f" {cmd}: {desc}" for cmd, desc in COMMANDS.items())
|
||||
elif command == "about":
|
||||
output = "This is a simulated terminal interface created by Nathan Woodburn."
|
||||
|
||||
elif command == "whoami":
|
||||
output = getClientIP(request)
|
||||
elif command == "pwd":
|
||||
# Get pwd from session or simulate
|
||||
output = session.get("pwd", f"/home/{getClientIP(request)}")
|
||||
else:
|
||||
output = f"Command not found: {command}"
|
||||
|
||||
return json_response(request, {"output": output}, 200)
|
||||
except Exception as e:
|
||||
return json_response(request, {"output": f"{command}: {str(e)}"}, 200)
|
||||
|
||||
@terminal_bp.route("/terminal/execute/reset", methods=["POST"])
|
||||
def reset():
|
||||
try:
|
||||
# Clear the session data related to terminal
|
||||
session.pop("pwd", None)
|
||||
session.pop("paths", None)
|
||||
output = "Terminal session has been reset."
|
||||
return json_response(request, {"output": output}, 200)
|
||||
except Exception as e:
|
||||
return json_response(request, {"output": f"reset: {str(e)}"}, 200)
|
||||
|
||||
# Add error handler at the end
|
||||
@terminal_bp.errorhandler(Exception)
|
||||
def handle_terminal_error(error):
|
||||
"""Handle all exceptions in terminal blueprint."""
|
||||
error_message = f"Terminal error: {str(error)}"
|
||||
return json_response(request, {"output": error_message}, 500)
|
||||
50
curl.py
50
curl.py
@@ -1,8 +1,9 @@
|
||||
from flask import render_template
|
||||
from tools import error_response, getAddress
|
||||
from tools import error_response, getAddress, get_tools_data, getClientIP
|
||||
import os
|
||||
from functools import lru_cache
|
||||
import requests
|
||||
from blueprints.spotify import get_spotify_track
|
||||
|
||||
|
||||
def clean_path(path:str):
|
||||
@@ -32,7 +33,9 @@ def get_current_project():
|
||||
repo_name = git["repo"]["name"]
|
||||
repo_name = repo_name.lower()
|
||||
repo_description = git["repo"]["description"]
|
||||
return f"[1m{repo_name}[0m - {repo_description}"
|
||||
if not repo_description:
|
||||
return f"[1;36m{repo_name}[0m"
|
||||
return f"[1;36m{repo_name}[0m - [1m{repo_description}[0m"
|
||||
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
@@ -74,6 +77,35 @@ def get_projects():
|
||||
|
||||
return projects
|
||||
|
||||
@lru_cache(maxsize=32)
|
||||
def valid_curl_path(path: str) -> bool:
|
||||
"""Check if the given path corresponds to a valid curl/ascii response."""
|
||||
path = clean_path(path)
|
||||
|
||||
# Special cases
|
||||
special_paths = [
|
||||
"index",
|
||||
"projects",
|
||||
"donate",
|
||||
"donate/more",
|
||||
"tools"
|
||||
]
|
||||
if path in special_paths:
|
||||
return True
|
||||
|
||||
# Check for donate/<coin> pattern
|
||||
if path.startswith("donate/"):
|
||||
coin = path.split("/")[1]
|
||||
address = getAddress(coin)
|
||||
if address != "":
|
||||
return True
|
||||
|
||||
# Check if .ascii template exists
|
||||
if os.path.exists(f"templates/{path}.ascii"):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def curl_response(request):
|
||||
# Check if <path>.ascii exists
|
||||
path = clean_path(request.path)
|
||||
@@ -81,7 +113,7 @@ def curl_response(request):
|
||||
# Handle special cases
|
||||
if path == "index":
|
||||
# Get current project
|
||||
return render_template("index.ascii",header=get_header(),repo=get_current_project()), 200, {'Content-Type': 'text/plain; charset=utf-8'}
|
||||
return render_template("index.ascii",repo=get_current_project(), ip=getClientIP(request), spotify=get_spotify_track()), 200, {'Content-Type': 'text/plain; charset=utf-8'}
|
||||
if path == "projects":
|
||||
# Get projects
|
||||
return render_template("projects.ascii",header=get_header(),projects=get_projects()), 200, {'Content-Type': 'text/plain; charset=utf-8'}
|
||||
@@ -99,10 +131,8 @@ def curl_response(request):
|
||||
coinList.sort()
|
||||
return render_template("donate_more.ascii",header=get_header(),
|
||||
coins=coinList
|
||||
), 200, {'Content-Type': 'text/plain; charset=utf-8'}
|
||||
), 200, {'Content-Type': 'text/plain; charset=utf-8'}
|
||||
|
||||
|
||||
|
||||
# For other donation pages, fall back to ascii if it exists
|
||||
if path.startswith("donate/"):
|
||||
coin = path.split("/")[1]
|
||||
@@ -110,12 +140,12 @@ def curl_response(request):
|
||||
if address != "":
|
||||
return render_template("donate_coin.ascii",header=get_header(),coin=coin.upper(),address=address), 200, {'Content-Type': 'text/plain; charset=utf-8'}
|
||||
|
||||
if path == "tools":
|
||||
tools = get_tools_data()
|
||||
return render_template("tools.ascii",header=get_header(),tools=tools), 200, {'Content-Type': 'text/plain; charset=utf-8'}
|
||||
|
||||
|
||||
if os.path.exists(f"templates/{path}.ascii"):
|
||||
return render_template(f"{path}.ascii",header=get_header()), 200, {'Content-Type': 'text/plain; charset=utf-8'}
|
||||
|
||||
# Fallback to html if it exists
|
||||
if os.path.exists(f"templates/{path}.html"):
|
||||
return render_template(f"{path}.html")
|
||||
|
||||
return error_response(request)
|
||||
@@ -1,7 +1,9 @@
|
||||
G'day,
|
||||
Just thought it might be useful to write down some of the software I use regularly. I've no clue if you'll find any useful :)
|
||||
|
||||
For a more complete list, check out [/tools](/tools)
|
||||
|
||||
<br>
|
||||
## Overview
|
||||
OS: Arch Linux | Because it is quick to update and has all the latest tools I can play with
|
||||
DE: Hyprland | Feel free to check out my dotfiles if you're interested
|
||||
|
||||
170
data/tools.json
Normal file
170
data/tools.json
Normal file
@@ -0,0 +1,170 @@
|
||||
[
|
||||
{
|
||||
"name":"Obsidian",
|
||||
"type":"Desktop Applications",
|
||||
"url":"https://obsidian.md/",
|
||||
"description":"Note taking app that stores everything in Markdown files"
|
||||
},
|
||||
{
|
||||
"name": "Alacritty",
|
||||
"type": "Desktop Applications",
|
||||
"url": "https://alacritty.org/",
|
||||
"description": "A cross-platform, GPU-accelerated terminal emulator"
|
||||
},
|
||||
{
|
||||
"name": "Brave",
|
||||
"type": "Desktop Applications",
|
||||
"url": "https://brave.com/",
|
||||
"description": "Privacy-focused web browser"
|
||||
},
|
||||
{
|
||||
"name": "VSCode",
|
||||
"type": "Desktop Applications",
|
||||
"url": "https://code.visualstudio.com/",
|
||||
"description": "Source-code editor developed by Microsoft"
|
||||
},
|
||||
{
|
||||
"name": "Zellij",
|
||||
"type": "Terminal Tools",
|
||||
"url": "https://zellij.dev/",
|
||||
"description": "A terminal workspace and multiplexer"
|
||||
},
|
||||
{
|
||||
"name": "Fx",
|
||||
"type": "Terminal Tools",
|
||||
"url": "https://fx.wtf/",
|
||||
"description": "A command-line JSON viewer and processor",
|
||||
"demo": "<script src=\"https://asciinema.c.woodburn.au/a/4.js\" id=\"asciicast-4\" async=\"true\"></script>",
|
||||
"demo_url": "https://asciinema.c.woodburn.au/a/4"
|
||||
},
|
||||
{
|
||||
"name": "Zoxide",
|
||||
"type": "Terminal Tools",
|
||||
"url": "https://github.com/ajeetdsouza/zoxide",
|
||||
"description": "cd but with fuzzy matching and other cool features",
|
||||
"demo": "<script src=\"https://asciinema.c.woodburn.au/a/5.js\" id=\"asciicast-5\" async=\"true\"></script>",
|
||||
"demo_url": "https://asciinema.c.woodburn.au/a/5"
|
||||
},
|
||||
{
|
||||
"name": "Atuin",
|
||||
"type": "Terminal Tools",
|
||||
"url": "https://atuin.sh/",
|
||||
"description": "A next-generation shell history manager",
|
||||
"demo": "<script src=\"https://asciinema.c.woodburn.au/a/6.js\" id=\"asciicast-6\" async=\"true\"></script>",
|
||||
"demo_url": "https://asciinema.c.woodburn.au/a/6"
|
||||
},
|
||||
{
|
||||
"name": "Tmate",
|
||||
"type": "Terminal Tools",
|
||||
"url": "https://tmate.io/",
|
||||
"description": "Instant terminal sharing",
|
||||
"demo": "<script src=\"https://asciinema.c.woodburn.au/a/7.js\" id=\"asciicast-7\" async=\"true\"></script>",
|
||||
"demo_url": "https://asciinema.c.woodburn.au/a/7"
|
||||
},
|
||||
{
|
||||
"name": "Eza",
|
||||
"type": "Terminal Tools",
|
||||
"url": "https://eza.rocks/",
|
||||
"description": "A modern replacement for 'ls'",
|
||||
"demo": "<script src=\"https://asciinema.c.woodburn.au/a/8.js\" id=\"asciicast-8\" async=\"true\"></script>",
|
||||
"demo_url": "https://asciinema.c.woodburn.au/a/8"
|
||||
},
|
||||
{
|
||||
"name": "Bat",
|
||||
"type": "Terminal Tools",
|
||||
"url": "https://github.com/sharkdp/bat",
|
||||
"description": "A cat clone with syntax highlighting and Git integration",
|
||||
"demo": "<script src=\"https://asciinema.c.woodburn.au/a/9.js\" id=\"asciicast-9\" async=\"true\"></script>",
|
||||
"demo_url": "https://asciinema.c.woodburn.au/a/9"
|
||||
},
|
||||
{
|
||||
"name": "Oh My Zsh",
|
||||
"type": "Terminal Tools",
|
||||
"url": "https://ohmyz.sh/",
|
||||
"description": "A delightful community-driven framework for managing your Zsh configuration"
|
||||
},
|
||||
{
|
||||
"name": "Proxmox",
|
||||
"type": "Server Management",
|
||||
"url": "https://www.proxmox.com/en",
|
||||
"description": "Open-source server virtualization management solution"
|
||||
},
|
||||
{
|
||||
"name": "Portainer",
|
||||
"type": "Server Management",
|
||||
"url": "https://www.portainer.io/",
|
||||
"description": "Lightweight management UI which allows you to easily manage your Docker containers"
|
||||
},
|
||||
{
|
||||
"name": "Coolify",
|
||||
"type": "Server Management",
|
||||
"url": "https://coolify.io/",
|
||||
"description": "An open-source self-hosted Heroku alternative"
|
||||
},
|
||||
{
|
||||
"name": "OpnSense",
|
||||
"type": "Server Management",
|
||||
"url": "https://opnsense.org/",
|
||||
"description": "Open source, easy-to-use and easy-to-build FreeBSD based firewall and routing platform"
|
||||
},
|
||||
{
|
||||
"name": "Nginx Proxy Manager",
|
||||
"type": "Server Management",
|
||||
"url": "https://nginxproxymanager.com/",
|
||||
"description": "A powerful yet easy to use web interface for managing Nginx proxy hosts"
|
||||
},
|
||||
{
|
||||
"name": "Tailscale",
|
||||
"type": "Server Management",
|
||||
"url": "https://tailscale.com/",
|
||||
"description": "A zero-config VPN that just works"
|
||||
},
|
||||
{
|
||||
"name": "Authentik",
|
||||
"type": "Self-Hosting Services",
|
||||
"url": "https://goauthentik.io/",
|
||||
"description": "An open-source identity provider focused on flexibility and ease of use"
|
||||
},
|
||||
{
|
||||
"name": "Uptime Kuma",
|
||||
"type": "Self-Hosting Services",
|
||||
"url": "https://uptime.kuma.pet/",
|
||||
"description": "A fancy self-hosted monitoring tool"
|
||||
},
|
||||
{
|
||||
"name": "Gitea",
|
||||
"type": "Self-Hosting Services",
|
||||
"url": "https://about.gitea.com/",
|
||||
"description": "A painless self-hosted Git service"
|
||||
},
|
||||
{
|
||||
"name": "Nextcloud",
|
||||
"type": "Self-Hosting Services",
|
||||
"url": "https://nextcloud.com/",
|
||||
"description": "A suite of client-server software for creating and using file hosting services"
|
||||
},
|
||||
{
|
||||
"name": "Umami",
|
||||
"type": "Self-Hosting Services",
|
||||
"url": "https://umami.is/",
|
||||
"description": "A simple, fast, privacy-focused alternative to Google Analytics"
|
||||
},
|
||||
{
|
||||
"name": "PhotoPrism",
|
||||
"type": "Self-Hosting Services",
|
||||
"url": "https://photoprism.app/",
|
||||
"description": "AI-powered app for browsing, organizing & sharing your photo collection"
|
||||
},
|
||||
{
|
||||
"name": "FreeScout",
|
||||
"type": "Self-Hosting Services",
|
||||
"url": "https://freescout.net/",
|
||||
"description": "Self hosted email dashboard"
|
||||
},
|
||||
{
|
||||
"name": "Vaultwarden",
|
||||
"type": "Miscellaneous",
|
||||
"url": "https://github.com/dani-garcia/vaultwarden",
|
||||
"description": "Password manager server implementation compatible with Bitwarden clients"
|
||||
}
|
||||
]
|
||||
20
server.py
20
server.py
@@ -25,10 +25,13 @@ from blueprints.wellknown import wk_bp
|
||||
from blueprints.api import api_bp
|
||||
from blueprints.podcast import podcast_bp
|
||||
from blueprints.acme import acme_bp
|
||||
from tools import isCurl, isCrawler, getAddress, getFilePath, error_response, getClientIP, json_response, getHandshakeScript
|
||||
from curl import curl_response
|
||||
from blueprints.spotify import spotify_bp
|
||||
from blueprints.terminal import terminal_bp
|
||||
from tools import isCurl, isCrawler, getAddress, getFilePath, error_response, getClientIP, json_response, getHandshakeScript, get_tools_data
|
||||
from curl import curl_response, valid_curl_path
|
||||
|
||||
app = Flask(__name__)
|
||||
app.secret_key = os.getenv("FLASK_SECRET_KEY", "supersecretkey")
|
||||
CORS(app)
|
||||
|
||||
# Register blueprints
|
||||
@@ -38,6 +41,8 @@ app.register_blueprint(wk_bp, url_prefix='/.well-known')
|
||||
app.register_blueprint(api_bp, url_prefix='/api/v1')
|
||||
app.register_blueprint(podcast_bp)
|
||||
app.register_blueprint(acme_bp)
|
||||
app.register_blueprint(spotify_bp, url_prefix='/spotify')
|
||||
app.register_blueprint(terminal_bp)
|
||||
|
||||
dotenv.load_dotenv()
|
||||
|
||||
@@ -393,8 +398,6 @@ def index():
|
||||
return resp
|
||||
|
||||
# region Donate
|
||||
|
||||
|
||||
@app.route("/donate")
|
||||
def donate():
|
||||
if isCurl(request):
|
||||
@@ -560,7 +563,6 @@ def qrcodee(data):
|
||||
|
||||
# endregion
|
||||
|
||||
|
||||
@app.route("/supersecretpath")
|
||||
def supersecretpath():
|
||||
ascii_art = ""
|
||||
@@ -686,6 +688,12 @@ def resume_pdf():
|
||||
return send_file("data/resume.pdf")
|
||||
return error_response(request, message="Resume not found")
|
||||
|
||||
@app.route("/tools")
|
||||
def tools():
|
||||
if isCurl(request):
|
||||
return curl_response(request)
|
||||
return render_template("tools.html", tools=get_tools_data())
|
||||
|
||||
# endregion
|
||||
# region Error Catching
|
||||
|
||||
@@ -699,7 +707,7 @@ def catch_all(path: str):
|
||||
return error_response(request, message="Restricted route", code=403)
|
||||
|
||||
# If curl request, return curl response
|
||||
if isCurl(request):
|
||||
if isCurl(request) and valid_curl_path(path):
|
||||
return curl_response(request)
|
||||
|
||||
if path in REDIRECT_ROUTES:
|
||||
|
||||
2
templates/assets/css/brand-reveal.min.css
vendored
2
templates/assets/css/brand-reveal.min.css
vendored
@@ -1 +1 @@
|
||||
.name-container{display:inline-flex;align-items:center;overflow:hidden;position:absolute;width:fit-content;left:50%;transform:translateX(-50%)}.slider{position:relative;left:0;animation:1s linear 1s forwards slide}@keyframes slide{0%{left:0}100%{left:calc(100%)}}.brand{mask-image:linear-gradient(to right,black 50%,transparent 50%);-webkit-mask-image:linear-gradient(to right,black 50%,transparent 50%);mask-position:100% 0;-webkit-mask-position:100% 0;mask-size:200%;-webkit-mask-size:200%;animation:1s linear 1s forwards reveal}@keyframes reveal{0%{mask-position:100% 0;-webkit-mask-position:100% 0}100%{mask-position:0 0;-webkit-mask-position:0 0}}
|
||||
.name-container{display:inline-flex;align-items:center;overflow:hidden;position:absolute;width:fit-content;left:50%;transform:translateX(-50%)}.slider{position:relative;left:0;animation:1s linear 1s forwards slide}@keyframes slide{0%{left:0}100%{left:calc(100%)}}.brand{mask-image:linear-gradient(to right,black 50%,transparent 50%);-webkit-mask-image:linear-gradient(to right,black 50%,transparent 50%);mask-position:100% 0;-webkit-mask-position:100% 0;mask-size:200%;-webkit-mask-size:200%;animation:1s linear 1s forwards reveal}@keyframes reveal{0%{mask-position:100% 0;-webkit-mask-position:100% 0}100%{mask-position:0 0;-webkit-mask-position:0 0}}.now-playing{position:fixed;bottom:0;right:0;border-top-left-radius:10px;background:#10101039;padding:1em}
|
||||
2
templates/assets/css/styles.min.css
vendored
2
templates/assets/css/styles.min.css
vendored
@@ -1 +1 @@
|
||||
:root,[data-bs-theme=light]{--bs-primary:#6E0E9C;--bs-primary-rgb:110,14,156;--bs-primary-text-emphasis:#2C063E;--bs-primary-bg-subtle:#E2CFEB;--bs-primary-border-subtle:#C59FD7;--bs-link-color:#6E0E9C;--bs-link-color-rgb:110,14,156;--bs-link-hover-color:#a41685;--bs-link-hover-color-rgb:164,22,133}.btn-primary{--bs-btn-color:#fff;--bs-btn-bg:#6E0E9C;--bs-btn-border-color:#6E0E9C;--bs-btn-hover-color:#fff;--bs-btn-hover-bg:#5E0C85;--bs-btn-hover-border-color:#580B7D;--bs-btn-focus-shadow-rgb:233,219,240;--bs-btn-active-color:#fff;--bs-btn-active-bg:#580B7D;--bs-btn-active-border-color:#530B75;--bs-btn-disabled-color:#fff;--bs-btn-disabled-bg:#6E0E9C;--bs-btn-disabled-border-color:#6E0E9C}.btn-outline-primary{--bs-btn-color:#6E0E9C;--bs-btn-border-color:#6E0E9C;--bs-btn-focus-shadow-rgb:110,14,156;--bs-btn-hover-color:#fff;--bs-btn-hover-bg:#6E0E9C;--bs-btn-hover-border-color:#6E0E9C;--bs-btn-active-color:#fff;--bs-btn-active-bg:#6E0E9C;--bs-btn-active-border-color:#6E0E9C;--bs-btn-disabled-color:#6E0E9C;--bs-btn-disabled-bg:transparent;--bs-btn-disabled-border-color:#6E0E9C}.py-4{padding-top:1.5rem!important;padding-bottom:1.5rem!important}@media (min-width:992px){.py-lg-5{padding-top:3rem!important;padding-bottom:3rem!important}}
|
||||
:root,[data-bs-theme=light]{--bs-primary:#6E0E9C;--bs-primary-rgb:110,14,156;--bs-primary-text-emphasis:#2C063E;--bs-primary-bg-subtle:#E2CFEB;--bs-primary-border-subtle:#C59FD7;--bs-link-color:#6E0E9C;--bs-link-color-rgb:110,14,156;--bs-link-hover-color:#a41685;--bs-link-hover-color-rgb:164,22,133}.btn-primary{--bs-btn-color:#fff;--bs-btn-bg:#6E0E9C;--bs-btn-border-color:#6E0E9C;--bs-btn-hover-color:#fff;--bs-btn-hover-bg:#5E0C85;--bs-btn-hover-border-color:#580B7D;--bs-btn-focus-shadow-rgb:233,219,240;--bs-btn-active-color:#fff;--bs-btn-active-bg:#580B7D;--bs-btn-active-border-color:#530B75;--bs-btn-disabled-color:#fff;--bs-btn-disabled-bg:#6E0E9C;--bs-btn-disabled-border-color:#6E0E9C}.btn-outline-primary{--bs-btn-color:#6E0E9C;--bs-btn-border-color:#6E0E9C;--bs-btn-focus-shadow-rgb:110,14,156;--bs-btn-hover-color:#fff;--bs-btn-hover-bg:#6E0E9C;--bs-btn-hover-border-color:#6E0E9C;--bs-btn-active-color:#fff;--bs-btn-active-bg:#6E0E9C;--bs-btn-active-border-color:#6E0E9C;--bs-btn-disabled-color:#6E0E9C;--bs-btn-disabled-bg:transparent;--bs-btn-disabled-border-color:#6E0E9C}.py-2{padding-top:.5rem!important;padding-bottom:.5rem!important}.py-4{padding-top:1.5rem!important;padding-bottom:1.5rem!important}@media (min-width:992px){.py-lg-5{padding-top:3rem!important;padding-bottom:3rem!important}}
|
||||
BIN
templates/assets/img/external/spotify.png
vendored
Normal file
BIN
templates/assets/img/external/spotify.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.7 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 12 KiB |
BIN
templates/assets/img/profile.webp
Normal file
BIN
templates/assets/img/profile.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
@@ -55,6 +55,7 @@ Find something interesting to read. Or maybe check one of my tutorials">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -56,6 +56,7 @@ Find something interesting to read. Or maybe check one of my tutorials">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
If you’d like to support my work 💙
|
||||
|
||||
- PayPal: [https://paypal.me/nathanwoodburn]
|
||||
- GitHub: [https://github.com/sponsors/Nathanwoodburn]
|
||||
- Stripe: [https://donate.stripe.com/8wM6pv0VD08Xe408ww]
|
||||
- PayPal: https://paypal.me/nathanwoodburn
|
||||
- GitHub: https://github.com/sponsors/Nathanwoodburn
|
||||
- Stripe: https://donate.stripe.com/8wM6pv0VD08Xe408ww
|
||||
|
||||
[1mHNS: nathan.woodburn[0m
|
||||
[1m{{ HNS }}[0m
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -7,5 +7,6 @@
|
||||
Home [/]
|
||||
Contact [/contact]
|
||||
Projects [/projects]
|
||||
Tools [/tools]
|
||||
Donate [/donate]
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
{{header}}
|
||||
[1;36m─────────────────────────────────────────────────────[0m
|
||||
[1;36m . . , . . . .. / [0m
|
||||
[1;36m |\ | _.-+-|_ _.._ | | _ _ _||_ . .._.._ / [0m
|
||||
[1;36m | \|(_] | [ )(_][ ) * |/\|(_)(_)(_][_)(_|[ [ )/ [0m
|
||||
[1;36m─────────────────────────────────────────────────────[0m
|
||||
|
||||
Home [/]
|
||||
Contact [/contact]
|
||||
Projects [/projects]
|
||||
Tools [/tools]
|
||||
Donate [/donate]
|
||||
API [/api/v1/]
|
||||
|
||||
[1;36m───────────────────────────────────────────────[0m
|
||||
[1;36m ABOUT ME [0m
|
||||
[1;36m──────────[0m
|
||||
@@ -12,13 +24,14 @@ I'm also one of the founders of [1;36mHandshake AU[0m [https://hns.au],
|
||||
working to grow Handshake adoption across Australia.
|
||||
|
||||
I'm currently working on: {{ repo | safe }}
|
||||
{% if not spotify.message %}Currently listening to: [1;36m{{ spotify.song_name }}[0m by [1;36m{{ spotify.artist }}[0m{% endif %}
|
||||
|
||||
[1;36m───────────────────────────────────────────────[0m
|
||||
[1;36m SKILLS [0m
|
||||
[1;36m────────[0m
|
||||
|
||||
- Linux servers & CLI
|
||||
- DNS, DNSSEC, and Trustless SSL
|
||||
- DNS & DNSSEC
|
||||
- NGINX web servers
|
||||
- Programming:
|
||||
- Python 3
|
||||
@@ -26,3 +39,7 @@ I'm currently working on: {{ repo | safe }}
|
||||
- Java
|
||||
- Bash
|
||||
|
||||
|
||||
Served to: {{ ip }}
|
||||
[1;36m───────────────────────────────────────────────[0m
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
<link rel="stylesheet" href="/assets/css/Social-Icons.min.css">
|
||||
<link rel="stylesheet" href="/assets/css/swiper.min.css">
|
||||
<link rel="me" href="https://mastodon.woodburn.au/@nathanwoodburn" />
|
||||
<script async src="https://umami.woodburn.au/script.js" data-website-id="6a55028e-aad3-481c-9a37-3e096ff75589"></script>
|
||||
<script async src="https://umami.woodburn.au/script.js" data-website-id="6a55028e-aad3-481c-9a37-3e096ff75589"></script><link rel="preload" as="image" href="/assets/img/bg/BlueMountains.jpg" type="image/jpeg">
|
||||
</head>
|
||||
|
||||
<body id="page-top" data-bs-spy="scroll" data-bs-target="#mainNav" data-bs-offset="77"><script>
|
||||
@@ -69,6 +69,7 @@
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
@@ -78,7 +79,7 @@
|
||||
<div class="text-end d-none d-xl-block d-xxl-block" id="downtime"><blockquote class="speech bubble"><em>G'day!</em><br>
|
||||
Some services are down.<br>
|
||||
Check them out here!</blockquote><img class="img-fluid" src="/assets/img/pfront.webp"></div>
|
||||
<header class="masthead main" style="background: url("/assets/img/bg/BlueMountains.jpg") center / cover;position: relative;height: 400px;">
|
||||
<header class="masthead main" style="position: relative;height: 400px;background: url("/assets/img/bg/BlueMountains.jpg") center / cover;">
|
||||
<div class="intro-body text parallax">
|
||||
<div class="name-container" style="padding-right: 1em;">
|
||||
<div class="slider">
|
||||
@@ -94,7 +95,7 @@ Check them out here!</blockquote><img class="img-fluid" src="/assets/img/pfront.
|
||||
<div class="row">
|
||||
<div class="col-lg-8 mx-auto">
|
||||
<h2>About ME</h2>
|
||||
<div class="profile-container" style="margin-bottom: 2em;"><img class="profile background" src="/assets/img/profile.jpg" style="border-radius: 50%;" alt="My Profile"><img class="profile foreground" src="/assets/img/pfront.webp" alt=""></div>
|
||||
<div class="profile-container" style="margin-bottom: 2em;"><img class="profile background" src="/assets/img/profile.webp" style="border-radius: 50%;" alt="My Profile"><img class="profile foreground" src="/assets/img/pfront.webp" alt=""></div>
|
||||
<p style="margin-bottom: 5px;">Hi, I'm Nathan Woodburn and I live in Canberra, Australia.<br>I've been home schooled all the way to Yr 12.<br>I'm currently studying a Bachelor of Computer Science.<br>I create tons of random projects so this site is often behind.<br>I'm one of the founders of <a href="https://hns.au" target="_blank">Handshake AU</a> working to increase Handshake adoption in Australia.</p>
|
||||
<p title="{{repo_description}}" style="margin-bottom: 0px;display: inline-block;">I'm currently working on</p>
|
||||
<p data-bs-toggle="tooltip" data-bss-tooltip="" title="{{repo_description}}" style="display: inline-block;">{{repo | safe}}</p>
|
||||
@@ -105,7 +106,7 @@ Check them out here!</blockquote><img class="img-fluid" src="/assets/img/pfront.
|
||||
<h2>Skills</h2>
|
||||
<ul class="list-unstyled" style="font-size: 18px;">
|
||||
<li class="programlinux">Linux Servers and CLI</li>
|
||||
<li>DNS, DNSSEC and Trustless SSL</li>
|
||||
<li>DNS and DNSSEC</li>
|
||||
<li class="programnginx">NGINX Web Servers</li>
|
||||
<li class="programc">Programming in<ul class="list-inline">
|
||||
<li class="list-inline-item">Python 3</li>
|
||||
@@ -126,7 +127,7 @@ Check them out here!</blockquote><img class="img-fluid" src="/assets/img/pfront.
|
||||
<div class="swiper">
|
||||
<div class="swiper-wrapper">{% for project in projects %}
|
||||
<div class="swiper-slide site" data-url="{{ project.html_url }}">
|
||||
<img class="site-img" src="{{ project.avatar_url }}" />
|
||||
<img class="site-img" src="{{ project.avatar_url }}" alt="{{ project.name }} Icon" />
|
||||
<div class="site-body">
|
||||
<div class="site-detail" style="width: 100%;">
|
||||
<h2 class="site-name" style="text-align: left;">{{ project.name }}</h2>
|
||||
@@ -227,7 +228,7 @@ Check them out here!</blockquote><img class="img-fluid" src="/assets/img/pfront.
|
||||
<div class="container text-center">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<p>Verify me with this <a href="pgp" target="_blank">long lifetime Public Key</a> or this <a href="gitpgp" target="_blank">short term one for Github commits</a></p>
|
||||
<p>Verify me with this <a href="pgp" target="_blank">PGP Public Key</a></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@@ -291,7 +292,164 @@ Check them out here!</blockquote><img class="img-fluid" src="/assets/img/pfront.
|
||||
<div class="d-none d-print-none d-sm-none d-md-block d-lg-block d-xl-block d-xxl-block clock" style="padding: 1em;background: #10101039;border-top-right-radius: 10px;"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 20 20" fill="none" class="fs-2">
|
||||
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M10 18C14.4183 18 18 14.4183 18 10C18 5.58172 14.4183 2 10 2C5.58172 2 2 5.58172 2 10C2 14.4183 5.58172 18 10 18ZM11 6C11 5.44772 10.5523 5 10 5C9.44771 5 9 5.44772 9 6V10C9 10.2652 9.10536 10.5196 9.29289 10.7071L12.1213 13.5355C12.5118 13.9261 13.145 13.9261 13.5355 13.5355C13.9261 13.145 13.9261 12.5118 13.5355 12.1213L11 9.58579V6Z" fill="currentColor"></path>
|
||||
</svg><span style="margin-left: 10px;font-family: 'Anonymous Pro', monospace;">{{time|safe}}</span></div>
|
||||
</svg><span style="margin-left: 10px;font-family: 'Anonymous Pro', monospace;">{{time|safe}}</span></div><!-- Pop-out button for mobile -->
|
||||
<button id="spotify-toggle" style="
|
||||
display: none;
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
z-index: 9999;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
border: none;
|
||||
background: none;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
">
|
||||
<img src="/assets/img/external/spotify.png" alt="Spotify" style="
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 50%;
|
||||
"></img>
|
||||
</button>
|
||||
|
||||
<div id="spotify-widget" style="
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #121212;
|
||||
color: white;
|
||||
padding: 10px 15px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.4);
|
||||
font-family: sans-serif;
|
||||
max-width: 300px;
|
||||
z-index: 9999;
|
||||
transition: transform 0.3s ease, opacity 0.3s ease;
|
||||
opacity: 0.9;
|
||||
transform: translateX(120%); /* start hidden off-screen */
|
||||
">
|
||||
<img id="spotify-album-art" src="" alt="Album Art" style="
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
border-radius: 6px;
|
||||
margin-right: 12px;
|
||||
flex-shrink: 0;
|
||||
">
|
||||
<div style="flex: 1; overflow: hidden;">
|
||||
<div id="spotify-song" style="
|
||||
font-weight: bold;
|
||||
font-size: 0.95rem;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
"></div>
|
||||
<div id="spotify-artist" style="
|
||||
font-size: 0.85rem;
|
||||
color: #ccc;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
"></div>
|
||||
<div id="spotify-album" style="
|
||||
font-size: 0.75rem;
|
||||
color: #888;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const widget = document.getElementById('spotify-widget');
|
||||
const toggleBtn = document.getElementById('spotify-toggle');
|
||||
|
||||
function isMobile() {
|
||||
return window.innerWidth <= 768;
|
||||
}
|
||||
|
||||
function updateVisibility() {
|
||||
if(isMobile()){
|
||||
widget.style.transform = 'translateX(120%)'; // hidden off-screen
|
||||
toggleBtn.style.display = 'block';
|
||||
} else {
|
||||
widget.style.transform = 'translateX(0)'; // visible
|
||||
toggleBtn.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
// Toggle widget slide in/out on mobile
|
||||
toggleBtn.addEventListener('click', (e) => {
|
||||
widget.style.transform = 'translateX(0)'; // slide in
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
// Close widget when clicking outside
|
||||
document.addEventListener('click', (e) => {
|
||||
if(isMobile()){
|
||||
if(!widget.contains(e.target) && e.target !== toggleBtn){
|
||||
widget.style.transform = 'translateX(120%)'; // slide out
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Prevent clicks inside widget from closing it
|
||||
widget.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
// --- Spotify fetch ---
|
||||
async function updateSpotifyWidget() {
|
||||
try {
|
||||
const res = await fetch('/spotify/');
|
||||
if (!res.ok) return;
|
||||
|
||||
const data = await res.json();
|
||||
// Check if data contains an error or message indicating nothing is playing
|
||||
if (data.error || data.message) {
|
||||
// If existing data
|
||||
if (document.getElementById('spotify-song').textContent) {
|
||||
return;
|
||||
}
|
||||
// Alternate text when nothing is playing
|
||||
document.getElementById('spotify-album-art').src = '/assets/img/external/spotify.png';
|
||||
document.getElementById('spotify-song').textContent = 'Not Playing';
|
||||
document.getElementById('spotify-artist').textContent = '';
|
||||
document.getElementById('spotify-album').textContent = '';
|
||||
return;
|
||||
}
|
||||
|
||||
const track = data.spotify;
|
||||
var firstLoad = false;
|
||||
// Check if this is the first time loading data
|
||||
if (!document.getElementById('spotify-song').textContent) {
|
||||
firstLoad = true;
|
||||
}
|
||||
|
||||
|
||||
document.getElementById('spotify-album-art').src = track.album_art;
|
||||
document.getElementById('spotify-song').textContent = track.song_name;
|
||||
document.getElementById('spotify-artist').textContent = track.artist;
|
||||
document.getElementById('spotify-album').textContent = track.album_name;
|
||||
if (firstLoad) {
|
||||
widget.style.transform = 'translateX(0)'; // slide in on first load
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch Spotify data', err);
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for Spotify API to have responded before initial display
|
||||
updateSpotifyWidget();
|
||||
|
||||
window.addEventListener('resize', updateVisibility);
|
||||
setInterval(updateSpotifyWidget, 15000);
|
||||
</script>
|
||||
|
||||
<script src="/assets/bootstrap/js/bootstrap.min.js"></script>
|
||||
<script src="/assets/js/script.min.js"></script>
|
||||
<script src="/assets/js/grayscale.min.js"></script>
|
||||
|
||||
@@ -56,6 +56,7 @@ Find out what I've been up to in the last week">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -56,6 +56,7 @@ Find out what I've been up to in the last week">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -56,6 +56,7 @@ Find out what I've been up to in the last week">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -55,6 +55,7 @@ Find out what I've been up to in the last week">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -55,6 +55,7 @@ Find out what I've been up to in the last week">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -55,6 +55,7 @@ Find out what I've been up to in the last week">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -55,6 +55,7 @@ Find out what I've been up to in the last week">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -55,6 +55,7 @@ Find out what I've been up to in the last week">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -55,6 +55,7 @@ Find out what I've been up to in the last week">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -55,6 +55,7 @@ Find out what I've been up to in the last week">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -55,6 +55,7 @@ Find out what I've been up to in the last week">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -55,6 +55,7 @@ Find out what I've been up to in the last week">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -55,6 +55,7 @@ Find out what I've been up to in the last week">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -55,6 +55,7 @@ Find out what I've been up to in the last week">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -55,6 +55,7 @@ Find out what I've been up to in the last week">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -55,6 +55,7 @@ Find out what I've been up to in the last week">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -55,6 +55,7 @@ Find out what I've been up to in the last week">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -55,6 +55,7 @@ Find out what I've been up to in the last week">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -55,6 +55,7 @@ Find out what I've been up to in the last week">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -55,6 +55,7 @@ Find out what I've been up to in the last week">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -55,6 +55,7 @@ Find out what I've been up to in the last week">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -55,6 +55,7 @@ Find out what I've been up to in the last little bit">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -55,6 +55,7 @@ Find out what I've been up to in the last little bit">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -55,6 +55,7 @@ Find out what I've been up to in the last little bit">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -56,6 +56,7 @@ Find out what I've been up to in the last week">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -56,6 +56,7 @@ Find out what I've been up to in the last little bit">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -5,3 +5,5 @@
|
||||
|
||||
{{projects}}
|
||||
|
||||
Look at more projects on my Git: [1;36mhttps://git.woodburn.au[0m
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -96,4 +96,7 @@
|
||||
<url>
|
||||
<loc>https://nathan.woodburn.au/resume</loc>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://nathan.woodburn.au/tools</loc>
|
||||
</url>
|
||||
</urlset>
|
||||
472
templates/terminal.html
Normal file
472
templates/terminal.html
Normal file
@@ -0,0 +1,472 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Terminal | Nathan.Woodburn/</title>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body {
|
||||
background: #000;
|
||||
font-family: 'Courier New', monospace;
|
||||
color: #0f0;
|
||||
overflow: hidden;
|
||||
}
|
||||
#terminal {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
padding: 20px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.line { margin-bottom: 5px; }
|
||||
.prompt { color: #0f0; white-space: pre; }
|
||||
.prompt-line { color: #0f0; }
|
||||
.output { color: #fff; white-space: pre-wrap; }
|
||||
.error { color: #f00; }
|
||||
#input-line {
|
||||
display: block;
|
||||
}
|
||||
.input-row {
|
||||
display: flex;
|
||||
}
|
||||
#command-input {
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: #0f0;
|
||||
font-family: 'Courier New', monospace;
|
||||
font-size: 16px;
|
||||
outline: none;
|
||||
flex: 1;
|
||||
caret-color: #0f0;
|
||||
}
|
||||
#nano-editor {
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background: #000;
|
||||
z-index: 1000;
|
||||
flex-direction: column;
|
||||
}
|
||||
#nano-editor.active {
|
||||
display: flex;
|
||||
}
|
||||
#nano-header {
|
||||
padding: 10px 20px;
|
||||
border-bottom: 1px solid #0f0;
|
||||
color: #0f0;
|
||||
}
|
||||
#nano-textarea {
|
||||
flex: 1;
|
||||
background: #000;
|
||||
color: #fff;
|
||||
border: none;
|
||||
padding: 20px;
|
||||
font-family: 'Courier New', monospace;
|
||||
font-size: 16px;
|
||||
resize: none;
|
||||
outline: none;
|
||||
}
|
||||
#nano-footer {
|
||||
padding: 10px 20px;
|
||||
border-top: 1px solid #0f0;
|
||||
color: #0f0;
|
||||
font-size: 14px;
|
||||
}
|
||||
#nano-save-prompt {
|
||||
display: none;
|
||||
padding: 10px 20px;
|
||||
background: #111;
|
||||
border-top: 1px solid #0f0;
|
||||
color: #fff;
|
||||
}
|
||||
#nano-save-prompt.active {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="terminal">
|
||||
<div class="line output">Nathan.Woodburn/</div>
|
||||
<div class="line output">Type 'help' for available commands</div>
|
||||
<div class="line output"></div>
|
||||
<div id="input-line">
|
||||
<div class="prompt-line">┌──({{user}}@NW)-[~]</div>
|
||||
<div class="input-row">
|
||||
<span class="prompt-line">└─$ </span>
|
||||
<input type="text" id="command-input" autofocus autocomplete="off" spellcheck="false" autocapitalize="none">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Nano Editor -->
|
||||
<div id="nano-editor">
|
||||
<div id="nano-header">nano - <span id="nano-filename"></span></div>
|
||||
<textarea id="nano-textarea"></textarea>
|
||||
<div id="nano-save-prompt">Save modified buffer? (Y/N)</div>
|
||||
<div id="nano-footer">^X Exit ^O Save (Ctrl+X to exit, Ctrl+O to save)</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const terminal = document.getElementById('terminal');
|
||||
const input = document.getElementById('command-input');
|
||||
const inputLine = document.getElementById('input-line');
|
||||
const nanoEditor = document.getElementById('nano-editor');
|
||||
const nanoTextarea = document.getElementById('nano-textarea');
|
||||
const nanoFilename = document.getElementById('nano-filename');
|
||||
let commandHistory = [];
|
||||
let historyIndex = -1;
|
||||
let currentPwd = '~';
|
||||
let nanoCurrentFile = '';
|
||||
let nanoOriginalContent = '';
|
||||
let nanoSavePromptActive = false;
|
||||
let tabCompletionIndex = 0;
|
||||
let tabCompletionMatches = [];
|
||||
let lastTabInput = '';
|
||||
|
||||
// Function to update the prompt with current pwd
|
||||
async function updatePrompt() {
|
||||
try {
|
||||
const response = await fetch('/terminal/pwd');
|
||||
const data = await response.json();
|
||||
if (data.output) {
|
||||
currentPwd = data.output;
|
||||
inputLine.querySelector('.prompt-line:first-child').textContent = `┌──({{user}}@NW)-[${currentPwd}]`;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch pwd:', err);
|
||||
}
|
||||
}
|
||||
|
||||
// Function to open nano editor
|
||||
async function openNano(filename) {
|
||||
nanoCurrentFile = filename;
|
||||
nanoFilename.textContent = filename;
|
||||
nanoSavePromptActive = false;
|
||||
document.getElementById('nano-save-prompt').classList.remove('active');
|
||||
|
||||
// Try to fetch existing file content
|
||||
try {
|
||||
const parts = ['cat'].concat(filename.split(' '));
|
||||
const response = await fetch('/terminal/execute/cat', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ args: filename })
|
||||
});
|
||||
const data = await response.json();
|
||||
|
||||
if (data.output && !data.output.startsWith('cat:')) {
|
||||
nanoTextarea.value = data.output;
|
||||
nanoOriginalContent = data.output;
|
||||
} else {
|
||||
nanoTextarea.value = '';
|
||||
nanoOriginalContent = '';
|
||||
}
|
||||
} catch (err) {
|
||||
nanoTextarea.value = '';
|
||||
nanoOriginalContent = '';
|
||||
}
|
||||
|
||||
nanoEditor.classList.add('active');
|
||||
nanoTextarea.focus();
|
||||
}
|
||||
|
||||
// Function to close nano editor
|
||||
async function closeNano(shouldSave = false) {
|
||||
if (shouldSave) {
|
||||
await saveNano();
|
||||
}
|
||||
|
||||
nanoEditor.classList.remove('active');
|
||||
nanoSavePromptActive = false;
|
||||
document.getElementById('nano-save-prompt').classList.remove('active');
|
||||
terminal.appendChild(inputLine);
|
||||
inputLine.style.display = 'block';
|
||||
input.disabled = false;
|
||||
input.focus();
|
||||
terminal.scrollTop = terminal.scrollHeight;
|
||||
}
|
||||
|
||||
// Function to save nano content
|
||||
async function saveNano() {
|
||||
const content = nanoTextarea.value;
|
||||
try {
|
||||
const response = await fetch('/terminal/execute/nano', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ args: `${nanoCurrentFile} CONTENT ${content}` })
|
||||
});
|
||||
const data = await response.json();
|
||||
|
||||
nanoOriginalContent = content; // Update original content after save
|
||||
// If output contains error, display it
|
||||
if (data.output && data.output.startsWith('nano:')) {
|
||||
const errorLine = document.createElement('div');
|
||||
errorLine.className = 'line error';
|
||||
errorLine.textContent = data.output;
|
||||
terminal.appendChild(errorLine);
|
||||
}
|
||||
|
||||
// Don't display output - nano saves silently
|
||||
} catch (err) {
|
||||
const errorLine = document.createElement('div');
|
||||
errorLine.className = 'line error';
|
||||
errorLine.textContent = 'Error saving file: ' + err.message;
|
||||
terminal.appendChild(errorLine);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if content has changed
|
||||
function hasUnsavedChanges() {
|
||||
return nanoTextarea.value !== nanoOriginalContent;
|
||||
}
|
||||
|
||||
// Nano editor keyboard shortcuts
|
||||
nanoTextarea.addEventListener('keydown', async (e) => {
|
||||
if (e.ctrlKey && e.key === 'x') {
|
||||
e.preventDefault();
|
||||
|
||||
if (nanoSavePromptActive) {
|
||||
return; // Ignore if prompt is already active
|
||||
}
|
||||
|
||||
if (hasUnsavedChanges()) {
|
||||
// Show save prompt
|
||||
nanoSavePromptActive = true;
|
||||
document.getElementById('nano-save-prompt').classList.add('active');
|
||||
document.getElementById('nano-footer').textContent = 'Press Y to save, N to discard, Ctrl+C to cancel';
|
||||
} else {
|
||||
await closeNano(false);
|
||||
}
|
||||
} else if (e.ctrlKey && e.key === 'o') {
|
||||
e.preventDefault();
|
||||
await saveNano();
|
||||
} else if (e.ctrlKey && e.key === 'c' && nanoSavePromptActive) {
|
||||
e.preventDefault();
|
||||
// Cancel save prompt
|
||||
nanoSavePromptActive = false;
|
||||
document.getElementById('nano-save-prompt').classList.remove('active');
|
||||
document.getElementById('nano-footer').textContent = '^X Exit ^O Save (Ctrl+X to exit, Ctrl+O to save)';
|
||||
} else if (nanoSavePromptActive && (e.key === 'y' || e.key === 'Y')) {
|
||||
e.preventDefault();
|
||||
await closeNano(true);
|
||||
} else if (nanoSavePromptActive && (e.key === 'n' || e.key === 'N')) {
|
||||
e.preventDefault();
|
||||
await closeNano(false);
|
||||
}
|
||||
});
|
||||
|
||||
// Function to get available commands
|
||||
function getAvailableCommands() {
|
||||
return ['help', 'about', 'clear', 'echo', 'whoami', 'ls', 'pwd', 'date', 'cd', 'cat', 'rm', 'tree', 'touch', 'nano', 'reset', 'exit'];
|
||||
}
|
||||
|
||||
// Function to get files/directories for tab completion
|
||||
async function getFilesForCompletion(path = '') {
|
||||
try {
|
||||
const response = await fetch('/terminal/execute/ls', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ args: path ? path : '' })
|
||||
});
|
||||
const data = await response.json();
|
||||
|
||||
if (data.output && !data.output.startsWith('ls:')) {
|
||||
return data.output.split(' ').filter(f => f.length > 0);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to get files:', err);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
// Function to handle tab completion
|
||||
async function handleTabCompletion(currentInput) {
|
||||
const parts = currentInput.split(' ');
|
||||
const isFirstWord = parts.length === 1;
|
||||
|
||||
if (isFirstWord) {
|
||||
// Complete command names
|
||||
const commands = getAvailableCommands();
|
||||
const matches = commands.filter(cmd => cmd.startsWith(parts[0]));
|
||||
|
||||
if (matches.length === 1) {
|
||||
return matches[0] + ' ';
|
||||
} else if (matches.length > 1) {
|
||||
// Cycle through matches
|
||||
if (lastTabInput === currentInput) {
|
||||
tabCompletionIndex = (tabCompletionIndex + 1) % matches.length;
|
||||
} else {
|
||||
tabCompletionIndex = 0;
|
||||
tabCompletionMatches = matches;
|
||||
}
|
||||
lastTabInput = currentInput;
|
||||
return matches[tabCompletionIndex] + ' ';
|
||||
}
|
||||
} else {
|
||||
// Complete file/directory names
|
||||
const lastPart = parts[parts.length - 1];
|
||||
const files = await getFilesForCompletion();
|
||||
const matches = files.filter(f => f.startsWith(lastPart));
|
||||
|
||||
if (matches.length === 1) {
|
||||
parts[parts.length - 1] = matches[0];
|
||||
return parts.join(' ') + ' ';
|
||||
} else if (matches.length > 1) {
|
||||
// Cycle through matches
|
||||
if (lastTabInput === currentInput) {
|
||||
tabCompletionIndex = (tabCompletionIndex + 1) % matches.length;
|
||||
} else {
|
||||
tabCompletionIndex = 0;
|
||||
tabCompletionMatches = matches;
|
||||
}
|
||||
lastTabInput = currentInput;
|
||||
parts[parts.length - 1] = matches[tabCompletionIndex];
|
||||
return parts.join(' ');
|
||||
}
|
||||
}
|
||||
|
||||
return currentInput;
|
||||
}
|
||||
|
||||
// Update prompt on load
|
||||
updatePrompt();
|
||||
|
||||
input.addEventListener('keydown', async (e) => {
|
||||
if (e.key === 'Tab') {
|
||||
e.preventDefault();
|
||||
const currentInput = input.value;
|
||||
const completed = await handleTabCompletion(currentInput);
|
||||
input.value = completed;
|
||||
return;
|
||||
}
|
||||
|
||||
// Reset tab completion on any other key
|
||||
if (e.key !== 'Tab') {
|
||||
tabCompletionIndex = 0;
|
||||
tabCompletionMatches = [];
|
||||
lastTabInput = '';
|
||||
}
|
||||
|
||||
if (e.key === 'Enter') {
|
||||
const command = input.value.trim();
|
||||
|
||||
// Disable input and hide prompt during execution
|
||||
input.disabled = true;
|
||||
inputLine.style.display = 'none';
|
||||
|
||||
// Display command
|
||||
const cmdLine = document.createElement('div');
|
||||
cmdLine.className = 'line';
|
||||
cmdLine.innerHTML = `<span class="prompt">┌──({{user}}@NW)-[${currentPwd}]\n└─$ </span>${command}`;
|
||||
terminal.appendChild(cmdLine);
|
||||
|
||||
// Add to history
|
||||
if (command) {
|
||||
commandHistory.push(command);
|
||||
historyIndex = commandHistory.length;
|
||||
}
|
||||
|
||||
input.value = '';
|
||||
|
||||
// Handle clear command locally
|
||||
if (command === 'clear') {
|
||||
terminal.innerHTML = '';
|
||||
terminal.appendChild(inputLine);
|
||||
inputLine.style.display = 'block';
|
||||
input.disabled = false;
|
||||
input.focus();
|
||||
return;
|
||||
}
|
||||
if (command === 'exit') {
|
||||
// Redirect to /
|
||||
window.location.href = '/';
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle nano command specially
|
||||
const parts = command.split(' ');
|
||||
const baseCommand = parts[0];
|
||||
|
||||
if (baseCommand === 'nano') {
|
||||
if (parts.length < 2) {
|
||||
const errorLine = document.createElement('div');
|
||||
errorLine.className = 'line output';
|
||||
errorLine.textContent = 'Usage: nano [filename]';
|
||||
terminal.appendChild(errorLine);
|
||||
terminal.appendChild(inputLine);
|
||||
inputLine.style.display = 'block';
|
||||
input.disabled = false;
|
||||
input.focus();
|
||||
return;
|
||||
}
|
||||
await openNano(parts.slice(1).join(' '));
|
||||
return;
|
||||
}
|
||||
|
||||
// Execute command
|
||||
if (command) {
|
||||
try {
|
||||
// Split command by space
|
||||
const args = parts.slice(1).join(' ');
|
||||
|
||||
// POST request to /terminal/execute/command
|
||||
const response = await fetch(`/terminal/execute/${encodeURIComponent(baseCommand)}`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ args: args })
|
||||
});
|
||||
const data = await response.json();
|
||||
|
||||
if (data.output) {
|
||||
const outputLine = document.createElement('div');
|
||||
outputLine.className = 'line output';
|
||||
outputLine.textContent = data.output;
|
||||
terminal.appendChild(outputLine);
|
||||
}
|
||||
|
||||
// Update prompt after cd command
|
||||
if (baseCommand === 'cd' || baseCommand === 'reset') {
|
||||
await updatePrompt();
|
||||
}
|
||||
} catch (err) {
|
||||
const errorLine = document.createElement('div');
|
||||
errorLine.className = 'line error';
|
||||
errorLine.textContent = 'Error: ' + err.message;
|
||||
terminal.appendChild(errorLine);
|
||||
}
|
||||
}
|
||||
|
||||
// Show prompt and re-enable input after command completes
|
||||
terminal.appendChild(inputLine);
|
||||
inputLine.style.display = 'block';
|
||||
input.disabled = false;
|
||||
input.focus();
|
||||
terminal.scrollTop = terminal.scrollHeight;
|
||||
} else if (e.key === 'ArrowUp') {
|
||||
e.preventDefault();
|
||||
if (historyIndex > 0) {
|
||||
historyIndex--;
|
||||
input.value = commandHistory[historyIndex];
|
||||
}
|
||||
} else if (e.key === 'ArrowDown') {
|
||||
e.preventDefault();
|
||||
if (historyIndex < commandHistory.length - 1) {
|
||||
historyIndex++;
|
||||
input.value = commandHistory[historyIndex];
|
||||
} else {
|
||||
historyIndex = commandHistory.length;
|
||||
input.value = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Keep input focused
|
||||
document.addEventListener('click', () => input.focus());
|
||||
input.focus();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
20
templates/tools.ascii
Normal file
20
templates/tools.ascii
Normal file
@@ -0,0 +1,20 @@
|
||||
{{header}}
|
||||
[1;36m───────────────────────────────────────────────[0m
|
||||
[1;36m Tools [0m
|
||||
[1;36m────────────[0m
|
||||
|
||||
Here are some of the tools I use regularly — most of them are open source! 🛠️
|
||||
|
||||
{% for type, tools_in_type in tools | groupby('type') %}
|
||||
[4m[1;33m{{type}}[0m
|
||||
{% for tool in tools_in_type %}
|
||||
[1;33m{{tool.name}}[0m
|
||||
{{tool.description}}
|
||||
Website: {{tool.url}}
|
||||
{% if tool.demo_url %}Demo: {{tool.demo_url}}{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
[1;36m───────────────────────────────────────────────[0m
|
||||
{% endfor %}
|
||||
|
||||
|
||||
149
templates/tools.html
Normal file
149
templates/tools.html
Normal file
@@ -0,0 +1,149 @@
|
||||
<!DOCTYPE html>
|
||||
<html data-bs-theme="light" lang="en-au">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
|
||||
<title>Tools | Nathan.Woodburn/</title>
|
||||
<meta name="theme-color" content="#000000">
|
||||
<link rel="canonical" href="https://nathan.woodburn.au/tools">
|
||||
<meta property="og:url" content="https://nathan.woodburn.au/tools">
|
||||
<meta name="fediverse:creator" content="@nathanwoodburn@mastodon.woodburn.au">
|
||||
<meta name="twitter:description" content="G'day, this is my personal website. You can find out about me or check out some of my projects.">
|
||||
<meta property="og:title" content="Nathan.Woodburn/">
|
||||
<meta name="twitter:card" content="summary">
|
||||
<meta name="twitter:image" content="https://nathan.woodburn.au/assets/img/profile.jpg">
|
||||
<meta property="og:type" content="website">
|
||||
<meta name="twitter:title" content="Nathan.Woodburn/">
|
||||
<meta property="og:description" content="G'day, this is my personal website. You can find out about me or check out some of my projects.">
|
||||
<meta property="og:image" content="https://nathan.woodburn.au/assets/img/profile.jpg">
|
||||
<meta name="description" content="Check out some tools I use">
|
||||
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="/assets/img/favicon/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/assets/img/favicon/favicon-16x16.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/assets/img/favicon/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="180x180" href="/assets/img/favicon/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="192x192" href="/assets/img/favicon/android-chrome-192x192.png">
|
||||
<link rel="icon" type="image/png" sizes="512x512" href="/assets/img/favicon/android-chrome-512x512.png">
|
||||
<link rel="stylesheet" href="/assets/bootstrap/css/bootstrap.min.css">
|
||||
<link rel="manifest" href="/manifest.json" crossorigin="use-credentials">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic&display=swap">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Cabin:700&display=swap">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Anonymous+Pro&display=swap">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap">
|
||||
<link rel="stylesheet" href="/assets/fonts/font-awesome.min.css">
|
||||
<link rel="stylesheet" href="/assets/css/styles.min.css">
|
||||
<link rel="stylesheet" href="/assets/css/brand-reveal.min.css">
|
||||
<link rel="stylesheet" href="/assets/css/profile.min.css">
|
||||
<link rel="stylesheet" href="/assets/css/Social-Icons.min.css">
|
||||
<link rel="me" href="https://mastodon.woodburn.au/@nathanwoodburn" />
|
||||
<script async src="https://umami.woodburn.au/script.js" data-website-id="6a55028e-aad3-481c-9a37-3e096ff75589"></script>
|
||||
</head>
|
||||
|
||||
<body id="page-top" data-bs-spy="scroll" data-bs-target="#mainNav" data-bs-offset="77">
|
||||
<nav class="navbar navbar-expand-md fixed-top navbar-light" id="mainNav" style="background: var(--bs-navbar-hover-color);">
|
||||
<div class="container-fluid"><a class="navbar-brand" href="/#">
|
||||
<div style="padding-right: 1em;display: inline-flex;">
|
||||
<div class="slider"><span>/</span></div><span class="brand">Nathan.Woodburn</span>
|
||||
</div>
|
||||
</a><button data-bs-toggle="collapse" class="navbar-toggler navbar-toggler-right" data-bs-target="#navbarResponsive" type="button" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation" value="Menu"><i class="fa fa-bars"></i></button>
|
||||
<div class="collapse navbar-collapse" id="navbarResponsive">
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/hosting">Hosting</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/projects">Projects</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/tools">Tools</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/blog">Blog</a></li>
|
||||
<li class="nav-item nav-link"><a class="nav-link" href="/now">Now</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<header class="masthead" style="background: url("/assets/img/bg/projects.webp") bottom / cover no-repeat;height: auto;padding-top: 20px;">
|
||||
<div style="margin-top: 150px;margin-bottom: 100px;">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 mx-auto">
|
||||
<h1 class="brand-heading">Tools</h1>
|
||||
<p>Here is a list of applications, tools and services I use regularly.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<section class="text-center content-section" id="tools" style="padding-bottom: 100px;">
|
||||
<div class="container">{% for type, tools_in_type in tools | groupby('type') %}
|
||||
<h2 class="mt-4 mb-3 sticky-top bg-primary py-2 section-header" id="{{type}}">{{ type }}</h2>
|
||||
<div class="row">
|
||||
{% for tool in tools_in_type %}
|
||||
<div class="col-md-6 col-lg-4 mb-4">
|
||||
<div class="card h-100 shadow-sm transition-all" style="transition: transform 0.2s, box-shadow 0.2s;" onmouseover="this.style.transform='translateY(-5px)'; this.style.boxShadow='0 0.5rem 1rem rgba(0,0,0,0.15)';" onmouseout="this.style.transform='translateY(0)'; this.style.boxShadow='';">
|
||||
<div class="card-body d-flex flex-column">
|
||||
<h4 class="card-title">{{tool.name}}</h4>
|
||||
<p class="card-text">{{ tool.description }}</p>
|
||||
<div class="btn-group gap-3 mt-auto" role="group">{% if tool.demo %}<button class="btn btn-primary" type="button" data-bs-target="#modal-{{tool.name}}" data-bs-toggle="modal" style="transition: transform 0.2s, background-color 0.2s;" onmouseover="this.style.transform='scale(1.05)'" onmouseout="this.style.transform='scale(1)'">View Demo</button>{% endif %}<a class="btn btn-primary" role="button" href="{{tool.url}}" target="_blank" style="transition: transform 0.2s, background-color 0.2s;" onmouseover="this.style.transform='scale(1.05)'" onmouseout="this.style.transform='scale(1)'">{{tool.name}} Website</a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<!-- Modals for this type -->
|
||||
{% for tool in tools_in_type %}
|
||||
{% if tool.demo %}
|
||||
<div id="modal-{{tool.name}}" class="modal fade" role="dialog" tabindex="-1" style="z-index: 1055;">
|
||||
<div class="modal-dialog modal-xl" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">{{tool.name}}</h4><button class="btn-close" type="button" aria-label="Close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
{{ tool.demo | safe }}
|
||||
</div>
|
||||
<div class="modal-footer"><button class="btn btn-light" type="button" data-bs-dismiss="modal">Close</button></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const navbar = document.getElementById('mainNav');
|
||||
const headers = document.querySelectorAll('.section-header');
|
||||
|
||||
if (navbar) {
|
||||
const navbarHeight = navbar.offsetHeight;
|
||||
headers.forEach(header => {
|
||||
header.style.top = navbarHeight + 'px';
|
||||
header.style.zIndex = '100';
|
||||
header.style.scrollMarginTop = navbarHeight + 'px';
|
||||
});
|
||||
|
||||
// Handle hash navigation on page load
|
||||
if (window.location.hash) {
|
||||
setTimeout(() => {
|
||||
const target = document.querySelector(window.location.hash);
|
||||
if (target) {
|
||||
window.scrollTo({
|
||||
top: target.offsetTop - navbarHeight,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script></div>
|
||||
</section>
|
||||
<footer>
|
||||
<div class="container text-center">
|
||||
<p class="copyright">Copyright © Nathan.Woodburn/ 2025</p>
|
||||
</div>
|
||||
</footer>{{handshake_scripts | safe}}
|
||||
<script src="/assets/bootstrap/js/bootstrap.min.js"></script>
|
||||
<script src="/assets/js/script.min.js"></script>
|
||||
<script src="/assets/js/grayscale.min.js"></script>
|
||||
<script src="/assets/js/hacker.min.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -14,4 +14,7 @@ GET http://127.0.0.1:5000/api/v1/message
|
||||
HTTP 200
|
||||
GET http://127.0.0.1:5000/api/v1/project
|
||||
HTTP 200
|
||||
|
||||
GET http://127.0.0.1:5000/api/v1/tools
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$.tools" count > 5
|
||||
22
tools.py
22
tools.py
@@ -5,12 +5,28 @@ import datetime
|
||||
from typing import Optional, Dict, Union, Tuple
|
||||
import re
|
||||
from dateutil.parser import parse
|
||||
import json
|
||||
|
||||
# HTTP status codes
|
||||
HTTP_OK = 200
|
||||
HTTP_BAD_REQUEST = 400
|
||||
HTTP_NOT_FOUND = 404
|
||||
|
||||
CRAWLERS = [
|
||||
"Googlebot",
|
||||
"Bingbot",
|
||||
"Chrome-Lighthouse",
|
||||
"Slurp",
|
||||
"DuckDuckBot",
|
||||
"Baiduspider",
|
||||
"YandexBot",
|
||||
"Sogou",
|
||||
"Exabot",
|
||||
"facebot",
|
||||
"ia_archiver",
|
||||
"Twitterbot"
|
||||
]
|
||||
|
||||
|
||||
def getClientIP(request: Request) -> str:
|
||||
"""
|
||||
@@ -87,7 +103,7 @@ def isCrawler(request: Request) -> bool:
|
||||
"""
|
||||
if request.headers and request.headers.get("User-Agent"):
|
||||
user_agent = request.headers.get("User-Agent", "")
|
||||
return "Googlebot" in user_agent or "Bingbot" in user_agent
|
||||
return any(crawler in user_agent for crawler in CRAWLERS)
|
||||
return False
|
||||
|
||||
@cache
|
||||
@@ -250,3 +266,7 @@ def parse_date(date_groups: list[str]) -> str | None:
|
||||
|
||||
except (ValueError, TypeError):
|
||||
return None
|
||||
|
||||
def get_tools_data():
|
||||
with open("data/tools.json", "r") as f:
|
||||
return json.load(f)
|
||||
Reference in New Issue
Block a user