Compare commits
10 Commits
a6670f6533
...
copilot/im
| Author | SHA1 | Date | |
|---|---|---|---|
|
e489764ff8
|
|||
|
51c4416d4d
|
|||
|
|
a78d999a61 | ||
|
|
74afdc1b5b | ||
|
|
607fdd4d46 | ||
|
|
ca01b96e80 | ||
|
467faff592
|
|||
|
3791d0be6e
|
|||
|
06526ca92d
|
|||
|
e1ff6e42a5
|
@@ -20,7 +20,7 @@ RUN --mount=type=cache,target=/root/.cache/uv \
|
|||||||
|
|
||||||
# Copy only app source files
|
# Copy only app source files
|
||||||
COPY blueprints blueprints
|
COPY blueprints blueprints
|
||||||
COPY main.py server.py curl.py tools.py mail.py ./
|
COPY main.py server.py curl.py tools.py mail.py cache_helper.py ./
|
||||||
COPY templates templates
|
COPY templates templates
|
||||||
COPY data data
|
COPY data data
|
||||||
COPY pwa pwa
|
COPY pwa pwa
|
||||||
@@ -55,6 +55,7 @@ COPY --from=build --chown=appuser:appgroup /app/server.py /app/
|
|||||||
COPY --from=build --chown=appuser:appgroup /app/curl.py /app/
|
COPY --from=build --chown=appuser:appgroup /app/curl.py /app/
|
||||||
COPY --from=build --chown=appuser:appgroup /app/tools.py /app/
|
COPY --from=build --chown=appuser:appgroup /app/tools.py /app/
|
||||||
COPY --from=build --chown=appuser:appgroup /app/mail.py /app/
|
COPY --from=build --chown=appuser:appgroup /app/mail.py /app/
|
||||||
|
COPY --from=build --chown=appuser:appgroup /app/cache_helper.py /app/
|
||||||
|
|
||||||
USER appuser
|
USER appuser
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
|||||||
Binary file not shown.
31
addCoin.py
31
addCoin.py
@@ -1,35 +1,38 @@
|
|||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
|
|
||||||
if not os.path.exists('.well-known/wallets'):
|
if not os.path.exists(".well-known/wallets"):
|
||||||
os.makedirs('.well-known/wallets')
|
os.makedirs(".well-known/wallets")
|
||||||
|
|
||||||
|
|
||||||
def addCoin(token: str, name: str, address: str):
|
def addCoin(token: str, name: str, address: str):
|
||||||
with open('.well-known/wallets/'+token.upper(),'w') as f:
|
with open(".well-known/wallets/" + token.upper(), "w") as f:
|
||||||
f.write(address)
|
f.write(address)
|
||||||
|
|
||||||
with open('.well-known/wallets/.coins','r') as f:
|
with open(".well-known/wallets/.coins", "r") as f:
|
||||||
coins = json.load(f)
|
coins = json.load(f)
|
||||||
|
|
||||||
coins[token.upper()] = f'{name} ({token.upper()})'
|
coins[token.upper()] = f"{name} ({token.upper()})"
|
||||||
with open('.well-known/wallets/.coins','w') as f:
|
with open(".well-known/wallets/.coins", "w") as f:
|
||||||
f.write(json.dumps(coins, indent=4))
|
f.write(json.dumps(coins, indent=4))
|
||||||
|
|
||||||
|
|
||||||
def addDomain(token: str, domain: str):
|
def addDomain(token: str, domain: str):
|
||||||
with open('.well-known/wallets/.domains','r') as f:
|
with open(".well-known/wallets/.domains", "r") as f:
|
||||||
domains = json.load(f)
|
domains = json.load(f)
|
||||||
|
|
||||||
domains[token.upper()] = domain
|
domains[token.upper()] = domain
|
||||||
with open('.well-known/wallets/.domains','w') as f:
|
with open(".well-known/wallets/.domains", "w") as f:
|
||||||
f.write(json.dumps(domains, indent=4))
|
f.write(json.dumps(domains, indent=4))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
|
if __name__ == "__main__":
|
||||||
# Ask user for token
|
# Ask user for token
|
||||||
token = input('Enter token symbol: ')
|
token = input("Enter token symbol: ")
|
||||||
name = input('Enter token name: ')
|
name = input("Enter token name: ")
|
||||||
address = input('Enter wallet address: ')
|
address = input("Enter wallet address: ")
|
||||||
addCoin(token, name, address)
|
addCoin(token, name, address)
|
||||||
|
|
||||||
if input('Do you want to add a domain? (y/n): ').lower() == 'y':
|
if input("Do you want to add a domain? (y/n): ").lower() == "y":
|
||||||
domain = input('Enter domain: ')
|
domain = input("Enter domain: ")
|
||||||
addDomain(token, domain)
|
addDomain(token, domain)
|
||||||
@@ -3,7 +3,7 @@ import os
|
|||||||
from cloudflare import Cloudflare
|
from cloudflare import Cloudflare
|
||||||
from tools import json_response
|
from tools import json_response
|
||||||
|
|
||||||
app = Blueprint('acme', __name__)
|
app = Blueprint("acme", __name__)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/hnsdoh-acme", methods=["POST"])
|
@app.route("/hnsdoh-acme", methods=["POST"])
|
||||||
@@ -23,7 +23,9 @@ def post():
|
|||||||
zone = cf.zones.list(name="hnsdoh.com").to_dict()
|
zone = cf.zones.list(name="hnsdoh.com").to_dict()
|
||||||
zone_id = zone["result"][0]["id"] # type: ignore
|
zone_id = zone["result"][0]["id"] # type: ignore
|
||||||
existing_records = cf.dns.records.list(
|
existing_records = cf.dns.records.list(
|
||||||
zone_id=zone_id, type="TXT", name="_acme-challenge.hnsdoh.com" # type: ignore
|
zone_id=zone_id,
|
||||||
|
type="TXT",
|
||||||
|
name="_acme-challenge.hnsdoh.com", # type: ignore
|
||||||
).to_dict()
|
).to_dict()
|
||||||
record_id = existing_records["result"][0]["id"] # type: ignore
|
record_id = existing_records["result"][0]["id"] # type: ignore
|
||||||
cf.dns.records.delete(dns_record_id=record_id, zone_id=zone_id)
|
cf.dns.records.delete(dns_record_id=record_id, zone_id=zone_id)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from tools import getClientIP, getGitCommit, json_response, parse_date, get_tool
|
|||||||
from blueprints import sol
|
from blueprints import sol
|
||||||
from dateutil import parser as date_parser
|
from dateutil import parser as date_parser
|
||||||
from blueprints.spotify import get_spotify_track
|
from blueprints.spotify import get_spotify_track
|
||||||
|
from cache_helper import get_nc_config, get_git_latest_activity
|
||||||
|
|
||||||
# Constants
|
# Constants
|
||||||
HTTP_OK = 200
|
HTTP_OK = 200
|
||||||
@@ -17,24 +18,17 @@ HTTP_NOT_FOUND = 404
|
|||||||
HTTP_UNSUPPORTED_MEDIA = 415
|
HTTP_UNSUPPORTED_MEDIA = 415
|
||||||
HTTP_SERVER_ERROR = 500
|
HTTP_SERVER_ERROR = 500
|
||||||
|
|
||||||
app = Blueprint('api', __name__, url_prefix='/api/v1')
|
app = Blueprint("api", __name__, url_prefix="/api/v1")
|
||||||
# Register solana blueprint
|
# Register solana blueprint
|
||||||
app.register_blueprint(sol.app)
|
app.register_blueprint(sol.app)
|
||||||
|
|
||||||
# Load configuration
|
|
||||||
NC_CONFIG = requests.get(
|
|
||||||
"https://cloud.woodburn.au/s/4ToXgFe3TnnFcN7/download/website-conf.json"
|
|
||||||
).json()
|
|
||||||
|
|
||||||
if 'time-zone' not in NC_CONFIG:
|
|
||||||
NC_CONFIG['time-zone'] = 10
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/", strict_slashes=False)
|
@app.route("/", strict_slashes=False)
|
||||||
@app.route("/help")
|
@app.route("/help")
|
||||||
def help():
|
def help():
|
||||||
"""Provide API documentation and help."""
|
"""Provide API documentation and help."""
|
||||||
return jsonify({
|
return jsonify(
|
||||||
|
{
|
||||||
"message": "Welcome to Nathan.Woodburn/ API! This is a personal website. For more information, visit https://nathan.woodburn.au",
|
"message": "Welcome to Nathan.Woodburn/ API! This is a personal website. For more information, visit https://nathan.woodburn.au",
|
||||||
"endpoints": {
|
"endpoints": {
|
||||||
"/time": "Get the current time",
|
"/time": "Get the current time",
|
||||||
@@ -49,19 +43,22 @@ def help():
|
|||||||
"/ping": "Just check if the site is up",
|
"/ping": "Just check if the site is up",
|
||||||
"/ip": "Get your IP address",
|
"/ip": "Get your IP address",
|
||||||
"/headers": "Get your request headers",
|
"/headers": "Get your request headers",
|
||||||
"/help": "Get this help message"
|
"/help": "Get this help message",
|
||||||
},
|
},
|
||||||
"base_url": "/api/v1",
|
"base_url": "/api/v1",
|
||||||
"version": getGitCommit(),
|
"version": getGitCommit(),
|
||||||
"ip": getClientIP(request),
|
"ip": getClientIP(request),
|
||||||
"status": HTTP_OK
|
"status": HTTP_OK,
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/status")
|
@app.route("/status")
|
||||||
@app.route("/ping")
|
@app.route("/ping")
|
||||||
def status():
|
def status():
|
||||||
return json_response(request, "200 OK", HTTP_OK)
|
return json_response(request, "200 OK", HTTP_OK)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/version")
|
@app.route("/version")
|
||||||
def version():
|
def version():
|
||||||
"""Get the current version of the website."""
|
"""Get the current version of the website."""
|
||||||
@@ -71,46 +68,48 @@ def version():
|
|||||||
@app.route("/time")
|
@app.route("/time")
|
||||||
def time():
|
def time():
|
||||||
"""Get the current time in the configured timezone."""
|
"""Get the current time in the configured timezone."""
|
||||||
timezone_offset = datetime.timedelta(hours=NC_CONFIG["time-zone"])
|
nc_config = get_nc_config()
|
||||||
|
timezone_offset = datetime.timedelta(hours=nc_config["time-zone"])
|
||||||
timezone = datetime.timezone(offset=timezone_offset)
|
timezone = datetime.timezone(offset=timezone_offset)
|
||||||
current_time = datetime.datetime.now(tz=timezone)
|
current_time = datetime.datetime.now(tz=timezone)
|
||||||
return jsonify({
|
return jsonify(
|
||||||
|
{
|
||||||
"timestring": current_time.strftime("%A, %B %d, %Y %I:%M %p"),
|
"timestring": current_time.strftime("%A, %B %d, %Y %I:%M %p"),
|
||||||
"timestamp": current_time.timestamp(),
|
"timestamp": current_time.timestamp(),
|
||||||
"timezone": NC_CONFIG["time-zone"],
|
"timezone": nc_config["time-zone"],
|
||||||
"timeISO": current_time.isoformat(),
|
"timeISO": current_time.isoformat(),
|
||||||
"ip": getClientIP(request),
|
"ip": getClientIP(request),
|
||||||
"status": HTTP_OK
|
"status": HTTP_OK,
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/timezone")
|
@app.route("/timezone")
|
||||||
def timezone():
|
def timezone():
|
||||||
"""Get the current timezone setting."""
|
"""Get the current timezone setting."""
|
||||||
return jsonify({
|
nc_config = get_nc_config()
|
||||||
"timezone": NC_CONFIG["time-zone"],
|
return jsonify(
|
||||||
|
{
|
||||||
|
"timezone": nc_config["time-zone"],
|
||||||
"ip": getClientIP(request),
|
"ip": getClientIP(request),
|
||||||
"status": HTTP_OK
|
"status": HTTP_OK,
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/message")
|
@app.route("/message")
|
||||||
def message():
|
def message():
|
||||||
"""Get the message from the configuration."""
|
"""Get the message from the configuration."""
|
||||||
return jsonify({
|
nc_config = get_nc_config()
|
||||||
"message": NC_CONFIG["message"],
|
return jsonify(
|
||||||
"ip": getClientIP(request),
|
{"message": nc_config["message"], "ip": getClientIP(request), "status": HTTP_OK}
|
||||||
"status": HTTP_OK
|
)
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/ip")
|
@app.route("/ip")
|
||||||
def ip():
|
def ip():
|
||||||
"""Get the client's IP address."""
|
"""Get the client's IP address."""
|
||||||
return jsonify({
|
return jsonify({"ip": getClientIP(request), "status": HTTP_OK})
|
||||||
"ip": getClientIP(request),
|
|
||||||
"status": HTTP_OK
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/email", methods=["POST"])
|
@app.route("/email", methods=["POST"])
|
||||||
@@ -118,7 +117,9 @@ def email_post():
|
|||||||
"""Send an email via the API (requires API key)."""
|
"""Send an email via the API (requires API key)."""
|
||||||
# Verify json
|
# Verify json
|
||||||
if not request.is_json:
|
if not request.is_json:
|
||||||
return json_response(request, "415 Unsupported Media Type", HTTP_UNSUPPORTED_MEDIA)
|
return json_response(
|
||||||
|
request, "415 Unsupported Media Type", HTTP_UNSUPPORTED_MEDIA
|
||||||
|
)
|
||||||
|
|
||||||
# Check if api key sent
|
# Check if api key sent
|
||||||
data = request.json
|
data = request.json
|
||||||
@@ -138,35 +139,27 @@ def email_post():
|
|||||||
@app.route("/project")
|
@app.route("/project")
|
||||||
def project():
|
def project():
|
||||||
"""Get information about the current git project."""
|
"""Get information about the current git project."""
|
||||||
gitinfo = {
|
git = get_git_latest_activity()
|
||||||
"website": None,
|
repo_name = git["repo"]["name"].lower()
|
||||||
}
|
|
||||||
try:
|
|
||||||
git = requests.get(
|
|
||||||
"https://git.woodburn.au/api/v1/users/nathanwoodburn/activities/feeds?only-performed-by=true&limit=1",
|
|
||||||
headers={"Authorization": os.getenv("git_token")},
|
|
||||||
)
|
|
||||||
git = git.json()
|
|
||||||
git = git[0]
|
|
||||||
repo_name = git["repo"]["name"]
|
|
||||||
repo_name = repo_name.lower()
|
|
||||||
repo_description = git["repo"]["description"]
|
repo_description = git["repo"]["description"]
|
||||||
gitinfo["name"] = repo_name
|
|
||||||
gitinfo["description"] = repo_description
|
|
||||||
gitinfo["url"] = git["repo"]["html_url"]
|
|
||||||
if "website" in git["repo"]:
|
|
||||||
gitinfo["website"] = git["repo"]["website"]
|
|
||||||
except Exception as e:
|
|
||||||
print(f"Error getting git data: {e}")
|
|
||||||
return json_response(request, "500 Internal Server Error", HTTP_SERVER_ERROR)
|
|
||||||
|
|
||||||
return jsonify({
|
gitinfo = {
|
||||||
|
"name": repo_name,
|
||||||
|
"description": repo_description,
|
||||||
|
"url": git["repo"]["html_url"],
|
||||||
|
"website": git["repo"].get("website"),
|
||||||
|
}
|
||||||
|
|
||||||
|
return jsonify(
|
||||||
|
{
|
||||||
"repo_name": repo_name,
|
"repo_name": repo_name,
|
||||||
"repo_description": repo_description,
|
"repo_description": repo_description,
|
||||||
"repo": gitinfo,
|
"repo": gitinfo,
|
||||||
"ip": getClientIP(request),
|
"ip": getClientIP(request),
|
||||||
"status": HTTP_OK
|
"status": HTTP_OK,
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/tools")
|
@app.route("/tools")
|
||||||
def tools():
|
def tools():
|
||||||
@@ -179,6 +172,7 @@ def tools():
|
|||||||
|
|
||||||
return json_response(request, {"tools": tools}, HTTP_OK)
|
return json_response(request, {"tools": tools}, HTTP_OK)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/playing")
|
@app.route("/playing")
|
||||||
def playing():
|
def playing():
|
||||||
"""Get the currently playing Spotify track."""
|
"""Get the currently playing Spotify track."""
|
||||||
@@ -201,15 +195,11 @@ def headers():
|
|||||||
# Remove from headers
|
# Remove from headers
|
||||||
toremove.append(key)
|
toremove.append(key)
|
||||||
|
|
||||||
|
|
||||||
for key in toremove:
|
for key in toremove:
|
||||||
headers.pop(key)
|
headers.pop(key)
|
||||||
|
|
||||||
return jsonify({
|
return jsonify({"headers": headers, "ip": getClientIP(request), "status": HTTP_OK})
|
||||||
"headers": headers,
|
|
||||||
"ip": getClientIP(request),
|
|
||||||
"status": HTTP_OK
|
|
||||||
})
|
|
||||||
|
|
||||||
@app.route("/page_date")
|
@app.route("/page_date")
|
||||||
def page_date():
|
def page_date():
|
||||||
@@ -226,33 +216,33 @@ def page_date():
|
|||||||
r = requests.get(url, timeout=5)
|
r = requests.get(url, timeout=5)
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
return json_response(request, f"400 Bad Request 'url' unreachable: {e}", HTTP_BAD_REQUEST)
|
return json_response(
|
||||||
|
request, f"400 Bad Request 'url' unreachable: {e}", HTTP_BAD_REQUEST
|
||||||
|
)
|
||||||
|
|
||||||
page_text = r.text
|
page_text = r.text
|
||||||
|
|
||||||
# Remove ordinal suffixes globally
|
# Remove ordinal suffixes globally
|
||||||
page_text = re.sub(r'(\d+)(st|nd|rd|th)', r'\1', page_text, flags=re.IGNORECASE)
|
page_text = re.sub(r"(\d+)(st|nd|rd|th)", r"\1", page_text, flags=re.IGNORECASE)
|
||||||
# Remove HTML comments
|
# Remove HTML comments
|
||||||
page_text = re.sub(r'<!--.*?-->', '', page_text, flags=re.DOTALL)
|
page_text = re.sub(r"<!--.*?-->", "", page_text, flags=re.DOTALL)
|
||||||
|
|
||||||
date_patterns = [
|
date_patterns = [
|
||||||
r'(\d{4})[/-](\d{1,2})[/-](\d{1,2})', # YYYY-MM-DD
|
r"(\d{4})[/-](\d{1,2})[/-](\d{1,2})", # YYYY-MM-DD
|
||||||
r'(\d{1,2})[/-](\d{1,2})[/-](\d{4})', # DD-MM-YYYY
|
r"(\d{1,2})[/-](\d{1,2})[/-](\d{4})", # DD-MM-YYYY
|
||||||
r'(?:Last updated:|Updated:|Updated last:)?\s*(\d{1,2})\s+([A-Za-z]{3,9})[, ]?\s*(\d{4})', # DD Month YYYY
|
r"(?:Last updated:|Updated:|Updated last:)?\s*(\d{1,2})\s+([A-Za-z]{3,9})[, ]?\s*(\d{4})", # DD Month YYYY
|
||||||
r'(?:\b\w+\b\s+){0,3}([A-Za-z]{3,9})\s+(\d{1,2}),?\s*(\d{4})', # Month DD, YYYY with optional words
|
r"(?:\b\w+\b\s+){0,3}([A-Za-z]{3,9})\s+(\d{1,2}),?\s*(\d{4})", # Month DD, YYYY with optional words
|
||||||
r'\b(\d{4})(\d{2})(\d{2})\b', # YYYYMMDD
|
r"\b(\d{4})(\d{2})(\d{2})\b", # YYYYMMDD
|
||||||
r'(?:Last updated:|Updated:|Last update)?\s*([A-Za-z]{3,9})\s+(\d{4})', # Month YYYY only
|
r"(?:Last updated:|Updated:|Last update)?\s*([A-Za-z]{3,9})\s+(\d{4})", # Month YYYY only
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Structured data patterns
|
# Structured data patterns
|
||||||
json_date_patterns = {
|
json_date_patterns = {
|
||||||
r'"datePublished"\s*:\s*"([^"]+)"': "published",
|
r'"datePublished"\s*:\s*"([^"]+)"': "published",
|
||||||
r'"dateModified"\s*:\s*"([^"]+)"': "modified",
|
r'"dateModified"\s*:\s*"([^"]+)"': "modified",
|
||||||
r'<meta\s+(?:[^>]*?)property\s*=\s*"article:published_time"\s+content\s*=\s*"([^"]+)"': "published",
|
r'<meta\s+(?:[^>]*?)property\s*=\s*"article:published_time"\s+content\s*=\s*"([^"]+)"': "published",
|
||||||
r'<meta\s+(?:[^>]*?)property\s*=\s*"article:modified_time"\s+content\s*=\s*"([^"]+)"': "modified",
|
r'<meta\s+(?:[^>]*?)property\s*=\s*"article:modified_time"\s+content\s*=\s*"([^"]+)"': "modified",
|
||||||
r'<time\s+datetime\s*=\s*"([^"]+)"': "published"
|
r'<time\s+datetime\s*=\s*"([^"]+)"': "published",
|
||||||
}
|
}
|
||||||
|
|
||||||
found_dates = []
|
found_dates = []
|
||||||
@@ -270,7 +260,7 @@ def page_date():
|
|||||||
for match in re.findall(pattern, page_text):
|
for match in re.findall(pattern, page_text):
|
||||||
try:
|
try:
|
||||||
dt = date_parser.isoparse(match)
|
dt = date_parser.isoparse(match)
|
||||||
formatted_date = dt.strftime('%Y-%m-%d')
|
formatted_date = dt.strftime("%Y-%m-%d")
|
||||||
found_dates.append([[formatted_date], -1, date_type])
|
found_dates.append([[formatted_date], -1, date_type])
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
continue
|
continue
|
||||||
@@ -279,7 +269,9 @@ def page_date():
|
|||||||
return json_response(request, "Date not found on page", HTTP_BAD_REQUEST)
|
return json_response(request, "Date not found on page", HTTP_BAD_REQUEST)
|
||||||
|
|
||||||
today = datetime.date.today()
|
today = datetime.date.today()
|
||||||
tolerance_date = today + datetime.timedelta(days=1) # Allow for slight future dates (e.g., time zones)
|
tolerance_date = today + datetime.timedelta(
|
||||||
|
days=1
|
||||||
|
) # Allow for slight future dates (e.g., time zones)
|
||||||
# When processing dates
|
# When processing dates
|
||||||
processed_dates = []
|
processed_dates = []
|
||||||
for date_groups, pattern_format, date_type in found_dates:
|
for date_groups, pattern_format, date_type in found_dates:
|
||||||
@@ -300,18 +292,32 @@ def page_date():
|
|||||||
date_obj = {"date": dt.strftime("%Y-%m-%d"), "type": date_type}
|
date_obj = {"date": dt.strftime("%Y-%m-%d"), "type": date_type}
|
||||||
if verbose:
|
if verbose:
|
||||||
if pattern_format == -1:
|
if pattern_format == -1:
|
||||||
date_obj.update({"source": "metadata", "pattern_used": pattern_format, "raw": date_groups[0]})
|
date_obj.update(
|
||||||
|
{
|
||||||
|
"source": "metadata",
|
||||||
|
"pattern_used": pattern_format,
|
||||||
|
"raw": date_groups[0],
|
||||||
|
}
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
date_obj.update({"source": "content", "pattern_used": pattern_format, "raw": " ".join(date_groups)})
|
date_obj.update(
|
||||||
|
{
|
||||||
|
"source": "content",
|
||||||
|
"pattern_used": pattern_format,
|
||||||
|
"raw": " ".join(date_groups),
|
||||||
|
}
|
||||||
|
)
|
||||||
processed_dates.append(date_obj)
|
processed_dates.append(date_obj)
|
||||||
|
|
||||||
if not processed_dates:
|
if not processed_dates:
|
||||||
if verbose:
|
if verbose:
|
||||||
return jsonify({
|
return jsonify(
|
||||||
|
{
|
||||||
"message": "No valid dates found on page",
|
"message": "No valid dates found on page",
|
||||||
"found_dates": found_dates,
|
"found_dates": found_dates,
|
||||||
"processed_dates": processed_dates
|
"processed_dates": processed_dates,
|
||||||
}), HTTP_BAD_REQUEST
|
}
|
||||||
|
), HTTP_BAD_REQUEST
|
||||||
return json_response(request, "No valid dates found on page", HTTP_BAD_REQUEST)
|
return json_response(request, "No valid dates found on page", HTTP_BAD_REQUEST)
|
||||||
# Sort dates and return latest
|
# Sort dates and return latest
|
||||||
processed_dates.sort(key=lambda x: x["date"])
|
processed_dates.sort(key=lambda x: x["date"])
|
||||||
|
|||||||
@@ -3,63 +3,83 @@ from flask import Blueprint, render_template, request, jsonify
|
|||||||
import markdown
|
import markdown
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
import re
|
import re
|
||||||
|
from functools import lru_cache
|
||||||
from tools import isCLI, getClientIP, getHandshakeScript
|
from tools import isCLI, getClientIP, getHandshakeScript
|
||||||
|
|
||||||
app = Blueprint('blog', __name__, url_prefix='/blog')
|
app = Blueprint("blog", __name__, url_prefix="/blog")
|
||||||
|
|
||||||
|
|
||||||
|
@lru_cache(maxsize=32)
|
||||||
def list_page_files():
|
def list_page_files():
|
||||||
blog_pages = os.listdir("data/blog")
|
blog_pages = os.listdir("data/blog")
|
||||||
# Sort pages by modified time, newest first
|
# Sort pages by modified time, newest first
|
||||||
blog_pages.sort(
|
blog_pages.sort(
|
||||||
key=lambda x: os.path.getmtime(os.path.join("data/blog", x)), reverse=True)
|
key=lambda x: os.path.getmtime(os.path.join("data/blog", x)), reverse=True
|
||||||
|
)
|
||||||
|
|
||||||
# Remove .md extension
|
# Remove .md extension
|
||||||
blog_pages = [page.removesuffix(".md")
|
blog_pages = [
|
||||||
for page in blog_pages if page.endswith(".md")]
|
page.removesuffix(".md") for page in blog_pages if page.endswith(".md")
|
||||||
|
]
|
||||||
|
|
||||||
return blog_pages
|
return blog_pages
|
||||||
|
|
||||||
|
|
||||||
def render_page(date, handshake_scripts=None):
|
@lru_cache(maxsize=64)
|
||||||
# Convert md to html
|
def get_blog_content(date):
|
||||||
|
"""Get and cache blog content."""
|
||||||
if not os.path.exists(f"data/blog/{date}.md"):
|
if not os.path.exists(f"data/blog/{date}.md"):
|
||||||
return render_template("404.html"), 404
|
return None
|
||||||
|
|
||||||
with open(f"data/blog/{date}.md", "r") as f:
|
with open(f"data/blog/{date}.md", "r") as f:
|
||||||
content = f.read()
|
return f.read()
|
||||||
|
|
||||||
|
|
||||||
|
@lru_cache(maxsize=64)
|
||||||
|
def render_markdown_to_html(content):
|
||||||
|
"""Convert markdown to HTML with caching."""
|
||||||
|
html = markdown.markdown(
|
||||||
|
content, extensions=["sane_lists", "codehilite", "fenced_code"]
|
||||||
|
)
|
||||||
|
# Add target="_blank" to all links
|
||||||
|
html = html.replace('<a href="', '<a target="_blank" href="')
|
||||||
|
html = html.replace("<h4", "<h4 style='margin-bottom:0px;'")
|
||||||
|
html = fix_numbered_lists(html)
|
||||||
|
return html
|
||||||
|
|
||||||
|
|
||||||
|
def render_page(date, handshake_scripts=None):
|
||||||
|
# Get cached content
|
||||||
|
content = get_blog_content(date)
|
||||||
|
if content is None:
|
||||||
|
return render_template("404.html"), 404
|
||||||
|
|
||||||
# Get the title from the file name
|
# Get the title from the file name
|
||||||
title = date.removesuffix(".md").replace("_", " ")
|
title = date.removesuffix(".md").replace("_", " ")
|
||||||
# Convert the md to html
|
# Convert the md to html (cached)
|
||||||
content = markdown.markdown(
|
html_content = render_markdown_to_html(content)
|
||||||
content, extensions=['sane_lists', 'codehilite', 'fenced_code'])
|
|
||||||
# Add target="_blank" to all links
|
|
||||||
content = content.replace('<a href="', '<a target="_blank" href="')
|
|
||||||
|
|
||||||
content = content.replace("<h4", "<h4 style='margin-bottom:0px;'")
|
|
||||||
content = fix_numbered_lists(content)
|
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"blog/template.html",
|
"blog/template.html",
|
||||||
title=title,
|
title=title,
|
||||||
content=content,
|
content=html_content,
|
||||||
handshake_scripts=handshake_scripts,
|
handshake_scripts=handshake_scripts,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def fix_numbered_lists(html):
|
def fix_numbered_lists(html):
|
||||||
soup = BeautifulSoup(html, 'html.parser')
|
soup = BeautifulSoup(html, "html.parser")
|
||||||
|
|
||||||
# Find the <p> tag containing numbered steps
|
# Find the <p> tag containing numbered steps
|
||||||
paragraphs = soup.find_all('p')
|
paragraphs = soup.find_all("p")
|
||||||
for p in paragraphs:
|
for p in paragraphs:
|
||||||
content = p.decode_contents() # type: ignore
|
content = p.decode_contents() # type: ignore
|
||||||
|
|
||||||
# Check for likely numbered step structure
|
# Check for likely numbered step structure
|
||||||
if re.search(r'1\.\s', content):
|
if re.search(r"1\.\s", content):
|
||||||
# Split into pre-list and numbered steps
|
# Split into pre-list and numbered steps
|
||||||
# Match: <br>, optional whitespace, then a number and dot
|
# Match: <br>, optional whitespace, then a number and dot
|
||||||
parts = re.split(r'(?:<br\s*/?>)?\s*(\d+)\.\s', content)
|
parts = re.split(r"(?:<br\s*/?>)?\s*(\d+)\.\s", content)
|
||||||
|
|
||||||
# Result: [pre-text, '1', step1, '2', step2, ..., '10', step10]
|
# Result: [pre-text, '1', step1, '2', step2, ..., '10', step10]
|
||||||
pre_text = parts[0].strip()
|
pre_text = parts[0].strip()
|
||||||
@@ -70,8 +90,7 @@ def fix_numbered_lists(html):
|
|||||||
for i in range(0, len(steps), 2):
|
for i in range(0, len(steps), 2):
|
||||||
if i + 1 < len(steps):
|
if i + 1 < len(steps):
|
||||||
step_html = steps[i + 1].strip()
|
step_html = steps[i + 1].strip()
|
||||||
ol_items.append(
|
ol_items.append(f"<li style='list-style: auto;'>{step_html}</li>")
|
||||||
f"<li style='list-style: auto;'>{step_html}</li>")
|
|
||||||
|
|
||||||
# Build the final list HTML
|
# Build the final list HTML
|
||||||
ol_html = "<ol>\n" + "\n".join(ol_items) + "\n</ol>"
|
ol_html = "<ol>\n" + "\n".join(ol_items) + "\n</ol>"
|
||||||
@@ -80,7 +99,7 @@ def fix_numbered_lists(html):
|
|||||||
new_html = f"{pre_text}<br />\n{ol_html}" if pre_text else ol_html
|
new_html = f"{pre_text}<br />\n{ol_html}" if pre_text else ol_html
|
||||||
|
|
||||||
# Replace old <p> with parsed version
|
# Replace old <p> with parsed version
|
||||||
new_fragment = BeautifulSoup(new_html, 'html.parser')
|
new_fragment = BeautifulSoup(new_html, "html.parser")
|
||||||
p.replace_with(new_fragment)
|
p.replace_with(new_fragment)
|
||||||
break # Only process the first matching <p>
|
break # Only process the first matching <p>
|
||||||
|
|
||||||
@@ -117,16 +136,23 @@ def index():
|
|||||||
blog_pages = list_page_files()
|
blog_pages = list_page_files()
|
||||||
# Create a html list of pages
|
# Create a html list of pages
|
||||||
blog_pages = [
|
blog_pages = [
|
||||||
{"name": page.replace("_", " "), "url": f"/blog/{page}", "download": f"/blog/{page}.md"} for page in blog_pages
|
{
|
||||||
|
"name": page.replace("_", " "),
|
||||||
|
"url": f"/blog/{page}",
|
||||||
|
"download": f"/blog/{page}.md",
|
||||||
|
}
|
||||||
|
for page in blog_pages
|
||||||
]
|
]
|
||||||
|
|
||||||
# Render the template
|
# Render the template
|
||||||
return jsonify({
|
return jsonify(
|
||||||
|
{
|
||||||
"status": 200,
|
"status": 200,
|
||||||
"message": "Check out my various blog postsa",
|
"message": "Check out my various blog postsa",
|
||||||
"ip": getClientIP(request),
|
"ip": getClientIP(request),
|
||||||
"blogs": blog_pages
|
"blogs": blog_pages,
|
||||||
}), 200
|
}
|
||||||
|
), 200
|
||||||
|
|
||||||
|
|
||||||
@app.route("/<path:path>")
|
@app.route("/<path:path>")
|
||||||
@@ -134,31 +160,30 @@ def path(path):
|
|||||||
if not isCLI(request):
|
if not isCLI(request):
|
||||||
return render_page(path, handshake_scripts=getHandshakeScript(request.host))
|
return render_page(path, handshake_scripts=getHandshakeScript(request.host))
|
||||||
|
|
||||||
# Convert md to html
|
# Get cached content
|
||||||
if not os.path.exists(f"data/blog/{path}.md"):
|
content = get_blog_content(path)
|
||||||
|
if content is None:
|
||||||
return render_template("404.html"), 404
|
return render_template("404.html"), 404
|
||||||
|
|
||||||
with open(f"data/blog/{path}.md", "r") as f:
|
|
||||||
content = f.read()
|
|
||||||
# Get the title from the file name
|
# Get the title from the file name
|
||||||
title = path.replace("_", " ")
|
title = path.replace("_", " ")
|
||||||
return jsonify({
|
return jsonify(
|
||||||
|
{
|
||||||
"status": 200,
|
"status": 200,
|
||||||
"message": f"Blog post: {title}",
|
"message": f"Blog post: {title}",
|
||||||
"ip": getClientIP(request),
|
"ip": getClientIP(request),
|
||||||
"title": title,
|
"title": title,
|
||||||
"content": content,
|
"content": content,
|
||||||
"download": f"/blog/{path}.md"
|
"download": f"/blog/{path}.md",
|
||||||
}), 200
|
}
|
||||||
|
), 200
|
||||||
|
|
||||||
|
|
||||||
@app.route("/<path:path>.md")
|
@app.route("/<path:path>.md")
|
||||||
def path_md(path):
|
def path_md(path):
|
||||||
if not os.path.exists(f"data/blog/{path}.md"):
|
content = get_blog_content(path)
|
||||||
|
if content is None:
|
||||||
return render_template("404.html"), 404
|
return render_template("404.html"), 404
|
||||||
|
|
||||||
with open(f"data/blog/{path}.md", "r") as f:
|
|
||||||
content = f.read()
|
|
||||||
|
|
||||||
# Return the raw markdown file
|
# Return the raw markdown file
|
||||||
return content, 200, {'Content-Type': 'text/plain; charset=utf-8'}
|
return content, 200, {"Content-Type": "text/plain; charset=utf-8"}
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
from flask import Blueprint, render_template, make_response, request, jsonify
|
from flask import Blueprint, render_template, make_response, request, jsonify
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
|
from functools import lru_cache
|
||||||
from tools import getHandshakeScript, error_response, isCLI
|
from tools import getHandshakeScript, error_response, isCLI
|
||||||
from curl import get_header, MAX_WIDTH
|
from curl import get_header, MAX_WIDTH
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
import re
|
import re
|
||||||
|
|
||||||
# Create blueprint
|
# Create blueprint
|
||||||
app = Blueprint('now', __name__, url_prefix='/now')
|
app = Blueprint("now", __name__, url_prefix="/now")
|
||||||
|
|
||||||
|
|
||||||
|
@lru_cache(maxsize=16)
|
||||||
def list_page_files():
|
def list_page_files():
|
||||||
now_pages = os.listdir("templates/now")
|
now_pages = os.listdir("templates/now")
|
||||||
now_pages = [
|
now_pages = [
|
||||||
@@ -19,12 +21,14 @@ def list_page_files():
|
|||||||
return now_pages
|
return now_pages
|
||||||
|
|
||||||
|
|
||||||
|
@lru_cache(maxsize=16)
|
||||||
def list_dates():
|
def list_dates():
|
||||||
now_pages = list_page_files()
|
now_pages = list_page_files()
|
||||||
now_dates = [page.split(".")[0] for page in now_pages]
|
now_dates = [page.split(".")[0] for page in now_pages]
|
||||||
return now_dates
|
return now_dates
|
||||||
|
|
||||||
|
|
||||||
|
@lru_cache(maxsize=8)
|
||||||
def get_latest_date(formatted=False):
|
def get_latest_date(formatted=False):
|
||||||
if formatted:
|
if formatted:
|
||||||
date = list_dates()[0]
|
date = list_dates()[0]
|
||||||
@@ -51,7 +55,10 @@ def render(date, handshake_scripts=None):
|
|||||||
|
|
||||||
date_formatted = datetime.datetime.strptime(date, "%y_%m_%d")
|
date_formatted = datetime.datetime.strptime(date, "%y_%m_%d")
|
||||||
date_formatted = date_formatted.strftime("%A, %B %d, %Y")
|
date_formatted = date_formatted.strftime("%A, %B %d, %Y")
|
||||||
return render_template(f"now/{date}.html", DATE=date_formatted, handshake_scripts=handshake_scripts)
|
return render_template(
|
||||||
|
f"now/{date}.html", DATE=date_formatted, handshake_scripts=handshake_scripts
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def render_curl(date=None):
|
def render_curl(date=None):
|
||||||
# If the date is not available, render the latest page
|
# If the date is not available, render the latest page
|
||||||
@@ -71,7 +78,7 @@ def render_curl(date=None):
|
|||||||
# Load HTML
|
# Load HTML
|
||||||
with open(f"templates/now/{date}.html", "r", encoding="utf-8") as f:
|
with open(f"templates/now/{date}.html", "r", encoding="utf-8") as f:
|
||||||
raw_html = f.read().replace("{{ date }}", date_formatted)
|
raw_html = f.read().replace("{{ date }}", date_formatted)
|
||||||
soup = BeautifulSoup(raw_html, 'html.parser')
|
soup = BeautifulSoup(raw_html, "html.parser")
|
||||||
|
|
||||||
posts = []
|
posts = []
|
||||||
|
|
||||||
@@ -103,7 +110,7 @@ def render_curl(date=None):
|
|||||||
for line in text.splitlines():
|
for line in text.splitlines():
|
||||||
while len(line) > MAX_WIDTH:
|
while len(line) > MAX_WIDTH:
|
||||||
# Find last space within max_width
|
# Find last space within max_width
|
||||||
split_at = line.rfind(' ', 0, MAX_WIDTH)
|
split_at = line.rfind(" ", 0, MAX_WIDTH)
|
||||||
if split_at == -1:
|
if split_at == -1:
|
||||||
split_at = MAX_WIDTH
|
split_at = MAX_WIDTH
|
||||||
wrapped_lines.append(line[:split_at].rstrip())
|
wrapped_lines.append(line[:split_at].rstrip())
|
||||||
@@ -124,8 +131,9 @@ def render_curl(date=None):
|
|||||||
for post in posts:
|
for post in posts:
|
||||||
response += f"[1m{post['header']}[0m\n\n{post['content']}\n\n"
|
response += f"[1m{post['header']}[0m\n\n{post['content']}\n\n"
|
||||||
|
|
||||||
return render_template("now.ascii", date=date_formatted, content=response, header=get_header())
|
return render_template(
|
||||||
|
"now.ascii", date=date_formatted, content=response, header=get_header()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/", strict_slashes=False)
|
@app.route("/", strict_slashes=False)
|
||||||
@@ -153,8 +161,9 @@ def old():
|
|||||||
date_fmt = datetime.datetime.strptime(date, "%y_%m_%d")
|
date_fmt = datetime.datetime.strptime(date, "%y_%m_%d")
|
||||||
date_fmt = date_fmt.strftime("%A, %B %d, %Y")
|
date_fmt = date_fmt.strftime("%A, %B %d, %Y")
|
||||||
response += f"{date_fmt} - /now/{link}\n"
|
response += f"{date_fmt} - /now/{link}\n"
|
||||||
return render_template("now.ascii", date="Old Now Pages", content=response, header=get_header())
|
return render_template(
|
||||||
|
"now.ascii", date="Old Now Pages", content=response, header=get_header()
|
||||||
|
)
|
||||||
|
|
||||||
html = '<ul class="list-group">'
|
html = '<ul class="list-group">'
|
||||||
html += f'<a style="text-decoration:none;" href="/now"><li class="list-group-item" style="background-color:#000000;color:#ffffff;">{get_latest_date(True)}</li></a>'
|
html += f'<a style="text-decoration:none;" href="/now"><li class="list-group-item" style="background-color:#000000;color:#ffffff;">{get_latest_date(True)}</li></a>'
|
||||||
@@ -167,7 +176,9 @@ def old():
|
|||||||
|
|
||||||
html += "</ul>"
|
html += "</ul>"
|
||||||
return render_template(
|
return render_template(
|
||||||
"now/old.html", handshake_scripts=getHandshakeScript(request.host), now_pages=html
|
"now/old.html",
|
||||||
|
handshake_scripts=getHandshakeScript(request.host),
|
||||||
|
now_pages=html,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -185,7 +196,7 @@ def rss():
|
|||||||
link = page.strip(".html")
|
link = page.strip(".html")
|
||||||
date = datetime.datetime.strptime(link, "%y_%m_%d")
|
date = datetime.datetime.strptime(link, "%y_%m_%d")
|
||||||
date = date.strftime("%A, %B %d, %Y")
|
date = date.strftime("%A, %B %d, %Y")
|
||||||
rss += f'<item><title>What\'s Happening {date}</title><link>{host}/now/{link}</link><description>Latest updates for {date}</description><guid>{host}/now/{link}</guid></item>'
|
rss += f"<item><title>What's Happening {date}</title><link>{host}/now/{link}</link><description>Latest updates for {date}</description><guid>{host}/now/{link}</guid></item>"
|
||||||
rss += "</channel></rss>"
|
rss += "</channel></rss>"
|
||||||
return make_response(rss, 200, {"Content-Type": "application/rss+xml"})
|
return make_response(rss, 200, {"Content-Type": "application/rss+xml"})
|
||||||
|
|
||||||
@@ -196,6 +207,17 @@ def json():
|
|||||||
host = "https://" + request.host
|
host = "https://" + request.host
|
||||||
if ":" in request.host:
|
if ":" in request.host:
|
||||||
host = "http://" + request.host
|
host = "http://" + request.host
|
||||||
now_pages = [{"url": host+"/now/"+page.strip(".html"), "date": datetime.datetime.strptime(page.strip(".html"), "%y_%m_%d").strftime(
|
now_pages = [
|
||||||
"%A, %B %d, %Y"), "title": "What's Happening "+datetime.datetime.strptime(page.strip(".html"), "%y_%m_%d").strftime("%A, %B %d, %Y")} for page in now_pages]
|
{
|
||||||
|
"url": host + "/now/" + page.strip(".html"),
|
||||||
|
"date": datetime.datetime.strptime(
|
||||||
|
page.strip(".html"), "%y_%m_%d"
|
||||||
|
).strftime("%A, %B %d, %Y"),
|
||||||
|
"title": "What's Happening "
|
||||||
|
+ datetime.datetime.strptime(page.strip(".html"), "%y_%m_%d").strftime(
|
||||||
|
"%A, %B %d, %Y"
|
||||||
|
),
|
||||||
|
}
|
||||||
|
for page in now_pages
|
||||||
|
]
|
||||||
return jsonify(now_pages)
|
return jsonify(now_pages)
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ from flask import Blueprint, make_response, request
|
|||||||
from tools import error_response
|
from tools import error_response
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
app = Blueprint('podcast', __name__)
|
app = Blueprint("podcast", __name__)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/ID1")
|
@app.route("/ID1")
|
||||||
def index():
|
def index():
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ import binascii
|
|||||||
import base64
|
import base64
|
||||||
import os
|
import os
|
||||||
|
|
||||||
app = Blueprint('sol', __name__)
|
app = Blueprint("sol", __name__)
|
||||||
|
|
||||||
SOLANA_HEADERS = {
|
SOLANA_HEADERS = {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"X-Action-Version": "2.4.2",
|
"X-Action-Version": "2.4.2",
|
||||||
"X-Blockchain-Ids": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"
|
"X-Blockchain-Ids": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
|
||||||
}
|
}
|
||||||
|
|
||||||
SOLANA_ADDRESS = None
|
SOLANA_ADDRESS = None
|
||||||
@@ -23,15 +23,19 @@ if os.path.isfile(".well-known/wallets/SOL"):
|
|||||||
address = file.read()
|
address = file.read()
|
||||||
SOLANA_ADDRESS = Pubkey.from_string(address.strip())
|
SOLANA_ADDRESS = Pubkey.from_string(address.strip())
|
||||||
|
|
||||||
|
|
||||||
def create_transaction(sender_address: str, amount: float) -> str:
|
def create_transaction(sender_address: str, amount: float) -> str:
|
||||||
if SOLANA_ADDRESS is None:
|
if SOLANA_ADDRESS is None:
|
||||||
raise ValueError("SOLANA_ADDRESS is not set. Please ensure the .well-known/wallets/SOL file exists and contains a valid address.")
|
raise ValueError(
|
||||||
|
"SOLANA_ADDRESS is not set. Please ensure the .well-known/wallets/SOL file exists and contains a valid address."
|
||||||
|
)
|
||||||
# Create transaction
|
# Create transaction
|
||||||
sender = Pubkey.from_string(sender_address)
|
sender = Pubkey.from_string(sender_address)
|
||||||
transfer_ix = transfer(
|
transfer_ix = transfer(
|
||||||
TransferParams(
|
TransferParams(
|
||||||
from_pubkey=sender, to_pubkey=SOLANA_ADDRESS, lamports=int(
|
from_pubkey=sender,
|
||||||
amount * 1000000000)
|
to_pubkey=SOLANA_ADDRESS,
|
||||||
|
lamports=int(amount * 1000000000),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
solana_client = Client("https://api.mainnet-beta.solana.com")
|
solana_client = Client("https://api.mainnet-beta.solana.com")
|
||||||
@@ -50,11 +54,15 @@ def create_transaction(sender_address: str, amount: float) -> str:
|
|||||||
base64_string = base64.b64encode(raw_bytes).decode("utf-8")
|
base64_string = base64.b64encode(raw_bytes).decode("utf-8")
|
||||||
return base64_string
|
return base64_string
|
||||||
|
|
||||||
|
|
||||||
def get_solana_address() -> str:
|
def get_solana_address() -> str:
|
||||||
if SOLANA_ADDRESS is None:
|
if SOLANA_ADDRESS is None:
|
||||||
raise ValueError("SOLANA_ADDRESS is not set. Please ensure the .well-known/wallets/SOL file exists and contains a valid address.")
|
raise ValueError(
|
||||||
|
"SOLANA_ADDRESS is not set. Please ensure the .well-known/wallets/SOL file exists and contains a valid address."
|
||||||
|
)
|
||||||
return str(SOLANA_ADDRESS)
|
return str(SOLANA_ADDRESS)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/donate", methods=["GET", "OPTIONS"])
|
@app.route("/donate", methods=["GET", "OPTIONS"])
|
||||||
def sol_donate():
|
def sol_donate():
|
||||||
data = {
|
data = {
|
||||||
@@ -103,7 +111,6 @@ def sol_donate_amount(amount):
|
|||||||
|
|
||||||
@app.route("/donate/<amount>", methods=["POST"])
|
@app.route("/donate/<amount>", methods=["POST"])
|
||||||
def sol_donate_post(amount):
|
def sol_donate_post(amount):
|
||||||
|
|
||||||
if not request.json:
|
if not request.json:
|
||||||
return jsonify({"message": "Error: No JSON data provided"}), 400, SOLANA_HEADERS
|
return jsonify({"message": "Error: No JSON data provided"}), 400, SOLANA_HEADERS
|
||||||
|
|
||||||
@@ -122,4 +129,8 @@ def sol_donate_post(amount):
|
|||||||
return jsonify({"message": "Error: Amount too small"}), 400, SOLANA_HEADERS
|
return jsonify({"message": "Error: Amount too small"}), 400, SOLANA_HEADERS
|
||||||
|
|
||||||
transaction = create_transaction(sender, amount)
|
transaction = create_transaction(sender, amount)
|
||||||
return jsonify({"message": "Success", "transaction": transaction}), 200, SOLANA_HEADERS
|
return (
|
||||||
|
jsonify({"message": "Success", "transaction": transaction}),
|
||||||
|
200,
|
||||||
|
SOLANA_HEADERS,
|
||||||
|
)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import requests
|
|||||||
import time
|
import time
|
||||||
import base64
|
import base64
|
||||||
|
|
||||||
app = Blueprint('spotify', __name__, url_prefix='/spotify')
|
app = Blueprint("spotify", __name__, url_prefix="/spotify")
|
||||||
|
|
||||||
CLIENT_ID = os.getenv("SPOTIFY_CLIENT_ID")
|
CLIENT_ID = os.getenv("SPOTIFY_CLIENT_ID")
|
||||||
CLIENT_SECRET = os.getenv("SPOTIFY_CLIENT_SECRET")
|
CLIENT_SECRET = os.getenv("SPOTIFY_CLIENT_SECRET")
|
||||||
@@ -21,6 +21,7 @@ ACCESS_TOKEN = None
|
|||||||
REFRESH_TOKEN = os.getenv("SPOTIFY_REFRESH_TOKEN")
|
REFRESH_TOKEN = os.getenv("SPOTIFY_REFRESH_TOKEN")
|
||||||
TOKEN_EXPIRES = 0
|
TOKEN_EXPIRES = 0
|
||||||
|
|
||||||
|
|
||||||
def refresh_access_token():
|
def refresh_access_token():
|
||||||
"""Refresh Spotify access token when expired."""
|
"""Refresh Spotify access token when expired."""
|
||||||
global ACCESS_TOKEN, TOKEN_EXPIRES
|
global ACCESS_TOKEN, TOKEN_EXPIRES
|
||||||
@@ -52,6 +53,7 @@ def refresh_access_token():
|
|||||||
TOKEN_EXPIRES = time.time() + token_info.get("expires_in", 3600)
|
TOKEN_EXPIRES = time.time() + token_info.get("expires_in", 3600)
|
||||||
return ACCESS_TOKEN
|
return ACCESS_TOKEN
|
||||||
|
|
||||||
|
|
||||||
@app.route("/login")
|
@app.route("/login")
|
||||||
def login():
|
def login():
|
||||||
auth_query = (
|
auth_query = (
|
||||||
@@ -60,6 +62,7 @@ def login():
|
|||||||
)
|
)
|
||||||
return redirect(auth_query)
|
return redirect(auth_query)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/callback")
|
@app.route("/callback")
|
||||||
def callback():
|
def callback():
|
||||||
code = request.args.get("code")
|
code = request.args.get("code")
|
||||||
@@ -76,12 +79,14 @@ def callback():
|
|||||||
response = requests.post(SPOTIFY_TOKEN_URL, data=data)
|
response = requests.post(SPOTIFY_TOKEN_URL, data=data)
|
||||||
token_info = response.json()
|
token_info = response.json()
|
||||||
if "access_token" not in token_info:
|
if "access_token" not in token_info:
|
||||||
return json_response(request, {"error": "Failed to obtain token", "details": token_info}, 400)
|
return json_response(
|
||||||
|
request, {"error": "Failed to obtain token", "details": token_info}, 400
|
||||||
|
)
|
||||||
|
|
||||||
access_token = token_info["access_token"]
|
access_token = token_info["access_token"]
|
||||||
me = requests.get(
|
me = requests.get(
|
||||||
"https://api.spotify.com/v1/me",
|
"https://api.spotify.com/v1/me",
|
||||||
headers={"Authorization": f"Bearer {access_token}"}
|
headers={"Authorization": f"Bearer {access_token}"},
|
||||||
).json()
|
).json()
|
||||||
|
|
||||||
if me.get("id") != ALLOWED_SPOTIFY_USER_ID:
|
if me.get("id") != ALLOWED_SPOTIFY_USER_ID:
|
||||||
@@ -93,6 +98,7 @@ def callback():
|
|||||||
print("Refresh Token:", REFRESH_TOKEN)
|
print("Refresh Token:", REFRESH_TOKEN)
|
||||||
return redirect(url_for("spotify.currently_playing"))
|
return redirect(url_for("spotify.currently_playing"))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/", strict_slashes=False)
|
@app.route("/", strict_slashes=False)
|
||||||
@app.route("/playing")
|
@app.route("/playing")
|
||||||
def currently_playing():
|
def currently_playing():
|
||||||
@@ -100,6 +106,7 @@ def currently_playing():
|
|||||||
track = get_spotify_track()
|
track = get_spotify_track()
|
||||||
return json_response(request, {"spotify": track}, 200)
|
return json_response(request, {"spotify": track}, 200)
|
||||||
|
|
||||||
|
|
||||||
def get_spotify_track():
|
def get_spotify_track():
|
||||||
"""Internal function to get current playing track without HTTP context."""
|
"""Internal function to get current playing track without HTTP context."""
|
||||||
token = refresh_access_token()
|
token = refresh_access_token()
|
||||||
@@ -125,6 +132,6 @@ def get_spotify_track():
|
|||||||
"album_art": data["item"]["album"]["images"][0]["url"],
|
"album_art": data["item"]["album"]["images"][0]["url"],
|
||||||
"is_playing": data["is_playing"],
|
"is_playing": data["is_playing"],
|
||||||
"progress_ms": data.get("progress_ms", 0),
|
"progress_ms": data.get("progress_ms", 0),
|
||||||
"duration_ms": data["item"].get("duration_ms",1)
|
"duration_ms": data["item"].get("duration_ms", 1),
|
||||||
}
|
}
|
||||||
return track
|
return track
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
from flask import Blueprint, request
|
from flask import Blueprint, request
|
||||||
from tools import json_response
|
from tools import json_response
|
||||||
|
|
||||||
app = Blueprint('template', __name__)
|
app = Blueprint("template", __name__)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/", strict_slashes=False)
|
@app.route("/", strict_slashes=False)
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
from flask import Blueprint, make_response, request, jsonify, send_from_directory, redirect
|
from flask import (
|
||||||
|
Blueprint,
|
||||||
|
make_response,
|
||||||
|
request,
|
||||||
|
jsonify,
|
||||||
|
send_from_directory,
|
||||||
|
redirect,
|
||||||
|
)
|
||||||
from tools import error_response
|
from tools import error_response
|
||||||
import os
|
import os
|
||||||
|
|
||||||
app = Blueprint('well-known', __name__, url_prefix='/.well-known')
|
app = Blueprint("well-known", __name__, url_prefix="/.well-known")
|
||||||
|
|
||||||
|
|
||||||
@app.route("/<path:path>")
|
@app.route("/<path:path>")
|
||||||
@@ -12,7 +19,7 @@ def index(path):
|
|||||||
|
|
||||||
@app.route("/wallets/<path:path>")
|
@app.route("/wallets/<path:path>")
|
||||||
def wallets(path):
|
def wallets(path):
|
||||||
if path[0] == "." and 'proof' not in path:
|
if path[0] == "." and "proof" not in path:
|
||||||
return send_from_directory(
|
return send_from_directory(
|
||||||
".well-known/wallets", path, mimetype="application/json"
|
".well-known/wallets", path, mimetype="application/json"
|
||||||
)
|
)
|
||||||
|
|||||||
264
cache_helper.py
Normal file
264
cache_helper.py
Normal file
@@ -0,0 +1,264 @@
|
|||||||
|
"""
|
||||||
|
Cache helper module for expensive API calls and configuration.
|
||||||
|
Provides centralized caching with TTL for external API calls.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
import os
|
||||||
|
import json
|
||||||
|
import requests
|
||||||
|
from functools import lru_cache
|
||||||
|
|
||||||
|
|
||||||
|
# Cache storage for NC_CONFIG with timestamp
|
||||||
|
_nc_config_cache = {"data": None, "timestamp": 0}
|
||||||
|
_nc_config_ttl = 3600 # 1 hour cache
|
||||||
|
|
||||||
|
|
||||||
|
def get_nc_config():
|
||||||
|
"""
|
||||||
|
Get NC_CONFIG with caching (1 hour TTL).
|
||||||
|
Falls back to default config on error.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: Configuration dictionary
|
||||||
|
"""
|
||||||
|
global _nc_config_cache
|
||||||
|
current_time = datetime.datetime.now().timestamp()
|
||||||
|
|
||||||
|
# Check if cache is valid
|
||||||
|
if (
|
||||||
|
_nc_config_cache["data"]
|
||||||
|
and (current_time - _nc_config_cache["timestamp"]) < _nc_config_ttl
|
||||||
|
):
|
||||||
|
return _nc_config_cache["data"]
|
||||||
|
|
||||||
|
# Fetch new config
|
||||||
|
try:
|
||||||
|
config = requests.get(
|
||||||
|
"https://cloud.woodburn.au/s/4ToXgFe3TnnFcN7/download/website-conf.json",
|
||||||
|
timeout=5,
|
||||||
|
).json()
|
||||||
|
_nc_config_cache = {"data": config, "timestamp": current_time}
|
||||||
|
return config
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error fetching NC_CONFIG: {e}")
|
||||||
|
# Return cached data if available, otherwise default
|
||||||
|
if _nc_config_cache["data"]:
|
||||||
|
return _nc_config_cache["data"]
|
||||||
|
return {"time-zone": 10, "message": ""}
|
||||||
|
|
||||||
|
|
||||||
|
# Cache storage for git data
|
||||||
|
_git_data_cache = {"data": None, "timestamp": 0}
|
||||||
|
_git_data_ttl = 300 # 5 minutes cache
|
||||||
|
|
||||||
|
|
||||||
|
def get_git_latest_activity():
|
||||||
|
"""
|
||||||
|
Get latest git activity with caching (5 minute TTL).
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: Git activity data or default values
|
||||||
|
"""
|
||||||
|
global _git_data_cache
|
||||||
|
current_time = datetime.datetime.now().timestamp()
|
||||||
|
|
||||||
|
# Check if cache is valid
|
||||||
|
if (
|
||||||
|
_git_data_cache["data"]
|
||||||
|
and (current_time - _git_data_cache["timestamp"]) < _git_data_ttl
|
||||||
|
):
|
||||||
|
return _git_data_cache["data"]
|
||||||
|
|
||||||
|
# Fetch new data
|
||||||
|
try:
|
||||||
|
git = requests.get(
|
||||||
|
"https://git.woodburn.au/api/v1/users/nathanwoodburn/activities/feeds?only-performed-by=true&limit=1",
|
||||||
|
headers={
|
||||||
|
"Authorization": os.getenv("GIT_AUTH") or os.getenv("git_token") or ""
|
||||||
|
},
|
||||||
|
timeout=5,
|
||||||
|
)
|
||||||
|
git_data = git.json()
|
||||||
|
if git_data and len(git_data) > 0:
|
||||||
|
result = git_data[0]
|
||||||
|
_git_data_cache = {"data": result, "timestamp": current_time}
|
||||||
|
return result
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error fetching git data: {e}")
|
||||||
|
|
||||||
|
# Return cached or default
|
||||||
|
if _git_data_cache["data"]:
|
||||||
|
return _git_data_cache["data"]
|
||||||
|
|
||||||
|
return {
|
||||||
|
"repo": {
|
||||||
|
"html_url": "https://nathan.woodburn.au",
|
||||||
|
"name": "nathanwoodburn.github.io",
|
||||||
|
"description": "Personal website",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Cache storage for projects
|
||||||
|
_projects_cache = {"data": None, "timestamp": 0}
|
||||||
|
_projects_ttl = 7200 # 2 hours cache
|
||||||
|
|
||||||
|
|
||||||
|
def get_projects(limit=3):
|
||||||
|
"""
|
||||||
|
Get projects list with caching (2 hour TTL).
|
||||||
|
|
||||||
|
Args:
|
||||||
|
limit (int): Number of projects to return
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list: List of project dictionaries
|
||||||
|
"""
|
||||||
|
global _projects_cache
|
||||||
|
current_time = datetime.datetime.now().timestamp()
|
||||||
|
|
||||||
|
# Check if cache is valid
|
||||||
|
if (
|
||||||
|
_projects_cache["data"]
|
||||||
|
and (current_time - _projects_cache["timestamp"]) < _projects_ttl
|
||||||
|
):
|
||||||
|
return _projects_cache["data"][:limit]
|
||||||
|
|
||||||
|
# Fetch new data
|
||||||
|
try:
|
||||||
|
projects = []
|
||||||
|
projectsreq = requests.get(
|
||||||
|
"https://git.woodburn.au/api/v1/users/nathanwoodburn/repos", timeout=5
|
||||||
|
)
|
||||||
|
projects = projectsreq.json()
|
||||||
|
|
||||||
|
# Check for pagination
|
||||||
|
pageNum = 2
|
||||||
|
while 'rel="next"' in projectsreq.headers.get("link", ""):
|
||||||
|
projectsreq = requests.get(
|
||||||
|
f"https://git.woodburn.au/api/v1/users/nathanwoodburn/repos?page={pageNum}",
|
||||||
|
timeout=5,
|
||||||
|
)
|
||||||
|
projects += projectsreq.json()
|
||||||
|
pageNum += 1
|
||||||
|
# Safety limit
|
||||||
|
if pageNum > 10:
|
||||||
|
break
|
||||||
|
|
||||||
|
# Process projects
|
||||||
|
for project in projects:
|
||||||
|
if project.get("avatar_url") in ("https://git.woodburn.au/", ""):
|
||||||
|
project["avatar_url"] = "/favicon.png"
|
||||||
|
project["name"] = project["name"].replace("_", " ").replace("-", " ")
|
||||||
|
|
||||||
|
# Sort by last updated
|
||||||
|
projects_sorted = sorted(
|
||||||
|
projects, key=lambda x: x.get("updated_at", ""), reverse=True
|
||||||
|
)
|
||||||
|
|
||||||
|
# Remove duplicates by name
|
||||||
|
seen_names = set()
|
||||||
|
unique_projects = []
|
||||||
|
for project in projects_sorted:
|
||||||
|
if project["name"] not in seen_names:
|
||||||
|
unique_projects.append(project)
|
||||||
|
seen_names.add(project["name"])
|
||||||
|
|
||||||
|
_projects_cache = {"data": unique_projects, "timestamp": current_time}
|
||||||
|
return unique_projects[:limit]
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error fetching projects: {e}")
|
||||||
|
if _projects_cache["data"]:
|
||||||
|
return _projects_cache["data"][:limit]
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
# Cache storage for uptime status
|
||||||
|
_uptime_cache = {"data": None, "timestamp": 0}
|
||||||
|
_uptime_ttl = 300 # 5 minutes cache
|
||||||
|
|
||||||
|
|
||||||
|
def get_uptime_status():
|
||||||
|
"""
|
||||||
|
Get uptime status with caching (5 minute TTL).
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: True if services are up, False otherwise
|
||||||
|
"""
|
||||||
|
global _uptime_cache
|
||||||
|
current_time = datetime.datetime.now().timestamp()
|
||||||
|
|
||||||
|
# Check if cache is valid
|
||||||
|
if (
|
||||||
|
_uptime_cache["data"] is not None
|
||||||
|
and (current_time - _uptime_cache["timestamp"]) < _uptime_ttl
|
||||||
|
):
|
||||||
|
return _uptime_cache["data"]
|
||||||
|
|
||||||
|
# Fetch new data
|
||||||
|
try:
|
||||||
|
uptime = requests.get(
|
||||||
|
"https://uptime.woodburn.au/api/status-page/main/badge", timeout=5
|
||||||
|
)
|
||||||
|
content = uptime.content.decode("utf-8").lower()
|
||||||
|
status = "maintenance" in content or uptime.content.count(b"Up") > 1
|
||||||
|
_uptime_cache = {"data": status, "timestamp": current_time}
|
||||||
|
return status
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error fetching uptime: {e}")
|
||||||
|
# Return cached or default (assume up)
|
||||||
|
if _uptime_cache["data"] is not None:
|
||||||
|
return _uptime_cache["data"]
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
# Cached wallet data loaders
|
||||||
|
@lru_cache(maxsize=1)
|
||||||
|
def get_wallet_tokens():
|
||||||
|
"""
|
||||||
|
Get wallet tokens with caching.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list: List of token dictionaries
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
with open(".well-known/wallets/.tokens") as file:
|
||||||
|
return json.load(file)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error loading tokens: {e}")
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
@lru_cache(maxsize=1)
|
||||||
|
def get_coin_names():
|
||||||
|
"""
|
||||||
|
Get coin names with caching.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: Dictionary of coin names
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
with open(".well-known/wallets/.coins") as file:
|
||||||
|
return json.load(file)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error loading coin names: {e}")
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
|
@lru_cache(maxsize=1)
|
||||||
|
def get_wallet_domains():
|
||||||
|
"""
|
||||||
|
Get wallet domains with caching.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: Dictionary of wallet domains
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
if os.path.isfile(".well-known/wallets/.domains"):
|
||||||
|
with open(".well-known/wallets/.domains") as file:
|
||||||
|
return json.load(file)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error loading domains: {e}")
|
||||||
|
return {}
|
||||||
21
cleanSite.py
21
cleanSite.py
@@ -1,36 +1,37 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
def cleanSite(path: str):
|
def cleanSite(path: str):
|
||||||
# Check if the file is sitemap.xml
|
# Check if the file is sitemap.xml
|
||||||
if path.endswith('sitemap.xml'):
|
if path.endswith("sitemap.xml"):
|
||||||
# Open the file
|
# Open the file
|
||||||
with open(path, 'r') as f:
|
with open(path, "r") as f:
|
||||||
# Read the content
|
# Read the content
|
||||||
content = f.read()
|
content = f.read()
|
||||||
# Replace all .html with empty string
|
# Replace all .html with empty string
|
||||||
content = content.replace('.html', '')
|
content = content.replace(".html", "")
|
||||||
# Write the content back to the file
|
# Write the content back to the file
|
||||||
with open(path, 'w') as f:
|
with open(path, "w") as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
# Skip the file
|
# Skip the file
|
||||||
return
|
return
|
||||||
|
|
||||||
# If the file is not an html file, skip it
|
# If the file is not an html file, skip it
|
||||||
if not path.endswith('.html'):
|
if not path.endswith(".html"):
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
for file in os.listdir(path):
|
for file in os.listdir(path):
|
||||||
cleanSite(path + '/' + file)
|
cleanSite(path + "/" + file)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# Open the file
|
# Open the file
|
||||||
with open(path, 'r') as f:
|
with open(path, "r") as f:
|
||||||
# Read and remove all .html
|
# Read and remove all .html
|
||||||
content = f.read().replace('.html"', '"')
|
content = f.read().replace('.html"', '"')
|
||||||
# Write the cleaned content back to the file
|
# Write the cleaned content back to the file
|
||||||
with open(path, 'w') as f:
|
with open(path, "w") as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
|
|
||||||
|
|
||||||
for file in os.listdir('templates'):
|
for file in os.listdir("templates"):
|
||||||
cleanSite('templates/' + file)
|
cleanSite("templates/" + file)
|
||||||
|
|||||||
130
curl.py
130
curl.py
@@ -2,12 +2,13 @@ from flask import render_template
|
|||||||
from tools import getAddress, get_tools_data, getClientIP
|
from tools import getAddress, get_tools_data, getClientIP
|
||||||
import os
|
import os
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
import requests
|
|
||||||
from blueprints.spotify import get_spotify_track
|
from blueprints.spotify import get_spotify_track
|
||||||
|
from cache_helper import get_git_latest_activity, get_projects as get_projects_cached
|
||||||
|
|
||||||
|
|
||||||
MAX_WIDTH = 80
|
MAX_WIDTH = 80
|
||||||
|
|
||||||
|
|
||||||
def clean_path(path: str):
|
def clean_path(path: str):
|
||||||
path = path.strip("/ ").lower()
|
path = path.strip("/ ").lower()
|
||||||
# Strip any .html extension
|
# Strip any .html extension
|
||||||
@@ -19,66 +20,35 @@ def clean_path(path:str):
|
|||||||
path = "index"
|
path = "index"
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
@lru_cache(maxsize=1)
|
@lru_cache(maxsize=1)
|
||||||
def get_header():
|
def get_header():
|
||||||
with open("templates/header.ascii", "r") as f:
|
with open("templates/header.ascii", "r") as f:
|
||||||
return f.read()
|
return f.read()
|
||||||
|
|
||||||
@lru_cache(maxsize=1)
|
|
||||||
|
@lru_cache(maxsize=16)
|
||||||
def get_current_project():
|
def get_current_project():
|
||||||
git = requests.get(
|
git = get_git_latest_activity()
|
||||||
"https://git.woodburn.au/api/v1/users/nathanwoodburn/activities/feeds?only-performed-by=true&limit=1",
|
repo_name = git["repo"]["name"].lower()
|
||||||
headers={"Authorization": os.getenv("GIT_AUTH") if os.getenv("GIT_AUTH") else os.getenv("git_token")},
|
|
||||||
)
|
|
||||||
git = git.json()
|
|
||||||
git = git[0]
|
|
||||||
repo_name = git["repo"]["name"]
|
|
||||||
repo_name = repo_name.lower()
|
|
||||||
repo_description = git["repo"]["description"]
|
repo_description = git["repo"]["description"]
|
||||||
if not repo_description:
|
if not repo_description:
|
||||||
return f"[1;36m{repo_name}[0m"
|
return f"[1;36m{repo_name}[0m"
|
||||||
return f"[1;36m{repo_name}[0m - [1m{repo_description}[0m"
|
return f"[1;36m{repo_name}[0m - [1m{repo_description}[0m"
|
||||||
|
|
||||||
|
|
||||||
@lru_cache(maxsize=1)
|
@lru_cache(maxsize=16)
|
||||||
def get_projects():
|
def get_projects():
|
||||||
projectsreq = requests.get(
|
projects_data = get_projects_cached(limit=5)
|
||||||
"https://git.woodburn.au/api/v1/users/nathanwoodburn/repos"
|
|
||||||
)
|
|
||||||
|
|
||||||
projects = projectsreq.json()
|
|
||||||
|
|
||||||
# Check for next page
|
|
||||||
pageNum = 1
|
|
||||||
while 'rel="next"' in projectsreq.headers["link"]:
|
|
||||||
projectsreq = requests.get(
|
|
||||||
"https://git.woodburn.au/api/v1/users/nathanwoodburn/repos?page="
|
|
||||||
+ str(pageNum)
|
|
||||||
)
|
|
||||||
projects += projectsreq.json()
|
|
||||||
pageNum += 1
|
|
||||||
|
|
||||||
# Sort by last updated
|
|
||||||
projectsList = sorted(
|
|
||||||
projects, key=lambda x: x["updated_at"], reverse=True)
|
|
||||||
projects = ""
|
projects = ""
|
||||||
projectNum = 0
|
for project in projects_data:
|
||||||
includedNames = []
|
projects += f"""[1m{project["name"]}[0m - {project["description"] if project["description"] else "No description"}
|
||||||
while len(includedNames) < 5 and projectNum < len(projectsList):
|
{project["html_url"]}
|
||||||
# Avoid duplicates
|
|
||||||
if projectsList[projectNum]["name"] in includedNames:
|
|
||||||
projectNum += 1
|
|
||||||
continue
|
|
||||||
includedNames.append(projectsList[projectNum]["name"])
|
|
||||||
project = projectsList[projectNum]
|
|
||||||
projects += f"""[1m{project['name']}[0m - {project['description'] if project['description'] else 'No description'}
|
|
||||||
{project['html_url']}
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
projectNum += 1
|
|
||||||
|
|
||||||
return projects
|
return projects
|
||||||
|
|
||||||
|
|
||||||
def curl_response(request):
|
def curl_response(request):
|
||||||
# Check if <path>.ascii exists
|
# Check if <path>.ascii exists
|
||||||
path = clean_path(request.path)
|
path = clean_path(request.path)
|
||||||
@@ -86,39 +56,81 @@ def curl_response(request):
|
|||||||
# Handle special cases
|
# Handle special cases
|
||||||
if path == "index":
|
if path == "index":
|
||||||
# Get current project
|
# Get current project
|
||||||
return render_template("index.ascii",repo=get_current_project(), ip=getClientIP(request), spotify=get_spotify_track()), 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":
|
if path == "projects":
|
||||||
# Get projects
|
# Get projects
|
||||||
return render_template("projects.ascii",header=get_header(),projects=get_projects()), 200, {'Content-Type': 'text/plain; charset=utf-8'}
|
return (
|
||||||
|
render_template(
|
||||||
|
"projects.ascii", header=get_header(), projects=get_projects()
|
||||||
|
),
|
||||||
|
200,
|
||||||
|
{"Content-Type": "text/plain; charset=utf-8"},
|
||||||
|
)
|
||||||
|
|
||||||
if path == "donate":
|
if path == "donate":
|
||||||
# Get donation info
|
# Get donation info
|
||||||
return render_template("donate.ascii",header=get_header(),
|
return (
|
||||||
HNS=getAddress("HNS"), BTC=getAddress("BTC"),
|
render_template(
|
||||||
SOL=getAddress("SOL"), ETH=getAddress("ETH")
|
"donate.ascii",
|
||||||
), 200, {'Content-Type': 'text/plain; charset=utf-8'}
|
header=get_header(),
|
||||||
|
HNS=getAddress("HNS"),
|
||||||
|
BTC=getAddress("BTC"),
|
||||||
|
SOL=getAddress("SOL"),
|
||||||
|
ETH=getAddress("ETH"),
|
||||||
|
),
|
||||||
|
200,
|
||||||
|
{"Content-Type": "text/plain; charset=utf-8"},
|
||||||
|
)
|
||||||
|
|
||||||
if path == "donate/more":
|
if path == "donate/more":
|
||||||
coinList = os.listdir(".well-known/wallets")
|
coinList = os.listdir(".well-known/wallets")
|
||||||
coinList = [file for file in coinList if file[0] != "."]
|
coinList = [file for file in coinList if file[0] != "."]
|
||||||
coinList.sort()
|
coinList.sort()
|
||||||
return render_template("donate_more.ascii",header=get_header(),
|
return (
|
||||||
coins=coinList
|
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
|
# For other donation pages, fall back to ascii if it exists
|
||||||
if path.startswith("donate/"):
|
if path.startswith("donate/"):
|
||||||
coin = path.split("/")[1]
|
coin = path.split("/")[1]
|
||||||
address = getAddress(coin)
|
address = getAddress(coin)
|
||||||
if address != "":
|
if address != "":
|
||||||
return render_template("donate_coin.ascii",header=get_header(),coin=coin.upper(),address=address), 200, {'Content-Type': 'text/plain; charset=utf-8'}
|
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":
|
if path == "tools":
|
||||||
tools = get_tools_data()
|
tools = get_tools_data()
|
||||||
return render_template("tools.ascii",header=get_header(),tools=tools), 200, {'Content-Type': 'text/plain; charset=utf-8'}
|
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"):
|
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'}
|
return (
|
||||||
|
render_template(f"{path}.ascii", header=get_header()),
|
||||||
|
200,
|
||||||
|
{"Content-Type": "text/plain; charset=utf-8"},
|
||||||
|
)
|
||||||
|
|
||||||
# Fallback to html if it exists
|
# Fallback to html if it exists
|
||||||
if os.path.exists(f"templates/{path}.html"):
|
if os.path.exists(f"templates/{path}.html"):
|
||||||
@@ -127,6 +139,10 @@ def curl_response(request):
|
|||||||
# Return curl error page
|
# Return curl error page
|
||||||
error = {
|
error = {
|
||||||
"code": 404,
|
"code": 404,
|
||||||
"message": "The requested resource was not found on this server."
|
"message": "The requested resource was not found on this server.",
|
||||||
}
|
}
|
||||||
return render_template("error.ascii",header=get_header(),error=error), 404, {'Content-Type': 'text/plain; charset=utf-8'}
|
return (
|
||||||
|
render_template("error.ascii", header=get_header(), error=error),
|
||||||
|
404,
|
||||||
|
{"Content-Type": "text/plain; charset=utf-8"},
|
||||||
|
)
|
||||||
|
|||||||
57
mail.py
57
mail.py
@@ -21,6 +21,7 @@ import os
|
|||||||
# "body":"G'\''day\nThis is a test email from my website api\n\nRegards,\nNathan.Woodburn/"
|
# "body":"G'\''day\nThis is a test email from my website api\n\nRegards,\nNathan.Woodburn/"
|
||||||
# }'
|
# }'
|
||||||
|
|
||||||
|
|
||||||
def validateSender(email):
|
def validateSender(email):
|
||||||
domains = os.getenv("EMAIL_DOMAINS")
|
domains = os.getenv("EMAIL_DOMAINS")
|
||||||
if not domains:
|
if not domains:
|
||||||
@@ -33,37 +34,29 @@ def validateSender(email):
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def sendEmail(data):
|
def sendEmail(data):
|
||||||
fromEmail = "noreply@woodburn.au"
|
fromEmail = "noreply@woodburn.au"
|
||||||
if "from" in data:
|
if "from" in data:
|
||||||
fromEmail = data["from"]
|
fromEmail = data["from"]
|
||||||
|
|
||||||
if not validateSender(fromEmail):
|
if not validateSender(fromEmail):
|
||||||
return jsonify({
|
return jsonify({"status": 400, "message": "Bad request 'from' email invalid"})
|
||||||
"status": 400,
|
|
||||||
"message": "Bad request 'from' email invalid"
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
if "to" not in data:
|
if "to" not in data:
|
||||||
return jsonify({
|
return jsonify({"status": 400, "message": "Bad request 'to' json data missing"})
|
||||||
"status": 400,
|
|
||||||
"message": "Bad request 'to' json data missing"
|
|
||||||
})
|
|
||||||
to = data["to"]
|
to = data["to"]
|
||||||
|
|
||||||
if "subject" not in data:
|
if "subject" not in data:
|
||||||
return jsonify({
|
return jsonify(
|
||||||
"status": 400,
|
{"status": 400, "message": "Bad request 'subject' json data missing"}
|
||||||
"message": "Bad request 'subject' json data missing"
|
)
|
||||||
})
|
|
||||||
subject = data["subject"]
|
subject = data["subject"]
|
||||||
|
|
||||||
if "body" not in data:
|
if "body" not in data:
|
||||||
return jsonify({
|
return jsonify(
|
||||||
"status": 400,
|
{"status": 400, "message": "Bad request 'body' json data missing"}
|
||||||
"message": "Bad request 'body' json data missing"
|
)
|
||||||
})
|
|
||||||
body = data["body"]
|
body = data["body"]
|
||||||
|
|
||||||
if not re.match(r"[^@]+@[^@]+\.[^@]+", to):
|
if not re.match(r"[^@]+@[^@]+\.[^@]+", to):
|
||||||
@@ -76,15 +69,15 @@ def sendEmail(data):
|
|||||||
raise ValueError("Body cannot be empty.")
|
raise ValueError("Body cannot be empty.")
|
||||||
|
|
||||||
fromName = "Nathan Woodburn"
|
fromName = "Nathan Woodburn"
|
||||||
if 'sender' in data:
|
if "sender" in data:
|
||||||
fromName = data['sender']
|
fromName = data["sender"]
|
||||||
|
|
||||||
# Create the email message
|
# Create the email message
|
||||||
msg = MIMEMultipart()
|
msg = MIMEMultipart()
|
||||||
msg['From'] = formataddr((fromName, fromEmail))
|
msg["From"] = formataddr((fromName, fromEmail))
|
||||||
msg['To'] = to
|
msg["To"] = to
|
||||||
msg['Subject'] = subject
|
msg["Subject"] = subject
|
||||||
msg.attach(MIMEText(body, 'plain'))
|
msg.attach(MIMEText(body, "plain"))
|
||||||
|
|
||||||
# Sending the email
|
# Sending the email
|
||||||
try:
|
try:
|
||||||
@@ -92,24 +85,12 @@ def sendEmail(data):
|
|||||||
user = os.getenv("EMAIL_USER")
|
user = os.getenv("EMAIL_USER")
|
||||||
password = os.getenv("EMAIL_PASS")
|
password = os.getenv("EMAIL_PASS")
|
||||||
if host is None or user is None or password is None:
|
if host is None or user is None or password is None:
|
||||||
return jsonify({
|
return jsonify({"status": 500, "error": "Email server not configured"})
|
||||||
"status": 500,
|
|
||||||
"error": "Email server not configured"
|
|
||||||
})
|
|
||||||
|
|
||||||
with smtplib.SMTP_SSL(host, 465) as server:
|
with smtplib.SMTP_SSL(host, 465) as server:
|
||||||
server.login(user, password)
|
server.login(user, password)
|
||||||
server.sendmail(fromEmail, to, msg.as_string())
|
server.sendmail(fromEmail, to, msg.as_string())
|
||||||
print("Email sent successfully.")
|
print("Email sent successfully.")
|
||||||
return jsonify({
|
return jsonify({"status": 200, "message": "Send email successfully"})
|
||||||
"status": 200,
|
|
||||||
"message": "Send email successfully"
|
|
||||||
})
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify({
|
return jsonify({"status": 500, "error": "Sending email failed", "exception": e})
|
||||||
"status": 500,
|
|
||||||
"error": "Sending email failed",
|
|
||||||
"exception":e
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
22
main.py
22
main.py
@@ -17,9 +17,10 @@ class GunicornApp(BaseApplication):
|
|||||||
def load(self):
|
def load(self):
|
||||||
return self.application
|
return self.application
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
workers = os.getenv('WORKERS')
|
if __name__ == "__main__":
|
||||||
threads = os.getenv('THREADS')
|
workers = os.getenv("WORKERS")
|
||||||
|
threads = os.getenv("THREADS")
|
||||||
if workers is None:
|
if workers is None:
|
||||||
workers = 1
|
workers = 1
|
||||||
if threads is None:
|
if threads is None:
|
||||||
@@ -27,10 +28,17 @@ if __name__ == '__main__':
|
|||||||
workers = int(workers)
|
workers = int(workers)
|
||||||
threads = int(threads)
|
threads = int(threads)
|
||||||
options = {
|
options = {
|
||||||
'bind': '0.0.0.0:5000',
|
"bind": "0.0.0.0:5000",
|
||||||
'workers': workers,
|
"workers": workers,
|
||||||
'threads': threads,
|
"threads": threads,
|
||||||
}
|
}
|
||||||
gunicorn_app = GunicornApp(app, options)
|
gunicorn_app = GunicornApp(app, options)
|
||||||
print('Starting server with ' + str(workers) + ' workers and ' + str(threads) + ' threads', flush=True)
|
print(
|
||||||
|
"Starting server with "
|
||||||
|
+ str(workers)
|
||||||
|
+ " workers and "
|
||||||
|
+ str(threads)
|
||||||
|
+ " threads",
|
||||||
|
flush=True,
|
||||||
|
)
|
||||||
gunicorn_app.run()
|
gunicorn_app.run()
|
||||||
|
|||||||
247
server.py
247
server.py
@@ -18,10 +18,30 @@ import qrcode
|
|||||||
from qrcode.constants import ERROR_CORRECT_L, ERROR_CORRECT_H
|
from qrcode.constants import ERROR_CORRECT_L, ERROR_CORRECT_H
|
||||||
from ansi2html import Ansi2HTMLConverter
|
from ansi2html import Ansi2HTMLConverter
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
# Import blueprints
|
# Import blueprints
|
||||||
from blueprints import now, blog, wellknown, api, podcast, acme, spotify
|
from blueprints import now, blog, wellknown, api, podcast, acme, spotify
|
||||||
from tools import isCLI, isCrawler, getAddress, getFilePath, error_response, getClientIP, json_response, getHandshakeScript, get_tools_data
|
from tools import (
|
||||||
|
isCLI,
|
||||||
|
isCrawler,
|
||||||
|
getAddress,
|
||||||
|
getFilePath,
|
||||||
|
error_response,
|
||||||
|
getClientIP,
|
||||||
|
json_response,
|
||||||
|
getHandshakeScript,
|
||||||
|
get_tools_data,
|
||||||
|
)
|
||||||
from curl import curl_response
|
from curl import curl_response
|
||||||
|
from cache_helper import (
|
||||||
|
get_nc_config,
|
||||||
|
get_git_latest_activity,
|
||||||
|
get_projects,
|
||||||
|
get_uptime_status,
|
||||||
|
get_wallet_tokens,
|
||||||
|
get_coin_names,
|
||||||
|
get_wallet_domains,
|
||||||
|
)
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
CORS(app)
|
CORS(app)
|
||||||
@@ -50,25 +70,14 @@ REDIRECT_ROUTES = {
|
|||||||
"/meeting": "https://cloud.woodburn.au/apps/calendar/appointment/PamrmmspWJZr",
|
"/meeting": "https://cloud.woodburn.au/apps/calendar/appointment/PamrmmspWJZr",
|
||||||
"/appointment": "https://cloud.woodburn.au/apps/calendar/appointment/PamrmmspWJZr",
|
"/appointment": "https://cloud.woodburn.au/apps/calendar/appointment/PamrmmspWJZr",
|
||||||
}
|
}
|
||||||
DOWNLOAD_ROUTES = {
|
DOWNLOAD_ROUTES = {"pgp": "data/nathanwoodburn.asc"}
|
||||||
"pgp": "data/nathanwoodburn.asc"
|
|
||||||
}
|
|
||||||
|
|
||||||
SITES = []
|
SITES = []
|
||||||
if os.path.isfile("data/sites.json"):
|
if os.path.isfile("data/sites.json"):
|
||||||
with open("data/sites.json") as file:
|
with open("data/sites.json") as file:
|
||||||
SITES = json.load(file)
|
SITES = json.load(file)
|
||||||
# Remove any sites that are not enabled
|
# Remove any sites that are not enabled
|
||||||
SITES = [
|
SITES = [site for site in SITES if "enabled" not in site or site["enabled"]]
|
||||||
site for site in SITES if "enabled" not in site or site["enabled"]
|
|
||||||
]
|
|
||||||
|
|
||||||
PROJECTS = []
|
|
||||||
PROJECTS_UPDATED = 0
|
|
||||||
|
|
||||||
NC_CONFIG = requests.get(
|
|
||||||
"https://cloud.woodburn.au/s/4ToXgFe3TnnFcN7/download/website-conf.json"
|
|
||||||
).json()
|
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
@@ -114,6 +123,13 @@ def asset(path):
|
|||||||
return error_response(request)
|
return error_response(request)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/fonts/<path:path>")
|
||||||
|
def fonts(path):
|
||||||
|
if os.path.isfile("templates/assets/fonts/" + path):
|
||||||
|
return send_from_directory("templates/assets/fonts", path)
|
||||||
|
return error_response(request)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/sitemap")
|
@app.route("/sitemap")
|
||||||
@app.route("/sitemap.xml")
|
@app.route("/sitemap.xml")
|
||||||
def sitemap():
|
def sitemap():
|
||||||
@@ -153,6 +169,7 @@ def download(path):
|
|||||||
|
|
||||||
return error_response(request, message="File not found")
|
return error_response(request, message="File not found")
|
||||||
|
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
# region PWA routes
|
# region PWA routes
|
||||||
|
|
||||||
@@ -177,6 +194,7 @@ def manifest():
|
|||||||
def serviceWorker():
|
def serviceWorker():
|
||||||
return send_from_directory("pwa", "sw.js")
|
return send_from_directory("pwa", "sw.js")
|
||||||
|
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
|
|
||||||
@@ -185,12 +203,14 @@ def serviceWorker():
|
|||||||
def links():
|
def links():
|
||||||
return render_template("link.html")
|
return render_template("link.html")
|
||||||
|
|
||||||
|
|
||||||
@app.route("/actions.json")
|
@app.route("/actions.json")
|
||||||
def sol_actions():
|
def sol_actions():
|
||||||
return jsonify(
|
return jsonify(
|
||||||
{"rules": [{"pathPattern": "/donate**", "apiPath": "/api/v1/donate**"}]}
|
{"rules": [{"pathPattern": "/donate**", "apiPath": "/api/v1/donate**"}]}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/api/<path:function>")
|
@app.route("/api/<path:function>")
|
||||||
def api_legacy(function):
|
def api_legacy(function):
|
||||||
# Check if function is in api blueprint
|
# Check if function is in api blueprint
|
||||||
@@ -200,6 +220,7 @@ def api_legacy(function):
|
|||||||
return redirect(f"/api/v1/{function}", code=301)
|
return redirect(f"/api/v1/{function}", code=301)
|
||||||
return error_response(request, message="404 Not Found", code=404)
|
return error_response(request, message="404 Not Found", code=404)
|
||||||
|
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
# region Main routes
|
# region Main routes
|
||||||
@@ -207,9 +228,6 @@ def api_legacy(function):
|
|||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def index():
|
def index():
|
||||||
global PROJECTS
|
|
||||||
global PROJECTS_UPDATED
|
|
||||||
|
|
||||||
# Check if host if podcast.woodburn.au
|
# Check if host if podcast.woodburn.au
|
||||||
if "podcast.woodburn.au" in request.host:
|
if "podcast.woodburn.au" in request.host:
|
||||||
return render_template("podcast.html")
|
return render_template("podcast.html")
|
||||||
@@ -240,79 +258,22 @@ def index():
|
|||||||
resp.set_cookie("loaded", "true", max_age=604800)
|
resp.set_cookie("loaded", "true", max_age=604800)
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
try:
|
# Use cached git data
|
||||||
git = requests.get(
|
git = get_git_latest_activity()
|
||||||
"https://git.woodburn.au/api/v1/users/nathanwoodburn/activities/feeds?only-performed-by=true&limit=1",
|
repo_name = git["repo"]["name"].lower()
|
||||||
headers={"Authorization": os.getenv("GIT_AUTH")},
|
|
||||||
)
|
|
||||||
git = git.json()
|
|
||||||
git = git[0]
|
|
||||||
repo_name = git["repo"]["name"]
|
|
||||||
repo_name = repo_name.lower()
|
|
||||||
repo_description = git["repo"]["description"]
|
repo_description = git["repo"]["description"]
|
||||||
except Exception as e:
|
|
||||||
repo_name = "nathanwoodburn.github.io"
|
|
||||||
repo_description = "Personal website"
|
|
||||||
git = {
|
|
||||||
"repo": {
|
|
||||||
"html_url": "https://nathan.woodburn.au",
|
|
||||||
"name": "nathanwoodburn.github.io",
|
|
||||||
"description": "Personal website",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print(f"Error getting git data: {e}")
|
|
||||||
|
|
||||||
# Get only repo names for the newest updates
|
# Use cached projects data
|
||||||
if PROJECTS == [] or PROJECTS_UPDATED < (datetime.datetime.now() - datetime.timedelta(
|
projects = get_projects(limit=3)
|
||||||
hours=2
|
|
||||||
)).timestamp():
|
|
||||||
projectsreq = requests.get(
|
|
||||||
"https://git.woodburn.au/api/v1/users/nathanwoodburn/repos"
|
|
||||||
)
|
|
||||||
|
|
||||||
PROJECTS = projectsreq.json()
|
|
||||||
|
|
||||||
# Check for next page
|
|
||||||
pageNum = 1
|
|
||||||
while 'rel="next"' in projectsreq.headers["link"]:
|
|
||||||
projectsreq = requests.get(
|
|
||||||
"https://git.woodburn.au/api/v1/users/nathanwoodburn/repos?page="
|
|
||||||
+ str(pageNum)
|
|
||||||
)
|
|
||||||
PROJECTS += projectsreq.json()
|
|
||||||
pageNum += 1
|
|
||||||
|
|
||||||
for project in PROJECTS:
|
|
||||||
if (
|
|
||||||
project["avatar_url"] == "https://git.woodburn.au/"
|
|
||||||
or project["avatar_url"] == ""
|
|
||||||
):
|
|
||||||
project["avatar_url"] = "/favicon.png"
|
|
||||||
project["name"] = project["name"].replace(
|
|
||||||
"_", " ").replace("-", " ")
|
|
||||||
# Sort by last updated
|
|
||||||
projectsList = sorted(
|
|
||||||
PROJECTS, key=lambda x: x["updated_at"], reverse=True)
|
|
||||||
PROJECTS = []
|
|
||||||
projectNames = []
|
|
||||||
projectNum = 0
|
|
||||||
while len(PROJECTS) < 3:
|
|
||||||
if projectsList[projectNum]["name"] not in projectNames:
|
|
||||||
PROJECTS.append(projectsList[projectNum])
|
|
||||||
projectNames.append(projectsList[projectNum]["name"])
|
|
||||||
projectNum += 1
|
|
||||||
PROJECTS_UPDATED = datetime.datetime.now().timestamp()
|
|
||||||
|
|
||||||
|
# Use cached uptime status
|
||||||
|
uptime = get_uptime_status()
|
||||||
custom = ""
|
custom = ""
|
||||||
# Check for downtime
|
|
||||||
uptime = requests.get(
|
|
||||||
"https://uptime.woodburn.au/api/status-page/main/badge")
|
|
||||||
uptime = uptime.content.count(b"Up") > 1
|
|
||||||
|
|
||||||
if uptime:
|
if uptime:
|
||||||
custom += "<style>#downtime{display:none !important;}</style>"
|
custom += "<style>#downtime{display:none !important;}</style>"
|
||||||
else:
|
else:
|
||||||
custom += "<style>#downtime{opacity:1;}</style>"
|
custom += "<style>#downtime{opacity:1;}</style>"
|
||||||
|
|
||||||
# Special names
|
# Special names
|
||||||
if repo_name == "nathanwoodburn.github.io":
|
if repo_name == "nathanwoodburn.github.io":
|
||||||
repo_name = "Nathan.Woodburn/"
|
repo_name = "Nathan.Woodburn/"
|
||||||
@@ -320,8 +281,9 @@ def index():
|
|||||||
html_url = git["repo"]["html_url"]
|
html_url = git["repo"]["html_url"]
|
||||||
repo = '<a href="' + html_url + '" target="_blank">' + repo_name + "</a>"
|
repo = '<a href="' + html_url + '" target="_blank">' + repo_name + "</a>"
|
||||||
|
|
||||||
# Get time
|
# Get time using cached config
|
||||||
timezone_offset = datetime.timedelta(hours=NC_CONFIG["time-zone"])
|
nc_config = get_nc_config()
|
||||||
|
timezone_offset = datetime.timedelta(hours=nc_config["time-zone"])
|
||||||
timezone = datetime.timezone(offset=timezone_offset)
|
timezone = datetime.timezone(offset=timezone_offset)
|
||||||
time = datetime.datetime.now(tz=timezone)
|
time = datetime.datetime.now(tz=timezone)
|
||||||
|
|
||||||
@@ -344,7 +306,7 @@ def index():
|
|||||||
setInterval(updateClock, 1000);
|
setInterval(updateClock, 1000);
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
time += f"startClock({NC_CONFIG['time-zone']});"
|
time += f"startClock({nc_config['time-zone']});"
|
||||||
time += "</script>"
|
time += "</script>"
|
||||||
|
|
||||||
HNSaddress = getAddress("HNS")
|
HNSaddress = getAddress("HNS")
|
||||||
@@ -364,9 +326,9 @@ def index():
|
|||||||
repo_description=repo_description,
|
repo_description=repo_description,
|
||||||
custom=custom,
|
custom=custom,
|
||||||
sites=SITES,
|
sites=SITES,
|
||||||
projects=PROJECTS,
|
projects=projects,
|
||||||
time=time,
|
time=time,
|
||||||
message=NC_CONFIG.get("message", ""),
|
message=nc_config.get("message", ""),
|
||||||
),
|
),
|
||||||
200,
|
200,
|
||||||
{"Content-Type": "text/html"},
|
{"Content-Type": "text/html"},
|
||||||
@@ -375,6 +337,7 @@ def index():
|
|||||||
|
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
|
||||||
# region Donate
|
# region Donate
|
||||||
|
|
||||||
|
|
||||||
@@ -387,31 +350,25 @@ def donate():
|
|||||||
coinList = [file for file in coinList if file[0] != "."]
|
coinList = [file for file in coinList if file[0] != "."]
|
||||||
coinList.sort()
|
coinList.sort()
|
||||||
|
|
||||||
tokenList = []
|
tokenList = get_wallet_tokens()
|
||||||
|
coinNames = get_coin_names()
|
||||||
with open(".well-known/wallets/.tokens") as file:
|
|
||||||
tokenList = file.read()
|
|
||||||
tokenList = json.loads(tokenList)
|
|
||||||
|
|
||||||
coinNames = {}
|
|
||||||
with open(".well-known/wallets/.coins") as file:
|
|
||||||
coinNames = file.read()
|
|
||||||
coinNames = json.loads(coinNames)
|
|
||||||
|
|
||||||
coins = ""
|
coins = ""
|
||||||
default_coins = ["btc", "eth", "hns", "sol", "xrp", "ada", "dot"]
|
default_coins = ["btc", "eth", "hns", "sol", "xrp", "ada", "dot"]
|
||||||
|
|
||||||
for file in coinList:
|
for file in coinList:
|
||||||
if file in coinNames:
|
coin_name = coinNames.get(file, file)
|
||||||
coins += f'<a class="dropdown-item" style="{"display:none;" if file.lower() not in default_coins else ""}" href="?c={file.lower()}">{coinNames[file]}</a>'
|
display_style = "" if file.lower() in default_coins else "display:none;"
|
||||||
else:
|
coins += f'<a class="dropdown-item" style="{display_style}" href="?c={file.lower()}">{coin_name}</a>'
|
||||||
coins += f'<a class="dropdown-item" style="{"display:none;" if file.lower() not in default_coins else ""}" href="?c={file.lower()}">{file}</a>'
|
|
||||||
|
|
||||||
for token in tokenList:
|
for token in tokenList:
|
||||||
if token["chain"] != "null":
|
chain_display = f" on {token['chain']}" if token["chain"] != "null" else ""
|
||||||
coins += f'<a class="dropdown-item" style="display:none;" href="?t={token["symbol"].lower()}&c={token["chain"].lower()}">{token["name"]} ({token["symbol"] + " on " if token["symbol"] != token["name"] else ""}{token["chain"]})</a>'
|
symbol_display = (
|
||||||
else:
|
f" ({token['symbol']}{chain_display})"
|
||||||
coins += f'<a class="dropdown-item" style="display:none;" href="?t={token["symbol"].lower()}&c={token["chain"].lower()}">{token["name"]} ({token["symbol"] if token["symbol"] != token["name"] else ""})</a>'
|
if token["symbol"] != token["name"]
|
||||||
|
else chain_display
|
||||||
|
)
|
||||||
|
coins += f'<a class="dropdown-item" style="display:none;" href="?t={token["symbol"].lower()}&c={token["chain"].lower()}">{token["name"]}{symbol_display}</a>'
|
||||||
|
|
||||||
crypto = request.args.get("c")
|
crypto = request.args.get("c")
|
||||||
if not crypto:
|
if not crypto:
|
||||||
@@ -438,7 +395,6 @@ def donate():
|
|||||||
token = {"name": "Unknown token", "symbol": token, "chain": crypto}
|
token = {"name": "Unknown token", "symbol": token, "chain": crypto}
|
||||||
|
|
||||||
address = ""
|
address = ""
|
||||||
domain = ""
|
|
||||||
cryptoHTML = ""
|
cryptoHTML = ""
|
||||||
|
|
||||||
proof = ""
|
proof = ""
|
||||||
@@ -448,10 +404,16 @@ def donate():
|
|||||||
if os.path.isfile(f".well-known/wallets/{crypto}"):
|
if os.path.isfile(f".well-known/wallets/{crypto}"):
|
||||||
with open(f".well-known/wallets/{crypto}") as file:
|
with open(f".well-known/wallets/{crypto}") as file:
|
||||||
address = file.read()
|
address = file.read()
|
||||||
|
coin_display = coinNames.get(crypto, crypto)
|
||||||
if not token:
|
if not token:
|
||||||
cryptoHTML += f"<br>Donate with {coinNames[crypto] if crypto in coinNames else crypto}:"
|
cryptoHTML += f"<br>Donate with {coin_display}:"
|
||||||
else:
|
else:
|
||||||
cryptoHTML += f'<br>Donate with {token["name"]} {"("+token["symbol"]+") " if token["symbol"] != token["name"] else ""}on {crypto}:'
|
token_symbol = (
|
||||||
|
f" ({token['symbol']})" if token["symbol"] != token["name"] else ""
|
||||||
|
)
|
||||||
|
cryptoHTML += (
|
||||||
|
f"<br>Donate with {token['name']}{token_symbol} on {crypto}:"
|
||||||
|
)
|
||||||
cryptoHTML += f'<br><code data-bs-toggle="tooltip" data-bss-tooltip="" id="crypto-address" class="address" style="color: rgb(242,90,5);display: inline-block;" data-bs-original-title="Click to copy">{address}</code>'
|
cryptoHTML += f'<br><code data-bs-toggle="tooltip" data-bss-tooltip="" id="crypto-address" class="address" style="color: rgb(242,90,5);display: inline-block;" data-bs-original-title="Click to copy">{address}</code>'
|
||||||
|
|
||||||
if proof:
|
if proof:
|
||||||
@@ -459,25 +421,27 @@ def donate():
|
|||||||
elif token:
|
elif token:
|
||||||
if "address" in token:
|
if "address" in token:
|
||||||
address = token["address"]
|
address = token["address"]
|
||||||
cryptoHTML += f'<br>Donate with {token["name"]} {"("+token["symbol"]+")" if token["symbol"] != token["name"] else ""}{" on "+crypto if crypto != "NULL" else ""}:'
|
token_symbol = (
|
||||||
|
f" ({token['symbol']})" if token["symbol"] != token["name"] else ""
|
||||||
|
)
|
||||||
|
chain_display = f" on {crypto}" if crypto != "NULL" else ""
|
||||||
|
cryptoHTML += (
|
||||||
|
f"<br>Donate with {token['name']}{token_symbol}{chain_display}:"
|
||||||
|
)
|
||||||
cryptoHTML += f'<br><code data-bs-toggle="tooltip" data-bss-tooltip="" id="crypto-address" class="address" style="color: rgb(242,90,5);display: inline-block;" data-bs-original-title="Click to copy">{address}</code>'
|
cryptoHTML += f'<br><code data-bs-toggle="tooltip" data-bss-tooltip="" id="crypto-address" class="address" style="color: rgb(242,90,5);display: inline-block;" data-bs-original-title="Click to copy">{address}</code>'
|
||||||
if proof:
|
if proof:
|
||||||
cryptoHTML += proof
|
cryptoHTML += proof
|
||||||
else:
|
else:
|
||||||
cryptoHTML += f'<br>Invalid offchain token: {token["symbol"]}<br>'
|
cryptoHTML += f"<br>Invalid offchain token: {token['symbol']}<br>"
|
||||||
else:
|
else:
|
||||||
cryptoHTML += f"<br>Invalid chain: {crypto}<br>"
|
cryptoHTML += f"<br>Invalid chain: {crypto}<br>"
|
||||||
|
|
||||||
if os.path.isfile(".well-known/wallets/.domains"):
|
domains = get_wallet_domains()
|
||||||
# Get json of all domains
|
|
||||||
with open(".well-known/wallets/.domains") as file:
|
|
||||||
domains = file.read()
|
|
||||||
domains = json.loads(domains)
|
|
||||||
|
|
||||||
if crypto in domains:
|
if crypto in domains:
|
||||||
domain = domains[crypto]
|
domain = domains[crypto]
|
||||||
cryptoHTML += "<br>Or send to this domain on compatible wallets:<br>"
|
cryptoHTML += "<br>Or send to this domain on compatible wallets:<br>"
|
||||||
cryptoHTML += f'<code data-bs-toggle="tooltip" data-bss-tooltip="" id="crypto-domain" class="address" style="color: rgb(242,90,5);display: block;" data-bs-original-title="Click to copy">{domain}</code>'
|
cryptoHTML += f'<code data-bs-toggle="tooltip" data-bss-tooltip="" id="crypto-domain" class="address" style="color: rgb(242,90,5);display: block;" data-bs-original-title="Click to copy">{domain}</code>'
|
||||||
|
|
||||||
if address:
|
if address:
|
||||||
cryptoHTML += (
|
cryptoHTML += (
|
||||||
'<br><img src="/address/'
|
'<br><img src="/address/'
|
||||||
@@ -520,27 +484,30 @@ def qraddress(address):
|
|||||||
@app.route("/qrcode/<path:data>")
|
@app.route("/qrcode/<path:data>")
|
||||||
@app.route("/qr/<path:data>")
|
@app.route("/qr/<path:data>")
|
||||||
def qrcodee(data):
|
def qrcodee(data):
|
||||||
qr = qrcode.QRCode(
|
qr = qrcode.QRCode(error_correction=ERROR_CORRECT_H, box_size=10, border=2)
|
||||||
error_correction=ERROR_CORRECT_H, box_size=10, border=2)
|
|
||||||
qr.add_data(data)
|
qr.add_data(data)
|
||||||
qr.make()
|
qr.make()
|
||||||
|
|
||||||
qr_image: Image.Image = qr.make_image(
|
qr_image: Image.Image = qr.make_image(
|
||||||
fill_color="black", back_color="white").convert('RGB') # type: ignore
|
fill_color="black", back_color="white"
|
||||||
|
).convert("RGB") # type: ignore
|
||||||
|
|
||||||
# Add logo
|
# Add logo
|
||||||
logo = Image.open("templates/assets/img/favicon/logo.png")
|
logo = Image.open("templates/assets/img/favicon/logo.png")
|
||||||
basewidth = qr_image.size[0] // 3
|
basewidth = qr_image.size[0] // 3
|
||||||
wpercent = (basewidth / float(logo.size[0]))
|
wpercent = basewidth / float(logo.size[0])
|
||||||
hsize = int((float(logo.size[1]) * float(wpercent)))
|
hsize = int((float(logo.size[1]) * float(wpercent)))
|
||||||
logo = logo.resize((basewidth, hsize), Image.Resampling.LANCZOS)
|
logo = logo.resize((basewidth, hsize), Image.Resampling.LANCZOS)
|
||||||
pos = ((qr_image.size[0] - logo.size[0]) // 2,
|
pos = (
|
||||||
(qr_image.size[1] - logo.size[1]) // 2)
|
(qr_image.size[0] - logo.size[0]) // 2,
|
||||||
|
(qr_image.size[1] - logo.size[1]) // 2,
|
||||||
|
)
|
||||||
qr_image.paste(logo, pos, mask=logo)
|
qr_image.paste(logo, pos, mask=logo)
|
||||||
|
|
||||||
qr_image.save("/tmp/qr_code.png")
|
qr_image.save("/tmp/qr_code.png")
|
||||||
return send_file("/tmp/qr_code.png", mimetype="image/png")
|
return send_file("/tmp/qr_code.png", mimetype="image/png")
|
||||||
|
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
|
|
||||||
@@ -580,15 +547,18 @@ def hosting_post():
|
|||||||
|
|
||||||
# Check email rate limit
|
# Check email rate limit
|
||||||
if email in EMAIL_REQUEST_COUNT:
|
if email in EMAIL_REQUEST_COUNT:
|
||||||
if (current_time - EMAIL_REQUEST_COUNT[email]["last_reset"]) > RATE_LIMIT_WINDOW:
|
if (
|
||||||
|
current_time - EMAIL_REQUEST_COUNT[email]["last_reset"]
|
||||||
|
) > RATE_LIMIT_WINDOW:
|
||||||
# Reset counter if the time window has passed
|
# Reset counter if the time window has passed
|
||||||
EMAIL_REQUEST_COUNT[email] = {
|
EMAIL_REQUEST_COUNT[email] = {"count": 1, "last_reset": current_time}
|
||||||
"count": 1, "last_reset": current_time}
|
|
||||||
else:
|
else:
|
||||||
# Increment counter
|
# Increment counter
|
||||||
EMAIL_REQUEST_COUNT[email]["count"] += 1
|
EMAIL_REQUEST_COUNT[email]["count"] += 1
|
||||||
if EMAIL_REQUEST_COUNT[email]["count"] > EMAIL_RATE_LIMIT:
|
if EMAIL_REQUEST_COUNT[email]["count"] > EMAIL_RATE_LIMIT:
|
||||||
return json_response(request, "Rate limit exceeded. Please try again later.", 429)
|
return json_response(
|
||||||
|
request, "Rate limit exceeded. Please try again later.", 429
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
# First request for this email
|
# First request for this email
|
||||||
EMAIL_REQUEST_COUNT[email] = {"count": 1, "last_reset": current_time}
|
EMAIL_REQUEST_COUNT[email] = {"count": 1, "last_reset": current_time}
|
||||||
@@ -602,7 +572,9 @@ def hosting_post():
|
|||||||
# Increment counter
|
# Increment counter
|
||||||
IP_REQUEST_COUNT[ip]["count"] += 1
|
IP_REQUEST_COUNT[ip]["count"] += 1
|
||||||
if IP_REQUEST_COUNT[ip]["count"] > IP_RATE_LIMIT:
|
if IP_REQUEST_COUNT[ip]["count"] > IP_RATE_LIMIT:
|
||||||
return json_response(request, "Rate limit exceeded. Please try again later.", 429)
|
return json_response(
|
||||||
|
request, "Rate limit exceeded. Please try again later.", 429
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
# First request for this IP
|
# First request for this IP
|
||||||
IP_REQUEST_COUNT[ip] = {"count": 1, "last_reset": current_time}
|
IP_REQUEST_COUNT[ip] = {"count": 1, "last_reset": current_time}
|
||||||
@@ -661,12 +633,13 @@ def hosting_post():
|
|||||||
return json_response(request, "Failed to send enquiry", 500)
|
return json_response(request, "Failed to send enquiry", 500)
|
||||||
return json_response(request, "Enquiry sent", 200)
|
return json_response(request, "Enquiry sent", 200)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/resume")
|
@app.route("/resume")
|
||||||
def resume():
|
def resume():
|
||||||
# Check if arg for support is passed
|
# Check if arg for support is passed
|
||||||
support = request.args.get("support")
|
support = request.args.get("support")
|
||||||
return render_template(
|
return render_template("resume.html", support=support)
|
||||||
"resume.html", support=support)
|
|
||||||
|
|
||||||
@app.route("/resume.pdf")
|
@app.route("/resume.pdf")
|
||||||
def resume_pdf():
|
def resume_pdf():
|
||||||
@@ -683,13 +656,14 @@ def tools():
|
|||||||
return curl_response(request)
|
return curl_response(request)
|
||||||
return render_template("tools.html", tools=get_tools_data())
|
return render_template("tools.html", tools=get_tools_data())
|
||||||
|
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
# region Error Catching
|
# region Error Catching
|
||||||
|
|
||||||
|
|
||||||
# Catch all for GET requests
|
# Catch all for GET requests
|
||||||
@app.route("/<path:path>")
|
@app.route("/<path:path>")
|
||||||
def catch_all(path: str):
|
def catch_all(path: str):
|
||||||
|
|
||||||
if path.lower().replace(".html", "") in RESTRICTED_ROUTES:
|
if path.lower().replace(".html", "") in RESTRICTED_ROUTES:
|
||||||
return error_response(request, message="Restricted route", code=403)
|
return error_response(request, message="Restricted route", code=403)
|
||||||
|
|
||||||
@@ -702,17 +676,23 @@ def catch_all(path: str):
|
|||||||
|
|
||||||
# If file exists, load it
|
# If file exists, load it
|
||||||
if os.path.isfile("templates/" + path):
|
if os.path.isfile("templates/" + path):
|
||||||
return render_template(path, handshake_scripts=getHandshakeScript(request.host), sites=SITES)
|
return render_template(
|
||||||
|
path, handshake_scripts=getHandshakeScript(request.host), sites=SITES
|
||||||
|
)
|
||||||
|
|
||||||
# Try with .html
|
# Try with .html
|
||||||
if os.path.isfile("templates/" + path + ".html"):
|
if os.path.isfile("templates/" + path + ".html"):
|
||||||
return render_template(
|
return render_template(
|
||||||
path + ".html", handshake_scripts=getHandshakeScript(request.host), sites=SITES
|
path + ".html",
|
||||||
|
handshake_scripts=getHandshakeScript(request.host),
|
||||||
|
sites=SITES,
|
||||||
)
|
)
|
||||||
|
|
||||||
if os.path.isfile("templates/" + path.strip("/") + ".html"):
|
if os.path.isfile("templates/" + path.strip("/") + ".html"):
|
||||||
return render_template(
|
return render_template(
|
||||||
path.strip("/") + ".html", handshake_scripts=getHandshakeScript(request.host), sites=SITES
|
path.strip("/") + ".html",
|
||||||
|
handshake_scripts=getHandshakeScript(request.host),
|
||||||
|
sites=SITES,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Try to find a file matching
|
# Try to find a file matching
|
||||||
@@ -729,6 +709,7 @@ def catch_all(path: str):
|
|||||||
def not_found(e):
|
def not_found(e):
|
||||||
return error_response(request)
|
return error_response(request)
|
||||||
|
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
167
templates/now/25_11_20.html
Normal file
167
templates/now/25_11_20.html
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html data-bs-theme="light" lang="en-au" style="background: black;height: auto;">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
|
||||||
|
<title>What's up at the moment | Nathan.Woodburn/</title>
|
||||||
|
<meta name="theme-color" content="#000000">
|
||||||
|
<link rel="canonical" href="https://nathan.woodburn.au/now/25_11_20">
|
||||||
|
<meta property="og:url" content="https://nathan.woodburn.au/now/25_11_20">
|
||||||
|
<meta name="fediverse:creator" content="@nathanwoodburn@mastodon.woodburn.au">
|
||||||
|
<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 property="og:image" content="https://nathan.woodburn.au/assets/img/profile.jpg">
|
||||||
|
<meta property="og:description" content="G'day,
|
||||||
|
Find out what I've been up to in the last little bit">
|
||||||
|
<meta name="twitter:title" content="What's up at the moment | Nathan.Woodburn/">
|
||||||
|
<meta property="og:title" content="What's up at the moment | Nathan.Woodburn/">
|
||||||
|
<meta name="description" content="G'day,
|
||||||
|
Find out what I've been up to in the last little bit">
|
||||||
|
<meta name="twitter:description" content="G'day,
|
||||||
|
Find out what I've been up to in the last little bit">
|
||||||
|
<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/fonts/ionicons.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 class="text-center" style="background: linear-gradient(rgba(0,0,0,0.80), rgba(0,0,0,0.80)), url("/assets/img/bg/background.webp") center / cover no-repeat;">
|
||||||
|
<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>{{handshake_scripts | safe}}
|
||||||
|
<div style="height: 10em;"></div>
|
||||||
|
<div class="profile-container" style="margin-bottom: 2em;"><img class="profile background" src="/assets/img/profile.jpg" style="border-radius: 50%;"><img class="profile foreground" src="/assets/img/pfront.webp"></div>
|
||||||
|
<h1 class="nathanwoodburn" style="margin-bottom: 0px;">Nathan.Woodburn/</h1>
|
||||||
|
<h3 style="margin-bottom: 0px;">WHat's Happening Now</h3>
|
||||||
|
<h6>{{DATE}}</h6>
|
||||||
|
<section style="margin-bottom: 50px;max-width: 95%;margin-right: auto;margin-left: auto;">
|
||||||
|
<div style="max-width: 700px;margin: auto;">
|
||||||
|
<h1 style="margin-bottom: 0px;">Starting at CSIRO</h1>
|
||||||
|
<p>I’m excited to share that I'm starting a new position at CSIRO as a Web Hosting System Administrator. It’s a role that sits right at the intersection of technology, security, and supporting the research happening across the organisation.</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<section style="margin-bottom: 50px;max-width: 95%;margin-right: auto;margin-left: auto;">
|
||||||
|
<div style="max-width: 700px;margin: auto;">
|
||||||
|
<h1 style="margin-bottom: 0px;">Website Updates</h1>
|
||||||
|
<p>I've updated my python3 flask website code to use UV for the package manager. It has cut down the initial install and startup from over 30s to under 10. This also makes building the docker image quicker and more consistent.</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<section class="text-center content-section" id="contact" style="padding-top: 0px;padding-bottom: 3em;">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-8 d-none d-print-block d-sm-block d-md-block d-lg-block d-xl-block d-xxl-block mx-auto">
|
||||||
|
<div class="social-div">
|
||||||
|
<ul class="list-unstyled social-list">
|
||||||
|
<li class="social-link"><a href="https://twitter.com/woodburn_nathan" target="_blank"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" viewBox="0 0 16 16" class="bi bi-twitter-x icon">
|
||||||
|
<path d="M12.6.75h2.454l-5.36 6.142L16 15.25h-4.937l-3.867-5.07-4.425 5.07H.316l5.733-6.57L0 .75h5.063l3.495 4.633L12.601.75Zm-.86 13.028h1.36L4.323 2.145H2.865l8.875 11.633Z"></path>
|
||||||
|
</svg></a></li>
|
||||||
|
<li class="social-link"><a href="https://github.com/Nathanwoodburn" target="_blank"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" viewBox="0 0 16 16" class="bi bi-github icon">
|
||||||
|
<path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8"></path>
|
||||||
|
</svg></a></li>
|
||||||
|
<li class="social-link"><a href="mailto:about@nathan.woodburn.au" target="_blank"><i class="icon ion-email icon"></i></a></li>
|
||||||
|
<li class="social-link discord"><a href="https://l.woodburn.au/discord" target="_blank"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" viewBox="0 0 16 16" class="bi bi-discord icon">
|
||||||
|
<path d="M13.545 2.907a13.227 13.227 0 0 0-3.257-1.011.05.05 0 0 0-.052.025c-.141.25-.297.577-.406.833a12.19 12.19 0 0 0-3.658 0 8.258 8.258 0 0 0-.412-.833.051.051 0 0 0-.052-.025c-1.125.194-2.22.534-3.257 1.011a.041.041 0 0 0-.021.018C.356 6.024-.213 9.047.066 12.032c.001.014.01.028.021.037a13.276 13.276 0 0 0 3.995 2.02.05.05 0 0 0 .056-.019c.308-.42.582-.863.818-1.329a.05.05 0 0 0-.01-.059.051.051 0 0 0-.018-.011 8.875 8.875 0 0 1-1.248-.595.05.05 0 0 1-.02-.066.051.051 0 0 1 .015-.019c.084-.063.168-.129.248-.195a.05.05 0 0 1 .051-.007c2.619 1.196 5.454 1.196 8.041 0a.052.052 0 0 1 .053.007c.08.066.164.132.248.195a.051.051 0 0 1-.004.085 8.254 8.254 0 0 1-1.249.594.05.05 0 0 0-.03.03.052.052 0 0 0 .003.041c.24.465.515.909.817 1.329a.05.05 0 0 0 .056.019 13.235 13.235 0 0 0 4.001-2.02.049.049 0 0 0 .021-.037c.334-3.451-.559-6.449-2.366-9.106a.034.034 0 0 0-.02-.019Zm-8.198 7.307c-.789 0-1.438-.724-1.438-1.612 0-.889.637-1.613 1.438-1.613.807 0 1.45.73 1.438 1.613 0 .888-.637 1.612-1.438 1.612m5.316 0c-.788 0-1.438-.724-1.438-1.612 0-.889.637-1.613 1.438-1.613.807 0 1.451.73 1.438 1.613 0 .888-.631 1.612-1.438 1.612"></path>
|
||||||
|
</svg></a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="social-div">
|
||||||
|
<ul class="list-unstyled social-list">
|
||||||
|
<li class="social-link mastodon"><a href="https://mastodon.woodburn.au/@nathanwoodburn" target="_blank"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" viewBox="0 0 16 16" class="bi bi-mastodon icon">
|
||||||
|
<path d="M11.19 12.195c2.016-.24 3.77-1.475 3.99-2.603.348-1.778.32-4.339.32-4.339 0-3.47-2.286-4.488-2.286-4.488C12.062.238 10.083.017 8.027 0h-.05C5.92.017 3.942.238 2.79.765c0 0-2.285 1.017-2.285 4.488l-.002.662c-.004.64-.007 1.35.011 2.091.083 3.394.626 6.74 3.78 7.57 1.454.383 2.703.463 3.709.408 1.823-.1 2.847-.647 2.847-.647l-.06-1.317s-1.303.41-2.767.36c-1.45-.05-2.98-.156-3.215-1.928a3.614 3.614 0 0 1-.033-.496s1.424.346 3.228.428c1.103.05 2.137-.064 3.188-.189zm1.613-2.47H11.13v-4.08c0-.859-.364-1.295-1.091-1.295-.804 0-1.207.517-1.207 1.541v2.233H7.168V5.89c0-1.024-.403-1.541-1.207-1.541-.727 0-1.091.436-1.091 1.296v4.079H3.197V5.522c0-.859.22-1.541.66-2.046.456-.505 1.052-.764 1.793-.764.856 0 1.504.328 1.933.983L8 4.39l.417-.695c.429-.655 1.077-.983 1.934-.983.74 0 1.336.259 1.791.764.442.505.661 1.187.661 2.046v4.203z"></path>
|
||||||
|
</svg></a></li>
|
||||||
|
<li class="social-link youtube"><a href="https://www.youtube.com/@nathanjwoodburn" target="_blank"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" viewBox="0 0 16 16" class="bi bi-youtube icon">
|
||||||
|
<path d="M8.051 1.999h.089c.822.003 4.987.033 6.11.335a2.01 2.01 0 0 1 1.415 1.42c.101.38.172.883.22 1.402l.01.104.022.26.008.104c.065.914.073 1.77.074 1.957v.075c-.001.194-.01 1.108-.082 2.06l-.008.105-.009.104c-.05.572-.124 1.14-.235 1.558a2.007 2.007 0 0 1-1.415 1.42c-1.16.312-5.569.334-6.18.335h-.142c-.309 0-1.587-.006-2.927-.052l-.17-.006-.087-.004-.171-.007-.171-.007c-1.11-.049-2.167-.128-2.654-.26a2.007 2.007 0 0 1-1.415-1.419c-.111-.417-.185-.986-.235-1.558L.09 9.82l-.008-.104A31.4 31.4 0 0 1 0 7.68v-.123c.002-.215.01-.958.064-1.778l.007-.103.003-.052.008-.104.022-.26.01-.104c.048-.519.119-1.023.22-1.402a2.007 2.007 0 0 1 1.415-1.42c.487-.13 1.544-.21 2.654-.26l.17-.007.172-.006.086-.003.171-.007A99.788 99.788 0 0 1 7.858 2h.193zM6.4 5.209v4.818l4.157-2.408z"></path>
|
||||||
|
</svg></a></li>
|
||||||
|
<li class="social-link signal"><a href="/signalQR" target="_blank"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" viewBox="0 0 16 16" class="bi bi-signal icon">
|
||||||
|
<path d="m6.08.234.179.727a7.264 7.264 0 0 0-2.01.832l-.383-.643A7.9 7.9 0 0 1 6.079.234zm3.84 0L9.742.96a7.265 7.265 0 0 1 2.01.832l.388-.643A7.957 7.957 0 0 0 9.92.234zm-8.77 3.63a7.944 7.944 0 0 0-.916 2.215l.727.18a7.264 7.264 0 0 1 .832-2.01l-.643-.386zM.75 8a7.3 7.3 0 0 1 .081-1.086L.091 6.8a8 8 0 0 0 0 2.398l.74-.112A7.262 7.262 0 0 1 .75 8m11.384 6.848-.384-.64a7.23 7.23 0 0 1-2.007.831l.18.728a7.965 7.965 0 0 0 2.211-.919zM15.251 8c0 .364-.028.727-.082 1.086l.74.112a7.966 7.966 0 0 0 0-2.398l-.74.114c.054.36.082.722.082 1.086m.516 1.918-.728-.18a7.252 7.252 0 0 1-.832 2.012l.643.387a7.933 7.933 0 0 0 .917-2.219zm-6.68 5.25c-.72.11-1.453.11-2.173 0l-.112.742a7.99 7.99 0 0 0 2.396 0l-.112-.741zm4.75-2.868a7.229 7.229 0 0 1-1.537 1.534l.446.605a8.07 8.07 0 0 0 1.695-1.689l-.604-.45zM12.3 2.163c.587.432 1.105.95 1.537 1.537l.604-.45a8.06 8.06 0 0 0-1.69-1.691l-.45.604zM2.163 3.7A7.242 7.242 0 0 1 3.7 2.163l-.45-.604a8.06 8.06 0 0 0-1.691 1.69l.604.45zm12.688.163-.644.387c.377.623.658 1.3.832 2.007l.728-.18a7.931 7.931 0 0 0-.916-2.214M6.913.831a7.254 7.254 0 0 1 2.172 0l.112-.74a7.985 7.985 0 0 0-2.396 0l.112.74zM2.547 14.64 1 15l.36-1.549-.729-.17-.361 1.548a.75.75 0 0 0 .9.902l1.548-.357-.17-.734zM.786 12.612l.732.168.25-1.073A7.187 7.187 0 0 1 .96 9.74l-.727.18a8 8 0 0 0 .736 1.902l-.184.79zm3.5 1.623-1.073.25.17.731.79-.184c.6.327 1.239.574 1.902.737l.18-.728a7.197 7.197 0 0 1-1.962-.811l-.007.005zM8 1.5a6.502 6.502 0 0 0-6.498 6.502 6.516 6.516 0 0 0 .998 3.455l-.625 2.668L4.54 13.5a6.502 6.502 0 0 0 6.93-11A6.516 6.516 0 0 0 8 1.5"></path>
|
||||||
|
</svg></a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-8 d-block d-print-none d-sm-none d-md-none d-lg-none d-xl-none d-xxl-none mx-auto">
|
||||||
|
<div class="social-div">
|
||||||
|
<ul class="list-unstyled social-list-sml">
|
||||||
|
<li class="social-link-sml"><a href="https://twitter.com/woodburn_nathan" target="_blank"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" viewBox="0 0 16 16" class="bi bi-twitter-x icon-sml">
|
||||||
|
<path d="M12.6.75h2.454l-5.36 6.142L16 15.25h-4.937l-3.867-5.07-4.425 5.07H.316l5.733-6.57L0 .75h5.063l3.495 4.633L12.601.75Zm-.86 13.028h1.36L4.323 2.145H2.865l8.875 11.633Z"></path>
|
||||||
|
</svg></a></li>
|
||||||
|
<li class="social-link-sml"><a href="https://github.com/Nathanwoodburn" target="_blank"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" viewBox="0 0 16 16" class="bi bi-github icon-sml">
|
||||||
|
<path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8"></path>
|
||||||
|
</svg></a></li>
|
||||||
|
<li class="social-link-sml"><a href="mailto:about@nathan.woodburn.au" target="_blank"><i class="icon ion-email icon-sml"></i></a></li>
|
||||||
|
<li class="discord social-link-sml"><a href="https://l.woodburn.au/discord" target="_blank"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" viewBox="0 0 16 16" class="bi bi-discord icon-sml">
|
||||||
|
<path d="M13.545 2.907a13.227 13.227 0 0 0-3.257-1.011.05.05 0 0 0-.052.025c-.141.25-.297.577-.406.833a12.19 12.19 0 0 0-3.658 0 8.258 8.258 0 0 0-.412-.833.051.051 0 0 0-.052-.025c-1.125.194-2.22.534-3.257 1.011a.041.041 0 0 0-.021.018C.356 6.024-.213 9.047.066 12.032c.001.014.01.028.021.037a13.276 13.276 0 0 0 3.995 2.02.05.05 0 0 0 .056-.019c.308-.42.582-.863.818-1.329a.05.05 0 0 0-.01-.059.051.051 0 0 0-.018-.011 8.875 8.875 0 0 1-1.248-.595.05.05 0 0 1-.02-.066.051.051 0 0 1 .015-.019c.084-.063.168-.129.248-.195a.05.05 0 0 1 .051-.007c2.619 1.196 5.454 1.196 8.041 0a.052.052 0 0 1 .053.007c.08.066.164.132.248.195a.051.051 0 0 1-.004.085 8.254 8.254 0 0 1-1.249.594.05.05 0 0 0-.03.03.052.052 0 0 0 .003.041c.24.465.515.909.817 1.329a.05.05 0 0 0 .056.019 13.235 13.235 0 0 0 4.001-2.02.049.049 0 0 0 .021-.037c.334-3.451-.559-6.449-2.366-9.106a.034.034 0 0 0-.02-.019Zm-8.198 7.307c-.789 0-1.438-.724-1.438-1.612 0-.889.637-1.613 1.438-1.613.807 0 1.45.73 1.438 1.613 0 .888-.637 1.612-1.438 1.612m5.316 0c-.788 0-1.438-.724-1.438-1.612 0-.889.637-1.613 1.438-1.613.807 0 1.451.73 1.438 1.613 0 .888-.631 1.612-1.438 1.612"></path>
|
||||||
|
</svg></a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="social-div">
|
||||||
|
<ul class="list-unstyled social-list-sml">
|
||||||
|
<li class="mastodon social-link-sml"><a href="https://mastodon.woodburn.au/@nathanwoodburn" target="_blank"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" viewBox="0 0 16 16" class="bi bi-mastodon icon-sml">
|
||||||
|
<path d="M11.19 12.195c2.016-.24 3.77-1.475 3.99-2.603.348-1.778.32-4.339.32-4.339 0-3.47-2.286-4.488-2.286-4.488C12.062.238 10.083.017 8.027 0h-.05C5.92.017 3.942.238 2.79.765c0 0-2.285 1.017-2.285 4.488l-.002.662c-.004.64-.007 1.35.011 2.091.083 3.394.626 6.74 3.78 7.57 1.454.383 2.703.463 3.709.408 1.823-.1 2.847-.647 2.847-.647l-.06-1.317s-1.303.41-2.767.36c-1.45-.05-2.98-.156-3.215-1.928a3.614 3.614 0 0 1-.033-.496s1.424.346 3.228.428c1.103.05 2.137-.064 3.188-.189zm1.613-2.47H11.13v-4.08c0-.859-.364-1.295-1.091-1.295-.804 0-1.207.517-1.207 1.541v2.233H7.168V5.89c0-1.024-.403-1.541-1.207-1.541-.727 0-1.091.436-1.091 1.296v4.079H3.197V5.522c0-.859.22-1.541.66-2.046.456-.505 1.052-.764 1.793-.764.856 0 1.504.328 1.933.983L8 4.39l.417-.695c.429-.655 1.077-.983 1.934-.983.74 0 1.336.259 1.791.764.442.505.661 1.187.661 2.046v4.203z"></path>
|
||||||
|
</svg></a></li>
|
||||||
|
<li class="youtube social-link-sml"><a href="https://www.youtube.com/@nathanjwoodburn" target="_blank"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" viewBox="0 0 16 16" class="bi bi-youtube icon-sml">
|
||||||
|
<path d="M8.051 1.999h.089c.822.003 4.987.033 6.11.335a2.01 2.01 0 0 1 1.415 1.42c.101.38.172.883.22 1.402l.01.104.022.26.008.104c.065.914.073 1.77.074 1.957v.075c-.001.194-.01 1.108-.082 2.06l-.008.105-.009.104c-.05.572-.124 1.14-.235 1.558a2.007 2.007 0 0 1-1.415 1.42c-1.16.312-5.569.334-6.18.335h-.142c-.309 0-1.587-.006-2.927-.052l-.17-.006-.087-.004-.171-.007-.171-.007c-1.11-.049-2.167-.128-2.654-.26a2.007 2.007 0 0 1-1.415-1.419c-.111-.417-.185-.986-.235-1.558L.09 9.82l-.008-.104A31.4 31.4 0 0 1 0 7.68v-.123c.002-.215.01-.958.064-1.778l.007-.103.003-.052.008-.104.022-.26.01-.104c.048-.519.119-1.023.22-1.402a2.007 2.007 0 0 1 1.415-1.42c.487-.13 1.544-.21 2.654-.26l.17-.007.172-.006.086-.003.171-.007A99.788 99.788 0 0 1 7.858 2h.193zM6.4 5.209v4.818l4.157-2.408z"></path>
|
||||||
|
</svg></a></li>
|
||||||
|
<li class="signal social-link-sml"><a href="/signalQR" target="_blank"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" viewBox="0 0 16 16" class="bi bi-signal icon-sml">
|
||||||
|
<path d="m6.08.234.179.727a7.264 7.264 0 0 0-2.01.832l-.383-.643A7.9 7.9 0 0 1 6.079.234zm3.84 0L9.742.96a7.265 7.265 0 0 1 2.01.832l.388-.643A7.957 7.957 0 0 0 9.92.234zm-8.77 3.63a7.944 7.944 0 0 0-.916 2.215l.727.18a7.264 7.264 0 0 1 .832-2.01l-.643-.386zM.75 8a7.3 7.3 0 0 1 .081-1.086L.091 6.8a8 8 0 0 0 0 2.398l.74-.112A7.262 7.262 0 0 1 .75 8m11.384 6.848-.384-.64a7.23 7.23 0 0 1-2.007.831l.18.728a7.965 7.965 0 0 0 2.211-.919zM15.251 8c0 .364-.028.727-.082 1.086l.74.112a7.966 7.966 0 0 0 0-2.398l-.74.114c.054.36.082.722.082 1.086m.516 1.918-.728-.18a7.252 7.252 0 0 1-.832 2.012l.643.387a7.933 7.933 0 0 0 .917-2.219zm-6.68 5.25c-.72.11-1.453.11-2.173 0l-.112.742a7.99 7.99 0 0 0 2.396 0l-.112-.741zm4.75-2.868a7.229 7.229 0 0 1-1.537 1.534l.446.605a8.07 8.07 0 0 0 1.695-1.689l-.604-.45zM12.3 2.163c.587.432 1.105.95 1.537 1.537l.604-.45a8.06 8.06 0 0 0-1.69-1.691l-.45.604zM2.163 3.7A7.242 7.242 0 0 1 3.7 2.163l-.45-.604a8.06 8.06 0 0 0-1.691 1.69l.604.45zm12.688.163-.644.387c.377.623.658 1.3.832 2.007l.728-.18a7.931 7.931 0 0 0-.916-2.214M6.913.831a7.254 7.254 0 0 1 2.172 0l.112-.74a7.985 7.985 0 0 0-2.396 0l.112.74zM2.547 14.64 1 15l.36-1.549-.729-.17-.361 1.548a.75.75 0 0 0 .9.902l1.548-.357-.17-.734zM.786 12.612l.732.168.25-1.073A7.187 7.187 0 0 1 .96 9.74l-.727.18a8 8 0 0 0 .736 1.902l-.184.79zm3.5 1.623-1.073.25.17.731.79-.184c.6.327 1.239.574 1.902.737l.18-.728a7.197 7.197 0 0 1-1.962-.811l-.007.005zM8 1.5a6.502 6.502 0 0 0-6.498 6.502 6.516 6.516 0 0 0 .998 3.455l-.625 2.668L4.54 13.5a6.502 6.502 0 0 0 6.93-11A6.516 6.516 0 0 0 8 1.5"></path>
|
||||||
|
</svg></a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<footer style="background: #110033;">
|
||||||
|
<div class="container text-center">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<p class="d-none d-print-inline-block d-sm-inline-block d-md-inline-block d-lg-inline-block d-xl-inline-block d-xxl-inline-block">Want to look at some past Now pages?<br>Check out <a href="/old">/old</a></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<p class="d-none d-print-inline-block d-sm-inline-block d-md-inline-block d-lg-inline-block d-xl-inline-block d-xxl-inline-block">This site is also available on<br><a href="https://learn.namebase.io/" target="_blank">Handshake</a> at <a href="https://nathan.woodburn">https://nathan.woodburn/</a></p>
|
||||||
|
<p class="copyright">Copyright © Nathan.Woodburn/ 2025</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
<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>
|
||||||
@@ -38,7 +38,15 @@
|
|||||||
<script async src="https://umami.woodburn.au/script.js" data-website-id="6a55028e-aad3-481c-9a37-3e096ff75589"></script><link rel="stylesheet" href="/assets/css/resume-print.css" media="print">
|
<script async src="https://umami.woodburn.au/script.js" data-website-id="6a55028e-aad3-481c-9a37-3e096ff75589"></script><link rel="stylesheet" href="/assets/css/resume-print.css" media="print">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body style="font-family: 'Noto Sans', sans-serif;">
|
<body style="font-family: 'Noto Sans', sans-serif;"><div id="mobile-pdf-notice" style="display: none; background: #0d6efd; color: white; padding: 1rem; text-align: center; position: fixed; top: 0; left: 0; right: 0; z-index: 9999;">
|
||||||
|
<strong>Mobile detected!</strong>
|
||||||
|
<a href="/resume.pdf" style="color: white; text-decoration: underline;">View PDF version instead</a>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
if (window.innerWidth <= 768) {
|
||||||
|
document.getElementById('mobile-pdf-notice').style.display = 'block';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
<div class="container-fluid h-100">
|
<div class="container-fluid h-100">
|
||||||
<div class="row h-100 resume-row">
|
<div class="row h-100 resume-row">
|
||||||
<div class="col-md-4 resume-column resume-column-left">
|
<div class="col-md-4 resume-column resume-column-left">
|
||||||
@@ -119,6 +127,14 @@
|
|||||||
<div class="col">
|
<div class="col">
|
||||||
<h1 class="r-heading1">Experience</h1>
|
<h1 class="r-heading1">Experience</h1>
|
||||||
<hr class="hr-l-primary">
|
<hr class="hr-l-primary">
|
||||||
|
<div class="noprintbreak">
|
||||||
|
<h4 class="l-heading2 float-right">Dec 2025 - Present</h4>
|
||||||
|
<h4 class="l-heading2">Web Hosting System Administrator</h4>
|
||||||
|
<h6 class="l-heading3">CSIRO - Canberra</h6>
|
||||||
|
<ul class="r-body">
|
||||||
|
<li>Configure and manage web services</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
<div class="noprintbreak">
|
<div class="noprintbreak">
|
||||||
<h4 class="l-heading2 float-right">Oct 2022 - Jun 2025</h4>
|
<h4 class="l-heading2 float-right">Oct 2022 - Jun 2025</h4>
|
||||||
<h4 class="l-heading2">Technical Support Specialist</h4>
|
<h4 class="l-heading2">Technical Support Specialist</h4>
|
||||||
|
|||||||
@@ -72,6 +72,9 @@
|
|||||||
<url>
|
<url>
|
||||||
<loc>https://nathan.woodburn.au/now/25_10_23</loc>
|
<loc>https://nathan.woodburn.au/now/25_10_23</loc>
|
||||||
</url>
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>https://nathan.woodburn.au/now/25_11_20</loc>
|
||||||
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://nathan.woodburn.au/now/old</loc>
|
<loc>https://nathan.woodburn.au/now/old</loc>
|
||||||
</url>
|
</url>
|
||||||
|
|||||||
54
tools.py
54
tools.py
@@ -1,6 +1,6 @@
|
|||||||
from flask import Request, render_template, jsonify, make_response
|
from flask import Request, render_template, jsonify, make_response
|
||||||
import os
|
import os
|
||||||
from functools import lru_cache as cache
|
from functools import lru_cache
|
||||||
import datetime
|
import datetime
|
||||||
from typing import Optional, Dict, Union, Tuple
|
from typing import Optional, Dict, Union, Tuple
|
||||||
import re
|
import re
|
||||||
@@ -24,17 +24,10 @@ CRAWLERS = [
|
|||||||
"Exabot",
|
"Exabot",
|
||||||
"facebot",
|
"facebot",
|
||||||
"ia_archiver",
|
"ia_archiver",
|
||||||
"Twitterbot"
|
"Twitterbot",
|
||||||
]
|
]
|
||||||
|
|
||||||
CLI_AGENTS = [
|
CLI_AGENTS = ["curl", "hurl", "xh", "Posting", "HTTPie", "nushell"]
|
||||||
"curl",
|
|
||||||
"hurl",
|
|
||||||
"xh",
|
|
||||||
"Posting",
|
|
||||||
"HTTPie",
|
|
||||||
"nushell"
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def getClientIP(request: Request) -> str:
|
def getClientIP(request: Request) -> str:
|
||||||
@@ -56,7 +49,8 @@ def getClientIP(request: Request) -> str:
|
|||||||
ip = "unknown"
|
ip = "unknown"
|
||||||
return ip
|
return ip
|
||||||
|
|
||||||
@cache
|
|
||||||
|
@lru_cache(maxsize=1)
|
||||||
def getGitCommit() -> str:
|
def getGitCommit() -> str:
|
||||||
"""
|
"""
|
||||||
Get the current git commit hash.
|
Get the current git commit hash.
|
||||||
@@ -115,7 +109,8 @@ def isCrawler(request: Request) -> bool:
|
|||||||
return any(crawler in user_agent for crawler in CRAWLERS)
|
return any(crawler in user_agent for crawler in CRAWLERS)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@cache
|
|
||||||
|
@lru_cache(maxsize=128)
|
||||||
def isDev(host: str) -> bool:
|
def isDev(host: str) -> bool:
|
||||||
"""
|
"""
|
||||||
Check if the host indicates a development environment.
|
Check if the host indicates a development environment.
|
||||||
@@ -135,7 +130,8 @@ def isDev(host: str) -> bool:
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@cache
|
|
||||||
|
@lru_cache(maxsize=128)
|
||||||
def getHandshakeScript(host: str) -> str:
|
def getHandshakeScript(host: str) -> str:
|
||||||
"""
|
"""
|
||||||
Get the handshake script HTML snippet.
|
Get the handshake script HTML snippet.
|
||||||
@@ -150,7 +146,8 @@ def getHandshakeScript(host: str) -> str:
|
|||||||
return ""
|
return ""
|
||||||
return '<script src="https://nathan.woodburn/handshake.js" domain="nathan.woodburn" async></script><script src="https://nathan.woodburn/https.js" async></script>'
|
return '<script src="https://nathan.woodburn/handshake.js" domain="nathan.woodburn" async></script><script src="https://nathan.woodburn/https.js" async></script>'
|
||||||
|
|
||||||
@cache
|
|
||||||
|
@lru_cache(maxsize=64)
|
||||||
def getAddress(coin: str) -> str:
|
def getAddress(coin: str) -> str:
|
||||||
"""
|
"""
|
||||||
Get the wallet address for a cryptocurrency.
|
Get the wallet address for a cryptocurrency.
|
||||||
@@ -169,7 +166,7 @@ def getAddress(coin: str) -> str:
|
|||||||
return address
|
return address
|
||||||
|
|
||||||
|
|
||||||
@cache
|
@lru_cache(maxsize=256)
|
||||||
def getFilePath(name: str, path: str) -> Optional[str]:
|
def getFilePath(name: str, path: str) -> Optional[str]:
|
||||||
"""
|
"""
|
||||||
Find a file in a directory tree.
|
Find a file in a directory tree.
|
||||||
@@ -187,7 +184,9 @@ def getFilePath(name: str, path: str) -> Optional[str]:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def json_response(request: Request, message: Union[str, Dict] = "404 Not Found", code: int = 404):
|
def json_response(
|
||||||
|
request: Request, message: Union[str, Dict] = "404 Not Found", code: int = 404
|
||||||
|
):
|
||||||
"""
|
"""
|
||||||
Create a JSON response with standard formatting.
|
Create a JSON response with standard formatting.
|
||||||
|
|
||||||
@@ -205,17 +204,20 @@ def json_response(request: Request, message: Union[str, Dict] = "404 Not Found",
|
|||||||
message["ip"] = getClientIP(request)
|
message["ip"] = getClientIP(request)
|
||||||
return jsonify(message), code
|
return jsonify(message), code
|
||||||
|
|
||||||
return jsonify({
|
return jsonify(
|
||||||
|
{
|
||||||
"status": code,
|
"status": code,
|
||||||
"message": message,
|
"message": message,
|
||||||
"ip": getClientIP(request),
|
"ip": getClientIP(request),
|
||||||
}), code
|
}
|
||||||
|
), code
|
||||||
|
|
||||||
|
|
||||||
def error_response(
|
def error_response(
|
||||||
request: Request,
|
request: Request,
|
||||||
message: str = "404 Not Found",
|
message: str = "404 Not Found",
|
||||||
code: int = 404,
|
code: int = 404,
|
||||||
force_json: bool = False
|
force_json: bool = False,
|
||||||
) -> Union[Tuple[Dict, int], object]:
|
) -> Union[Tuple[Dict, int], object]:
|
||||||
"""
|
"""
|
||||||
Create an error response in JSON or HTML format.
|
Create an error response in JSON or HTML format.
|
||||||
@@ -233,10 +235,12 @@ def error_response(
|
|||||||
return json_response(request, message, code)
|
return json_response(request, message, code)
|
||||||
|
|
||||||
# Check if <error code>.html exists in templates
|
# Check if <error code>.html exists in templates
|
||||||
template_name = f"{code}.html" if os.path.isfile(
|
template_name = (
|
||||||
f"templates/{code}.html") else "404.html"
|
f"{code}.html" if os.path.isfile(f"templates/{code}.html") else "404.html"
|
||||||
response = make_response(render_template(
|
)
|
||||||
template_name, code=code, message=message), code)
|
response = make_response(
|
||||||
|
render_template(template_name, code=code, message=message), code
|
||||||
|
)
|
||||||
|
|
||||||
# Add message to response headers
|
# Add message to response headers
|
||||||
response.headers["X-Error-Message"] = message
|
response.headers["X-Error-Message"] = message
|
||||||
@@ -260,8 +264,7 @@ def parse_date(date_groups: list[str]) -> str | None:
|
|||||||
date_str = " ".join(date_groups).strip()
|
date_str = " ".join(date_groups).strip()
|
||||||
|
|
||||||
# Remove ordinal suffixes
|
# Remove ordinal suffixes
|
||||||
date_str = re.sub(r'(\d+)(st|nd|rd|th)', r'\1',
|
date_str = re.sub(r"(\d+)(st|nd|rd|th)", r"\1", date_str, flags=re.IGNORECASE)
|
||||||
date_str, flags=re.IGNORECASE)
|
|
||||||
|
|
||||||
# Parse with dateutil, default day=1 if missing
|
# Parse with dateutil, default day=1 if missing
|
||||||
dt = parse(date_str, default=datetime.datetime(1900, 1, 1))
|
dt = parse(date_str, default=datetime.datetime(1900, 1, 1))
|
||||||
@@ -275,6 +278,7 @@ def parse_date(date_groups: list[str]) -> str | None:
|
|||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_tools_data():
|
def get_tools_data():
|
||||||
with open("data/tools.json", "r") as f:
|
with open("data/tools.json", "r") as f:
|
||||||
return json.load(f)
|
return json.load(f)
|
||||||
|
|||||||
Reference in New Issue
Block a user