feat: highlight six best battles and compact the archive table
This commit is contained in:
7 files changed
+31
-19
No files matched your search
@@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"en": {
|
"en": {
|
||||||
"moreBattleReports": "Explore {count} more reports",
|
|
||||||
"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",
|
"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",
|
"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",
|
"title": "OneUP — One United Power. | Albion Online Guild",
|
||||||
@@ -20,7 +19,6 @@
|
|||||||
"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."
|
"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": {
|
"fa": {
|
||||||
"moreBattleReports": "مشاهدهٔ {count} گزارش دیگر",
|
|
||||||
"battleArchive": "از آرشیو نبردها", "singleReport": "گزارش نبرد", "combinedReport": "گزارش مجموعه نبردها", "europe": "اروپا", "engagement": "نبرد", "engagements": "نبرد", "reportIds": "شناسه گزارش نبردها", "archivedReports": "گزارش ثبتشده", "loggedEngagements": "نبرد ثبتشده", "archiveMotto": "یک پرچم، در هر میدان نبرد.", "detailedLog": "جزئیات گزارش نبردها",
|
"battleArchive": "از آرشیو نبردها", "singleReport": "گزارش نبرد", "combinedReport": "گزارش مجموعه نبردها", "europe": "اروپا", "engagement": "نبرد", "engagements": "نبرد", "reportIds": "شناسه گزارش نبردها", "archivedReports": "گزارش ثبتشده", "loggedEngagements": "نبرد ثبتشده", "archiveMotto": "یک پرچم، در هر میدان نبرد.", "detailedLog": "جزئیات گزارش نبردها",
|
||||||
"mainContent": "فعالیتهای اصلی ما", "recruitmentRequirements": "شرایط پیوستن", "applicationTitle": "آماده پیوستن به ما هستید؟", "applyDiscord": "درخواست عضویت در دیسکورد",
|
"mainContent": "فعالیتهای اصلی ما", "recruitmentRequirements": "شرایط پیوستن", "applicationTitle": "آماده پیوستن به ما هستید؟", "applyDiscord": "درخواست عضویت در دیسکورد",
|
||||||
"title": "وانآپ — یک قدرت متحد | گیلد آلبیون آنلاین",
|
"title": "وانآپ — یک قدرت متحد | گیلد آلبیون آنلاین",
|
||||||
|
|||||||
@@ -85,9 +85,11 @@ a partially overlapping report stops the import for review.
|
|||||||
|
|
||||||
## Presentation and checks
|
## Presentation and checks
|
||||||
|
|
||||||
The first 12 cards are visible immediately. Remaining reports appear in a native,
|
Only six highlights are shown as full cards, ranked by OneUP's kills minus
|
||||||
keyboard-accessible disclosure in both languages. The detailed table contains
|
deaths, then kills, with newer reports breaking ties. Reports with incomplete
|
||||||
all reports. Each combined report uses its own combined scoreboard image.
|
stats follow verified results. All reports remain in the expandable detailed
|
||||||
|
table, which scrolls within a bounded height to keep the page compact. Each
|
||||||
|
combined report uses its own combined scoreboard image.
|
||||||
|
|
||||||
`npm test` checks pagination, unrestricted history, grouping boundaries, unrelated
|
`npm test` checks pagination, unrestricted history, grouping boundaries, unrelated
|
||||||
teams, roster continuity, duplicate IDs, source totals, preservation, and both
|
teams, roster continuity, duplicate IDs, source totals, preservation, and both
|
||||||
|
|||||||
+3
-2
@@ -60,8 +60,9 @@ PNG/JPEG/WebP images are downloaded to `public/assets/battles/` and included in
|
|||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
For archives larger than 12 reports, the first 12 cards appear immediately and
|
The six best guild performances appear as full cards, ranked by kills minus
|
||||||
the remainder are available through “Explore more reports.” See the
|
deaths, then kills and recency. All reports remain in the expandable detailed
|
||||||
|
table, which scrolls within a bounded height. See the
|
||||||
[battle importer documentation](battle-import.md) for ongoing imports and grouping.
|
[battle importer documentation](battle-import.md) for ongoing imports and grouping.
|
||||||
|
|
||||||
To download previews locally, run:
|
To download previews locally, run:
|
||||||
|
|||||||
@@ -11,10 +11,14 @@ export function battleDetails(url) {
|
|||||||
export function renderBattleCards({battles,previews,lang,base,icon,t}) {
|
export function renderBattleCards({battles,previews,lang,base,icon,t}) {
|
||||||
if (!battles.length) return '';
|
if (!battles.length) return '';
|
||||||
const number=n=>new Intl.NumberFormat(lang==='fa'?'fa-IR':'en-US').format(n);
|
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||''));
|
// Highlight guild performance, rather than filling the page with the newest
|
||||||
|
// reports. Incomplete stats follow verified results; the full archive stays
|
||||||
|
// available in the detailed table.
|
||||||
|
const advantage=b=>b.kills!=null&&b.deaths!=null?b.kills-b.deaths:-Infinity;
|
||||||
|
const featured=[...battles].sort((a,b)=>advantage(b)-advantage(a)||(b.kills??-1)-(a.kills??-1)||(b.date||'').localeCompare(a.date||'')).slice(0,6);
|
||||||
// Combined reports may overlap with single reports; count unique, explicit battle IDs.
|
// 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 engagements=new Set(battles.flatMap(b=>battleDetails(b.url).ids)).size;
|
||||||
const cards=sorted.map((battle,index)=>{
|
const cards=featured.map((battle,index)=>{
|
||||||
const info=battleDetails(battle.url);
|
const info=battleDetails(battle.url);
|
||||||
const preview=previews[battle.url]||battle.preview||directPreview(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 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">`:'';
|
||||||
@@ -22,7 +26,5 @@ export function renderBattleCards({battles,previews,lang,base,icon,t}) {
|
|||||||
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);
|
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>`;
|
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>`;
|
||||||
});
|
});
|
||||||
const visible=12;
|
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.join('')}</div>`;
|
||||||
const older=cards.length>visible?`<details class="battle-ledger battle-more"><summary>${icon('shield')}<span>${e(t.moreBattleReports.replace('{count}',number(cards.length-visible)))}</span><span class="ledger-toggle" aria-hidden="true">+</span></summary><div class="battle-card-grid">${cards.slice(visible).join('')}</div></details>`:'';
|
|
||||||
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.slice(0,visible).join('')}</div>${older}`;
|
|
||||||
}
|
}
|
||||||
+2
-1
@@ -73,7 +73,8 @@
|
|||||||
.ledger-toggle { margin-inline-start: auto; color: var(--accent); font-size: 23px; line-height: 1; transition: transform .2s; }
|
.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] .ledger-toggle { transform: rotate(45deg); }
|
||||||
.battle-ledger[open] > summary { border-bottom: 0; }
|
.battle-ledger[open] > summary { border-bottom: 0; }
|
||||||
.battle-more > .battle-card-grid { margin-top: 26px; }
|
.battle-ledger .table-scroll { max-height: 32rem; overflow: auto; }
|
||||||
|
.battle-table thead { position: sticky; top: 0; z-index: 1; background: #101111; }
|
||||||
[dir=rtl] .battle-archive-strip span, [dir=rtl] .battle-type, [dir=rtl] .battle-region, [dir=rtl] .battle-engagements { letter-spacing: 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-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-card-meta, [dir=rtl] .battle-open { font-size: 10px; }
|
||||||
|
|||||||
+10
-6
@@ -91,14 +91,18 @@ test('empty archives stay empty and report titles are escaped',()=>{
|
|||||||
assert.match(html,/<script>/);
|
assert.match(html,/<script>/);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('large archives expose twelve initial cards and keep older cards in a native disclosure',()=>{
|
test('large archives show only six complete highlights ranked by guild performance',()=>{
|
||||||
const battles=Array.from({length:15},(_,i)=>({...single,title:`Fight ${i}`,date:`2026-10-${String(i+1).padStart(2,'0')}`}));
|
const battles=Array.from({length:15},(_,i)=>({...single,title:`Fight ${i}`,kills:i*2,deaths:i,date:`2026-10-${String(15-i).padStart(2,'0')}`}));
|
||||||
|
battles.push({...single,title:'Unknown result',kills:1000});
|
||||||
for(const lang of ['en','fa']){
|
for(const lang of ['en','fa']){
|
||||||
const html=render(battles,lang);
|
const html=render(battles,lang);
|
||||||
const [visible,older]=html.split('<details class="battle-ledger battle-more">');
|
assert.equal((html.match(/<article /g)||[]).length,6);
|
||||||
assert.equal((visible.match(/<article /g)||[]).length,12);
|
assert.equal((html.match(/data-battle-preview/g)||[]).length,6);
|
||||||
assert.equal((older.match(/<article /g)||[]).length,3);
|
assert.equal((html.match(/battle-card-stats/g)||[]).length,6);
|
||||||
assert.ok(visible.includes('Fight 14'));assert.ok(older.includes('Fight 0'));
|
assert.ok(html.includes('Fight 14'));assert.ok(html.includes('Fight 9'));
|
||||||
|
assert.ok(!html.includes('Fight 8'));assert.ok(!html.includes('Unknown result'));
|
||||||
|
assert.ok(html.indexOf('Fight 14')<html.indexOf('Fight 13'));
|
||||||
|
assert.ok(!html.includes('battle-more'));
|
||||||
assert.ok(!html.includes('undefined'));
|
assert.ok(!html.includes('undefined'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -46,6 +46,10 @@ test('static output includes indexable bilingual content, metadata, and domain f
|
|||||||
assert.match(html,/og:image/);assert.match(html,/twitter:image/);
|
assert.match(html,/og:image/);assert.match(html,/twitter:image/);
|
||||||
assert.equal((html.match(/<h1 /g)||[]).length,1);
|
assert.equal((html.match(/<h1 /g)||[]).length,1);
|
||||||
assert.match(html,/id="rewards"/);
|
assert.match(html,/id="rewards"/);
|
||||||
|
const archive=html.match(/<section id="battles"[\s\S]*?<\/section>/)[0];
|
||||||
|
assert.equal((archive.match(/<article /g)||[]).length,Math.min(6,site.battles.length));
|
||||||
|
assert.equal((archive.match(/<tr>/g)||[]).length,site.battles.length+1);
|
||||||
|
assert.ok(!archive.includes('battle-more'));
|
||||||
assert.ok(!html.includes('undefined'));assert.ok(!html.includes('javascript:'));
|
assert.ok(!html.includes('undefined'));assert.ok(!html.includes('javascript:'));
|
||||||
const ids=[...html.matchAll(/\bid="([^"]+)"/g)].map(m=>m[1]);
|
const ids=[...html.matchAll(/\bid="([^"]+)"/g)].map(m=>m[1]);
|
||||||
assert.equal(ids.length,new Set(ids).size);
|
assert.equal(ids.length,new Set(ids).size);
|
||||||
|
|||||||
Reference in new issue
Block a user