#!/usr/bin/env python3
-import re
import os
+import re
from pathlib import Path
# Paths relative to repo root
return items
-import sys
import argparse
+import sys
+
def get_all_services(custom_config_path=None):
# Regex to find "Version X: Description" lines
return services_git, services_other
-
def generate_html(title, groups):
"""
groups: list of tuples (header_name, services_list)
for header, services in groups:
if header:
content_html += f'<h2 class="group-header">{header}</h2>'
-
+
for s in services:
# Use absolute URL if it starts with http, otherwise relative
- url = s['url']
+ url = s["url"]
content_html += f"""
<div class="service">
<h3><a href="{url}">{url}</a></h3>
return HTML_TEMPLATE.format(title=title, content=content_html)
-
def main():
- parser = argparse.ArgumentParser(description="Generate HTML services map from Nginx config")
- parser.add_argument("config_path", nargs="?", help="Path to the Nginx configuration file")
+ parser = argparse.ArgumentParser(
+ description="Generate HTML services map from Nginx config"
+ )
+ parser.add_argument(
+ "config_path", nargs="?", help="Path to the Nginx configuration file"
+ )
args = parser.parse_args()
print(f"Reading configs...")
print(f"Generating Git Services map with {len(services_git)} items...")
git_groups = [("", services_git)]
git_html = generate_html("Git Services", git_groups)
-
+
os.makedirs(OUTPUT_HTML.parent, exist_ok=True)
with open(OUTPUT_HTML, "w") as f:
f.write(git_html)
# Output 2: Homepage (All Services)
OUTPUT_HTML_HOME = REPO_ROOT / "scripts/homepage.html"
-
+
# Grouping logic
- all_groups = [
- ("Core Services", services_other),
- ("Git Services", services_git)
- ]
-
+ all_groups = [("Core Services", services_other), ("Git Services", services_git)]
+
# Calculate total items
total_items = sum(len(g[1]) for g in all_groups)
print(f"Generating Homepage map with {total_items} items...")
-
+
home_html = generate_html("All Services", all_groups)
-
+
with open(OUTPUT_HTML_HOME, "w") as f:
f.write(home_html)
print(f"Generated Homepage map at: {OUTPUT_HTML_HOME}")
if __name__ == "__main__":
main()
-
<div class="service">
- <h3><a href="/v1">/v1</a></h3>
+ <h3><a href="https://git.nutra.tk/v1">https://git.nutra.tk/v1</a></h3>
<div class="desc">Original Gitweb (Basic)</div>
</div>
<div class="service">
- <h3><a href="/v2">/v2</a></h3>
+ <h3><a href="https://git.nutra.tk/v2">https://git.nutra.tk/v2</a></h3>
<div class="desc">Styled Frontend (Theme, Static)</div>
</div>
<div class="service">
- <h3><a href="/v3">/v3</a></h3>
+ <h3><a href="https://git.nutra.tk/v3">https://git.nutra.tk/v3</a></h3>
<div class="desc">Gitea (Full Server with Backend, Main)</div>
</div>
<h1>All Services</h1>
<p class="meta">Generated automatically from Nginx configuration.</p>
- <h2 class="group-header">Core Services</h2>
+ <h2 class="group-header">Core Services</h2><h2 class="group-header">Git Services</h2>
<div class="service">
- <h3><a href="https://api.dev.nutra.tk">https://api.dev.nutra.tk</a></h3>
- <div class="desc">API</div>
- </div>
- <div class="service">
- <h3><a href="https://store.nutra.tk">https://store.nutra.tk</a></h3>
- <div class="desc">Store</div>
- </div>
- <div class="service">
- <h3><a href="https://store-admin-8b56411b.nutra.tk">https://store-admin-8b56411b.nutra.tk</a></h3>
- <div class="desc">Store Admin</div>
- </div>
- <div class="service">
- <h3><a href="https://chat.nutra.tk">https://chat.nutra.tk</a></h3>
- <div class="desc">Matrix Chat</div>
- </div><h2 class="group-header">Git Services</h2>
- <div class="service">
- <h3><a href="/v1">/v1</a></h3>
+ <h3><a href="https://git.nutra.tk/v1">https://git.nutra.tk/v1</a></h3>
<div class="desc">Original Gitweb (Basic)</div>
</div>
<div class="service">
- <h3><a href="/v2">/v2</a></h3>
+ <h3><a href="https://git.nutra.tk/v2">https://git.nutra.tk/v2</a></h3>
<div class="desc">Styled Frontend (Theme, Static)</div>
</div>
<div class="service">
- <h3><a href="/v3">/v3</a></h3>
+ <h3><a href="https://git.nutra.tk/v3">https://git.nutra.tk/v3</a></h3>
<div class="desc">Gitea (Full Server with Backend, Main)</div>
</div>