Skip to content

Commit 74843a7

Browse files
Merge pull request #11 from webexpress-framework/develop
Develop 0.0.11-alpha
2 parents 400f1db + d908aa3 commit 74843a7

18 files changed

Lines changed: 1485 additions & 61 deletions
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: Generate Docs
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'site/**'
8+
- '.github/workflows/generate-docs.yml'
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
pages: write
14+
id-token: write
15+
16+
concurrency:
17+
group: pages
18+
cancel-in-progress: false
19+
20+
jobs:
21+
build:
22+
name: Build landing page
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
- name: Configure GitHub Pages
29+
uses: actions/configure-pages@v5
30+
31+
- name: Stage static site
32+
run: |
33+
set -euo pipefail
34+
mkdir -p _site
35+
cp -r site/. _site/
36+
# disable Jekyll processing so files are served verbatim
37+
touch _site/.nojekyll
38+
# record build metadata (no personal data)
39+
date -u +"%Y-%m-%dT%H:%M:%SZ" > _site/build.txt
40+
41+
- name: Validate (no external resources)
42+
run: |
43+
set -euo pipefail
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
117+
118+
- name: Upload Pages artifact
119+
uses: actions/upload-pages-artifact@v3
120+
with:
121+
path: _site
122+
123+
deploy:
124+
name: Deploy to GitHub Pages
125+
needs: build
126+
runs-on: ubuntu-latest
127+
environment:
128+
name: github-pages
129+
url: ${{ steps.deployment.outputs.page_url }}
130+
steps:
131+
- name: Deploy
132+
id: deployment
133+
uses: actions/deploy-pages@v4

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

WebExpress.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<package>
33
<id>WebExpress</id>
4-
<version>0.0.10-alpha</version>
4+
<version>0.0.11-alpha</version>
55
<title>WebExpress</title>
66
<authors>webexpress-framework@outlook.com</authors>
77
<license>MIT</license>

0 commit comments

Comments
 (0)