Compare commits
No commits in common. "e2a14821ba17998de70a43a3f778c9316f99d51d" and "7bc0ad21ba1ca323bda2d6d1fb8e344839d8657a" have entirely different histories.
e2a14821ba
...
7bc0ad21ba
11 changed files with 70 additions and 134 deletions
4
Ideen.md
4
Ideen.md
|
@ -1,5 +1,7 @@
|
|||
# MUSS
|
||||
|
||||
- api: Config-Liste von Extra-Türchen (kein Buchstabe, nur manuelles Bild)
|
||||
- api: Config-Option "Überspringe leere Türchen" (standard ja)
|
||||
|
||||
# KANN
|
||||
|
||||
|
@ -19,5 +21,3 @@
|
|||
- `alert` durch bulma Komponente(n) ersetzen
|
||||
- api: admin Login case sensitivity (username "admin" == "AdMiN")
|
||||
- api: `config.solution` - whitespace="IGNORE"->"REMOVE" umbenennen, +Sonderzeichen
|
||||
- api: Config-Option "Überspringe leere Türchen" (standard ja)
|
||||
- api: Config-Liste von Extra-Türchen (kein Buchstabe, nur manuelles Bild)
|
||||
|
|
|
@ -43,12 +43,6 @@ class Puzzle(BaseModel):
|
|||
# Kalender so viele Tage nach der letzten Türöffnung schließen
|
||||
close_after: int = 90
|
||||
|
||||
# Tage, für die kein Buchstabe vorgesehen wird
|
||||
extra_days: set[int] = set()
|
||||
|
||||
# Türchen ohne Buchstabe überspringen
|
||||
skip_empty: bool = True
|
||||
|
||||
|
||||
class Image(BaseModel):
|
||||
# Quadrat, Seitenlänge in px
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import re
|
||||
from collections import defaultdict
|
||||
from dataclasses import dataclass
|
||||
from datetime import date
|
||||
from io import BytesIO
|
||||
|
@ -33,6 +34,23 @@ async def get_all_sorted_days(
|
|||
return sorted(set(door.day for door in cal_cfg.doors))
|
||||
|
||||
|
||||
async def get_all_event_dates(
|
||||
cfg: Config = Depends(get_config),
|
||||
days: list[int] = Depends(get_all_sorted_days),
|
||||
) -> EventDates:
|
||||
"""
|
||||
Aktueller Kalender-Zeitraum
|
||||
"""
|
||||
|
||||
return EventDates(
|
||||
today=date.today(),
|
||||
begin_month=cfg.puzzle.begin_month,
|
||||
begin_day=cfg.puzzle.begin_day,
|
||||
events=days,
|
||||
close_after=cfg.puzzle.close_after,
|
||||
)
|
||||
|
||||
|
||||
async def get_all_parts(
|
||||
cfg: Config = Depends(get_config),
|
||||
days: list[int] = Depends(get_all_sorted_days),
|
||||
|
@ -41,11 +59,6 @@ async def get_all_parts(
|
|||
Lösung auf vorhandene Tage aufteilen
|
||||
"""
|
||||
|
||||
# noch keine Buchstaben verteilt
|
||||
result = {day: "" for day in days}
|
||||
# extra-Tage ausfiltern
|
||||
days = [day for day in days if day not in cfg.puzzle.extra_days]
|
||||
|
||||
solution_length = len(cfg.solution.clean)
|
||||
num_days = len(days)
|
||||
|
||||
|
@ -59,33 +72,15 @@ async def get_all_parts(
|
|||
*rnd.sample(days, solution_length % num_days),
|
||||
]
|
||||
|
||||
result: defaultdict[int, str] = defaultdict(str)
|
||||
for day, letter in zip(solution_days, cfg.solution.clean):
|
||||
result[day] += letter
|
||||
|
||||
result |= {missed_day: "" for missed_day in set(days) - set(result.keys())}
|
||||
|
||||
return result
|
||||
|
||||
|
||||
async def get_all_event_dates(
|
||||
cfg: Config = Depends(get_config),
|
||||
days: list[int] = Depends(get_all_sorted_days),
|
||||
parts: dict[int, str] = Depends(get_all_parts),
|
||||
) -> EventDates:
|
||||
"""
|
||||
Aktueller Kalender-Zeitraum
|
||||
"""
|
||||
|
||||
if cfg.puzzle.skip_empty:
|
||||
days = [day for day in days if parts[day] != "" or day in cfg.puzzle.extra_days]
|
||||
|
||||
return EventDates(
|
||||
today=date.today(),
|
||||
begin_month=cfg.puzzle.begin_month,
|
||||
begin_day=cfg.puzzle.begin_day,
|
||||
events=days,
|
||||
close_after=cfg.puzzle.close_after,
|
||||
)
|
||||
|
||||
|
||||
async def get_all_auto_image_names(
|
||||
days: list[int] = Depends(get_all_sorted_days),
|
||||
images: list[str] = Depends(list_images_auto),
|
||||
|
|
|
@ -46,7 +46,7 @@ async def user_visible_days(
|
|||
event_dates: EventDates = Depends(get_all_event_dates),
|
||||
) -> list[int]:
|
||||
"""
|
||||
User-sichtbare Türchen
|
||||
Anzahl der user-sichtbaren Türchen
|
||||
"""
|
||||
|
||||
today = date.today()
|
||||
|
|
|
@ -41,8 +41,6 @@ class AdminConfigModel(BaseModel):
|
|||
last: date
|
||||
end: date
|
||||
seed: str
|
||||
extra_days: list[int]
|
||||
skip_empty: bool
|
||||
|
||||
class __Calendar(BaseModel):
|
||||
config_file: str
|
||||
|
@ -94,8 +92,6 @@ async def get_config_model(
|
|||
"last": event_dates.last,
|
||||
"end": event_dates.end,
|
||||
"seed": cfg.random_seed,
|
||||
"extra_days": sorted(cfg.puzzle.extra_days),
|
||||
"skip_empty": cfg.puzzle.skip_empty,
|
||||
},
|
||||
"calendar": {
|
||||
"config_file": cfg.calendar,
|
||||
|
|
|
@ -89,7 +89,6 @@ export default class extends Vue {
|
|||
this.store.when_initialized(() => {
|
||||
this.toast_timeout = setTimeout(() => {
|
||||
if (this.store.user_doors.length === 0) return;
|
||||
if (this.store.is_touch_device) return;
|
||||
|
||||
this.toast!.show({ duration: 600000, type: "is-warning" });
|
||||
}, 10e3);
|
||||
|
|
|
@ -68,23 +68,6 @@
|
|||
<dd class="is-family-monospace">
|
||||
"{{ admin_config_model.puzzle.seed }}"
|
||||
</dd>
|
||||
|
||||
<dt>Extra-Tage</dt>
|
||||
<dd>
|
||||
<template
|
||||
v-for="(day, index) in admin_config_model.puzzle.extra_days"
|
||||
:key="`extra_day-${index}`"
|
||||
>
|
||||
<span>
|
||||
<template v-if="index > 0">, </template>
|
||||
{{ day }}
|
||||
</span>
|
||||
</template>
|
||||
</dd>
|
||||
|
||||
<dt>Leere Türchen</dt>
|
||||
<dd v-if="admin_config_model.puzzle.skip_empty">Überspringen</dd>
|
||||
<dd v-else>Anzeigen</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -217,8 +200,6 @@ export default class extends Vue {
|
|||
last: "2023-12-24",
|
||||
end: "2024-04-01",
|
||||
seed: "",
|
||||
extra_days: [],
|
||||
skip_empty: true,
|
||||
},
|
||||
calendar: {
|
||||
config_file: "lorem ipsum",
|
||||
|
@ -248,20 +229,17 @@ export default class extends Vue {
|
|||
|
||||
public fmt_puzzle_date(name: keyof AdminConfigModel["puzzle"]): string {
|
||||
const iso_date = this.admin_config_model.puzzle[name];
|
||||
if (!(typeof iso_date == "string")) return "-";
|
||||
if (iso_date === null) return "-";
|
||||
|
||||
return DateTime.fromISO(iso_date).toLocaleString(DateTime.DATE_SHORT);
|
||||
}
|
||||
|
||||
public on_open(ready: () => void, fail: () => void): void {
|
||||
Promise.all([
|
||||
this.store.update(),
|
||||
this.$advent22.api_get<AdminConfigModel>("admin/config_model"),
|
||||
this.$advent22.api_get<DoorSaved[]>("admin/doors"),
|
||||
])
|
||||
.then(([store_update, admin_config_model, doors]) => {
|
||||
store_update; // discard value
|
||||
|
||||
.then(([admin_config_model, doors]) => {
|
||||
this.admin_config_model = admin_config_model;
|
||||
this.doors = doors;
|
||||
|
||||
|
|
|
@ -4,12 +4,7 @@
|
|||
:visible="store.is_touch_device || force_visible"
|
||||
:rectangle="door.position"
|
||||
>
|
||||
<div
|
||||
class="has-text-danger"
|
||||
style="text-shadow: 0 0 10px white, 0 0 20px white"
|
||||
>
|
||||
{{ door.day }}
|
||||
</div>
|
||||
<div class="has-text-danger">{{ door.day }}</div>
|
||||
</SVGRect>
|
||||
</template>
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
>
|
||||
<div
|
||||
xmlns="http://www.w3.org/1999/xhtml"
|
||||
:class="`px-2 is-flex is-align-items-center is-justify-content-center is-size-2 has-text-weight-bold ${extra_classes}`"
|
||||
:class="`px-4 is-flex is-align-items-center is-justify-content-center is-size-1 has-text-weight-bold ${extra_classes}`"
|
||||
style="height: inherit"
|
||||
:title="title"
|
||||
>
|
||||
|
@ -72,7 +72,7 @@ foreignObject > div {
|
|||
|
||||
&.visible,
|
||||
&:hover {
|
||||
border-width: 2px;
|
||||
border-width: 3px;
|
||||
border-style: solid;
|
||||
|
||||
@each $name, $color in $advent22-colors {
|
||||
|
|
|
@ -12,8 +12,6 @@ export interface AdminConfigModel {
|
|||
last: string;
|
||||
end: string;
|
||||
seed: string;
|
||||
extra_days: number[];
|
||||
skip_empty: boolean;
|
||||
};
|
||||
calendar: {
|
||||
config_file: string;
|
||||
|
|
|
@ -60,16 +60,8 @@ export const advent22Store = defineStore({
|
|||
|
||||
actions: {
|
||||
init(): void {
|
||||
this.update()
|
||||
.then(() => {
|
||||
this.is_initialized = true;
|
||||
for (const callback of this.on_initialized) callback();
|
||||
})
|
||||
.catch(this.advent22.alert_user_error);
|
||||
},
|
||||
this.update_is_admin();
|
||||
|
||||
update(): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.advent22
|
||||
.api_get_blob("user/favicon")
|
||||
.then((favicon_src) => {
|
||||
|
@ -86,22 +78,12 @@ export const advent22Store = defineStore({
|
|||
.catch(() => {});
|
||||
|
||||
Promise.all([
|
||||
this.update_is_admin(),
|
||||
this.advent22.api_get<SiteConfigModel>("user/site_config"),
|
||||
this.advent22.api_get_blob("user/background_image"),
|
||||
this.advent22.api_get<DoorSaved[]>("user/doors"),
|
||||
this.advent22.api_get<number | null>("user/next_door"),
|
||||
])
|
||||
.then(
|
||||
([
|
||||
is_admin,
|
||||
site_config,
|
||||
background_image,
|
||||
user_doors,
|
||||
next_door,
|
||||
]) => {
|
||||
is_admin; // discard value
|
||||
|
||||
.then(([site_config, background_image, user_doors, next_door]) => {
|
||||
document.title = site_config.title;
|
||||
|
||||
if (site_config.subtitle !== "")
|
||||
|
@ -119,11 +101,10 @@ export const advent22Store = defineStore({
|
|||
if (next_door !== null)
|
||||
this.next_door_target = Date.now() + next_door;
|
||||
|
||||
resolve();
|
||||
},
|
||||
)
|
||||
.catch(reject);
|
||||
});
|
||||
this.is_initialized = true;
|
||||
for (const callback of this.on_initialized) callback();
|
||||
})
|
||||
.catch(this.advent22.alert_user_error);
|
||||
},
|
||||
|
||||
when_initialized(callback: () => void): void {
|
||||
|
|
Loading…
Reference in a new issue