update todays page

This commit is contained in:
Fabrice Lamant
2024-07-30 20:53:48 +02:00
parent ce9769c584
commit 4eaab663fc
988 changed files with 50942 additions and 30008 deletions

View File

@ -55,9 +55,8 @@ export class Calendar {
public async generate() {
this.debug(`Generating calendar for ${this.language}`);
for (const sportKey of getAllSportsKeys()) {
await this.getSportCalendar(sportKey);
}
await Promise.all(getAllSportsKeys().map((sportKey) => this.getSportCalendar(sportKey)));
this.genereateEventsCeremonies();
this.generateCalendars();
@ -289,7 +288,6 @@ export class Calendar {
const buttonClass = "btn btn-sm bg-gray-300 min-w-24 mb-1";
const calendars: string[] = [];
const todays: string[] = [];
calendars.push(`<div class="${accordionClass}">`);
calendars.push(` <input type="radio" name="accordion" checked="checked">`);
@ -317,6 +315,16 @@ export class Calendar {
calendars.push(` </div>`);
calendars.push(`</div>`);
calendars.push(`<div class="${accordionClass}">`);
calendars.push(` <input type="radio" name="accordion">`);
calendars.push(` <div class="collapse-title text-xl font-medium">📅 ${translate.todaysEvents.get(this.language)}</div>`);
calendars.push(` <div class="collapse-content text-center">`)
for (const noc of this.nocs.sort()) {
calendars.push(` <a class="${buttonClass}" href="./today.html?noc=NOC">${getNOCFlag(noc)} ${noc}</a>`);
}
calendars.push(` </div>`);
calendars.push(`</div>`);
for (const sport of this.sports.sort()) {
calendars.push(`<div class="${accordionClass}">`);
calendars.push(` <input type="radio" name="accordion">`);
@ -336,7 +344,9 @@ export class Calendar {
const template = readFile(`${__dirname}/index/template.html`);
const output = template
.replace("{{calendars}}", calendars.join("\r\n"))
.replace("{{todays}}", [todays].join("\r\n"));
.replace("{{title}}", translate.calendars.get(this.language)!)
.replace("{{disclaimer}}", translate.disclaimer.get(this.language)!)
;
saveFile(
this.language === "en" ?
"docs/index.html" :
@ -389,7 +399,11 @@ export class Calendar {
const template = readFile(`${__dirname}/today/template.html`);
const output = template
.replace("{{events}}", content.join("\r\n"));
.replace("{{events}}", content.join("\r\n"))
.replace("{{title}}", translate.todaysEvents.get(this.language)!)
.replace("{{disclaimer}}", translate.disclaimer.get(this.language)!)
.replace("{{noEventToday}}", translate.noEventToday.get(this.language)!)
;
saveFile(
this.language === "en" ?
"docs/today.html" :

View File

@ -27,11 +27,13 @@
<li><a href="https://fabrice404.github.io/olympics-calendar/ko/index.html">한국어</a></li>
<li><a href="https://fabrice404.github.io/olympics-calendar/ru/index.html">Русский</a></li>
<li><a href="https://fabrice404.github.io/olympics-calendar/zh/index.html">中文</a></li>
<hr />
<li><a href="https://github.com/fabrice404/olympics-calendar">Source code</a></li>
</ul>
</div>
</div>
<div class="navbar-center">
<a class="btn btn-ghost text-xl" href="./">Paris 2024 calendars</a>
<a class="btn btn-ghost text-xl" href="./">Paris 2024 - {{title}}</a>
</div>
<div class="navbar-end">
</div>
@ -53,14 +55,8 @@
</div>
</dialog>
<div class="text-sm my-10">
<h2 class="text-3xl pb-4 pt-8">View today's events by NOC</h2>
{{todays}}
</div>
<div class="text-sm my-10 text-center">
This webiste is not affiliated with the International Olympic Committee.
All trademarks, logos and brand names are the property of their respective owners.
{{disclaimer}}
</div>
</div>
<script>

View File

@ -21,20 +21,42 @@
<body>
<div class="p-4">
<div class="border-b pb-4 border-slate-900/10">
<h1 class="text-4xl text-center">Paris 2024 - Today's events</h1>
<div class="navbar bg-base-100">
<div class="navbar-start">
<div class="dropdown">
<div tabindex="0" role="button" class="btn btn-ghost btn-circle">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h7" />
</svg>
</div>
<ul tabindex="0" class="menu menu-sm dropdown-content bg-base-100 rounded-box z-[1] mt-3 w-52 p-2 shadow">
<li><a href="https://fabrice404.github.io/olympics-calendar/today.html">English</a></li>
<li><a href="https://fabrice404.github.io/olympics-calendar/ja/today.html">日本語</a></li>
<li><a href="https://fabrice404.github.io/olympics-calendar/ko/today.html">한국어</a></li>
<li><a href="https://fabrice404.github.io/olympics-calendar/ru/today.html">Русский</a></li>
<li><a href="https://fabrice404.github.io/olympics-calendar/zh/today.html">中文</a></li>
<li><a href="https://github.com/fabrice404/olympics-calendar">Source code</a></li>
</ul>
</div>
</div>
<div class="navbar-center">
<a class="btn btn-ghost text-xl" href="./">Paris 2024 - {{title}}</a>
</div>
<div class="navbar-end">
</div>
</div>
<div>
{{events}}
</div>
<div class="no-event my-10 text-center text-2xl hidden">
No event today, come back tomorrow! :)
{{noEventToday}}
</div>
<div class="text-sm my-10 text-center">
This webiste is not affiliated with the International Olympic Committee.
All trademarks, logos and brand names are the property of their respective owners.
{{disclaimer}}
</div>
</div>
<script type="text/javascript">
@ -61,7 +83,7 @@
const end = DateTime.fromISO(element.getAttribute('data-end'));
const nocs = element.getAttribute('data-noc').split(",");
if (nocs.includes(noc)) {
if (!noc || nocs.includes(noc)) {
if (now.day === start.day) {
element.querySelector(".time").textContent = start.toLocaleString(DateTime.TIME_24_SIMPLE);
if (end < now) {

View File

@ -54,3 +54,35 @@ export const closingCeremony = new Map<string, string>([
["ru", "Церемония закрытия"],
["zh", "闭幕式"],
]);
export const disclaimer = new Map<string, string>([
["en", "This webiste is not affiliated with the International Olympic Committee. All trademarks, logos and brand names are the property of their respective owners."],
["ja", "このウェブサイトは国際オリンピック委員会とは関係ありません。すべての商標、ロゴ、およびブランド名はそれぞれの所有者の財産です。"],
["ko", "이 웹 사이트는 국제 올림픽 위원회와 관련이 없습니다. 모든 상표, 로고 및 상표는 각 소유자의 소유입니다."],
["ru", "Этот сайт не связан с Международным олимпийским комитетом. Все товарные знаки, логотипы и бренды являются собственностью их соответствующих владельцев."],
["zh", "本网站与国际奥林匹克委员会无关。所有商标、标志和品牌名称均为其各自所有者的财产。"],
]);
export const calendars = new Map<string, string>([
["en", "Calendars"],
["ja", "カレンダー"],
["ko", "달력"],
["ru", "Календари"],
["zh", "日历"],
]);
export const todaysEvents = new Map<string, string>([
["en", "Today's events"],
["ja", "今日のイベント"],
["ko", "오늘의 이벤트"],
["ru", "События сегодня"],
["zh", "今天的活动"],
]);
export const noEventToday = new Map<string, string>([
["en", "No event today, come back tomorrow! :)"],
["ja", "今日のイベントはありません。明日また来てください! :)"],
["ko", "오늘 이벤트가 없습니다. 내일 다시 오세요! :)"],
["ru", "Сегодня нет событий, вернитесь завтра! :)"],
["zh", "今天没有活动,请明天再来! :)"],
]);