This commit is contained in:
MeghdadFadaee committed 2026-10-18 14:28:53 +03:30
commit 584a04500f
21 files changed
+1014

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
name: Build and deploy OneUP
on:
push:
branches: [main, master]
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: pages-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v4
with:
node-version: '24'
- name: Verify content and behavior
run: npm test
- name: Download battle preview images
if: github.event_name != 'pull_request'
run: npm run sync:battles
- name: Build static pages
run: npm run build
- uses: actions/upload-pages-artifact@v4
if: github.event_name != 'pull_request'
with:
path: dist
deploy:
if: github.event_name != 'pull_request'
needs: build
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- uses: actions/configure-pages@v5
- name: Deploy
id: deployment
uses: actions/deploy-pages@v4
+19
View File
@@ -0,0 +1,19 @@
# Generated output and dependencies
/dist/
/node_modules/
/coverage/
*.log
# Local maintainer notes, environment files, and credentials
/.local/
.env
.env.*
!.env.example
/.aws/
# Editor and local agent state
/.idea/
/.vscode/
/.agents/
/.codex/
.DS_Store
+54
View File
@@ -0,0 +1,54 @@
# OneUP
**One United Power.** A bilingual static website for the OneUP Albion Online guild, with fight highlights, AlbionBB reports, recruitment, and seasonal rewards.
## Development
Requires Node.js 22 or newer. The project has no external build dependencies; no install step is needed.
```bash
npm run dev
```
Preview at `http://localhost:4173`. Restart after source or content changes to rebuild. Set `PORT` to use a different port.
| Command | Purpose |
| --- | --- |
| `npm run dev` | Build and serve a local preview |
| `npm run build` | Generate the static website in `dist/` |
| `npm test` | Validate content, URL handling, preview metadata, and generated pages |
| `npm run sync:battles` | Download social preview images for configured AlbionBB reports |
The build works offline. Battle image synchronization requires network access and preserves report links when previews are unavailable.
## Project structure
```text
content/ Guild data, reward configuration, and translations
docs/ Content format reference
public/assets/ Logo, jersey artwork, and optional media
scripts/ Static generator, preview server, and battle image sync
src/ Styles and browser interactions
test/ Node.js tests
.github/workflows/ Build and deployment workflow
```
## Content
| File | Purpose |
| --- | --- |
| `content/site.json` | Site URL, guild profile, recruitment, socials, clips, and battle reports |
| `content/rewards.json` | Milestone targets, Silver payouts, and reward artwork |
| `content/translations.json` | English and Persian interface copy |
Localized fields accept `{ "en": "English", "fa": "فارسی" }` or a plain string. Missing Persian values fall back to English. See [the content reference](docs/content.md) for media formats, battle report fields, recruitment, and rewards.
## Architecture
The Node.js generator renders complete HTML pages at `/` (English) and `/fa/` (Persian, RTL). Vanilla JavaScript handles navigation, reward tabs, media dialogs, and language preferences. A one-year `oneup_language` cookie remembers the selected language; `?lang=en` or `?lang=fa` overrides it.
The build emits canonical and language alternate links, social metadata, organization structured data, `robots.txt`, `sitemap.xml`, a circular SVG favicon, and a custom-domain `CNAME`. Hosting assumes the domain root rather than a repository subpath.
YouTube uses thumbnails and a privacy-enhanced player loaded on request. Direct video URLs use the native video element. AlbionBB previews are cached at build time; explicit image URLs and Europe single/combined battle preview URLs also work without a local cache. Fonts are served by Google Fonts, with system fallbacks.
The GitHub Actions workflow validates pull requests. Pushes to `main` or `master` also synchronize battle previews, build, and deploy the static artifact to GitHub Pages. Generated output is not tracked.
+13
View File
@@ -0,0 +1,13 @@
{
"jerseyImage": "assets/reward-picture.jpg",
"firstToTargetSilver": 20000000,
"categories": [
{ "id": "hellgate", "name": { "en": "Hellgate", "fa": "هل‌گیت" }, "target": 200000, "podium": [50000000, 20000000] },
{ "id": "depths", "name": { "en": "Depths", "fa": "اعماق" }, "target": 200000, "podium": [50000000, 20000000] },
{ "id": "power-core", "name": { "en": "Hideout Power Core", "fa": "پاورکور هاید‌اوت" }, "target": 150000, "podium": [30000000, 20000000, 10000000] },
{ "id": "ancient-lands", "name": { "en": "Ancient Lands", "fa": "سرزمین‌های باستانی" }, "target": 300000, "podium": [20000000, 10000000] },
{ "id": "gathering", "name": { "en": "Gathering", "fa": "جمع‌آوری منابع" }, "target": 300000, "podium": [20000000] },
{ "id": "corrupted", "name": { "en": "Corrupted", "fa": "کوراپتد" }, "target": 200000, "podium": [20000000] },
{ "id": "crystal-creatures", "name": { "en": "Crystal Creatures", "fa": "موجودات کریستالی" }, "target": 300000, "podium": [20000000] }
]
}
+68
View File
@@ -0,0 +1,68 @@
{
"siteUrl": "https://oneup.megh.dad",
"guildName": "OneUP",
"motto": "One United Power.",
"members": "100+",
"recruiting": true,
"recruitment": {
"intro": {
"en": "Welcome to OneUP recruitment! We are a PvP-focused guild looking for experienced and active players to join our community.",
"fa": "به بخش جذب اعضای وان‌آپ خوش آمدید! ما یک گیلد متمرکز بر PvP هستیم و از بازیکنان باتجربه و فعال برای پیوستن به جمعمان دعوت می‌کنیم."
},
"activities": [
{ "en": "Ganking", "fa": "گنکینگ" },
{ "en": "Dive Content", "fa": "دایو کانتنت" },
{ "en": "Small Scale PvP", "fa": "نبردهای PvP اسمال‌اسکیل" },
{ "en": "Group Roaming & Open World Fights", "fa": "رومینگ گروهی و نبردهای جهان باز" },
{ "en": "Static Diving and PvP Activities", "fa": "دایو استاتیک و فعالیت‌های PvP" }
],
"fameRequirements": [
{ "value": "200M+", "label": { "en": "Total Fame", "fa": "فیم کل" } },
{ "value": "10M+", "label": { "en": "PvP Fame", "fa": "فیم PvP" } }
],
"requirements": [
{ "en": "Active and willing to participate in guild content", "fa": "فعال باشید و برای شرکت در فعالیت‌های گیلد آمادگی داشته باشید" },
{ "en": "Team player with a positive attitude", "fa": "روحیه کار تیمی و نگرش مثبت داشته باشید" },
{ "en": "Able to communicate and coordinate with the guild", "fa": "توانایی ارتباط و هماهنگی با اعضای گیلد را داشته باشید" }
],
"applicationIntro": {
"en": "If you meet the requirements and want to be part of an active and competitive community, we’d be happy to have you!",
"fa": "اگر این شرایط را دارید و می‌خواهید عضوی از یک جمع فعال و رقابتی باشید، خوشحال می‌شویم به ما بپیوندید!"
},
"applicationInstructions": {
"en": "Open a ticket in the #apply section and tell us a little about yourself.",
"fa": "در بخش #apply یک تیکت باز کنید و کمی درباره خودتان بگویید."
},
"welcome": {
"en": "Welcome to OneUP — One United Power.",
"fa": "به وان‌آپ خوش آمدید — یک قدرت متحد."
}
},
"seasonLabel": { "en": "Season rewards", "fa": "جوایز فصل" },
"description": {
"en": "OneUP is an Albion Online guild of 100+ members. One United Power. Explore our battles, fight highlights, community, and seasonal member rewards.",
"fa": "وان‌آپ، گیلد آلبیون آنلاین با بیش از ۱۰۰ عضو. یک قدرت متحد. نبردها، ویدیوها، جامعه و جوایز فصلی اعضای ما را ببینید."
},
"socials": [
{ "name": "Discord", "kind": "discord", "url": "", "description": { "en": "Where the guild comes together.", "fa": "محل گردهمایی اعضای گیلد." } },
{ "name": "Telegram", "kind": "telegram", "url": "", "description": { "en": "News from the front line.", "fa": "تازه‌ترین خبرها از خط مقدم." } },
{ "name": "YouTube", "kind": "youtube", "url": "", "description": { "en": "Our fights. Our point of view.", "fa": "نبردهای ما، از نگاه ما." } }
],
"clips": [
{
"title": { "en": "OneUP — Battle highlights", "fa": "وان‌آپ — لحظه‌های نبرد" },
"type": "youtube",
"url": "https://www.youtube.com/watch?v=aVU4upHCGbc"
}
],
"battles": [
{
"title": { "en": "Battle #448776222", "fa": "نبرد شماره ۴۴۸۷۷۶۲۲۲" },
"url": "https://europe.albionbb.com/battles/448776222"
},
{
"title": { "en": "Combined battle report — 3 engagements", "fa": "گزارش ترکیبی — ۳ نبرد" },
"url": "https://europe.albionbb.com/battles/multi?ids=441002770,441001581,440997498"
}
]
}
+40
View File
@@ -0,0 +1,40 @@
{
"en": {
"battleArchive": "From the war archive", "singleReport": "Battle report", "combinedReport": "Campaign report", "europe": "Europe", "engagement": "engagement", "engagements": "engagements", "reportIds": "Battle report IDs", "archivedReports": "Archived reports", "loggedEngagements": "Recorded engagements", "archiveMotto": "One banner. Every battlefield.", "detailedLog": "Detailed battle log",
"mainContent": "Our main content", "recruitmentRequirements": "Entry requirements", "applicationTitle": "Ready to join the ranks?", "applyDiscord": "Apply on Discord",
"title": "OneUP — One United Power. | Albion Online Guild",
"skip": "Skip to content", "guild": "ALBION ONLINE GUILD", "nav": ["The guild", "War chronicles", "Battle board", "Rewards"],
"join": "Join the ranks", "recruiting": "THE RANKS ARE OPEN", "closed": "THE GUILD STANDS UNITED",
"eyebrow": "MANY WARRIORS. ONE BANNER.", "hero1": "ONE UNITED", "hero2": "POWER.",
"intro": "Different warriors. The same resolve. We are OneUP — a guild built on unity, driven by battle, and defined by the people beside us.",
"watch": "Watch us fight", "scroll": "ENTER THE WORLD OF ONEUP", "memberLabel": "MEMBERS. ONE PURPOSE.",
"manifestoLabel": "01 / THE GUILD", "manifestoTitle": "A guild is a name.", "manifestoAccent": "A brotherhood is a choice.",
"manifestoText": "From the first call to the final clash, we stand together. More than a hundred members, each bringing something to the banner. Every fight is ours. Every contribution matters.",
"pillars": [ { "title": "United in battle", "text": "One call. One direction. We fight as a guild, with trust in the people at our side." }, { "title": "Stronger together", "text": "From gathering to the front line, every role helps build the strength of OneUP." }, { "title": "Earn your legacy", "text": "Push your limits. Reach the milestones. Let your contribution become part of our story." } ],
"clipsLabel": "02 / WAR CHRONICLES", "clipsTitle": "Let the fights", "clipsAccent": "do the talking.", "clipsIntro": "The clashes, the calls, the moments worth reliving. From our side of the battlefield.",
"all": "All footage", "youtube": "YouTube", "direct": "Guild uploads", "play": "Play video", "close": "Close video", "clipsEmpty": "The next chapter is being written.", "clipsEmptyText": "Our fight highlights will appear here. Until then, the banner keeps moving.", "noFilter": "No footage in this category yet.",
"battlesLabel": "03 / THE BATTLE BOARD", "battlesTitle": "Every battle.", "battlesAccent": "Part of our story.", "battlesIntro": "Reports from the front line. Explore our recorded fights on AlbionBB.", "albionbb": "Explore AlbionBB", "report": "View battle report", "battleEmpty": "The field is quiet. For now.", "battleEmptyText": "Battle reports will be posted here after our fights.", "date": "Date", "battle": "Battle", "outcome": "Outcome", "kills": "Kills", "deaths": "Deaths", "victory": "Victory", "defeat": "Defeat", "draw": "Draw", "recorded": "Recorded",
"rewardsLabel": "04 / THE SPOILS OF DEDICATION", "rewardsTitle": "Your effort.", "rewardsAccent": "Your reward.", "rewardsIntro": "Two ways to make your mark. Race to a milestone or rise through the season rankings. Your contribution counts.",
"first": "First to the finish", "podium": "Season podium", "firstRule": "One winner per category: the first member to reach the target earns 20M Silver and a custom OneUP jersey.", "podiumRule": "Awarded at the end of the season to the highest-ranked members in each category.", "category": "Category", "target": "Point target", "prize": "Reward", "rank1": "1st place", "rank2": "2nd place", "rank3": "3rd place", "silver": "Silver", "jersey": "Custom jersey", "jerseyLabel": "WEAR THE BANNER", "jerseyTitle": "Earned. Never given.", "jerseyText": "The OneUP custom jersey. A real-world reward for the first member to hit each category’s milestone.", "jerseyAlt": "Black and white OneUP custom guild jerseys, front and back", "jerseyZoom": "View jersey artwork", "closeImage": "Close jersey artwork",
"communityLabel": "05 / ANSWER THE CALL", "communityTitle": "Your next chapter", "communityAccent": "starts with us.", "communityText": "Find your people. Bring your ambition. Stand beneath the OneUP banner.", "socialSoon": "Link coming soon", "socialOpen": "Visit", "footer": "Many warriors. One United Power.", "fan": "An independent Albion Online guild community. Albion Online belongs to Sandbox Interactive.", "top": "Back to top", "menu": "Toggle navigation", "videoFallback": "Open original video", "videoError": "This video could not be loaded. You can open the original link below."
},
"fa": {
"battleArchive": "از آرشیو نبردها", "singleReport": "گزارش نبرد", "combinedReport": "گزارش مجموعه نبردها", "europe": "اروپا", "engagement": "نبرد", "engagements": "نبرد", "reportIds": "شناسه گزارش نبردها", "archivedReports": "گزارش ثبت‌شده", "loggedEngagements": "نبرد ثبت‌شده", "archiveMotto": "یک پرچم، در هر میدان نبرد.", "detailedLog": "جزئیات گزارش نبردها",
"mainContent": "فعالیت‌های اصلی ما", "recruitmentRequirements": "شرایط پیوستن", "applicationTitle": "آماده پیوستن به ما هستید؟", "applyDiscord": "درخواست عضویت در دیسکورد",
"title": "وان‌آپ — یک قدرت متحد | گیلد آلبیون آنلاین",
"skip": "رفتن به محتوای اصلی", "guild": "گیلد آلبیون آنلاین", "nav": ["درباره گیلد", "روایت نبردها", "گزارش نبرد", "جوایز"],
"join": "به ما بپیوندید", "recruiting": "پذیرش جنگجویان تازه", "closed": "متحد زیر یک پرچم",
"eyebrow": "جنگجویان بسیار. یک پرچم.", "hero1": "یک قدرت", "hero2": "متحد.",
"intro": "جنگجویانی متفاوت، با اراده‌ای مشترک. ما وان‌آپ هستیم؛ گیلدی ساخته‌شده بر پایه اتحاد، با انگیزه نبرد و قدرت همراهانمان.",
"watch": "نبردهای ما را ببینید", "scroll": "به دنیای وان‌آپ قدم بگذارید", "memberLabel": "عضو. یک هدف مشترک.",
"manifestoLabel": "۰۱ / گیلد ما", "manifestoTitle": "گیلد یک نام است.", "manifestoAccent": "برادری یک انتخاب.",
"manifestoText": "از اولین فراخوان تا آخرین درگیری، کنار هم می‌ایستیم. بیش از صد عضو که هر کدام سهمی در قدرت این پرچم دارند. هر نبرد برای همه ماست و هر مشارکتی ارزش دارد.",
"pillars": [ { "title": "متحد در نبرد", "text": "یک فرمان، یک مسیر. با اعتماد به همراهانمان، در کنار هم می‌جنگیم." }, { "title": "با هم قوی‌تریم", "text": "از جمع‌آوری منابع تا خط مقدم، هر نقش به قدرت وان‌آپ اضافه می‌کند." }, { "title": "نامت را ماندگار کن", "text": "از محدودیت‌هایت عبور کن، به هدف‌ها برس و سهمت را در داستان ما بساز." } ],
"clipsLabel": "۰۲ / روایت نبردها", "clipsTitle": "بگذار نبردها", "clipsAccent": "حرف بزنند.", "clipsIntro": "درگیری‌ها، فرمان‌ها و لحظه‌هایی که ارزش دوباره دیدن دارند؛ از نگاه ما در میدان نبرد.",
"all": "همه ویدیوها", "youtube": "یوتیوب", "direct": "ویدیوهای گیلد", "play": "پخش ویدیو", "close": "بستن ویدیو", "clipsEmpty": "فصل بعدی در حال نوشته شدن است.", "clipsEmptyText": "ویدیوهای نبرد ما اینجا قرار می‌گیرند. تا آن زمان، پرچم همچنان برافراشته است.", "noFilter": "هنوز ویدیویی در این دسته قرار نگرفته است.",
"battlesLabel": "۰۳ / گزارش میدان نبرد", "battlesTitle": "هر نبرد،", "battlesAccent": "بخشی از داستان ما.", "battlesIntro": "گزارش‌هایی از خط مقدم. جزئیات نبردهای ما را در آلبیون‌بی‌بی ببینید.", "albionbb": "مشاهده آلبیون‌بی‌بی", "report": "مشاهده گزارش نبرد", "battleEmpty": "میدان فعلاً آرام است.", "battleEmptyText": "گزارش نبردها پس از هر مبارزه در این بخش منتشر می‌شود.", "date": "تاریخ", "battle": "نبرد", "outcome": "نتیجه", "kills": "کشتن", "deaths": "مرگ", "victory": "پیروزی", "defeat": "شکست", "draw": "مساوی", "recorded": "ثبت‌شده",
"rewardsLabel": "۰۴ / پاداش پشتکار", "rewardsTitle": "تلاش تو.", "rewardsAccent": "پاداش تو.", "rewardsIntro": "دو راه برای درخشیدن. زودتر به هدف برس یا در پایان فصل در صدر جدول باش. مشارکت تو ارزشمند است.",
"first": "اولین نفر در خط پایان", "podium": "سکوی پایان فصل", "firstRule": "در هر دسته فقط یک برنده: اولین عضوی که به امتیاز هدف برسد، ۲۰ میلیون سیلور و یک لباس اختصاصی وان‌آپ می‌گیرد.", "podiumRule": "این جوایز در پایان فصل، بر اساس رتبه جدول هر دسته، به اعضای برتر تعلق می‌گیرد.", "category": "دسته", "target": "امتیاز هدف", "prize": "جایزه", "rank1": "نفر اول", "rank2": "نفر دوم", "rank3": "نفر سوم", "silver": "سیلور", "jersey": "لباس اختصاصی", "jerseyLabel": "پرچم را به تن کن", "jerseyTitle": "با تلاش به دستش بیاور.", "jerseyText": "لباس اختصاصی وان‌آپ؛ پاداشی در دنیای واقعی برای اولین عضوی که به هدف امتیازی هر دسته برسد.", "jerseyAlt": "نمای جلو و پشت لباس‌های اختصاصی مشکی و سفید گیلد وان‌آپ", "jerseyZoom": "مشاهده طرح لباس", "closeImage": "بستن تصویر لباس",
"communityLabel": "۰۵ / به فراخوان پاسخ بده", "communityTitle": "فصل بعدی تو", "communityAccent": "با ما آغاز می‌شود.", "communityText": "همراهانت را پیدا کن. با انگیزه بیا و زیر پرچم وان‌آپ بایست.", "socialSoon": "لینک به‌زودی", "socialOpen": "مشاهده", "footer": "جنگجویان بسیار. یک قدرت متحد.", "fan": "جامعه مستقل گیلد آلبیون آنلاین. آلبیون آنلاین متعلق به Sandbox Interactive است.", "top": "بازگشت به بالا", "menu": "باز و بسته کردن منو", "videoFallback": "باز کردن لینک اصلی ویدیو", "videoError": "ویدیو بارگذاری نشد. می‌توانید لینک اصلی را در پایین باز کنید."
}
}
+82
View File
@@ -0,0 +1,82 @@
# Content reference
All guild content lives in three JSON files:
| File | What to edit |
| --- | --- |
| `content/site.json` | Domain, member count, recruitment status and details, social links, clips, battle reports, SEO descriptions |
| `content/rewards.json` | Point targets, Silver payouts, and jersey artwork |
| `content/translations.json` | English and Persian page text |
Translated fields accept `{ "en": "English text", "fa": "متن فارسی" }`. A plain string also works. Missing Persian entries fall back to English.
## Recruitment
Recruitment copy, PvP activities, fame thresholds, and application instructions are editable in `recruitment` within `content/site.json`. The community section presents these in English and Persian; an “Apply on Discord” button appears automatically when the Discord social URL is configured.
## Social links
Set each social's `url` to its real HTTPS invite/channel address. Empty URLs display a translated “Link coming soon” label. Add or remove entries freely; `kind` supports `discord`, `telegram`, `youtube`, or a generic globe for other services.
## Fight clips
Add to the `clips` array in `content/site.json`:
```json
{
"title": { "en": "Your fight title", "fa": "عنوان نبرد شما" },
"description": { "en": "A short description", "fa": "توضیح کوتاه" },
"type": "youtube",
"url": "https://www.youtube.com/watch?v=YOUR_VIDEO_ID",
"duration": "04:32"
}
```
Replace the video ID with a real 11-character YouTube ID. Watch, short-link, Shorts, Live, and embed URLs are supported. YouTube previews use the video's thumbnail; the privacy-enhanced player loads only after a click.
For a direct MP4/WebM file, use `"type": "direct"`, a publicly accessible HTTPS media URL, and optionally `"poster": "assets/my-fight.jpg"`. The media host must permit browser playback. Use a URL for the actual video file, rather than a sharing page. A link to the original is always available in the player.
Put additional local images under `public/assets/` and reference them as `assets/filename.jpg`. Do not add `public/` to content paths. Large videos are better hosted on YouTube or an external media host.
## Battle reports and AlbionBB preview images
Add each battle manually to `battles` after the fight:
```json
{
"title": { "en": "Your battle title", "fa": "عنوان نبرد شما" },
"date": "2026-10-18",
"url": "https://europe.albionbb.com/battles/448776222"
}
```
The sample title and date are illustrative. Omit the date or results when unknown.
Optional fields: `"date": "2026-10-18"`, `"outcome": "victory"` (also `defeat`, `draw`, or `recorded`), `"kills": 0`, and `"deaths": 0`. Enter verified guild-specific numbers. Omit unknown dates and figures; they display as dashes. Reports sort by date, newest first, with undated reports following in JSON order. Combined `/battles/multi?ids=...` links are supported and receive distinct preview cache filenames.
Only the report URL is needed to discover its preview; no `preview` field is required. The GitHub deployment automatically runs `npm run sync:battles`, which reads each report's `twitter:image` or `og:image`, including combined reports. If the report page cannot be read or has no image metadata, Europe reports fall back to endpoints derived from the report URL: `https://api.albionbb.com/eu/preview/BATTLE_ID` for a single battle, or `https://api.albionbb.com/eu/preview/multi?ids=ID1,ID2,...` for combined battles. An optional explicit `preview` field overrides discovery.
PNG/JPEG/WebP images are downloaded to `public/assets/battles/` and included in the generated site. If a download fails, the discovered remote URL remains usable by the browser; an existing local image cache is preserved. Europe single and combined preview URLs are also derived directly during local builds without synchronization. Image display does not require a cross-origin API request. Downloaded files on the Actions runner are included in deployment but are not committed back to Git.
Every report renders a visual card with local decorative terrain artwork, guild branding, report IDs, and single/combined report labels. Report images display in full without cropping; missing or failed images retain the local artwork. Combined reports use the combined scoreboard image; a single engagement's image is not substituted for the combined results. The map is decorative, not a reconstruction of the battle. Archive counts use report entries and unique battle IDs from their URLs. Only supplied dates and results are shown. The full table is available in the expandable detailed log.
To download previews locally, run:
```bash
npm run sync:battles
```
Commit `public/assets/battles/` if you want persistent local fallback images. An optional `preview` field can provide an explicit HTTPS image URL or a local `assets/` path. This is useful if AlbionBB changes its metadata. Override an old cached image by syncing the report again or removing its entry from `public/assets/battles/previews.json`.
You can inspect/download a report's preview without publishing it to the battle archive:
```bash
npm run sync:battles -- https://europe.albionbb.com/battles/448776222
```
## Rewards
The reward model supports one first-to-target winner per category and a separate end-of-season podium. Targets, payouts, and jersey artwork are configured in `content/rewards.json`. Values use whole Silver: `20000000` means 20M. Update the explanatory text in `content/translations.json` when changing the jersey rule or adding different prizes.
Artwork lives in `public/assets/`. The build copies it into the site and creates a circular favicon with transparent corners from the original logo. The reward rules are maintained in `content/rewards.json`.
+14
View File
@@ -0,0 +1,14 @@
{
"name": "oneup-guild",
"description": "Bilingual static website for the OneUP Albion Online guild.",
"version": "1.0.0",
"private": true,
"type": "module",
"engines": { "node": ">=22" },
"scripts": {
"build": "node scripts/build.mjs",
"dev": "node scripts/serve.mjs",
"test": "node --test",
"sync:battles": "node scripts/sync-battles.mjs"
}
}
+34
View File
@@ -0,0 +1,34 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 700" fill="none">
<defs>
<pattern id="grid" width="60" height="60" patternUnits="userSpaceOnUse"><path d="M60 0H0V60" stroke="#a6a1a1" stroke-opacity=".09"/></pattern>
<pattern id="hatch" width="12" height="12" patternUnits="userSpaceOnUse" patternTransform="rotate(35)"><path d="M0 0V12" stroke="#cf394c" stroke-opacity=".2"/></pattern>
<radialGradient id="glow"><stop stop-color="#b51f2f" stop-opacity=".3"/><stop offset="1" stop-color="#b51f2f" stop-opacity="0"/></radialGradient>
<linearGradient id="river" x1="430" y1="0" x2="880" y2="700" gradientUnits="userSpaceOnUse"><stop stop-color="#1d2930"/><stop offset="1" stop-color="#1c2024"/></linearGradient>
<symbol id="unit" viewBox="0 0 20 20"><path d="m10 2 8 8-8 8-8-8Z" fill="currentColor"/><path d="m6 10 4-4 4 4-4 4Z" stroke="#101111" stroke-width="1.5"/></symbol>
</defs>
<path fill="#141719" d="M0 0h1200v700H0z"/>
<path fill="url(#grid)" d="M0 0h1200v700H0z"/>
<g stroke="#7d8587" stroke-opacity=".2" stroke-width="1.3">
<path d="M-90 160c145-140 234-119 333-22s185 80 265 18 167-74 232-36 167 14 205-66S1105-9 1260 42"/>
<path d="M-75 182C72 38 153 63 241 157s190 93 279 23 157-65 210-33 182 34 229-52 154-83 291-27"/>
<path d="M-60 208C89 64 165 92 246 180s194 111 287 32 144-59 191-29 202 47 250-47 147-73 267-32"/>
<path d="M-50 240C95 94 167 122 246 207s203 127 301 38 128-52 175-24 212 64 267-42 137-56 253-26"/>
<path d="M-70 584c140-159 205-182 325-146s120 125 232 111 92-113 207-115 130 136 244 104 181-111 317-75"/>
<path d="M-45 614c129-156 187-177 297-144s128 125 243 110 90-113 195-113 134 136 254 104 170-105 299-76"/>
<path d="M-12 644c119-149 160-170 260-139s138 123 257 108 91-113 185-112 138 136 258 107 162-102 290-79"/>
<path d="M18 672c105-141 134-160 225-132s146 120 274 105 93-113 175-110 143 132 257 108 158-99 280-83"/>
<path d="M65 700c85-125 94-135 170-115s151 108 290 95 96-110 167-108 154 121 259 107 147-81 264-78"/>
<path d="M21 324c59-56 125-73 183-32s53 78 121 84 104-53 152-20M20 346c59-56 118-68 174-29s57 81 128 82 110-51 158-20"/>
<path d="M865 260c86-55 153-20 183 35s109 87 176 55M851 284c83-55 146-19 176 37s116 88 184 56M842 309c73-47 133-11 164 41s121 88 193 55"/>
</g>
<path d="M590-20c-22 103-140 156-143 247s175 74 157 166-11 101 87 150 59 123 35 184" stroke="#7e8c91" stroke-opacity=".12" stroke-width="33"/>
<path d="M590-20c-22 103-140 156-143 247s175 74 157 166-11 101 87 150 59 123 35 184" stroke="url(#river)" stroke-width="27"/>
<path d="m340 194 245-72 229 112 73 228-280 95-230-97Z" fill="url(#hatch)" stroke="#cf394c" stroke-opacity=".35" stroke-dasharray="7 8"/>
<ellipse cx="614" cy="345" rx="320" ry="280" fill="url(#glow)"/>
<g stroke="#ce4353" stroke-width="2" stroke-dasharray="6 10" opacity=".7"><path d="m205 470 92-73 70 12 121-73 126 9"/><path d="m931 167-65 83-90 15-71 77-91 3"/></g>
<g color="#d14655"><use href="#unit" x="218" y="433" width="20" height="20"/><use href="#unit" x="244" y="451" width="20" height="20"/><use href="#unit" x="270" y="469" width="20" height="20"/><use href="#unit" x="243" y="414" width="20" height="20"/><use href="#unit" x="269" y="432" width="20" height="20"/><use href="#unit" x="295" y="450" width="20" height="20"/></g>
<g color="#c1c3c0"><use href="#unit" x="877" y="176" width="20" height="20"/><use href="#unit" x="903" y="194" width="20" height="20"/><use href="#unit" x="929" y="212" width="20" height="20"/><use href="#unit" x="901" y="151" width="20" height="20"/><use href="#unit" x="927" y="169" width="20" height="20"/><use href="#unit" x="953" y="187" width="20" height="20"/></g>
<g stroke="#cf394c"><circle cx="614" cy="345" r="83" stroke-opacity=".4"/><circle cx="614" cy="345" r="107" stroke-opacity=".15"/><path d="M614 221v26m0 196v26M490 345h26m196 0h26" stroke-opacity=".6"/><circle cx="614" cy="345" r="56" fill="#171215" stroke-opacity=".7"/></g>
<g stroke="#e2d5d7" stroke-width="3" stroke-linecap="square"><path d="m586 317 8 2 43 43-6 6-43-43-2-8Zm56 0-8 2-16 16m-13 13-17 17 6 6 17-17M579 361l14 14m42-14 14 14m-57-6-9 9m53-9 9 9"/></g>
<g stroke="#a09a9b" stroke-opacity=".5"><path d="M67 62v40M47 82h40M1133 598v40m-20-20h40"/><path d="m1085 75 8-26 8 26-8-6Z" fill="#d4c8ca" stroke="none"/><path d="M1093 78v20"/></g>
</svg>

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

