mirror of
https://github.com/Coldsmiles/infstarweb.git
synced 2026-04-23 02:30:41 +08:00
5.4 KiB
5.4 KiB
Project Guidelines
Code Style
- This repo is framework-free: plain HTML + CSS + vanilla JavaScript — no frameworks, modules, or build tooling.
- Keep existing naming style:
camelCasefor JS functions/variables and descriptive DOM ids/classes (for examplefetchCrowdfunding,setupMobileMenu,#players-grid). - Preserve current formatting patterns: 4-space indentation in HTML/CSS, simple function-based JS.
- Shared JS utilities use the global-object pattern (e.g.
DataUtilsinjs/data_utils.js) — do not convert to ES modules. - Reuse shared tokens in
css/style.css(:rootvariables such as--bg-color,--accent-color) instead of introducing new ad-hoc styles. - Keep page-local style overrides scoped to their page blocks; avoid broad visual refactors unless explicitly requested.
- Keep user-facing copy in Chinese unless the surrounding section is already English.
Architecture
- Public pages are static entry points:
index.html+js/script.js: landing page, sponsors, fundraising progress, live server status.sponsor.html+js/sponsor_script.js: donation total, sponsor list, search/filter, donation modal.stats.html+js/stats_script.js: player leaderboard + searchable player cards + modal details.join.html+js/join_script.js: 4-step wizard (convention → agree → device → tutorial). Usesjs/marked.min.jsto renderdata/convention.mdas HTML.facilities.html+js/facilities_script.js: searchable/filterable catalog of server facilities fromdata/facilities.json. Supports Bilibili video embeds (BV IDs) in notes.doc.html,map.html,photo.html: iframe wrappers (navbar + fullscreen iframe to external hosts). No page-specific JS beyondjs/components.js.
- Shared utilities:
js/components.js: injected into#navbar-component/#footer-component, handles mobile menu & current-link highlighting.js/data_utils.js:DataUtils.parseSponsorsText()andDataUtils.buildSponsorTotals()— used by bothindex.htmlandsponsor.html.
- Shared visual system lives in
css/style.css; page-specific styles live incss/pages/(join.css,facilities.css,sponsor.css,stats.css). - Every page includes
<script type="application/ld+json">Schema.org metadata and full OG/Twitter Card meta tags. - Data flow for stats:
statsprocess.pyfetches raw player JSON files and writes normalized outputs tostats/.- It generates
stats/summary.jsonconsumed bystats_script.jsviafetch('stats/summary.json'). stats_script.jslazy-loadsstats/{uuid}.jsonwhen opening player details.
Build and Test
- No package manager/build step exists in this workspace.
- Local static preview:
python3 -m http.server 8000- open
http://localhost:8000/
- Regenerate player summary data:
python3 statsprocess.py(requiresSTATS_BASE_URL,STATS_USER,STATS_PASSenv vars for remote authentication).
- Python script dependencies are runtime imports in
statsprocess.py(not pinned):requests,tqdm. - CI/CD:
.github/workflows/deploy.ymlrunsstatsprocess.pythen deploys to GitHub Pages on push tomain, daily cron, or manual dispatch. Secrets live in GitHub Actions — never commit credentials.
Data Contracts
data/sponsors.txt: comma-separated fields (name, project, amount, [date]), parsed byDataUtils.parseSponsorsText().data/fund_progress.txt: line-parsed by frontend scripts.data/facilities.json: array of{title, intro, type, dimension, status, coordinates:{x,y,z}, contributors:[], instructions:[{type,content}], notes:[{type,content}]}. Notes withtype:"video"use Bilibili BV IDs.data/convention.md: Markdown server rules, rendered via marked.js in join wizard.stats/summary.jsonandstats/{uuid}.json: generated bystatsprocess.py— do not hand-edit.
Project Conventions
- Prefer progressive enhancement with
DOMContentLoadedinitializers (all page scripts andcomponents.js). - Keep network fetch paths relative for local assets.
- For unavailable remote APIs, follow existing behavior: log errors and render fallback text instead of throwing.
- Iframe wrapper pages (
doc.html,map.html,photo.html) share an identical pattern: navbar + inline-styled fullscreen iframe. Follow this pattern for new external-embed pages. - Do not introduce bundlers/framework migrations unless explicitly requested.
Integration Points
- External APIs/services:
- Server status:
https://api.mcstatus.io/v2/status/java/mcpure.lunadeer.cn - Avatars:
https://minotar.net/...andhttps://crafatar.com/... - Player name resolution in pipeline: Ashcon + Mojang Session APIs (
statsprocess.py). - Stats source endpoint: authenticated, URL in
STATS_BASE_URLsecret.
- Server status:
- External iframe hosts:
schema.lunadeer.cn(docs),mcmap.lunadeer.cn(map),mcphoto.lunadeer.cn(photo). - Navbar external links are centralized in
js/components.js. - External assets: Google Fonts, Font Awesome (CDN), Bilibili embeds (facilities notes).
Security
- Treat player UUID/name datasets in
stats/as production content; avoid destructive bulk edits. - Preserve SEO/verification metadata in page
<head>blocks unless a task explicitly targets SEO. - Avoid adding secrets/tokens to repository files; keep any future credentials out of static HTML/JS.
- Frontend rendering uses
innerHTMLwith fetched txt/json content in several views; keep those data sources trusted or sanitize before accepting untrusted input.