Merge branch 'develop' into wip/rect_rework

This commit is contained in:
Jörn-Michael Miehe 2023-10-06 16:33:59 +00:00
commit b3a4a20f16
4 changed files with 42 additions and 15 deletions

View file

@ -13,7 +13,7 @@ class User(BaseModel):
class Puzzle(BaseModel):
# Titel
# TODO neue Route GET /user/title
# TODO penner neue Route GET /user/title
title: str
# Lösungswort
@ -65,6 +65,11 @@ class Config(BaseModel):
# Serverseitiger zusätzlicher "random" seed
random_seed: str = ""
# Fußzeile der Seite
footer: str = (
'<strong>Advent22</strong> by <a href="//www.lenaisten.de">Lenaisten e.V.</a>'
)
async def get_config() -> Config:
"""

View file

@ -5,6 +5,7 @@ from fastapi.responses import StreamingResponse
from PIL import Image
from ..core.calendar_config import CalendarConfig, DoorsSaved, get_calendar_config
from ..core.config import Config, get_config
from ..core.depends import get_all_event_dates, get_day_image
from ..core.helpers import EventDates, api_return_image, load_image
from ._security import user_can_view_day, user_is_admin, user_visible_days
@ -38,6 +39,17 @@ async def get_doors(
return [door for door in cal_cfg.doors if door.day in visible_days]
@router.get("/footer")
async def get_footer(
cfg: Config = Depends(get_config),
) -> str:
"""
Seiten-Fußzeile lesen
"""
return cfg.footer
@router.get(
"/image_{day}",
response_class=StreamingResponse,

View file

@ -16,10 +16,7 @@
<footer class="footer">
<nav class="level is-mobile">
<div class="level-item">
<p>
<strong>Advent22</strong> by
<a href="https://www.lenaisten.de/">Lenaisten.de</a>.
</p>
<p v-html="footer" />
</div>
<div class="level-right">
<div class="level-item">
@ -46,6 +43,14 @@ import UserView from "./components/UserView.vue";
})
export default class extends Vue {
public is_admin = false;
public footer = "";
public mounted(): void {
this.$advent22
.api_get<string>("user/footer")
.then((footer) => (this.footer = footer))
.catch((error) => alert(this.$advent22.format_user_error(error)));
}
}
</script>

View file

@ -20,6 +20,9 @@
<dd v-if="next_door === null">Kein nächstes Türchen</dd>
<dd v-else><CountDown :millis="next_door" /></dd>
<dt>Fußzeile</dt>
<dd class="is-family-monospace">{{ footer }}</dd>
<dt>Erstes Türchen</dt>
<dd>{{ fmt_puzzle_date("first") }}</dd>
@ -49,13 +52,12 @@
<dt>Hintergrundbild</dt>
<dd>{{ config_model.calendar.background }}</dd>
<dt>Türchen</dt>
<dt>Türchen ({{ doors.length }} Stück)</dt>
<dd>
<template v-for="(part, day) in day_parts" :key="`door-${day}`">
<template v-for="(door, index) in doors" :key="`door-${index}`">
<span>
<template v-if="Number(day) > 1">, </template>
<span v-if="part == ''" class="tag is-warning">_</span>
<template v-else>{{ part }}</template>
<template v-if="door.day > 1">, </template>
{{ door.day }}
</span>
</template>
</dd>
@ -122,7 +124,7 @@
</template>
<script lang="ts">
import { ConfigModel, Credentials, DoorsSaved, NumStrDict } from "@/lib/api";
import { ConfigModel, Credentials, DoorsSaved } from "@/lib/api";
import { DateTime } from "luxon";
import { Options, Vue } from "vue-class-component";
@ -162,7 +164,8 @@ export default class extends Vue {
config_file: "sed diam nonumy",
},
};
public day_parts: NumStrDict = {};
public doors: DoorsSaved = [];
public footer = "";
public num_user_doors = 0;
public next_door: number | null = null;
public dav_credentials: Credentials = ["", ""];
@ -178,14 +181,16 @@ export default class extends Vue {
public on_open(ready: () => void, fail: () => void): void {
Promise.all([
this.$advent22.api_get<ConfigModel>("admin/config_model"),
this.$advent22.api_get<NumStrDict>("admin/day_parts"),
this.$advent22.api_get<DoorsSaved>("admin/doors"),
this.$advent22.api_get<DoorsSaved>("user/doors"),
this.$advent22.api_get<string>("user/footer"),
this.$advent22.api_get<number | null>("user/next_door"),
])
.then(([config_model, day_parts, user_doors, next_door]) => {
.then(([config_model, doors, user_doors, footer, next_door]) => {
this.config_model = config_model;
this.day_parts = day_parts;
this.doors = doors;
this.num_user_doors = user_doors.length;
this.footer = footer;
this.next_door = next_door;
ready();