From f5f3c9f84fd51638a8e4967bbca4b4796aa99dfa Mon Sep 17 00:00:00 2001 From: Shane Jaroch Date: Mon, 19 Jan 2026 02:45:08 -0500 Subject: [PATCH] new homepage map temporary --- Makefile | 1 + etc/nginx/conf.d/default.conf | 12 ++-- scripts/deploy.sh | 13 ++++ scripts/gen_services_map.py | 74 ++++++++++++--------- scripts/gitweb-simplefrontend/homepage.html | 53 +++++++++++++++ scripts/homepage.html | 53 +++++++++++++++ 6 files changed, 171 insertions(+), 35 deletions(-) create mode 100644 scripts/gitweb-simplefrontend/homepage.html create mode 100644 scripts/homepage.html diff --git a/Makefile b/Makefile index 3b3e3ac..3e0d556 100644 --- a/Makefile +++ b/Makefile @@ -49,6 +49,7 @@ stage/nginx: ##H @Remote Stage files on the remote VPS scp -q etc/gitweb.conf $(VPS):~/.nginx-staging/etc/gitweb.conf scp -q -r scripts/gitweb-simplefrontend/* $(VPS):~/.nginx-staging/scripts/gitweb-simplefrontend/ scp -q scripts/deploy.sh $(VPS):~/.nginx-staging/scripts/deploy.sh + scp -q scripts/gen_services_map.py $(VPS):~/.nginx-staging/scripts/gen_services_map.py .PHONY: diff/nginx diff/nginx: ##H @Remote Show diff between local and remote diff --git a/etc/nginx/conf.d/default.conf b/etc/nginx/conf.d/default.conf index 1836a11..b866859 100644 --- a/etc/nginx/conf.d/default.conf +++ b/etc/nginx/conf.d/default.conf @@ -1,5 +1,6 @@ # API server { + # Service: API | https://api.dev.nutra.tk server_name api-dev.nutra.tk api.dev.nutra.tk; #listen 80; listen 443 ssl; @@ -35,6 +36,7 @@ server { # Store Front (MedusaJS) server { + # Service: Store | https://store.nutra.tk server_name store.nutra.tk; #listen 80; listen 443 ssl; @@ -50,6 +52,7 @@ server { # Store [Admin UI] (MedusaJS) server { + # Service: Store Admin | https://store-admin-8b56411b.nutra.tk server_name store-api.nutra.tk store-admin-8b56411b.nutra.tk; #listen 80; listen 443 ssl; @@ -92,12 +95,10 @@ server { #ssl_stapling on; #ssl_stapling_verify on; - # React app (base URL) + # Services Map (Homepage) location / { - #return 302 https://$host/api$request_uri; - root /var/www/app; - index index.html; - #try_files $uri $uri/ /index.html =404; + alias /var/www/homepage.html; + default_type text/html; } # # Blog / Sphinx @@ -171,6 +172,7 @@ server { server_name matrix.nutra.tk chat.nutra.tk; location / { + # Service: Matrix Chat | https://chat.nutra.tk proxy_pass http://127.0.0.1:8008; proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto; proxy_set_header X-Forwarded-For $remote_addr; diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 90873c6..3c78b7e 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -106,11 +106,24 @@ if sudo nginx -t; then # Deploy Gitweb frontend assets if [ -d "$REPO_ROOT/scripts/gitweb-simplefrontend" ]; then + echo "Generating services map..." + if [ -f "$REPO_ROOT/scripts/gen_services_map.py" ]; then + python3 "$REPO_ROOT/scripts/gen_services_map.py" + fi + echo "Deploying Gitweb frontend..." sudo cp -r "$REPO_ROOT/scripts/gitweb-simplefrontend/"* /srv/git/ sudo chown -R www-data:www-data /srv/git/ fi + # Deploy Homepage + if [ -f "$REPO_ROOT/scripts/homepage.html" ]; then + echo "Deploying Homepage..." + sudo mkdir -p /var/www + sudo cp "$REPO_ROOT/scripts/homepage.html" /var/www/homepage.html + sudo chown www-data:www-data /var/www/homepage.html + fi + echo "✓ Deployment successful." else echo "✗ Configuration failed validation! Rolling back..." diff --git a/scripts/gen_services_map.py b/scripts/gen_services_map.py index 17de848..ca62bb2 100755 --- a/scripts/gen_services_map.py +++ b/scripts/gen_services_map.py @@ -35,33 +35,43 @@ HTML_TEMPLATE = """ """ -def parse_nginx_config(): - services = [] - if not NGINX_CONF.exists(): - print(f"Error: Could not find config at {NGINX_CONF}") - return [] - - # Regex to find "Version X: Description" lines - # Matches: # Version 1: Original Gitweb (Standard) - version_pattern = re.compile(r"^\s*#\s*Version\s+(\w+):\s*(.+)$", re.MULTILINE) - - with open(NGINX_CONF, "r") as f: +def parse_file(path, pattern, is_version=False): + if not path.exists(): + print(f"Warning: Could not find config at {path}") + return [] + + with open(path, "r") as f: content = f.read() - matches = version_pattern.findall(content) - for version_id, description in matches: + items = [] + matches = pattern.findall(content) + for m in matches: + if is_version: + version_id, description = m # Clean up version ID (e.g., '1' -> 'v1') if not version_id.startswith("v"): vid = f"v{version_id}" else: vid = version_id + items.append({"id": vid, "url": f"/{vid}", "description": description.strip()}) + else: + name, url = m + items.append({"id": name.strip(), "url": url.strip(), "description": name.strip()}) + return items + + +def get_all_services(): + # Regex to find "Version X: Description" lines + version_pattern = re.compile(r"^\s*#\s*Version\s+(\w+):\s*(.+)$", re.MULTILINE) + service_pattern = re.compile(r"^\s*#\s*Service:\s*(.+?)\s*\|\s*(.+)$", re.MULTILINE) - services.append( - {"id": vid, "url": f"/{vid}", "description": description.strip()} - ) + services_git = parse_file(NGINX_CONF, version_pattern, is_version=True) + + DEFAULT_CONF = REPO_ROOT / "etc/nginx/conf.d/default.conf" + services_other = parse_file(DEFAULT_CONF, service_pattern, is_version=False) - return services + return services_git, services_other def generate_html(services): @@ -78,22 +88,26 @@ def generate_html(services): def main(): - print(f"Reading config from: {NGINX_CONF}") - services = parse_nginx_config() - - if not services: - print("No services found!") - return - - print(f"Found {len(services)} services: {[s['id'] for s in services]}") - - html_content = generate_html(services) + print(f"Reading configs...") + services_git, services_other = get_all_services() + # Output 1: Git Services Only + print(f"Generating Git Services map with {len(services_git)} items...") + git_html = generate_html(services_git) os.makedirs(OUTPUT_HTML.parent, exist_ok=True) with open(OUTPUT_HTML, "w") as f: - f.write(html_content) - - print(f"Generated site map at: {OUTPUT_HTML}") + f.write(git_html) + print(f"Generated Git map at: {OUTPUT_HTML}") + + # Output 2: Homepage (All Services) + # Save to scripts/homepage.html to keep it separate from gitweb assets + OUTPUT_HTML_HOME = REPO_ROOT / "scripts/homepage.html" + services_all = services_git + services_other + print(f"Generating Homepage map with {len(services_all)} items...") + home_html = generate_html(services_all) + with open(OUTPUT_HTML_HOME, "w") as f: + f.write(home_html) + print(f"Generated Homepage map at: {OUTPUT_HTML_HOME}") if __name__ == "__main__": diff --git a/scripts/gitweb-simplefrontend/homepage.html b/scripts/gitweb-simplefrontend/homepage.html new file mode 100644 index 0000000..b5e27c0 --- /dev/null +++ b/scripts/gitweb-simplefrontend/homepage.html @@ -0,0 +1,53 @@ + + + + NutraTech Git Services + + + +

