|
6 | 6 | paths: |
7 | 7 | - 'TankAlarm-092025-Server-Hologram/*.ino' |
8 | 8 | - 'TankAlarm-112025-Server-BluesOpta/*.ino' |
| 9 | + - 'TankAlarm-112025-Viewer-BluesOpta/*.ino' |
9 | 10 | - '.github/workflows/html-render.yml' |
10 | 11 | pull_request: |
11 | 12 | branches: [main, master] |
12 | 13 | paths: |
13 | 14 | - 'TankAlarm-092025-Server-Hologram/*.ino' |
14 | 15 | - 'TankAlarm-112025-Server-BluesOpta/*.ino' |
| 16 | + - 'TankAlarm-112025-Viewer-BluesOpta/*.ino' |
15 | 17 | - '.github/workflows/html-render.yml' |
16 | 18 | workflow_dispatch: |
17 | 19 |
|
@@ -187,6 +189,35 @@ jobs: |
187 | 189 | print(f'Extracted config generator HTML: {len(config_html)} bytes') |
188 | 190 | EOF |
189 | 191 |
|
| 192 | + - name: Extract and render HTML for 112025 Viewer |
| 193 | + run: | |
| 194 | + mkdir -p /tmp/html-112025-viewer |
| 195 | + python3 << 'EOF' |
| 196 | + import re |
| 197 | + |
| 198 | + ino_file = 'TankAlarm-112025-Viewer-BluesOpta/TankAlarm-112025-Viewer-BluesOpta.ino' |
| 199 | + output_dir = '/tmp/html-112025-viewer' |
| 200 | + |
| 201 | + with open(ino_file, 'r', encoding='utf-8', errors='ignore') as f: |
| 202 | + content = f.read() |
| 203 | + |
| 204 | + # Find the VIEWER_DASHBOARD_HTML constant |
| 205 | + html_pattern = r'static const char VIEWER_DASHBOARD_HTML\[\] PROGMEM = R"HTML\((.*?)\)HTML"' |
| 206 | + match = re.search(html_pattern, content, re.DOTALL) |
| 207 | + |
| 208 | + if match: |
| 209 | + html_content = match.group(1) |
| 210 | + |
| 211 | + # Replace the STR(WEB_REFRESH_SECONDS) macro with a placeholder value |
| 212 | + html_content = re.sub(r'\)HTML" STR\(WEB_REFRESH_SECONDS\) R"HTML\(', '30', html_content) |
| 213 | + |
| 214 | + output_file = output_dir + '/dashboard.html' |
| 215 | + with open(output_file, 'w', encoding='utf-8') as out: |
| 216 | + out.write(html_content) |
| 217 | + |
| 218 | + print(f'Extracted viewer dashboard HTML: {len(html_content)} bytes') |
| 219 | + EOF |
| 220 | +
|
190 | 221 | - name: Take screenshots with Playwright |
191 | 222 | run: | |
192 | 223 | node << 'EOF' |
@@ -251,6 +282,31 @@ jobs: |
251 | 282 | } |
252 | 283 | } |
253 | 284 | |
| 285 | + // Screenshot 112025 Viewer pages |
| 286 | + const dir112025Viewer = '/tmp/html-112025-viewer'; |
| 287 | + const output112025Viewer = 'TankAlarm-112025-Viewer-BluesOpta/screenshots'; |
| 288 | + |
| 289 | + if (fs.existsSync(dir112025Viewer)) { |
| 290 | + fs.mkdirSync(output112025Viewer, { recursive: true }); |
| 291 | + const files = fs.readdirSync(dir112025Viewer); |
| 292 | + |
| 293 | + for (const file of files) { |
| 294 | + if (file.endsWith('.html')) { |
| 295 | + const htmlPath = path.join(dir112025Viewer, file); |
| 296 | + const screenshotName = file.replace('.html', '.png'); |
| 297 | + const screenshotPath = path.join(output112025Viewer, screenshotName); |
| 298 | + |
| 299 | + try { |
| 300 | + await page.goto('file://' + htmlPath, { waitUntil: 'networkidle' }); |
| 301 | + await page.screenshot({ path: screenshotPath, fullPage: true }); |
| 302 | + console.log(`Screenshot saved: ${screenshotPath}`); |
| 303 | + } catch (error) { |
| 304 | + console.error(`Error capturing ${file}:`, error.message); |
| 305 | + } |
| 306 | + } |
| 307 | + } |
| 308 | + } |
| 309 | + |
254 | 310 | await browser.close(); |
255 | 311 | } |
256 | 312 | |
@@ -302,13 +358,29 @@ jobs: |
302 | 358 | *Last updated: $(date -u +"%Y-%m-%d %H:%M:%S UTC")* |
303 | 359 | EOF |
304 | 360 |
|
| 361 | + - name: Generate WEBSITE_PREVIEW.md for 112025 Viewer |
| 362 | + run: | |
| 363 | + cat > TankAlarm-112025-Viewer-BluesOpta/WEBSITE_PREVIEW.md << 'EOF' |
| 364 | + # Website Preview - TankAlarm 112025 Viewer |
| 365 | +
|
| 366 | + This document contains screenshots of the web interface served by the TankAlarm-112025-Viewer-BluesOpta. |
| 367 | +
|
| 368 | + ## Dashboard |
| 369 | +  |
| 370 | +
|
| 371 | + --- |
| 372 | + *Screenshots automatically generated by GitHub Actions* |
| 373 | + *Last updated: $(date -u +"%Y-%m-%d %H:%M:%S UTC")* |
| 374 | + EOF |
| 375 | +
|
305 | 376 | - name: Commit and push changes |
306 | 377 | if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') |
307 | 378 | run: | |
308 | 379 | git config --local user.email "github-actions[bot]@users.noreply.github.com" |
309 | 380 | git config --local user.name "github-actions[bot]" |
310 | 381 | git add TankAlarm-092025-Server-Hologram/WEBSITE_PREVIEW.md TankAlarm-092025-Server-Hologram/screenshots/ |
311 | 382 | git add TankAlarm-112025-Server-BluesOpta/WEBSITE_PREVIEW.md TankAlarm-112025-Server-BluesOpta/screenshots/ |
| 383 | + git add TankAlarm-112025-Viewer-BluesOpta/WEBSITE_PREVIEW.md TankAlarm-112025-Viewer-BluesOpta/screenshots/ |
312 | 384 | git diff --staged --quiet || git commit -m "Update website preview screenshots [skip ci]" |
313 | 385 | git push origin HEAD:${{ github.head_ref || github.ref_name }} |
314 | 386 | env: |
|
0 commit comments