Rebuild videoreg as source-backed SVK technical library V2 candidate
This commit is contained in:
1 parent
056f1a6462
commit
d0fd7068bb
233 files changed
+6803
-42
No files matched your search
@@ -9,6 +9,7 @@ COPY ingestion ingestion
|
||||
RUN npm run build
|
||||
FROM nginx:1.28-alpine
|
||||
COPY deploy/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY deploy/legacy-map.conf /etc/nginx/conf.d/00-videoreg-legacy.conf
|
||||
COPY --from=build /app/web-front/out/ /usr/share/nginx/html/
|
||||
EXPOSE 8080
|
||||
HEALTHCHECK --interval=30s --timeout=3s CMD wget -qO- http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
@@ -0,0 +1,23 @@
|
||||
# Generated by scripts/rebuild-v2/legacy-routes.py; exact query meaning only.
|
||||
map "$uri|$args" $videoreg_legacy {
|
||||
default "";
|
||||
"~^/index\\.shtml\\|$" "/system";
|
||||
"~^/moves\\.htm\\|$" "/demo.shtml#section-3";
|
||||
"~^/shop/index\\.php\\|(?=(?:[^&]*&)*categoryID=78(?:&|$))(?:categoryID=78)(?:&(?:categoryID=78))*$" "/catalog#section-1";
|
||||
"~^/shop/index\\.php\\|(?=(?:[^&]*&)*categoryID=79(?:&|$))(?:categoryID=79)(?:&(?:categoryID=79))*$" "/catalog#section-0";
|
||||
"~^/shop/index\\.php\\|(?=(?:[^&]*&)*categoryID=80(?:&|$))(?:categoryID=80)(?:&(?:categoryID=80))*$" "/catalog#section-3";
|
||||
"~^/shop/index\\.php\\|(?=(?:[^&]*&)*productID=132(?:&|$))(?:productID=132)(?:&(?:productID=132))*$" "/equipment/svk002-lqcd";
|
||||
"~^/shop/index\\.php\\|(?=(?:[^&]*&)*productID=133(?:&|$))(?:productID=133)(?:&(?:productID=133))*$" "/equipment/svk002-gps";
|
||||
"~^/shop/index\\.php\\|(?=(?:[^&]*&)*productID=137(?:&|$))(?:productID=137)(?:&(?:productID=137))*$" "/equipment/svk004";
|
||||
"~^/forum/index\\.php\\|(?:(?:sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=)(?:&(?:sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=))*)?$" "/community";
|
||||
"~^/forum/index\\.php\\|(?=(?:[^&]*&)*c=2(?:&|$))(?:c=2|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=)(?:&(?:c=2|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=))*$" "/community";
|
||||
"~^/forum/viewtopic\\.php\\|(?=(?:[^&]*&)*t=184(?:&|$))(?:t=184|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=)(?:&(?:t=184|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=))*$" "/community/flash-start";
|
||||
"~^/forum/viewtopic\\.php\\|(?=(?:[^&]*&)*t=188(?:&|$))(?:t=188|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=)(?:&(?:t=188|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=))*$" "/community/usb-extension";
|
||||
"~^/forum/viewtopic\\.php\\|(?=(?:[^&]*&)*t=183(?:&|$))(?=(?:[^&]*&)*view=next(?:&|$))(?:t=183|view=next|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=)(?:&(?:t=183|view=next|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=))*$" "/community/flash-start";
|
||||
"~^/forum/viewtopic\\.php\\|(?=(?:[^&]*&)*t=8(?:&|$))(?=(?:[^&]*&)*view=next(?:&|$))(?:t=8|view=next|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=)(?:&(?:t=8|view=next|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=))*$" "/community/usb-extension";
|
||||
"~^/forum/viewtopic\\.php\\|(?=(?:[^&]*&)*p=220(?:&|$))(?:p=220|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=)(?:&(?:p=220|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=))*$" "/community/flash-start#section-0";
|
||||
"~^/forum/viewtopic\\.php\\|(?=(?:[^&]*&)*p=221(?:&|$))(?:p=221|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=)(?:&(?:p=221|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=))*$" "/community/flash-start#section-1";
|
||||
"~^/forum/viewtopic\\.php\\|(?=(?:[^&]*&)*p=223(?:&|$))(?:p=223|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=)(?:&(?:p=223|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=))*$" "/community/flash-start#section-2";
|
||||
"~^/forum/viewtopic\\.php\\|(?=(?:[^&]*&)*p=226(?:&|$))(?:p=226|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=)(?:&(?:p=226|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=))*$" "/community/usb-extension#section-0";
|
||||
"~^/forum/viewtopic\\.php\\|(?=(?:[^&]*&)*p=227(?:&|$))(?:p=227|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=)(?:&(?:p=227|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=))*$" "/community/usb-extension#section-1";
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
[
|
||||
{
|
||||
"original": "/index.shtml",
|
||||
"destination": "/system",
|
||||
"pattern": "^/index\\.shtml\\|$"
|
||||
},
|
||||
{
|
||||
"original": "/moves.htm",
|
||||
"destination": "/demo.shtml#section-3",
|
||||
"pattern": "^/moves\\.htm\\|$"
|
||||
},
|
||||
{
|
||||
"original": "/shop/index.php?categoryID=78",
|
||||
"destination": "/catalog#section-1",
|
||||
"pattern": "^/shop/index\\.php\\|(?=(?:[^&]*&)*categoryID=78(?:&|$))(?:categoryID=78)(?:&(?:categoryID=78))*$"
|
||||
},
|
||||
{
|
||||
"original": "/shop/index.php?categoryID=79",
|
||||
"destination": "/catalog#section-0",
|
||||
"pattern": "^/shop/index\\.php\\|(?=(?:[^&]*&)*categoryID=79(?:&|$))(?:categoryID=79)(?:&(?:categoryID=79))*$"
|
||||
},
|
||||
{
|
||||
"original": "/shop/index.php?categoryID=80",
|
||||
"destination": "/catalog#section-3",
|
||||
"pattern": "^/shop/index\\.php\\|(?=(?:[^&]*&)*categoryID=80(?:&|$))(?:categoryID=80)(?:&(?:categoryID=80))*$"
|
||||
},
|
||||
{
|
||||
"original": "/shop/index.php?productID=132",
|
||||
"destination": "/equipment/svk002-lqcd",
|
||||
"pattern": "^/shop/index\\.php\\|(?=(?:[^&]*&)*productID=132(?:&|$))(?:productID=132)(?:&(?:productID=132))*$"
|
||||
},
|
||||
{
|
||||
"original": "/shop/index.php?productID=133",
|
||||
"destination": "/equipment/svk002-gps",
|
||||
"pattern": "^/shop/index\\.php\\|(?=(?:[^&]*&)*productID=133(?:&|$))(?:productID=133)(?:&(?:productID=133))*$"
|
||||
},
|
||||
{
|
||||
"original": "/shop/index.php?productID=137",
|
||||
"destination": "/equipment/svk004",
|
||||
"pattern": "^/shop/index\\.php\\|(?=(?:[^&]*&)*productID=137(?:&|$))(?:productID=137)(?:&(?:productID=137))*$"
|
||||
},
|
||||
{
|
||||
"original": "/forum/index.php",
|
||||
"destination": "/community",
|
||||
"pattern": "^/forum/index\\.php\\|(?:(?:sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=)(?:&(?:sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=))*)?$"
|
||||
},
|
||||
{
|
||||
"original": "/forum/index.php?c=2",
|
||||
"destination": "/community",
|
||||
"pattern": "^/forum/index\\.php\\|(?=(?:[^&]*&)*c=2(?:&|$))(?:c=2|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=)(?:&(?:c=2|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=))*$"
|
||||
},
|
||||
{
|
||||
"original": "/forum/viewtopic.php?t=184",
|
||||
"destination": "/community/flash-start",
|
||||
"pattern": "^/forum/viewtopic\\.php\\|(?=(?:[^&]*&)*t=184(?:&|$))(?:t=184|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=)(?:&(?:t=184|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=))*$"
|
||||
},
|
||||
{
|
||||
"original": "/forum/viewtopic.php?t=188",
|
||||
"destination": "/community/usb-extension",
|
||||
"pattern": "^/forum/viewtopic\\.php\\|(?=(?:[^&]*&)*t=188(?:&|$))(?:t=188|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=)(?:&(?:t=188|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=))*$"
|
||||
},
|
||||
{
|
||||
"original": "/forum/viewtopic.php?t=183&view=next",
|
||||
"destination": "/community/flash-start",
|
||||
"pattern": "^/forum/viewtopic\\.php\\|(?=(?:[^&]*&)*t=183(?:&|$))(?=(?:[^&]*&)*view=next(?:&|$))(?:t=183|view=next|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=)(?:&(?:t=183|view=next|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=))*$"
|
||||
},
|
||||
{
|
||||
"original": "/forum/viewtopic.php?t=8&view=next",
|
||||
"destination": "/community/usb-extension",
|
||||
"pattern": "^/forum/viewtopic\\.php\\|(?=(?:[^&]*&)*t=8(?:&|$))(?=(?:[^&]*&)*view=next(?:&|$))(?:t=8|view=next|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=)(?:&(?:t=8|view=next|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=))*$"
|
||||
},
|
||||
{
|
||||
"original": "/forum/viewtopic.php?p=220",
|
||||
"destination": "/community/flash-start#section-0",
|
||||
"pattern": "^/forum/viewtopic\\.php\\|(?=(?:[^&]*&)*p=220(?:&|$))(?:p=220|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=)(?:&(?:p=220|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=))*$"
|
||||
},
|
||||
{
|
||||
"original": "/forum/viewtopic.php?p=221",
|
||||
"destination": "/community/flash-start#section-1",
|
||||
"pattern": "^/forum/viewtopic\\.php\\|(?=(?:[^&]*&)*p=221(?:&|$))(?:p=221|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=)(?:&(?:p=221|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=))*$"
|
||||
},
|
||||
{
|
||||
"original": "/forum/viewtopic.php?p=223",
|
||||
"destination": "/community/flash-start#section-2",
|
||||
"pattern": "^/forum/viewtopic\\.php\\|(?=(?:[^&]*&)*p=223(?:&|$))(?:p=223|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=)(?:&(?:p=223|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=))*$"
|
||||
},
|
||||
{
|
||||
"original": "/forum/viewtopic.php?p=226",
|
||||
"destination": "/community/usb-extension#section-0",
|
||||
"pattern": "^/forum/viewtopic\\.php\\|(?=(?:[^&]*&)*p=226(?:&|$))(?:p=226|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=)(?:&(?:p=226|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=))*$"
|
||||
},
|
||||
{
|
||||
"original": "/forum/viewtopic.php?p=227",
|
||||
"destination": "/community/usb-extension#section-1",
|
||||
"pattern": "^/forum/viewtopic\\.php\\|(?=(?:[^&]*&)*p=227(?:&|$))(?:p=227|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=)(?:&(?:p=227|sid=[^&]*|start=0|postdays=0|postorder=asc|highlight=))*$"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"/index.shtml": "/system",
|
||||
"/moves.htm": "/demo.shtml#section-3",
|
||||
"/shop/index.php?categoryID=78": "/catalog#section-1",
|
||||
"/shop/index.php?categoryID=79": "/catalog#section-0",
|
||||
"/shop/index.php?categoryID=80": "/catalog#section-3",
|
||||
"/shop/index.php?productID=132": "/equipment/svk002-lqcd",
|
||||
"/shop/index.php?productID=133": "/equipment/svk002-gps",
|
||||
"/shop/index.php?productID=137": "/equipment/svk004",
|
||||
"/forum/index.php": "/community",
|
||||
"/forum/index.php?c=2": "/community",
|
||||
"/forum/viewtopic.php?t=184": "/community/flash-start",
|
||||
"/forum/viewtopic.php?t=188": "/community/usb-extension",
|
||||
"/forum/viewtopic.php?t=183&view=next": "/community/flash-start",
|
||||
"/forum/viewtopic.php?t=8&view=next": "/community/usb-extension",
|
||||
"/forum/viewtopic.php?p=220": "/community/flash-start#section-0",
|
||||
"/forum/viewtopic.php?p=221": "/community/flash-start#section-1",
|
||||
"/forum/viewtopic.php?p=223": "/community/flash-start#section-2",
|
||||
"/forum/viewtopic.php?p=226": "/community/usb-extension#section-0",
|
||||
"/forum/viewtopic.php?p=227": "/community/usb-extension#section-1"
|
||||
}
|
||||
+1
-1
@@ -5,10 +5,10 @@ server {
|
||||
charset utf-8;
|
||||
server_tokens off;
|
||||
absolute_redirect off;
|
||||
if ($videoreg_legacy != "") { return 308 $videoreg_legacy; }
|
||||
add_header X-Content-Type-Options nosniff always;
|
||||
add_header Referrer-Policy strict-origin-when-cross-origin always;
|
||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'" always;
|
||||
location = /auto.shtml { return 308 /guides/choose; }
|
||||
location /api/ { return 404; }
|
||||
location ~ /showcase/?$ { return 404; }
|
||||
location /_next/static/ { expires 1y; add_header Cache-Control "public, immutable"; }
|
||||
|
||||
+100
-18
@@ -1,28 +1,110 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Preview the public static release on an OS-assigned local port."""
|
||||
"""Serve the reviewed static candidate, confined to its exported public tree."""
|
||||
from http.server import ThreadingHTTPServer, SimpleHTTPRequestHandler
|
||||
from pathlib import Path
|
||||
import json, os
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
OUT=ROOT/'web-front/out'
|
||||
from urllib.parse import urlsplit, unquote
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
OUT = ROOT / 'web-front/out'
|
||||
|
||||
|
||||
def resolve_public(root: Path, request_path: str):
|
||||
path = unquote(urlsplit(request_path).path)
|
||||
if '\\' in path or '..' in Path(path).parts or '\x00' in path:
|
||||
return None
|
||||
target = root / path.lstrip('/')
|
||||
if not path.startswith('/health/') and Path(str(target) + '.html').is_file():
|
||||
target = Path(str(target) + '.html')
|
||||
try:
|
||||
target.resolve().relative_to(root.resolve())
|
||||
except (ValueError, OSError):
|
||||
return None
|
||||
return target
|
||||
|
||||
|
||||
def legacy_destination(request_path: str):
|
||||
"""Redirect only an exact evidenced query or proved presentation defaults."""
|
||||
rules = json.loads((ROOT / 'deploy/legacy-matchers.json').read_text())
|
||||
parsed = urlsplit(request_path)
|
||||
key = unquote(parsed.path) + '|' + parsed.query
|
||||
for rule in rules:
|
||||
if re.fullmatch(rule['pattern'], key):
|
||||
return rule['destination']
|
||||
return None
|
||||
|
||||
|
||||
class Handler(SimpleHTTPRequestHandler):
|
||||
def __init__(self,*args,**kwargs):super().__init__(*args,directory=str(OUT),**kwargs)
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, directory=str(OUT), **kwargs)
|
||||
|
||||
def list_directory(self, path):
|
||||
self.send_error(404)
|
||||
return None
|
||||
|
||||
def send_error(self, code, message=None, explain=None):
|
||||
page = resolve_public(OUT, '/404.html')
|
||||
if code == 404 and page and page.is_file():
|
||||
body = page.read_bytes()
|
||||
self.send_response(404)
|
||||
self.send_header('Content-Type', 'text/html; charset=utf-8')
|
||||
self.send_header('Content-Length', str(len(body)))
|
||||
self.end_headers()
|
||||
if self.command != 'HEAD':
|
||||
self.wfile.write(body)
|
||||
return
|
||||
super().send_error(code, message, explain)
|
||||
|
||||
def copyfile(self, source, outputfile):
|
||||
if self.command != "HEAD":
|
||||
super().copyfile(source, outputfile)
|
||||
|
||||
def do_HEAD(self):
|
||||
self.do_GET()
|
||||
|
||||
def do_POST(self):
|
||||
self.send_error(404)
|
||||
|
||||
def do_GET(self):
|
||||
path=self.path.split('?',1)[0]
|
||||
if path=='/auto.shtml':
|
||||
self.send_response(308);self.send_header('Location','/guides/choose');self.end_headers();return
|
||||
target = resolve_public(OUT, self.path)
|
||||
if target is None:
|
||||
self.send_error(404)
|
||||
return
|
||||
destination = legacy_destination(self.path)
|
||||
if destination:
|
||||
self.send_response(308)
|
||||
self.send_header('Location', destination)
|
||||
self.end_headers()
|
||||
return
|
||||
path = unquote(urlsplit(self.path).path)
|
||||
if path.startswith('/api/') or path.rstrip('/').endswith('/showcase'):
|
||||
self.send_error(404);return
|
||||
target=OUT/path.lstrip('/')
|
||||
self.send_error(404)
|
||||
return
|
||||
if path.startswith('/health/') and target.is_file():
|
||||
self.send_response(200);self.send_header('Content-Type','application/json');self.end_headers();self.wfile.write(target.read_bytes());return
|
||||
if target.with_suffix('.html').is_file():self.path=path+'.html'
|
||||
body = target.read_bytes()
|
||||
self.send_response(200)
|
||||
self.send_header('Content-Type', 'application/json')
|
||||
self.send_header('Content-Length', str(len(body)))
|
||||
self.end_headers()
|
||||
if self.command != "HEAD":
|
||||
self.wfile.write(body)
|
||||
return
|
||||
relative = target.relative_to(OUT).as_posix()
|
||||
self.path = '/' if relative == '.' else '/' + relative
|
||||
super().do_GET()
|
||||
httpd=ThreadingHTTPServer(('127.0.0.1',0),Handler)
|
||||
runtime=ROOT/'.local-run';runtime.mkdir(exist_ok=True)
|
||||
state=dict(port=httpd.server_port,pid=os.getpid(),url=f'http://127.0.0.1:{httpd.server_port}')
|
||||
(runtime/'server.json').write_text(json.dumps(state,indent=2)+'\n')
|
||||
print(json.dumps(state),flush=True)
|
||||
httpd.serve_forever()
|
||||
|
||||
|
||||
def main():
|
||||
httpd = ThreadingHTTPServer(('127.0.0.1', int(os.environ.get('VIDEOREG_PREVIEW_PORT', '0'))), Handler)
|
||||
runtime = ROOT / '.local-run'
|
||||
runtime.mkdir(exist_ok=True)
|
||||
state = dict(port=httpd.server_port, pid=os.getpid(), url=f'http://127.0.0.1:{httpd.server_port}')
|
||||
(runtime / 'server.json').write_text(json.dumps(state, indent=2) + '\n')
|
||||
print(json.dumps(state), flush=True)
|
||||
httpd.serve_forever()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
+1
-1
@@ -25,7 +25,7 @@ services:
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.docker.network=${TRAEFIK_NETWORK:-traefik-public}"
|
||||
- "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`) && PathPrefix(`/`)"
|
||||
- "traefik.http.routers.${STACK_NAME}.rule=(Host(`${DOMAIN}`) || Host(`www.${DOMAIN}`)) && PathPrefix(`/`)"
|
||||
- "traefik.http.routers.${STACK_NAME}.priority=100"
|
||||
- "traefik.http.routers.${STACK_NAME}.entrypoints=${TRAEFIK_ENTRYPOINTS:-websecure}"
|
||||
- "traefik.http.routers.${STACK_NAME}.tls=${TRAEFIK_TLS:-true}"
|
||||
|
||||
Reference in new issue
Block a user