Git Services Map

+

Generated automatically from Nginx configuration.

+ + +
+

/v1

+
Original Gitweb (Basic)
+
+
+

/v2

+
Styled Frontend (Theme, Static)
+
+
+

/v3

+
Gitea (Full Server with Backend, Main)
+
+
+

https://api.dev.nutra.tk

+
API
+
+
+

https://store.nutra.tk

+
Store
+
+
+

https://store-admin-8b56411b.nutra.tk

+
Store Admin
+
+
+

https://chat.nutra.tk

+
Matrix Chat
+
+ + + \ No newline at end of file diff --git a/scripts/homepage.html b/scripts/homepage.html new file mode 100644 index 0000000..b5e27c0 --- /dev/null +++ b/scripts/homepage.html @@ -0,0 +1,53 @@ + + + + NutraTech Git Services + + + +

Git Services Map

+

Generated automatically from Nginx configuration.

+ + +
+

/v1

+
Original Gitweb (Basic)
+
+
+

/v2

+
Styled Frontend (Theme, Static)
+
+
+

/v3

+
Gitea (Full Server with Backend, Main)
+
+
+

https://api.dev.nutra.tk

+
API
+
+
+

https://store.nutra.tk

+
Store
+
+
+

https://store-admin-8b56411b.nutra.tk

+
Store Admin
+
+
+

https://chat.nutra.tk

+
Matrix Chat
+
+ + + \ No newline at end of file -- 2.52.0