Skip to content

Commit d908aa3

Browse files
fix review comments on landing page docs
Agent-Logs-Url: https://github.com/webexpress-framework/WebExpress/sessions/c73b8b0d-3fcc-4a17-a830-f5c49098af80 Co-authored-by: ReneSchwarzer <31061438+ReneSchwarzer@users.noreply.github.com>
1 parent 865a0cc commit d908aa3

5 files changed

Lines changed: 81 additions & 17 deletions

File tree

.github/workflows/generate-docs.yml

Lines changed: 73 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ on:
55
branches: [main]
66
paths:
77
- 'site/**'
8-
- 'README.md'
9-
- 'CONTRIBUTING.md'
10-
- 'docs/**'
118
- '.github/workflows/generate-docs.yml'
129
workflow_dispatch:
1310

@@ -44,12 +41,79 @@ jobs:
4441
- name: Validate (no external resources)
4542
run: |
4643
set -euo pipefail
47-
# fail the build if any HTML file references third-party origins, which would
48-
# break GDPR compliance and the "no external requests" guarantee
49-
if grep -RInE 'https?://(cdn\.|fonts\.googleapis\.com|fonts\.gstatic\.com|www\.google-analytics\.com|googletagmanager\.com)' _site --include='*.html'; then
50-
echo "ERROR: external resource reference found — landing page must be self-contained." >&2
51-
exit 1
52-
fi
44+
python - <<'PY'
45+
from html.parser import HTMLParser
46+
from pathlib import Path
47+
48+
RESOURCE_ATTRIBUTES = {
49+
("script", "src"),
50+
("img", "src"),
51+
("img", "srcset"),
52+
("iframe", "src"),
53+
("audio", "src"),
54+
("video", "src"),
55+
("track", "src"),
56+
("source", "src"),
57+
("source", "srcset"),
58+
("embed", "src"),
59+
("object", "data"),
60+
}
61+
62+
LINK_RESOURCE_RELS = {
63+
"stylesheet",
64+
"icon",
65+
"apple-touch-icon",
66+
"manifest",
67+
"preload",
68+
"modulepreload",
69+
"prefetch",
70+
"dns-prefetch",
71+
"preconnect",
72+
"mask-icon",
73+
"shortcut icon",
74+
}
75+
76+
def external_values(raw_value: str):
77+
for candidate in raw_value.split(","):
78+
value = candidate.strip().split(" ", 1)[0]
79+
if value.startswith(("http://", "https://", "//")):
80+
yield value
81+
82+
class ResourceParser(HTMLParser):
83+
def __init__(self, path: Path):
84+
super().__init__()
85+
self.path = path
86+
self.violations = []
87+
88+
def handle_starttag(self, tag, attrs):
89+
attr_map = dict(attrs)
90+
rel_tokens = set(attr_map.get("rel", "").lower().split())
91+
92+
for name, value in attrs:
93+
if not value:
94+
continue
95+
96+
if (tag, name) in RESOURCE_ATTRIBUTES:
97+
for external in external_values(value):
98+
self.violations.append((tag, name, external))
99+
100+
if tag == "link" and name == "href":
101+
rel_value = attr_map.get("rel", "").lower().strip()
102+
if rel_tokens & LINK_RESOURCE_RELS or rel_value in LINK_RESOURCE_RELS:
103+
for external in external_values(value):
104+
self.violations.append((tag, name, external))
105+
106+
violations = []
107+
for path in Path("_site").rglob("*.html"):
108+
parser = ResourceParser(path)
109+
parser.feed(path.read_text(encoding="utf-8"))
110+
violations.extend((path, *violation) for violation in parser.violations)
111+
112+
if violations:
113+
for path, tag, attr, value in violations:
114+
print(f"{path}: external resource via <{tag} {attr}=\"{value}\">", flush=True)
115+
raise SystemExit("ERROR: external resource reference found — landing page must be self-contained.")
116+
PY
53117
54118
- name: Upload Pages artifact
55119
uses: actions/upload-pages-artifact@v3

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
![WebExpress-Framework](https://raw.githubusercontent.com/webexpress-framework/.github/main/docs/assets/img/banner.png)
22

33
# WebExpress
4-
WebExpress is a lightweight web server optimized for use in low-performance environments (e.g., Rasperry PI). By providing a powerful plugin system and a comprehensive API, web applications can be easily and quickly integrated into a .net language (e.g., C#). Some advantages of WebExpress are:
4+
WebExpress is a lightweight web server optimized for use in low-performance environments (e.g., Raspberry Pi). By providing a powerful plugin system and a comprehensive API, web applications can be easily and quickly integrated into a .NET language (e.g., C#). Some advantages of WebExpress are:
55

66
- It is easy to use.
77
- It offers a variety of features and tools that can help you build and manage your website.
@@ -44,4 +44,4 @@ Begin with our basic tutorial:
4444
- [WebIndex](https://github.com/webexpress-framework/WebExpress.Tutorial.WebIndex#readme)
4545

4646
# Tags
47-
#WebExpress #WebServer
47+
#WebExpress #WebServer

site/404.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<meta name="theme-color" content="#1e40af">
88
<title>Page not found — WebExpress</title>
99
<meta name="robots" content="noindex">
10-
<link rel="icon" href="/assets/img/favicon.svg" type="image/svg+xml">
11-
<link rel="stylesheet" href="/assets/css/styles.css">
10+
<link rel="icon" href="assets/img/favicon.svg" type="image/svg+xml">
11+
<link rel="stylesheet" href="assets/css/styles.css">
1212
</head>
1313
<body class="error-body">
1414
<main class="error-page">
@@ -17,7 +17,7 @@
1717
<h1>This page is not part of the WebExpress site.</h1>
1818
<p class="muted">The URL you requested does not exist here. From the home page you can reach the documentation, the contribution guide and the project on GitHub.</p>
1919
<p>
20-
<a class="btn btn--primary" href="/">Back to home</a>
20+
<a class="btn btn--primary" href="./">Back to home</a>
2121
<a class="btn btn--ghost" href="https://github.com/webexpress-framework/WebExpress" rel="noopener external">View on GitHub</a>
2222
</p>
2323
</div>

site/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ This folder is the source of the static landing page that is deployed to GitHub
2020
- System fonts only.
2121
- Responsive, mobile-first, WCAG AA in mind.
2222

23-
The workflow validates that no third-party origins are referenced from any
24-
HTML file before it deploys to Pages.
23+
The workflow validates that HTML files do not load third-party resources
24+
automatically before it deploys to Pages. Outbound links are allowed.
2525

2626
## Local preview
2727

site/imprint.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ <h2>Responsible for the content</h2>
4242
Maintainer: René Schwarzer<br>
4343
Email: <a href="mailto:webexpress-framework@outlook.com">webexpress-framework@outlook.com</a><br>
4444
Project page: <a href="https://github.com/webexpress-framework/WebExpress" rel="noopener external">github.com/webexpress-framework/WebExpress</a><br>
45-
Postal address: Available upon request where a legitimate interest is demonstrated (in accordance with GDPR Art. 6(1)(f))]
45+
Postal address: Available upon request where a legitimate interest is demonstrated (in accordance with GDPR Art. 6(1)(f))<br>
4646
</p>
4747

4848
<h2>Hosting</h2>

0 commit comments

Comments
 (0)