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
# API
server {
+ # Service: API | https://api.dev.nutra.tk
server_name api-dev.nutra.tk api.dev.nutra.tk;
#listen 80;
listen 443 ssl;
# Store Front (MedusaJS)
server {
+ # Service: Store | https://store.nutra.tk
server_name store.nutra.tk;
#listen 80;
listen 443 ssl;
# 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;
#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
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;
# 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..."
</html>"""
-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):
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__":
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+ <title>NutraTech Git Services</title>
+ <style>
+ body { font-family: sans-serif; max-width: 800px; margin: 2rem auto; line-height: 1.6; padding: 0 1rem; color: #333; }
+ h1 { border-bottom: 2px solid #eee; padding-bottom: 0.5rem; }
+ .service { margin-bottom: 1.5rem; padding: 1.5rem; border: 1px solid #ddd; border-radius: 8px; background: #f9f9f9; }
+ .service:hover { background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,0.1); border-color: #ccc; }
+ .service h2 { margin-top: 0; margin-bottom: 0.5rem; }
+ .service a { text-decoration: none; color: #0066cc; }
+ .service a:hover { text-decoration: underline; }
+ .desc { margin-bottom: 0.5rem; }
+ .meta { font-size: 0.85em; color: #666; }
+ .tag { display: inline-block; padding: 2px 8px; background: #e0e0e0; border-radius: 12px; font-size: 0.8em; margin-right: 0.5rem; color: #444; }
+ </style>
+</head>
+<body>
+ <h1>Git Services Map</h1>
+ <p class="meta">Generated automatically from Nginx configuration.</p>
+
+
+ <div class="service">
+ <h2><a href="/v1">/v1</a></h2>
+ <div class="desc">Original Gitweb (Basic)</div>
+ </div>
+ <div class="service">
+ <h2><a href="/v2">/v2</a></h2>
+ <div class="desc">Styled Frontend (Theme, Static)</div>
+ </div>
+ <div class="service">
+ <h2><a href="/v3">/v3</a></h2>
+ <div class="desc">Gitea (Full Server with Backend, Main)</div>
+ </div>
+ <div class="service">
+ <h2><a href="https://api.dev.nutra.tk">https://api.dev.nutra.tk</a></h2>
+ <div class="desc">API</div>
+ </div>
+ <div class="service">
+ <h2><a href="https://store.nutra.tk">https://store.nutra.tk</a></h2>
+ <div class="desc">Store</div>
+ </div>
+ <div class="service">
+ <h2><a href="https://store-admin-8b56411b.nutra.tk">https://store-admin-8b56411b.nutra.tk</a></h2>
+ <div class="desc">Store Admin</div>
+ </div>
+ <div class="service">
+ <h2><a href="https://chat.nutra.tk">https://chat.nutra.tk</a></h2>
+ <div class="desc">Matrix Chat</div>
+ </div>
+
+</body>
+</html>
\ No newline at end of file
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+ <title>NutraTech Git Services</title>
+ <style>
+ body { font-family: sans-serif; max-width: 800px; margin: 2rem auto; line-height: 1.6; padding: 0 1rem; color: #333; }
+ h1 { border-bottom: 2px solid #eee; padding-bottom: 0.5rem; }
+ .service { margin-bottom: 1.5rem; padding: 1.5rem; border: 1px solid #ddd; border-radius: 8px; background: #f9f9f9; }
+ .service:hover { background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,0.1); border-color: #ccc; }
+ .service h2 { margin-top: 0; margin-bottom: 0.5rem; }
+ .service a { text-decoration: none; color: #0066cc; }
+ .service a:hover { text-decoration: underline; }
+ .desc { margin-bottom: 0.5rem; }
+ .meta { font-size: 0.85em; color: #666; }
+ .tag { display: inline-block; padding: 2px 8px; background: #e0e0e0; border-radius: 12px; font-size: 0.8em; margin-right: 0.5rem; color: #444; }
+ </style>
+</head>
+<body>
+ <h1>Git Services Map</h1>
+ <p class="meta">Generated automatically from Nginx configuration.</p>
+
+
+ <div class="service">
+ <h2><a href="/v1">/v1</a></h2>
+ <div class="desc">Original Gitweb (Basic)</div>
+ </div>
+ <div class="service">
+ <h2><a href="/v2">/v2</a></h2>
+ <div class="desc">Styled Frontend (Theme, Static)</div>
+ </div>
+ <div class="service">
+ <h2><a href="/v3">/v3</a></h2>
+ <div class="desc">Gitea (Full Server with Backend, Main)</div>
+ </div>
+ <div class="service">
+ <h2><a href="https://api.dev.nutra.tk">https://api.dev.nutra.tk</a></h2>
+ <div class="desc">API</div>
+ </div>
+ <div class="service">
+ <h2><a href="https://store.nutra.tk">https://store.nutra.tk</a></h2>
+ <div class="desc">Store</div>
+ </div>
+ <div class="service">
+ <h2><a href="https://store-admin-8b56411b.nutra.tk">https://store-admin-8b56411b.nutra.tk</a></h2>
+ <div class="desc">Store Admin</div>
+ </div>
+ <div class="service">
+ <h2><a href="https://chat.nutra.tk">https://chat.nutra.tk</a></h2>
+ <div class="desc">Matrix Chat</div>
+ </div>
+
+</body>
+</html>
\ No newline at end of file