+46
View File
@@ -0,0 +1,46 @@
import { safeUrl } from './lib.mjs';
import { createHash } from 'node:crypto';
const decode = value => value.replace(/&amp;/g,'&').replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&#(\d+);/g,(_,n)=>String.fromCodePoint(Number(n)));
// Europe preview routes supplied from AlbionBB's Twitter metadata.
export function directPreview(url) {
try {
const u=new URL(url);
if(u.protocol!=='https:'||u.hostname!=='europe.albionbb.com') return null;
if(/^\/battles\/multi\/?$/.test(u.pathname)){
const ids=u.searchParams.get('ids');
return /^\d+(?:,\d+)*$/.test(ids||'')?`https://api.albionbb.com/eu/preview/multi?ids=${ids}`:null;
}
const id=u.pathname.match(/^\/battles\/(\d+)\/?$/)?.[1];
return id?`https://api.albionbb.com/eu/preview/${id}`:null;
} catch { return null; }
}
export function socialImage(html, pageUrl) {
const images = new Map();
for (const tag of html.matchAll(/<meta\b[^>]*>/gi)) {
const attrs = {};
for (const a of tag[0].matchAll(/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/g)) attrs[a[1].toLowerCase()] = decode(a[2]??a[3]??a[4]);
const key=(attrs.property||attrs.name||'').toLowerCase();
if (attrs.content) images.set(key,attrs.content);
}
const value=images.get('twitter:image')||images.get('twitter:image:src')||images.get('og:image:secure_url')||images.get('og:image');
if (!value) return null;
try { const url=new URL(value,pageUrl).href; return safeUrl(url)?url:null; } catch { return null; }
}
export async function discoverPreview(battle, fetchImpl=fetch) {
if (battle.preview) return battle.preview;
let metadataError;
try {
const page=await fetchImpl(battle.url,{signal:AbortSignal.timeout(15000),headers:{'User-Agent':'OneUP-Guild-Preview/1.0'}});
if (!page.ok) throw Error(`Report returned HTTP ${page.status}`);
const discovered=socialImage(await page.text(),battle.url);
if (discovered) return discovered;
} catch(error) { metadataError=error; }
const fallback=directPreview(battle.url);
if (fallback) return fallback;
throw metadataError||Error('No Twitter/Open Graph preview found for this report.');
}
export function battleKey(url) {
const u=new URL(url);
const queryKey=u.search?`-${createHash('sha256').update(u.search).digest('hex').slice(0,16)}`:'';
return `${u.hostname.replace(/[^a-z0-9.-]/gi,'-')}-${u.pathname.split('/').filter(Boolean).pop().replace(/[^a-z0-9-]/gi,'-')}${queryKey}`;
}
+91
View File
@@ -0,0 +1,91 @@
import { readFile, writeFile, mkdir, rm, cp, access } from 'node:fs/promises';
import { escapeHtml as e, localized, youtubeId, validate } from './lib.mjs';
import { renderBattleCards } from './render-battles.mjs';
const read = async name => JSON.parse(await readFile(new URL(`../content/${name}.json`, import.meta.url), 'utf8'));
const [site, rewards, translations] = await Promise.all(['site','rewards','translations'].map(read));
validate(site, rewards);
let previews={};
try { previews=JSON.parse(await readFile(new URL('../public/assets/battles/previews.json',import.meta.url),'utf8')); } catch(err) { if(err.code!=='ENOENT') throw err; }
const root = new URL('../', import.meta.url);
const dist = new URL('../dist/', import.meta.url);
await rm(dist, { recursive: true, force: true });
await mkdir(new URL('assets/', dist), { recursive: true });
for (const [from,to] of [['src/styles.css','styles.css'],['src/app.js','app.js']]) await cp(new URL(from,root),new URL(`assets/${to}`,dist));
try { await cp(new URL('public/assets/',root),new URL('assets/',dist),{ recursive:true }); } catch(err) { if(err.code !== 'ENOENT') throw err; }
await rm(new URL('assets/battles/previews.json',dist),{force:true});
const faviconLogo=(await readFile(new URL('public/assets/logo.jpg',root))).toString('base64');
await writeFile(new URL('assets/favicon.svg',dist),`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><defs><clipPath id="circle"><circle cx="320" cy="320" r="320"/></clipPath></defs><image width="640" height="640" href="data:image/jpeg;base64,${faviconLogo}" clip-path="url(#circle)"/></svg>`);
for (const path of [rewards.jerseyImage,...site.clips.map(c=>c.poster).filter(p=>p?.startsWith('assets/'))]) await access(new URL(path,dist));
const origin = site.siteUrl.replace(/\/$/, '');
const icon = (name, cls='') => `<svg class="icon ${cls}" aria-hidden="true"><use href="#i-${name}"/></svg>`;
const glyphs = `<svg class="svg-defs" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><defs>
<symbol id="i-arrow" viewBox="0 0 24 24"><path d="M4 12h16m-6-6 6 6-6 6"/></symbol>
<symbol id="i-diagonal" viewBox="0 0 24 24"><path d="M5 19 19 5M5 5h14v14"/></symbol>
<symbol id="i-play" viewBox="0 0 24 24"><path d="m9 5 11 7-11 7Z"/></symbol>
<symbol id="i-swords" viewBox="0 0 24 24"><path d="m3 3 4 1 13 13-3 3L4 7 3 3Zm18 0-4 1-5 5M9 12l-5 5 3 3 5-5M2 18l4 4m12-20 4 4M16 16l6 6M8 16l-6 6"/></symbol>
<symbol id="i-shield" viewBox="0 0 24 24"><path d="m12 2 8 3v6c0 5-8 11-8 11S4 16 4 11V5l8-3Z"/><path d="M12 7v9m-4-5h8"/></symbol>
<symbol id="i-crown" viewBox="0 0 24 24"><path d="m3 6 4 4 5-7 5 7 4-4-2 12H5L3 6Zm2 15h14"/></symbol>
<symbol id="i-discord" viewBox="0 0 24 24"><path d="M8 5 5 6C3 9 2 13 3 17l4 2 2-3m7-11 3 1c2 3 3 7 2 11l-4 2-2-3M7 15c3 2 7 2 10 0M8 5c2-1 6-1 8 0"/><circle cx="8" cy="11" r="1"/><circle cx="16" cy="11" r="1"/></symbol>
<symbol id="i-telegram" viewBox="0 0 24 24"><path d="m2 10 20-7-4 18-7-6-4 3v-6l11-6-9 8-7-4Z"/></symbol>
<symbol id="i-youtube" viewBox="0 0 24 24"><rect x="2" y="5" width="20" height="14" rx="4"/><path d="m10 9 5 3-5 3Z"/></symbol>
<symbol id="i-globe" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3c6 5 6 13 0 18-6-5-6-13 0-18Z"/></symbol>
</defs></svg>`;
function render(lang) {
const t=translations[lang], fa=lang==='fa', base=fa?'../':'./', path=fa?'/fa/':'/';
const l=v=>e(localized(v,lang)), asset=p=>base+p;
const number=n=>new Intl.NumberFormat(fa?'fa-IR':'en-US').format(n);
const silver=n=>`${number(n/1e6)}${fa?' میلیون':'M'}`;
const external=(url,text,cls='')=>`<a class="${cls}" href="${e(url)}" target="_blank" rel="noopener noreferrer">${text}</a>`;
const heading=(label,title,accent)=>`<div class="section-heading"><p class="eyebrow">${e(label)}</p><h2>${e(title)}<br><span>${e(accent)}</span></h2></div>`;
const firstRule=t.firstRule.replace(fa?'۲۰ میلیون':'20M',fa?`${number(rewards.firstToTargetSilver/1e6)} میلیون`:`${rewards.firstToTargetSilver/1e6}M`);
const clips=site.clips.map((c,i)=>{
const poster=c.poster?assetOrUrl(c.poster):c.type==='youtube'?`https://i.ytimg.com/vi/${youtubeId(c.url)}/hqdefault.jpg`:asset('assets/logo.jpg');
return `<article class="clip-card ${i===0?'featured':''}" data-type="${c.type}"><button class="clip-visual" type="button" data-video="${e(c.url)}" data-video-type="${c.type}" data-title="${l(c.title)}" aria-label="${e(t.play)}: ${l(c.title)}"><img src="${e(poster)}" alt="" loading="lazy" width="640" height="360"><span class="play-button">${icon('play')}</span><span class="video-source">${e(c.type==='youtube'?t.youtube:t.direct)}</span>${c.duration?`<span class="duration" dir="ltr">${e(c.duration)}</span>`:''}</button><div class="clip-caption"><span class="clip-number">${String(i+1).padStart(2,'0')}</span><div><h3>${l(c.title)}</h3>${c.description?`<p>${l(c.description)}</p>`:''}</div>${icon('diagonal')}</div></article>`;
}).join('');
function assetOrUrl(p){return p.startsWith('assets/')?asset(p):p;}
const battleCards=renderBattleCards({battles:site.battles,previews,lang,base,icon,t});
const schema={ '@context':'https://schema.org', '@type':'Organization', name:site.guildName, slogan:site.motto, url:origin, logo:origin+'/assets/logo.jpg', description:localized(site.description,lang), sameAs:site.socials.filter(s=>s.url).map(s=>s.url) };
const recruitment=site.recruitment;
const discord=site.socials.find(s=>s.kind==='discord'&&s.url);
const recruitmentMarkup=recruitment?`<div class="recruitment-grid"><article class="recruitment-card"><div class="recruitment-card-heading">${icon('swords')}<h3>${e(t.mainContent)}</h3></div><ul class="recruitment-activities">${recruitment.activities.map(a=>`<li>${l(a)}</li>`).join('')}</ul></article><article class="recruitment-card"><div class="recruitment-card-heading">${icon('shield')}<h3>${e(t.recruitmentRequirements)}</h3></div><dl class="fame-requirements">${recruitment.fameRequirements.map(r=>`<div><dt>${l(r.label)}</dt><dd dir="ltr">${e(r.value)}</dd></div>`).join('')}</dl><ul class="recruitment-requirements">${recruitment.requirements.map(r=>`<li>${l(r)}</li>`).join('')}</ul></article></div><div class="application-callout"><div><h3>${e(t.applicationTitle)}</h3><p>${l(recruitment.applicationIntro)}</p><p class="application-instructions">${l(recruitment.applicationInstructions).replaceAll('#apply','<bdi class="apply-channel" dir="ltr">#apply</bdi>')}</p><p class="recruitment-welcome">${l(recruitment.welcome)}</p></div>${discord?external(discord.url,`${icon('discord')}${e(t.applyDiscord)}${icon('diagonal')}`,'button'):''}</div>`:'';
return `<!doctype html>
<html lang="${lang}" dir="${fa?'rtl':'ltr'}"><head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
<title>${e(t.title)}</title><meta name="description" content="${l(site.description)}"><meta name="theme-color" content="#101111"><meta name="color-scheme" content="dark">
<link rel="canonical" href="${origin}${path}"><link rel="alternate" hreflang="en" href="${origin}/"><link rel="alternate" hreflang="fa" href="${origin}/fa/"><link rel="alternate" hreflang="x-default" href="${origin}/">
<meta property="og:type" content="website"><meta property="og:site_name" content="OneUP"><meta property="og:locale" content="${fa?'fa_IR':'en_US'}"><meta property="og:locale:alternate" content="${fa?'en_US':'fa_IR'}"><meta property="og:title" content="${e(t.title)}"><meta property="og:description" content="${l(site.description)}"><meta property="og:url" content="${origin}${path}"><meta property="og:image" content="${origin}/assets/logo.jpg"><meta property="og:image:width" content="640"><meta property="og:image:height" content="640"><meta property="og:image:alt" content="OneUP guild emblem">
<meta name="twitter:card" content="summary"><meta name="twitter:title" content="${e(t.title)}"><meta name="twitter:description" content="${l(site.description)}"><meta name="twitter:image" content="${origin}/assets/logo.jpg">
<link rel="icon" href="${asset('assets/favicon.svg')}" type="image/svg+xml" sizes="any"><link rel="stylesheet" href="${asset('assets/styles.css')}">
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;600;700;800;900&family=Barlow:wght@400;500;600;700&family=Vazirmatn:wght@400;500;600;700;800;900&display=swap" rel="stylesheet">
<script type="application/ld+json">${JSON.stringify(schema).replace(/</g,'\\u003c')}</script><script src="${asset('assets/app.js')}" defer></script></head>
<body id="top" data-lang="${lang}" data-video-error="${e(t.videoError)}">${glyphs}<a class="skip-link" href="#main">${e(t.skip)}</a>
<header class="site-header"><div class="header-inner"><a class="brand" href="${base}" aria-label="OneUP"><img src="${asset('assets/logo.jpg')}" alt="" width="44" height="44"><span>ONE<span class="brand-up">UP</span><small>${e(t.guild)}</small></span></a>
<button class="menu-toggle" aria-expanded="false" aria-controls="navigation" aria-label="${e(t.menu)}"><span></span><span></span></button>
<nav id="navigation" aria-label="${fa?'منوی اصلی':'Main navigation'}">${['guild','chronicles','battles','rewards'].map((id,i)=>`<a href="#${id}">${e(t.nav[i])}</a>`).join('')}</nav>
<div class="header-actions"><div class="languages" aria-label="Language"><a href="${base}?lang=en" lang="en" data-language="en" ${!fa?'aria-current="page"':''}>EN</a><span>/</span><a href="${base}fa/?lang=fa" lang="fa" data-language="fa" ${fa?'aria-current="page"':''}>فا</a></div><a class="button button-small" href="#community">${e(t.join)}${icon('diagonal')}</a></div></div></header>
<main id="main"><section class="hero" aria-labelledby="hero-title"><div class="hero-art" aria-hidden="true"><div class="orbit orbit-one"></div><div class="orbit orbit-two"></div><img src="${asset('assets/logo.jpg')}" alt="" width="640" height="640" fetchpriority="high"><span class="art-caption">ONEUP / ALBION ONLINE</span></div><div class="hero-inner"><div class="status"><span></span>${e(site.recruiting?t.recruiting:t.closed)}</div><p class="eyebrow hero-eyebrow">${e(t.eyebrow)}</p><h1 id="hero-title">${e(t.hero1)}<br><span>${e(t.hero2)}</span></h1><p class="hero-copy">${e(t.intro)}</p><div class="hero-buttons"><a class="button" href="#community">${e(t.join)}${icon('diagonal')}</a><a class="text-button" href="#chronicles"><span class="small-play">${icon('play')}</span>${e(t.watch)}</a></div><div class="hero-proof"><strong dir="ltr">${e(site.members)}</strong><span>${e(t.memberLabel)}</span><div class="proof-line"></div>${icon('shield')}</div></div><a class="scroll-cue" href="#guild"><span>↓</span>${e(t.scroll)}</a><span class="hero-coordinate" aria-hidden="true">EST. IN UNITY / FORGED IN BATTLE</span></section>
<div class="motto-strip" aria-hidden="true"><span>ONE UNITED POWER</span><b>✦</b><span>ONE BANNER. ONE GUILD.</span><b>✦</b><span>ONE UNITED POWER</span><b>✦</b><span>ONE BANNER. ONE GUILD.</span></div>
<section id="guild" class="section guild-section"><div class="guild-overview">${heading(t.manifestoLabel,t.manifestoTitle,t.manifestoAccent)}<div class="guild-copy"><span class="tiny-rule"></span><p>${e(t.manifestoText)}</p><p class="signature" dir="ltr">${e(site.motto)}</p></div></div><div class="pillars">${t.pillars.map((p,i)=>`<article class="pillar"><div class="pillar-top">${icon(['swords','shield','crown'][i])}<span>0${i+1}</span></div><h3>${e(p.title)}</h3><p>${e(p.text)}</p></article>`).join('')}</div></section>
<section id="chronicles" class="section chronicles-section"><div class="section-top">${heading(t.clipsLabel,t.clipsTitle,t.clipsAccent)}<p class="section-intro">${e(t.clipsIntro)}</p></div>${site.clips.length?`<div class="filters" role="group" aria-label="${e(t.all)}">${['all','youtube','direct'].map((v,i)=>`<button type="button" data-filter="${v}" aria-pressed="${i===0}">${e(t[v])}</button>`).join('')}</div><div class="clip-grid">${clips}</div><p class="filter-empty" hidden>${e(t.noFilter)}</p>`:`<div class="empty-state footage-empty"><div class="empty-emblem">${icon('play')}</div><div><h3>${e(t.clipsEmpty)}</h3><p>${e(t.clipsEmptyText)}</p></div><span class="empty-index" aria-hidden="true">REC / 001</span></div>`}</section>
<section id="battles" class="section battles-section"><div class="section-top">${heading(t.battlesLabel,t.battlesTitle,t.battlesAccent)}<div class="board-aside"><p>${e(t.battlesIntro)}</p>${external('https://albionbb.com/',`${e(t.albionbb)} ${icon('diagonal')}`,'text-link')}</div></div>${battleCards}${site.battles.length?`<details class="battle-ledger"><summary>${icon('swords')}<span>${e(t.detailedLog)}</span><span class="ledger-toggle" aria-hidden="true">+</span></summary>`:''}<div class="board"><div class="board-top"><span>${icon('swords')} ONEUP <span class="muted">/ ${fa?'گزارش نبردها':'BATTLE LOG'}</span></span><span class="board-provider">POWERED BY ALBIONBB ↗</span></div>${site.battles.length?`<div class="table-scroll"><table class="battle-table"><thead><tr>${[t.date,t.battle,t.outcome,t.kills,t.deaths,''].map(v=>`<th scope="col">${e(v)}</th>`).join('')}</tr></thead><tbody>${[...site.battles].sort((a,b)=>(b.date||'').localeCompare(a.date||'')).map(b=>`<tr><td>${b.date?`<time datetime="${e(b.date)}">${new Intl.DateTimeFormat(fa?'fa-IR':'en-GB',{dateStyle:'medium',timeZone:'UTC'}).format(new Date(b.date))}</time>`:'—'}</td><th scope="row">${l(b.title)}</th><td><span class="outcome ${e(b.outcome||'recorded')}">${e(t[b.outcome||'recorded'])}</span></td><td>${b.kills==null?'—':number(b.kills)}</td><td>${b.deaths==null?'—':number(b.deaths)}</td><td>${external(b.url,`${e(t.report)} ${icon('diagonal')}`,'text-link')}</td></tr>`).join('')}</tbody></table></div>`:`<div class="empty-state battle-empty">${icon('shield')}<h3>${e(t.battleEmpty)}</h3><p>${e(t.battleEmptyText)}</p></div>`}</div>${site.battles.length?'</details>':''}</section>
<section id="rewards" class="section rewards-section"><div class="section-top">${heading(t.rewardsLabel,t.rewardsTitle,t.rewardsAccent)}<p class="section-intro">${e(t.rewardsIntro)}</p></div><div class="rewards-layout"><div class="reward-data"><div class="reward-tabs" role="tablist" aria-label="${e(t.nav[3])}"><button id="first-tab" role="tab" aria-selected="true" aria-controls="first-panel" tabindex="0">${e(t.first)}</button><button id="podium-tab" role="tab" aria-selected="false" aria-controls="podium-panel" tabindex="-1">${e(t.podium)}</button></div><div id="first-panel" role="tabpanel" aria-labelledby="first-tab"><p class="reward-rule">${e(firstRule)}</p><div class="table-scroll"><table class="rewards-table"><thead><tr><th scope="col">${e(t.category)}</th><th scope="col">${e(t.target)}</th><th scope="col">${e(t.prize)}</th></tr></thead><tbody>${rewards.categories.map((r,i)=>`<tr><th scope="row"><span class="row-number">0${i+1}</span>${l(r.name)}</th><td><span class="target-number" dir="ltr">${number(r.target/1000)}K</span></td><td><strong>${silver(rewards.firstToTargetSilver)} <small>${e(t.silver)}</small></strong><span class="jersey-bonus">+ ${e(t.jersey)}</span></td></tr>`).join('')}</tbody></table></div></div><div id="podium-panel" role="tabpanel" aria-labelledby="podium-tab" hidden><p class="reward-rule">${e(t.podiumRule)}</p><div class="table-scroll"><table class="rewards-table podium-table"><thead><tr>${[t.category,t.rank1,t.rank2,t.rank3].map(v=>`<th scope="col">${e(v)}</th>`).join('')}</tr></thead><tbody>${rewards.categories.map(r=>`<tr><th scope="row">${l(r.name)}</th>${[0,1,2].map(i=>`<td>${r.podium[i]?`<strong>${silver(r.podium[i])}</strong><small class="silver-label">${e(t.silver)}</small>`:'—'}</td>`).join('')}</tr>`).join('')}</tbody></table></div></div></div><aside class="jersey-card"><div class="jersey-card-top"><span>${e(t.jerseyLabel)}</span>${icon('crown')}</div><a href="${asset(rewards.jerseyImage)}" class="jersey-image" data-jersey aria-label="${e(t.jerseyZoom)}"><img src="${asset(rewards.jerseyImage)}" alt="${e(t.jerseyAlt)}" loading="lazy" width="1280" height="1169"><span>${icon('diagonal')}</span></a><div class="jersey-description"><p class="eyebrow">ONEUP / GUILD EDITION</p><h3>${e(t.jerseyTitle)}</h3><p>${e(t.jerseyText)}</p></div></aside></div></section>
<section id="community" class="section community-section"><div class="community-crest" aria-hidden="true"><img src="${asset('assets/logo.jpg')}" alt="" width="640" height="640" loading="lazy"></div><div class="community-content">${heading(t.communityLabel,t.communityTitle,t.communityAccent)}<p>${recruitment?l(recruitment.intro):e(t.communityText)}</p></div>${recruitmentMarkup}<div class="social-grid">${site.socials.map(s=>{const inner=`${icon(['discord','telegram','youtube'].includes(s.kind)?s.kind:'globe')}<span><strong>${e(s.name)}</strong><small>${l(s.description)}</small></span><span class="social-action">${s.url?icon('diagonal'):e(t.socialSoon)}</span>`;return s.url?external(s.url,inner,'social-card'):`<div class="social-card pending">${inner}</div>`}).join('')}</div></section></main>
<footer class="site-footer"><a class="footer-wordmark" href="#top" dir="ltr">ONE<span>UP</span><small>${e(t.footer)}</small></a><p>${e(t.fan)}<br>© ${new Date().getUTCFullYear()} OneUP</p><a class="back-top" href="#top" aria-label="${e(t.top)}">↑</a></footer>
<dialog id="video-dialog" aria-labelledby="video-title"><div class="dialog-top"><h2 id="video-title"></h2><button class="dialog-close" aria-label="${e(t.close)}">×</button></div><div id="video-container"></div><p id="video-error" role="status" hidden></p><a id="video-original" target="_blank" rel="noopener noreferrer">${e(t.videoFallback)} ↗</a></dialog>
<dialog id="jersey-dialog" aria-label="${e(t.jerseyZoom)}"><button class="dialog-close" aria-label="${e(t.closeImage)}">×</button><img src="${asset(rewards.jerseyImage)}" alt="${e(t.jerseyAlt)}" width="1280" height="1169" loading="lazy"></dialog>
</body></html>`;
}
for (const lang of ['en','fa']) {
const folder=lang==='en'?dist:new URL('fa/',dist);
await mkdir(folder,{recursive:true}); await writeFile(new URL('index.html',folder),render(lang));
}
await Promise.all([
writeFile(new URL('CNAME',dist),new URL(origin).hostname+'\n'),
writeFile(new URL('.nojekyll',dist),''),
writeFile(new URL('robots.txt',dist),`User-agent: *\nAllow: /\nSitemap: ${origin}/sitemap.xml\n`),
writeFile(new URL('sitemap.xml',dist),`<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">${['/','/fa/'].map(p=>`<url><loc>${origin}${p}</loc><xhtml:link rel="alternate" hreflang="en" href="${origin}/"/><xhtml:link rel="alternate" hreflang="fa" href="${origin}/fa/"/></url>`).join('')}</urlset>`),
writeFile(new URL('404.html',dist),`<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>Lost in the Outlands | OneUP</title><link rel="stylesheet" href="/assets/styles.css"><main class="not-found"><p class="eyebrow">404 / BEYOND THE FRONT LINE</p><h1>Lost in the<br><span>Outlands.</span></h1><p>The banner is this way.</p><a class="button" href="/">Return to OneUP →</a><a href="/fa/" lang="fa">بازگشت به وان‌آپ</a></main></html>`)
]);
console.log(`Built English and Persian pages in dist/ for ${origin}`);
+46
View File
@@ -0,0 +1,46 @@
export const escapeHtml = (value) => String(value ?? '').replace(/[&<>"']/g, c => ({'&':'&amp;', '<':'&lt;', '>':'&gt;', '"':'&quot;', "'":'&#39;'}[c]));
export const localized = (value, lang) => typeof value === 'string' ? value : value?.[lang] ?? value?.en ?? '';
export function youtubeId(value) {
try {
const u = new URL(value);
if (['youtu.be', 'www.youtu.be'].includes(u.hostname)) return /^[\w-]{11}$/.test(u.pathname.slice(1)) ? u.pathname.slice(1) : null;
if (!['youtube.com','www.youtube.com','m.youtube.com','youtube-nocookie.com','www.youtube-nocookie.com'].includes(u.hostname)) return null;
const id = u.searchParams.get('v') || u.pathname.match(/^\/(?:shorts|embed|live)\/([\w-]{11})/)?.[1];
return /^[\w-]{11}$/.test(id ?? '') ? id : null;
} catch { return null; }
}
export function safeUrl(value) {
try { const u = new URL(value); return u.protocol === 'https:'; } catch { return false; }
}
export function assetPath(value) {
return typeof value === 'string' && /^assets\/[a-zA-Z0-9_./-]+$/.test(value) && !value.split('/').includes('..');
}
export function validate(site, rewards) {
const fail = msg => { throw new Error(`Content error: ${msg}`); };
if (!safeUrl(site.siteUrl)) fail('siteUrl must use HTTPS.');
const origin = new URL(site.siteUrl);
if (origin.search || origin.hash || origin.pathname !== '/') fail('siteUrl must be a domain without a path, query, or fragment.');
for (const key of ['socials','clips','battles']) if (!Array.isArray(site[key])) fail(`${key} must be an array.`);
for (const s of site.socials) if (s.url && !safeUrl(s.url)) fail(`Invalid social URL: ${s.name}`);
for (const c of site.clips) {
if (!safeUrl(c.url)) fail(`Invalid clip URL: ${localized(c.title,'en')}`);
if (!['youtube','direct'].includes(c.type)) fail('Clip type must be youtube or direct.');
if (c.type === 'youtube' && !youtubeId(c.url)) fail(`Unrecognized YouTube URL: ${c.url}`);
if (c.poster && !safeUrl(c.poster) && !assetPath(c.poster)) fail('Poster must be an HTTPS URL or an assets/ path.');
if (!localized(c.title,'en')) fail('Clips need an English title.');
}
for (const b of site.battles) {
if (!safeUrl(b.url) || !/(^|\.)albionbb\.com$/.test(new URL(b.url).hostname)) fail('Battle URLs must be HTTPS albionbb.com links.');
if (b.date != null && (!/^\d{4}-\d{2}-\d{2}$/.test(b.date) || Number.isNaN(Date.parse(b.date)))) fail('Battle date must be YYYY-MM-DD when provided.');
if (!localized(b.title,'en')) fail('Battles need an English title.');
if (b.preview && !safeUrl(b.preview) && !assetPath(b.preview)) fail('Battle preview must be an HTTPS URL or assets/ path.');
if (b.outcome && !['victory','defeat','draw','recorded'].includes(b.outcome)) fail('Unknown battle outcome.');
for (const key of ['kills','deaths']) if (b[key] != null && (!Number.isInteger(b[key]) || b[key] < 0)) fail(`${key} must be a nonnegative integer.`);
}
if (!assetPath(rewards.jerseyImage)) fail('Jersey image must be an assets/ path.');
if (!Number.isFinite(rewards.firstToTargetSilver) || rewards.firstToTargetSilver <= 0) fail('Invalid milestone reward.');
if (!rewards.categories?.length) fail('Add at least one reward category.');
for (const r of rewards.categories) {
if (!Number.isFinite(r.target) || r.target <= 0 || !r.podium?.length || r.podium.length > 3 || r.podium.some(n => !Number.isFinite(n) || n <= 0)) fail(`Invalid rewards for ${r.id}`);
}
}
+26
View File
@@ -0,0 +1,26 @@
import { escapeHtml as e, localized } from './lib.mjs';
import { directPreview } from './battle-previews.mjs';
export function battleDetails(url) {
const u=new URL(url);
const combined=/\/battles\/multi\/?$/.test(u.pathname);
const ids=combined?[...new Set((u.searchParams.get('ids')||'').split(',').filter(id=>/^\d+$/.test(id)))]:[u.pathname.split('/').filter(Boolean).pop()].filter(id=>/^\d+$/.test(id));
return {combined,ids,region:u.hostname==='europe.albionbb.com'?'europe':u.hostname};
}
export function renderBattleCards({battles,previews,lang,base,icon,t}) {
if (!battles.length) return '';
const number=n=>new Intl.NumberFormat(lang==='fa'?'fa-IR':'en-US').format(n);
const sorted=[...battles].sort((a,b)=>(b.date||'').localeCompare(a.date||''));
// Combined reports may overlap with single reports; count unique, explicit battle IDs.
const engagements=new Set(battles.flatMap(b=>battleDetails(b.url).ids)).size;
const cards=sorted.map((battle,index)=>{
const info=battleDetails(battle.url);
const preview=previews[battle.url]||battle.preview||directPreview(battle.url);
const image=preview?`<img class="battle-report-image" data-battle-preview src="${e(preview.startsWith('assets/')?base+preview:preview)}" alt="${e(localized(battle.title,lang))} — AlbionBB" loading="lazy">`:'';
const outcome=battle.outcome||'recorded';
const date=battle.date?`<time datetime="${e(battle.date)}">${new Intl.DateTimeFormat(lang==='fa'?'fa-IR':'en-GB',{dateStyle:'medium',timeZone:'UTC'}).format(new Date(battle.date))}</time>`:e(t.battleArchive);
return `<article class="battle-card ${info.combined?'battle-card--campaign':'battle-card--single'}"><a class="battle-card-link" href="${e(battle.url)}" target="_blank" rel="noopener noreferrer"><div class="battle-art"><div class="battle-terrain" aria-hidden="true"></div>${image}<div class="battle-art-top"><span class="battle-type">${icon(info.combined?'shield':'swords')}${e(info.combined?t.combinedReport:t.singleReport)}</span><span class="battle-region">${e(info.region==='europe'?t.europe:info.region)}</span></div><div class="battle-crest" aria-hidden="true"><img src="${base}assets/logo.jpg" alt="" width="88" height="88" loading="lazy"></div><div class="battle-art-bottom"><span class="battle-record-number" aria-hidden="true">${String(index+1).padStart(2,'0')}</span><span class="battle-engagements"><strong>${number(info.ids.length||1)}</strong>${e(info.ids.length===1?t.engagement:t.engagements)}</span><span class="battle-art-seal" aria-hidden="true">ONEUP<br>WAR ARCHIVE</span></div></div><div class="battle-card-content"><div class="battle-card-meta"><span>${date}</span><span class="outcome ${e(outcome)}">${e(t[outcome])}</span></div><h3>${e(localized(battle.title,lang))}</h3><div class="battle-id-list" aria-label="${e(t.reportIds)}">${info.ids.map(id=>`<span dir="ltr">#${e(id)}</span>`).join('')}</div>${battle.kills!=null||battle.deaths!=null?`<dl class="battle-card-stats"><div><dt>${e(t.kills)}</dt><dd>${battle.kills==null?'—':number(battle.kills)}</dd></div><div><dt>${e(t.deaths)}</dt><dd>${battle.deaths==null?'—':number(battle.deaths)}</dd></div></dl>`:''}<div class="battle-card-footer"><span class="battle-source">ALBIONBB <span>↗</span></span><span class="battle-open">${e(t.report)}<span class="battle-open-icon">${icon('diagonal')}</span></span></div></div></a></article>`;
}).join('');
return `<div class="battle-archive-strip"><div><strong>${number(battles.length)}</strong><span>${e(t.archivedReports)}</span></div><div><strong>${number(engagements)}</strong><span>${e(t.loggedEngagements)}</span></div><p>${icon('shield')}${e(t.archiveMotto)}</p></div><div class="battle-card-grid">${cards}</div>`;
}
+17
View File
@@ -0,0 +1,17 @@
import http from 'node:http';
import { readFile, stat } from 'node:fs/promises';
import { resolve, extname, sep } from 'node:path';
import { spawnSync } from 'node:child_process';
const built = spawnSync(process.execPath, ['scripts/build.mjs'], { stdio:'inherit' });
if (built.status) process.exit(built.status);
const root=resolve('dist');
const types={'.html':'text/html; charset=utf-8','.css':'text/css','.js':'text/javascript','.jpg':'image/jpeg','.png':'image/png','.webp':'image/webp','.svg':'image/svg+xml','.xml':'application/xml','.txt':'text/plain'};
http.createServer(async(req,res)=>{
try {
let path=resolve(root, '.'+decodeURIComponent(new URL(req.url,'http://localhost').pathname));
if(path!==root && !path.startsWith(root+sep)){res.writeHead(403).end();return;}
if((await stat(path)).isDirectory()) path=resolve(path,'index.html');
const bytes=await readFile(path);
res.writeHead(200,{'Content-Type':types[extname(path)]||'application/octet-stream','Cache-Control':'no-store'}).end(bytes);
}catch{res.writeHead(404,{'Content-Type':'text/html; charset=utf-8'}).end(await readFile(resolve(root,'404.html')));}
}).listen(Number(process.env.PORT)||4173,'127.0.0.1',()=>console.log(`OneUP preview: http://localhost:${Number(process.env.PORT)||4173}`));
+36
View File
@@ -0,0 +1,36 @@
import { mkdir, readFile, writeFile } from 'node:fs/promises';
import { battleKey, discoverPreview } from './battle-previews.mjs';
import { safeUrl, validate } from './lib.mjs';
const site=JSON.parse(await readFile(new URL('../content/site.json',import.meta.url),'utf8'));
const rewards=JSON.parse(await readFile(new URL('../content/rewards.json',import.meta.url),'utf8'));
validate(site,rewards);
const folder=new URL('../public/assets/battles/',import.meta.url);
await mkdir(folder,{recursive:true});
const mapPath=new URL('previews.json',folder);
let previews={};
try{previews=JSON.parse(await readFile(mapPath,'utf8'));}catch(e){if(e.code!=='ENOENT')throw e;}
// An optional URL inspects/downloads a report without adding it to the public battle archive.
const inputs=process.argv[2]?[{url:process.argv[2]}]:site.battles;
for (const battle of inputs) {
try {
if (!safeUrl(battle.url) || !/(^|\.)albionbb\.com$/.test(new URL(battle.url).hostname)) throw Error('Expected an HTTPS AlbionBB report URL.');
if (battle.preview?.startsWith('assets/')) continue;
const imageUrl=await discoverPreview(battle);
// Keep the discovered URL usable by browsers even if downloading it fails here.
// Preserve an existing local cache when the remote image is temporarily unavailable.
if(!previews[battle.url]?.startsWith('assets/')) previews[battle.url]=imageUrl;
const response=await fetch(imageUrl,{signal:AbortSignal.timeout(15000)});
if(!response.ok)throw Error(`Image returned HTTP ${response.status}`);
const type=response.headers.get('content-type')?.split(';')[0];
const ext={'image/png':'png','image/jpeg':'jpg','image/webp':'webp'}[type];
if(!ext)throw Error(`Unsupported image type ${type}`);
if(Number(response.headers.get('content-length'))>10_000_000)throw Error('Preview exceeds 10 MB.');
const reader=response.body.getReader(); const chunks=[]; let size=0;
while(true){const {value,done}=await reader.read();if(done)break;size+=value.length;if(size>10_000_000){await reader.cancel();throw Error('Preview exceeds 10 MB.');}chunks.push(value);}
const file=`${battleKey(battle.url)}.${ext}`;
await writeFile(new URL(file,folder),Buffer.concat(chunks));
previews[battle.url]=`assets/battles/${file}`;
console.log(`Downloaded ${imageUrl} → public/assets/battles/${file}`);
}catch(error){console.warn(`Preview unavailable for ${battle.url}: ${error.message}. Existing preview or report link will be used.`);}
}
await writeFile(mapPath,JSON.stringify(previews,null,2)+'\n');
+105
View File
@@ -0,0 +1,105 @@
(() => {
document.querySelectorAll('[data-battle-preview]').forEach(img => {
const ready = () => img.closest('.battle-art').classList.add('has-report-preview');
const fallback = () => { img.hidden = true; img.closest('.battle-art').classList.remove('has-report-preview'); };
img.addEventListener('load', ready);
img.addEventListener('error', fallback);
if (img.complete) img.naturalWidth ? ready() : fallback();
});
const lang = document.documentElement.lang;
const fa = lang === 'fa';
const base = new URL(fa ? '../' : './', location.href);
const query = new URLSearchParams(location.search);
const explicit = query.get('lang');
const remembered = document.cookie.split('; ').find(c => c.startsWith('oneup_language='))?.split('=')[1];
const persist = value => {
document.cookie = `oneup_language=${value}; Max-Age=31536000; Path=/; SameSite=Lax${location.protocol === 'https:' ? '; Secure' : ''}`;
};
if (['en', 'fa'].includes(explicit)) {
persist(explicit);
if (explicit !== lang) {
const target = new URL(explicit === 'fa' ? 'fa/' : './', base);
target.search = `?lang=${explicit}`; target.hash = location.hash;
location.replace(target); return;
}
query.delete('lang');
history.replaceState(null, '', location.pathname + (query.size ? `?${query}` : '') + location.hash);
} else if (!fa && remembered === 'fa') {
const target = new URL('fa/', base); target.search = location.search; target.hash = location.hash;
location.replace(target); return;
}
document.querySelectorAll('[data-language]').forEach(a => a.addEventListener('click', () => persist(a.dataset.language)));
const menu = document.querySelector('.menu-toggle');
const nav = document.querySelector('#navigation');
const closeMenu = () => { menu.setAttribute('aria-expanded', 'false'); nav.classList.remove('open'); };
menu.addEventListener('click', () => {
const open = menu.getAttribute('aria-expanded') !== 'true';
menu.setAttribute('aria-expanded', String(open)); nav.classList.toggle('open', open);
});
nav.querySelectorAll('a').forEach(a => a.addEventListener('click', closeMenu));
document.addEventListener('keydown', event => { if (event.key === 'Escape') closeMenu(); });
const tabs = [...document.querySelectorAll('[role="tab"]')];
function activate(tab) {
tabs.forEach(t => {
const selected = t === tab;
t.setAttribute('aria-selected', String(selected)); t.tabIndex = selected ? 0 : -1;
document.getElementById(t.getAttribute('aria-controls')).hidden = !selected;
});
}
tabs.forEach((tab,index) => {
tab.addEventListener('click', () => activate(tab));
tab.addEventListener('keydown', event => {
let next;
if (event.key === 'Home') next = 0;
if (event.key === 'End') next = tabs.length - 1;
if (event.key === 'ArrowRight') next = (index + (fa ? -1 : 1) + tabs.length) % tabs.length;
if (event.key === 'ArrowLeft') next = (index + (fa ? 1 : -1) + tabs.length) % tabs.length;
if (next != null) { event.preventDefault(); activate(tabs[next]); tabs[next].focus(); }
});
});
document.querySelectorAll('[data-filter]').forEach(button => button.addEventListener('click', () => {
document.querySelectorAll('[data-filter]').forEach(b => b.setAttribute('aria-pressed', String(b === button)));
let visible = 0;
document.querySelectorAll('.clip-card').forEach(card => {
card.hidden = button.dataset.filter !== 'all' && card.dataset.type !== button.dataset.filter;
if (!card.hidden) visible++;
});
document.querySelector('.filter-empty').hidden = visible > 0;
}));
const videoDialog = document.getElementById('video-dialog');
const container = document.getElementById('video-container');
document.querySelectorAll('[data-video]').forEach(button => button.addEventListener('click', () => {
document.getElementById('video-title').textContent = button.dataset.title;
const error = document.getElementById('video-error'); error.hidden = true;
document.getElementById('video-original').href = button.dataset.video;
let player;
if (button.dataset.videoType === 'youtube') {
const url = new URL(button.dataset.video);
const id = url.hostname.endsWith('youtu.be') ? url.pathname.slice(1) : url.searchParams.get('v') || url.pathname.split('/')[2];
player = document.createElement('iframe');
player.src = `https://www.youtube-nocookie.com/embed/${id}?autoplay=1&rel=0`;
player.title = button.dataset.title;
player.allow = 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share';
player.allowFullscreen = true; player.referrerPolicy = 'strict-origin-when-cross-origin';
} else {
player = document.createElement('video');
player.controls = true; player.autoplay = true; player.playsInline = true;
player.src = button.dataset.video;
player.addEventListener('error', () => { error.textContent = document.body.dataset.videoError; error.hidden = false; });
}
container.replaceChildren(player); videoDialog.showModal();
}));
videoDialog.addEventListener('close', () => { const video=container.querySelector('video'); if(video) video.pause(); container.replaceChildren(); });
const jerseyDialog = document.getElementById('jersey-dialog');
document.querySelector('[data-jersey]').addEventListener('click', event => { event.preventDefault(); jerseyDialog.showModal(); });
document.querySelectorAll('dialog').forEach(dialog => {
dialog.querySelector('.dialog-close').addEventListener('click', () => dialog.close());
dialog.addEventListener('click', event => {
const rect = dialog.getBoundingClientRect();
if (event.target === dialog && (event.clientX < rect.left || event.clientX > rect.right || event.clientY < rect.top || event.clientY > rect.bottom)) dialog.close();
});
});
})();
+107
View File
@@ -0,0 +1,107 @@
:root{--bg:#101111;--panel:#171818;--text:#f0ede5;--muted:#a5a59d;--accent:#e34850;--accent-heading:#c92c39;--accent-strong:#b51f2f;--accent-hover:#cb2c3c;--on-accent:#fff5f5;--line:#ffffff16;--body:'Barlow',Arial,sans-serif;--display:'Barlow Condensed','Arial Narrow',Impact,sans-serif}*{box-sizing:border-box}html{scroll-behavior:smooth;scroll-padding-top:100px}body{margin:0;background:var(--bg);color:var(--text);font-family:var(--body);font-size:16px;line-height:1.65}body:has(dialog[open]){overflow:hidden}::selection{background:var(--accent-strong);color:var(--on-accent)}a{color:inherit;text-decoration:none}button{font:inherit;color:inherit;cursor:pointer}button,a{-webkit-tap-highlight-color:transparent}button{border:0}img{max-width:100%;display:block}svg{display:block}.icon{width:23px;height:23px;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;flex-shrink:0}.svg-defs{position:absolute;width:0;height:0;overflow:hidden}button:focus-visible,a:focus-visible{outline:2px solid var(--accent);outline-offset:6px}[hidden]{display:none!important}.skip-link{position:fixed;inset-block-start:10px;inset-inline-start:10px;background:var(--accent-strong);color:var(--on-accent);padding:10px 20px;z-index:100;transform:translateY(-150%)}.skip-link:focus{transform:translateY(0)}.site-header{height:92px;position:relative;z-index:10;border-bottom:1px solid var(--line);background:#101111ee}.header-inner{max-width:1440px;margin:auto;height:100%;padding:0 5%;display:flex;align-items:center;justify-content:space-between;gap:32px}.brand{display:flex;gap:12px;align-items:center}.brand img{border-radius:50%;border:1px solid #7776}.brand>span{font-family:var(--display);font-size:29px;font-weight:800;letter-spacing:1.3px;line-height:1}.brand-up{color:var(--accent)}.brand small{font-family:var(--body);font-size:8px;letter-spacing:2px;display:block;margin-top:8px;color:var(--muted)}nav{display:flex;gap:30px}nav a{font-size:13px;color:#bdbcb4;transition:color .2s}nav a:hover{color:var(--accent)}.header-actions{display:flex;align-items:center;gap:26px}.languages{display:flex;align-items:center;gap:8px;font-size:12px;white-space:nowrap}.languages a{color:var(--muted)}.languages a[aria-current]{color:var(--accent)}.languages>span{color:#565650}.button{display:inline-flex;align-items:center;justify-content:center;gap:28px;padding:17px 25px;background:var(--accent-strong);color:var(--on-accent);font-size:13px;font-weight:700;line-height:1.4;min-height:54px;transition:background .2s,transform .2s}.button:hover{background:var(--accent-hover);transform:translateY(-2px)}.button .icon{width:18px;height:18px}.button-small{padding:12px 18px;gap:20px;min-height:43px}.menu-toggle{display:none}.hero{position:relative;min-height:750px;max-width:1600px;margin:auto;overflow:hidden;background:radial-gradient(ellipse at 80% 45%,#4b101c26,transparent 65%)}.hero:after{content:'';position:absolute;inset:0;background:repeating-linear-gradient(115deg,transparent 0 140px,#ffffff02 141px 142px);pointer-events:none}.hero-inner{position:relative;z-index:2;max-width:1296px;margin:auto;padding:68px 5% 110px;pointer-events:none}.hero-inner a{pointer-events:auto}.status{display:flex;align-items:center;gap:9px;font-size:10px;font-weight:600;letter-spacing:1.8px;color:#c0beb2}.status>span{width:6px;height:6px;background:var(--accent);border-radius:50%;box-shadow:0 0 13px #c92c3960}.eyebrow{font-size:10px;font-weight:600;letter-spacing:2.4px;color:var(--accent);margin:0 0 23px;text-transform:uppercase}.hero-eyebrow{margin-top:48px;margin-bottom:14px;color:#aeaa9a}.hero h1{font-family:var(--display);font-size:clamp(78px,8.5vw,136px);font-weight:800;line-height:.93;letter-spacing:-2px;margin:0;text-transform:uppercase}.hero h1 span{color:var(--accent-heading)}.hero-copy{font-size:15px;color:#b6b6af;max-width:400px;line-height:1.8;margin:28px 0 29px}.hero-buttons{display:flex;gap:26px;align-items:center}.text-button{display:flex;align-items:center;gap:11px;font-size:13px}.small-play{width:34px;height:34px;border:1px solid #7776;display:grid;place-items:center;border-radius:50%}.small-play .icon{width:16px;height:16px}.hero-proof{display:flex;align-items:center;gap:17px;max-width:395px;margin-top:48px}.hero-proof strong{font-family:var(--display);font-size:40px;font-weight:600;line-height:1}.hero-proof>span{font-size:9px;letter-spacing:1.6px;max-width:90px;line-height:1.5;color:var(--muted)}.proof-line{height:1px;background:var(--line);flex:1}.hero-proof>.icon{color:var(--accent);width:29px;height:29px}.hero-art{position:absolute;top:16px;bottom:40px;inset-inline-end:-5%;width:65%;display:flex;align-items:center;justify-content:center;isolation:isolate}.hero-art:after{content:'';position:absolute;inset:0;background:radial-gradient(ellipse,transparent 24%,#101111 71%);z-index:1}.hero-art img{width:min(760px,100%);height:auto;filter:brightness(.72) saturate(1.1);mix-blend-mode:lighten;mask-image:radial-gradient(ellipse,#000 40%,transparenLine truncated
[dir=rtl]{--body:'Vazirmatn',Tahoma,sans-serif;--display:'Vazirmatn',Tahoma,sans-serif}[dir=rtl] .hero h1{font-size:clamp(64px,7.4vw,108px);line-height:1.3;letter-spacing:-4px}[dir=rtl] h2{font-size:clamp(32px,3.5vw,49px);line-height:1.6;letter-spacing:-1.4px}[dir=rtl] .eyebrow,[dir=rtl] .status,[dir=rtl] .scroll-cue{letter-spacing:0}[dir=rtl] .brand>span,[dir=rtl] .footer-wordmark,[dir=rtl] .motto-strip,[dir=rtl] .hero-proof strong,[dir=rtl] .board-top>span:first-child{font-family:'Barlow Condensed',Arial,sans-serif}[dir=rtl] .hero-copy{line-height:2;font-size:13px}[dir=rtl] .hero-art{transform:scaleX(-1)}[dir=rtl] .hero-art img,[dir=rtl] .art-caption{transform:scaleX(-1)}[dir=rtl] .pillar h3,[dir=rtl] .clip-caption h3,[dir=rtl] .empty-state h3,[dir=rtl] .jersey-description h3{font-size:21px;line-height:1.7}[dir=rtl] .section-intro,[dir=rtl] .guild-copy p,[dir=rtl] .board-aside{font-size:13px}[dir=rtl] .hero .icon use[href='#i-diagonal'],[dir=rtl] .button .icon,[dir=rtl] .text-link .icon{transform-origin:center;transform:scaleX(-1)}[dir=rtl] .rewards-table strong{font-size:17px}[dir=rtl] .rewards-table tbody th,[dir=rtl] .rewards-table td{font-size:11px}[dir=rtl] .target-number{font-size:17px}[dir=rtl] .rewards-layout{grid-template-columns:minmax(0,1.9fr) minmax(0,1fr)}[dir=rtl] .social-card strong{font-family:'Barlow Condensed',Arial,sans-serif}[dir=rtl] .signature{font-family:'Barlow Condensed',Arial,sans-serif}
@media(min-width:1500px){.hero-inner{padding-inline:0}.hero-art{inset-inline-end:0;width:64%}.scroll-cue{inset-inline-start:9.5%}}@media(max-width:1100px){nav{gap:18px}.header-inner{gap:18px}.header-actions{gap:20px}.hero-art{width:70%;inset-inline-end:-16%;opacity:.8}.hero-inner{padding-inline:5%}.hero h1{font-size:104px}.hero-copy{max-width:360px}.guild-overview{gap:50px}.rewards-layout{gap:25px}.social-grid{gap:12px}.social-card{gap:12px;padding:20px 14px}.social-card small{font-size:10px}.social-card strong{font-size:24px}.social-action{font-size:7px}.row-number{margin-inline-end:8px}.site-header .button-small{display:none}.board-top{padding-inline:20px}}
@media(max-width:760px){html{scroll-padding-top:30px}.site-header{height:78px}.header-inner{padding-inline:6%;gap:18px}.brand>span{font-size:25px}.brand img{width:38px;height:38px}.brand small{font-size:7px}.header-actions{margin-inline-start:auto}.languages{font-size:12px}.menu-toggle{display:flex;order:3;background:none;width:28px;height:34px;padding:5px 0;justify-content:center;flex-direction:column;gap:6px}.menu-toggle span{display:block;width:24px;height:1px;background:var(--text);transition:transform .2s}.menu-toggle[aria-expanded=true] span:first-child{transform:translateY(3.5px) rotate(45deg)}.menu-toggle[aria-expanded=true] span:last-child{transform:translateY(-3.5px) rotate(-45deg)}nav{display:none;position:absolute;top:78px;inset-inline:0;padding:24px 6%;background:#171817;border-bottom:1px solid #c92c3930;flex-direction:column;gap:20px}nav.open{display:flex}nav a{font-size:15px}.hero{min-height:760px}.hero-inner{padding:40px 6% 100px}.hero-eyebrow{margin-top:45px;font-size:9px}.hero h1{font-size:clamp(78px,14vw,105px);letter-spacing:-1.5px}.hero-copy{max-width:320px;font-size:14px;margin-top:26px}.hero-art{width:98%;inset-inline-end:-36%;top:30px;bottom:75px;opacity:.42;align-items:flex-start;padding-top:30px}.hero-art img{width:660px;max-width:none;flex-shrink:0}.hero-art:after{background:linear-gradient(90deg,#10111177,transparent 80%)}.orbit{display:none}.art-caption{display:none}.hero-proof{margin-top:44px;max-width:330px}.hero-buttons{gap:22px}.hero-buttons .button{padding:16px 20px;gap:16px}.hero-buttons .text-button{font-size:12px;gap:8px}.scroll-cue{inset-inline-start:6%;font-size:7px;bottom:28px;letter-spacing:1px}.hero-coordinate{display:none}.motto-strip{gap:30px;font-size:15px;padding:12px 0;letter-spacing:2px}.section{padding:65px 6%}.guild-overview{grid-template-columns:1fr;gap:25px}.guild-copy{max-width:520px}.guild-copy .signature{font-size:20px}.tiny-rule{display:none}.guild-copy p{font-size:14px}.pillars{grid-template-columns:1fr;margin-top:30px}.pillar{padding:26px;border-inline-end:0;border-bottom:1px solid var(--line)}.pillar h3{margin-top:18px}.pillar p{max-width:420px}.section-top{align-items:flex-start;flex-direction:column;gap:23px;margin-bottom:30px}.section-intro{max-width:460px;font-size:13px}.section-heading .eyebrow{font-size:9px;margin-bottom:18px}h2{font-size:46px}.footage-empty{padding:34px 25px;min-height:260px;gap:24px;align-items:flex-start;flex-direction:column}.empty-emblem{width:48px;height:48px}.empty-state h3{font-size:25px}.empty-state p{font-size:12px;max-width:400px}.clip-grid{grid-template-columns:1fr;gap:18px}.clip-card:first-child:nth-last-child(odd){grid-column:auto}.clip-caption h3{font-size:24px}.board-aside{max-width:440px;font-size:13px}.board-top{padding:17px;gap:12px}.board-top>span:first-child{font-size:16px;gap:8px}.board-provider{font-size:6px;letter-spacing:1px}.board-top .icon{width:17px}.rewards-layout,[dir=rtl] .rewards-layout{grid-template-columns:1fr;gap:30px}.jersey-card{display:grid;grid-template-columns:1fr 1fr;align-items:center}.jersey-card-top{grid-column:1/-1}.jersey-description{padding:20px}.jersey-description h3{font-size:27px}.jersey-description>p:last-child{font-size:11px}.reward-tabs{gap:25px}.reward-tabs button{font-size:12px}.rewards-table tbody th{width:45%}.community-content h2{font-size:52px}.community-content>p{font-size:13px}.social-grid{grid-template-columns:1fr;margin-top:30px;gap:12px}.social-card{padding:22px;gap:20px}.social-card small{font-size:12px}.social-card strong{font-size:27px}.social-action{max-width:none;font-size:10px}.community-crest{width:400px;inset-inline-end:-100px;top:-10px}.site-footer{padding:32px 6%;flex-wrap:wrap;gap:25px}.site-footer>p{order:3;width:100%;text-align:start;font-size:9px}.back-top{margin-inline-start:auto}.footer-wordmark small{font-size:9px}.dialog-top h2{font-size:23px}dialog{padding:15px;width:calc(100% - 24px)}[dir=rtl] .hero h1{font-size:clamp(65px,11vw,90px);letter-spacing:-3px}[dir=rtl] .hero-copy{max-width:310px;font-size:12px}[dir=rtl] h2{font-size:34px}[dir=rtl] .hero{min-height:790px}[dir=rtl] .hero-buttons{gap:16px}[dir=rtl] .hero-buttons .button{font-size:12px}[dir=rtl] .hero-buttons .text-button{font-size:11px}[dir=rtl] .community-content h2{font-size:38px}[dir=rtl] .hero-art:after{background:linear-gradient(-90deg,#10111177,transparent 80%)}[dir=rtl] .jersey-description h3{font-size:20px}}
@media(max-width:390px){.hero-buttons{gap:14px}.hero-buttons .button{font-size:12px;padding-inline:15px}.hero-buttons .text-button{font-size:11px}.hero-proof strong{font-size:36px}.hero h1{font-size:78px}.rewards-table{min-width:420px}.jersey-card{display:block}.jersey-image{max-height:320px}.jersey-image img{object-fit:cover;object-position:center;max-height:320px}.board-provider{display:none}.hero-eyebrow{font-size:8px}[dir=rtl] .hero-buttons{gap:10px}}
@media(prefers-reduced-motion:reduce){html{scroll-behavior:auto}*,*:before,*:after{transition:none!important;animation:none!important}}@media print{.site-header,.hero-art,.hero-coordinate,.scroll-cue,dialog,.motto-strip,.filters{display:none}body{background:white;color:black}.section{padding:30px 0;break-inside:avoid}.hero{min-height:0}.hero-inner{padding:30px 0}.hero h1{font-size:60px}.hero-copy,.section-intro,.guild-copy p{color:#333}h2{font-size:35px}a{color:#333}.community-section,.battles-section{background:white}.social-grid{grid-template-columns:repeat(3,1fr)}}
.recruitment-grid{position:relative;z-index:1;display:grid;grid-template-columns:1fr 1fr;gap:24px;margin-top:36px}.community-content:has(+.recruitment-grid)>p{max-width:660px}.recruitment-card{background:#101111b3;border:1px solid var(--line);padding:28px 30px}.recruitment-card-heading{display:flex;gap:14px;align-items:center;margin-bottom:24px}.recruitment-card-heading>.icon{color:var(--accent);width:25px;height:25px}.recruitment-card h3{font-family:var(--display);font-size:29px;font-weight:500;margin:0}.recruitment-activities,.recruitment-requirements{padding:0;margin:0;list-style:none}.recruitment-activities li{display:flex;align-items:center;gap:14px;padding:13px 0;border-bottom:1px solid var(--line);font-size:14px;color:var(--text)}.recruitment-activities li:last-child{border-bottom:0;padding-bottom:0}.recruitment-activities li:before{content:'';width:5px;height:5px;background:var(--accent-heading);transform:rotate(45deg);flex-shrink:0}.fame-requirements{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin:0 0 24px}.fame-requirements>div{display:flex;flex-direction:column-reverse;align-items:flex-start;border-inline-start:2px solid var(--accent-strong);padding-inline-start:16px}.fame-requirements dt{font-size:11px;color:var(--muted);margin-top:5px}.fame-requirements dd{margin:0;font-family:'Barlow Condensed','Arial Narrow',sans-serif;font-size:42px;font-weight:600;line-height:1.1;color:var(--accent)}.recruitment-requirements li{position:relative;padding-inline-start:20px;font-size:13px;color:var(--muted);line-height:1.8;margin-top:13px}.recruitment-requirements li:before{content:'✓';position:absolute;inset-inline-start:0;color:var(--accent)}.application-callout{position:relative;z-index:1;display:flex;align-items:center;gap:32px;justify-content:space-between;padding:30px;margin-top:24px;border:1px solid #c92c3938;border-inline-start:3px solid var(--accent-strong);background:linear-gradient(115deg,#c92c390a,#10111166)}.application-callout h3{font-family:var(--display);font-size:30px;font-weight:500;margin:0 0 12px}.application-callout p{font-size:13px;color:var(--muted);max-width:700px;margin:10px 0 0;line-height:1.9}.application-callout .button{flex-shrink:0;gap:14px}.application-callout .application-instructions{color:var(--text)}.apply-channel{display:inline-block;padding:1px 7px;border:1px solid #c92c3938;background:#c92c3914;color:var(--accent);font-weight:600;border-radius:3px;margin-inline:2px}.application-callout .recruitment-welcome{font-size:12px;color:var(--accent);margin-top:16px}[dir=rtl] .recruitment-card h3,[dir=rtl] .application-callout h3{font-size:23px;line-height:1.7}[dir=rtl] .recruitment-activities li,[dir=rtl] .recruitment-requirements li,[dir=rtl] .application-callout p{font-size:12px;line-height:2}@media(max-width:900px){.application-callout{align-items:flex-start;flex-direction:column;gap:22px}}@media(max-width:760px){.recruitment-grid{grid-template-columns:1fr;gap:18px;margin-top:28px}.recruitment-card{padding:24px}.recruitment-card h3{font-size:27px}.recruitment-activities li{font-size:13px}.application-callout{padding:24px;margin-top:18px}.application-callout h3{font-size:28px}.application-callout p{font-size:12px}.fame-requirements dd{font-size:38px}[dir=rtl] .recruitment-card h3,[dir=rtl] .application-callout h3{font-size:21px}}
/* Battle archive: offline artwork, report previews, and an optional detailed ledger. */
.battle-archive-strip {
display: flex;
align-items: center;
gap: 34px;
padding: 18px 0;
margin-bottom: 30px;
border-block: 1px solid var(--line);
}
.battle-archive-strip > div { display: flex; align-items: center; gap: 11px; }
.battle-archive-strip strong { font: 500 35px/1 'Barlow Condensed', sans-serif; color: var(--text); }
.battle-archive-strip span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.battle-archive-strip > p { display: flex; align-items: center; gap: 12px; margin: 0; margin-inline-start: auto; font-size: 11px; color: var(--muted); }
.battle-archive-strip .icon { color: var(--accent); width: 19px; height: 19px; }
.battle-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 26px; }
.battle-card { min-width: 0; border: 1px solid #ffffff20; background: #101111; transition: border-color .25s, transform .25s; }
.battle-card:hover, .battle-card:focus-within { border-color: #c92c3980; transform: translateY(-4px); }
.battle-card:only-child { grid-column: 1 / -1; max-width: 860px; width: 100%; margin-inline: auto; }
.battle-card-link { display: flex; flex-direction: column; height: 100%; }
.battle-art { position: relative; height: 290px; overflow: hidden; isolation: isolate; background: #141719; border-bottom: 1px solid #c92c3930; }
.battle-terrain { position: absolute; inset: 0; z-index: -2; background: url('./battle-terrain.svg') center / cover no-repeat; transition: transform .7s, opacity .3s; }
.battle-art::after { content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none; background: linear-gradient(#07090bb8, transparent 40%, #07090bc9), linear-gradient(90deg, #10111140, transparent 70%); }
.battle-card--campaign .battle-terrain { transform: scale(1.17) rotate(-9deg); filter: saturate(.85); background-position: 30% 60%; }
.battle-card:hover .battle-terrain { transform: scale(1.05); }
.battle-card--campaign:hover .battle-terrain { transform: scale(1.24) rotate(-9deg); }
.battle-art-top { position: absolute; top: 20px; inset-inline: 22px; display: flex; align-items: center; justify-content: space-between; gap: 15px; z-index: 2; }
.battle-type { display: flex; align-items: center; gap: 9px; padding: 6px 10px; background: #171215d9; border: 1px solid #c92c3955; color: #f0d4d8; font-size: 9px; letter-spacing: 1.3px; text-transform: uppercase; }
.battle-type .icon { width: 15px; height: 15px; color: var(--accent); }
.battle-region { color: #c1b7ba; font-size: 9px; text-transform: uppercase; letter-spacing: 1.8px; }
.battle-region::before { content: ''; display: inline-block; width: 5px; height: 5px; border: 1px solid var(--accent); margin-inline-end: 7px; transform: rotate(45deg); }
.battle-crest { position: absolute; top: 81px; inset-inline-start: 34px; padding: 6px; border: 1px solid #c92c395c; border-radius: 50%; background: #0a0b0c99; box-shadow: 0 0 0 8px #0a0b0c60, 0 0 38px #c92c3926; transition: opacity .2s; }
.battle-crest img { width: 88px; height: 88px; border-radius: 50%; opacity: .85; }
.battle-art-bottom { position: absolute; bottom: 16px; inset-inline: 22px; display: flex; align-items: flex-end; gap: 20px; z-index: 2; }
.battle-record-number { font: 600 58px/.9 'Barlow Condensed', sans-serif; color: #e9dfe1; opacity: .9; }
.battle-engagements { display: flex; align-items: baseline; gap: 7px; padding-bottom: 2px; font-size: 9px; letter-spacing: 1px; text-transform: uppercase; color: #bfb4b6; }
.battle-engagements strong { font: 500 25px/1 'Barlow Condensed', sans-serif; color: var(--accent); }
.battle-art-seal { margin-inline-start: auto; padding-bottom: 3px; font: 9px/1.7 var(--body); letter-spacing: 2px; color: #a68b92; text-align: end; }
.battle-report-image { position: absolute; top: 54px; left: 18px; width: calc(100% - 36px); height: calc(100% - 120px); object-fit: contain; z-index: 1; }
.has-report-preview .battle-terrain { opacity: .22; }
.has-report-preview .battle-crest { opacity: 0; }
.battle-card-content { padding: 25px 26px 0; display: flex; flex-direction: column; flex: 1; }
.battle-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 15px; color: var(--muted); font-size: 10px; }
.battle-card-meta .outcome { font-size: 9px; }
.battle-card-content h3 { font: 500 33px/1.12 var(--display); margin: 18px 0 17px; letter-spacing: -.2px; overflow-wrap: anywhere; }
.battle-id-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 25px; }
.battle-id-list span { display: inline-block; font-size: 9px; letter-spacing: .5px; color: #b0a2a5; border: 1px solid #ffffff13; padding: 3px 7px; background: #ffffff03; }
.battle-card-stats { display: grid; grid-template-columns: 1fr 1fr; margin: 0 0 22px; border-block: 1px solid var(--line); }
.battle-card-stats > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0; }
.battle-card-stats > div:first-child { padding-inline-end: 20px; border-inline-end: 1px solid var(--line); }
.battle-card-stats > div + div { padding-inline-start: 20px; }
.battle-card-stats dt { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.battle-card-stats dd { margin: 0; font: 500 28px/1 'Barlow Condensed', sans-serif; color: var(--text); }
.battle-card-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-top: 1px solid var(--line); padding: 17px 0; margin-top: auto; }
.battle-source { font-size: 8px; letter-spacing: 2px; color: #a89b9e; }
.battle-source > span { color: var(--accent); margin-inline-start: 4px; }
.battle-open { display: flex; align-items: center; gap: 13px; font-size: 11px; color: var(--text); }
.battle-open-icon { width: 31px; height: 31px; display: grid; place-items: center; background: #c92c3917; border: 1px solid #c92c3938; transition: background .2s; }
.battle-open-icon .icon { width: 15px; height: 15px; color: var(--accent); }
.battle-card:hover .battle-open-icon { background: #c92c3930; }
.battle-ledger { margin-top: 26px; }
.battle-ledger > summary { display: flex; align-items: center; gap: 12px; padding: 17px 20px; border: 1px solid var(--line); cursor: pointer; font-size: 11px; color: var(--muted); list-style: none; }
.battle-ledger > summary::-webkit-details-marker { display: none; }
.battle-ledger > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.battle-ledger > summary .icon { color: var(--accent); width: 18px; height: 18px; }
.ledger-toggle { margin-inline-start: auto; color: var(--accent); font-size: 23px; line-height: 1; transition: transform .2s; }
.battle-ledger[open] .ledger-toggle { transform: rotate(45deg); }
.battle-ledger[open] > summary { border-bottom: 0; }
[dir=rtl] .battle-archive-strip span, [dir=rtl] .battle-type, [dir=rtl] .battle-region, [dir=rtl] .battle-engagements { letter-spacing: 0; }
[dir=rtl] .battle-card-content h3 { font-size: 25px; line-height: 1.6; letter-spacing: -.6px; }
[dir=rtl] .battle-card-meta, [dir=rtl] .battle-open { font-size: 10px; }
[dir=rtl] .battle-open-icon .icon { transform: scaleX(-1); }
@media (max-width: 760px) {
.battle-archive-strip { gap: 24px; flex-wrap: wrap; margin-bottom: 24px; }
.battle-archive-strip > p { flex-basis: 100%; margin-inline-start: 0; font-size: 10px; }
.battle-archive-strip span { font-size: 9px; }
.battle-card-grid { grid-template-columns: 1fr; gap: 22px; }
.battle-art { height: 270px; }
.battle-card-content { padding: 23px 22px 0; }
.battle-card-content h3 { font-size: 31px; }
.battle-type { font-size: 8px; }
.battle-art-seal { font-size: 8px; }
.battle-crest { inset-inline-start: 26px; }
}
@media (max-width: 390px) {
.battle-art-top, .battle-art-bottom { inset-inline: 17px; }
.battle-art { height: 250px; }
.battle-art-seal { display: none; }
.battle-card-content { padding-inline: 18px; }
.battle-card-meta { font-size: 9px; }
[dir=rtl] .battle-card-content h3 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
.battle-card, .battle-terrain, .battle-crest, .battle-open-icon, .ledger-toggle { transition: none; }
.battle-card:hover, .battle-card:focus-within { transform: none; }
}
/* Preserve the complete AlbionBB scoreboard when a real report image loads. */
.has-report-preview.battle-art { height: auto; min-height: 290px; padding-block: 54px 66px; }
.has-report-preview .battle-report-image { position: relative; inset: auto; width: 100%; height: auto; object-fit: contain; }
+92
View File
@@ -0,0 +1,92 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import { battleDetails, renderBattleCards } from '../scripts/render-battles.mjs';
import { directPreview, discoverPreview } from '../scripts/battle-previews.mjs';
const translations=JSON.parse(await readFile(new URL('../content/translations.json',import.meta.url),'utf8'));
const single={title:{en:'A single fight',fa:'یک نبرد'},url:'https://europe.albionbb.com/battles/448776222'};
const combined={title:{en:'A campaign',fa:'مجموعه نبردها'},url:'https://europe.albionbb.com/battles/multi?ids=448776222,441001581,440997498'};
const render=(battles,lang='en',previews={})=>renderBattleCards({battles,lang,previews,base:lang==='fa'?'../':'./',t:translations[lang],icon:()=>'<svg aria-hidden="true"></svg>'});
test('reports use direct images without a cache and keep artwork for unavailable previews',()=>{
for(const lang of ['en','fa']){
const html=render([single,combined],lang);
assert.equal((html.match(/class="battle-art"/g)||[]).length,2);
assert.equal((html.match(/class="battle-terrain"/g)||[]).length,2);
assert.match(html,/battle-card--single/);
assert.match(html,/battle-card--campaign/);
assert.ok(html.includes(single.title[lang]));
assert.ok(html.includes(combined.title[lang]));
assert.match(html,/#441001581/);
assert.equal((html.match(/class="battle-report-image"/g)||[]).length,2);
assert.match(html,/src="https:\/\/api.albionbb.com\/eu\/preview\/448776222"/);
assert.match(html,/src="https:\/\/api.albionbb.com\/eu\/preview\/multi\?ids=448776222,441001581,440997498"/);
assert.ok(!html.includes('battle-card-stats'));
assert.ok(!html.includes('<time'));
assert.ok(!html.includes('undefined'));
}
});
test('Europe single and combined reports resolve to their respective preview routes',()=>{
assert.equal(directPreview(single.url),'https://api.albionbb.com/eu/preview/448776222');
assert.equal(directPreview(single.url+'/'),'https://api.albionbb.com/eu/preview/448776222');
assert.equal(directPreview(combined.url),'https://api.albionbb.com/eu/preview/multi?ids=448776222,441001581,440997498');
assert.equal(directPreview('https://europe.albionbb.com/battles/multi?ids=441002770%2C441001581%2C440997498'),'https://api.albionbb.com/eu/preview/multi?ids=441002770,441001581,440997498');
assert.equal(directPreview('https://europe.albionbb.com/battles/multi/?ids=441002770,441001581'),'https://api.albionbb.com/eu/preview/multi?ids=441002770,441001581');
assert.equal(directPreview('https://europe.albionbb.com/battles/multi'),null);
assert.equal(directPreview('https://europe.albionbb.com/battles/multi?ids=441002770,invalid'),null);
assert.equal(directPreview('https://albionbb.com/battles/448776222'),null);
assert.equal(directPreview('https://europe.albionbb.com.evil.test/battles/448776222'),null);
assert.equal(directPreview('invalid'),null);
});
test('automatic discovery prefers report metadata over a derived endpoint',async()=>{
const image='https://api.albionbb.com/eu/preview/new-format';
const fetchPage=async url=>{
assert.equal(url,single.url);
return new Response(`<meta name="twitter:image" content="${image}">`);
};
assert.equal(await discoverPreview(single,fetchPage),image);
});
test('combined reports discover their own preview and overrides skip metadata fetching',async()=>{
const fetchPage=async()=>new Response('<meta property="og:image" content="/combined-preview.png">');
assert.equal(await discoverPreview(combined,fetchPage),'https://europe.albionbb.com/combined-preview.png');
assert.equal(await discoverPreview({...single,preview:'https://example.com/override.png'},()=>{throw Error('Should not fetch metadata');}),'https://example.com/override.png');
});
test('discovery falls back to single and combined endpoints when report metadata is unavailable',async()=>{
const offline=async()=>{throw Error('Offline');};
assert.equal(await discoverPreview(single,offline),'https://api.albionbb.com/eu/preview/448776222');
assert.equal(await discoverPreview(single,async()=>new Response('<html>No image metadata</html>')),'https://api.albionbb.com/eu/preview/448776222');
assert.equal(await discoverPreview(combined,offline),'https://api.albionbb.com/eu/preview/multi?ids=448776222,441001581,440997498');
assert.equal(await discoverPreview(combined,async()=>new Response('<html>No metadata</html>')),'https://api.albionbb.com/eu/preview/multi?ids=448776222,441001581,440997498');
await assert.rejects(discoverPreview({url:'https://albionbb.com/battles/multi?ids=1,2'},offline),/Offline/);
});
test('combined reports deduplicate battle IDs when counting recorded engagements',()=>{
assert.deepEqual(battleDetails(combined.url).ids,['448776222','441001581','440997498']);
const html=render([single,combined]);
assert.match(html,/<strong>2<\/strong><span>Archived reports/);
assert.match(html,/<strong>3<\/strong><span>Recorded engagements/);
});
test('previews retain underlying artwork and verified zero values remain visible',()=>{
const battle={...single,preview:'https://example.com/preview.png',kills:0,deaths:7,date:'2026-10-18'};
const html=render([battle],'fa',{[battle.url]:'assets/battles/cached.png'});
assert.match(html,/src="\.\.\/assets\/battles\/cached.png"/);
assert.match(html,/data-battle-preview/);
assert.match(html,/class="battle-terrain"/);
assert.match(html,/<dd>۰<\/dd>/);
assert.match(html,/<dd>۷<\/dd>/);
assert.match(html,/datetime="2026-10-18"/);
assert.match(render([battle]),/https:\/\/example.com\/preview.png/);
});
test('empty archives stay empty and report titles are escaped',()=>{
assert.equal(render([]),'');
const html=render([{...single,title:'<script>alert("x")</script>'}]);
assert.ok(!html.includes('<script>'));
assert.match(html,/&lt;script&gt;/);
});
+79
View File
@@ -0,0 +1,79 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { readFile, mkdtemp, cp, writeFile, rm } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { spawnSync } from 'node:child_process';
import { escapeHtml, youtubeId, validate } from '../scripts/lib.mjs';
import { socialImage, battleKey } from '../scripts/battle-previews.mjs';
const site=JSON.parse(await readFile(new URL('../content/site.json',import.meta.url)));
const rewards=JSON.parse(await readFile(new URL('../content/rewards.json',import.meta.url)));
test('editable guild and reward content passes publication validation',()=>{
validate(site,rewards);
assert.equal(new Set(rewards.categories.map(c=>c.id)).size,rewards.categories.length);
});
test('YouTube parsing accepts supported URLs and rejects lookalike domains',()=>{
for(const u of ['https://youtu.be/dQw4w9WgXcQ','https://www.youtube.com/watch?v=dQw4w9WgXcQ','https://youtube.com/shorts/dQw4w9WgXcQ','https://youtube.com/live/dQw4w9WgXcQ']) assert.equal(youtubeId(u),'dQw4w9WgXcQ');
for(const u of ['javascript:alert(1)','https://youtube.com.evil.test/watch?v=dQw4w9WgXcQ','https://youtube.com/watch?v=bad']) assert.equal(youtubeId(u),null);
assert.equal(escapeHtml('<script>"&'), '&lt;script&gt;&quot;&amp;');
});
test('content validation rejects unsafe links and image paths',()=>{
for(const url of ['javascript:alert(1)','http://example.com']) assert.throws(()=>validate({...site,socials:[{name:'bad',url}]},rewards));
assert.throws(()=>validate({...site,battles:[{url:'https://albionbb.com.evil.test/battles/1'}]},rewards));
assert.throws(()=>validate({...site,clips:[{title:'test',type:'direct',url:'https://example.com/test.mp4',poster:'assets/../../private'}]},rewards));
});
test('battle preview metadata supports Twitter, Open Graph, attribute order and relative URLs',()=>{
const page='https://europe.albionbb.com/battles/448776222';
assert.equal(socialImage('<meta content="/image.png?a=1&amp;b=2" name="twitter:image">',page),'https://europe.albionbb.com/image.png?a=1&b=2');
assert.equal(socialImage("<meta property='og:image' content='https://example.com/battle.jpg'>",page),'https://example.com/battle.jpg');
assert.equal(socialImage('<meta name="twitter:image" content="javascript:alert(1)">',page),null);
assert.equal(socialImage('<html>No image</html>',page),null);
assert.equal(battleKey(page),'europe.albionbb.com-448776222');
const combined='https://europe.albionbb.com/battles/multi?ids=441002770,441001581,440997498';
const otherCombined='https://europe.albionbb.com/battles/multi?ids=441002770,441001581';
assert.notEqual(battleKey(combined),battleKey(otherCombined));
assert.equal(battleKey(combined),battleKey(combined));
});
test('static output includes indexable bilingual content, metadata, and domain files',async()=>{
const result=spawnSync(process.execPath,['scripts/build.mjs'],{cwd:new URL('../',import.meta.url),encoding:'utf8'});
assert.equal(result.status,0,result.stderr);
const read=p=>readFile(new URL(`../dist/${p}`,import.meta.url),'utf8');
const [en,fa,sitemap,cname,robots]=await Promise.all(['index.html','fa/index.html','sitemap.xml','CNAME','robots.txt'].map(read));
assert.match(en,/<html lang="en" dir="ltr">/);
assert.match(fa,/<html lang="fa" dir="rtl">/);
for(const html of [en,fa]){
assert.match(html,/application\/ld\+json/);assert.match(html,/hreflang="fa"/);assert.match(html,/rel="canonical"/);
assert.match(html,/og:image/);assert.match(html,/twitter:image/);
assert.equal((html.match(/<h1 /g)||[]).length,1);
assert.match(html,/id="rewards"/);
assert.ok(!html.includes('undefined'));assert.ok(!html.includes('javascript:'));
const ids=[...html.matchAll(/\bid="([^"]+)"/g)].map(m=>m[1]);
assert.equal(ids.length,new Set(ids).size);
}
assert.match(fa,/\.\.\/assets\/styles\.css/);
assert.match(sitemap,/\/fa\//);assert.equal(cname.trim(),new URL(site.siteUrl).hostname);
assert.match(robots,/Sitemap:/);
});
test('populated archive builds YouTube and direct clips, battle previews, and verified stats in both languages',async()=>{
const fixture=await mkdtemp(join(tmpdir(),'oneup-content-'));
try {
for(const file of ['scripts','content','src','public','package.json']) await cp(new URL(`../${file}`,import.meta.url),join(fixture,file),{recursive:true});
const configured=structuredClone(site);
configured.socials[0].url='https://discord.gg/example';
configured.clips=[
{title:{en:'YouTube fight',fa:'نبرد یوتیوب'},type:'youtube',url:'https://youtu.be/dQw4w9WgXcQ'},
{title:'Direct fight',type:'direct',url:'https://example.com/fight.mp4',poster:'assets/logo.jpg'}
];
configured.battles=[{title:{en:'Test battle',fa:'نبرد آزمایشی'},date:'2026-10-18',url:'https://europe.albionbb.com/battles/448776222',preview:'assets/logo.jpg',kills:42,deaths:7,outcome:'victory'}];
await writeFile(join(fixture,'content/site.json'),JSON.stringify(configured));
const result=spawnSync(process.execPath,['scripts/build.mjs'],{cwd:fixture,encoding:'utf8'});
assert.equal(result.status,0,result.stderr);
for(const path of ['index.html','fa/index.html']){
const html=await readFile(join(fixture,'dist',path),'utf8');
assert.match(html,/battle-card-grid/);assert.match(html,/battle-table/);assert.match(html,/data-video-type="youtube"/);
assert.match(html,/data-video-type="direct"/);assert.match(html,/discord.gg\/example/);assert.match(html,/2026-10-18/);
assert.ok(!html.includes('undefined'));
assert.match(html,/hqdefault.jpg/);
}
}finally{await rm(fixture,{recursive:true,force:true});}
});