Compare commits

..

3 commits

3 changed files with 53 additions and 29 deletions

View file

@ -18,11 +18,19 @@ from .settings import SETTINGS
_logger = getLogger(__name__) _logger = getLogger(__name__)
class TickerAPIConfig(BaseModel): class TickerUIConfig(BaseModel):
"""
Configuration for how the UI displays the ticker content.
""" """
Section "[ticker.api]" in "config.txt".
Configuration for how the API generates the ticker content. color: str = "primary"
class TickerConfig(TickerUIConfig):
"""
Section "[ticker]" in "config.txt".
Combined configuration for the ticker.
""" """
file_name: str = "ticker" file_name: str = "ticker"
@ -30,30 +38,17 @@ class TickerAPIConfig(BaseModel):
comment_marker: str = "#" comment_marker: str = "#"
class TickerUIConfig(BaseModel): class ImageUIConfig(BaseModel):
""" """
Section "[ticker.ui]" in "config.txt". Configuration for how the UI displays the image carousel.
Configuration for how the UI displays the ticker content.
""" """
display: bool = True height: int = 300
color: str = "primary" contain: bool = False
speed: int = 30 speed: int = 10000
class TickerConfig(BaseModel): class ImageConfig(ImageUIConfig):
"""
Section "[ticker]" in "config.txt".
Combined configuration for the ticker.
"""
api: TickerAPIConfig = TickerAPIConfig()
ui: TickerUIConfig = TickerUIConfig()
class ImageConfig(BaseModel):
""" """
Sections "[image*]" in "config.txt". Sections "[image*]" in "config.txt".
""" """
@ -65,7 +60,15 @@ class ImageConfig(BaseModel):
} }
class CalendarConfig(BaseModel): class CalendarUIConfig(BaseModel):
"""
Configuration for how the UI displays the calendar carousel.
"""
speed: int = 10000
class CalendarConfig(CalendarUIConfig):
""" """
Sections "[calendar*]" in "config.txt". Sections "[calendar*]" in "config.txt".
""" """
@ -74,6 +77,24 @@ class CalendarConfig(BaseModel):
aggregates: dict[str, list[str]] = {} aggregates: dict[str, list[str]] = {}
class ServerUIConfig(BaseModel):
"""
Section "[server]" in "config.txt".
"""
name: str = "OEKZident"
host: str = "https://oekzident.de"
class LogoUIConfig(BaseModel):
"""
Section "[logo]" in "config.txt".
"""
name: str = "Technisches Hilfswerk"
host: str = "OV Musterstadt"
class Config(BaseModel): class Config(BaseModel):
""" """
Main representation of "config.txt". Main representation of "config.txt".
@ -82,8 +103,10 @@ class Config(BaseModel):
image_dir: str = "image" image_dir: str = "image"
text_dir: str = "text" text_dir: str = "text"
ticker: TickerConfig = TickerConfig() logo: LogoUIConfig = LogoUIConfig()
image: ImageConfig = ImageConfig() image: ImageConfig = ImageConfig()
server: ServerUIConfig = ServerUIConfig()
ticker: TickerConfig = TickerConfig()
calendar: CalendarConfig = CalendarConfig() calendar: CalendarConfig = CalendarConfig()
@classmethod @classmethod

View file

@ -31,7 +31,7 @@ async def start_router() -> None:
async def get_ticker_lines() -> Iterator[str]: async def get_ticker_lines() -> Iterator[str]:
cfg = await Config.get() cfg = await Config.get()
file_name = await text_unique(cfg.ticker.api.file_name) file_name = await text_unique(cfg.ticker.file_name)
ticker = await DavFile( ticker = await DavFile(
f"{await text_lister.remote_path}/{file_name}", f"{await text_lister.remote_path}/{file_name}",
@ -52,7 +52,7 @@ async def get_ticker_content_lines(
return ( return (
line line
for line in ticker_lines for line in ticker_lines
if not line.startswith(cfg.ticker.api.comment_marker) if not line.startswith(cfg.ticker.comment_marker)
) )
@ -60,7 +60,7 @@ async def get_ticker_content(
ticker_content_lines: Iterator[str] = Depends(get_ticker_content_lines), ticker_content_lines: Iterator[str] = Depends(get_ticker_content_lines),
) -> str: ) -> str:
cfg = await Config.get() cfg = await Config.get()
ticker_content = cfg.ticker.api.separator.join( ticker_content = cfg.ticker.separator.join(
["", *ticker_content_lines, ""], ["", *ticker_content_lines, ""],
) )
@ -88,4 +88,4 @@ async def get_raw_ticker(
async def get_ui_config( async def get_ui_config(
cfg: Config = Depends(Config.get), cfg: Config = Depends(Config.get),
) -> TickerUIConfig: ) -> TickerUIConfig:
return cfg.ticker.ui return cfg.ticker

View file

@ -34,7 +34,7 @@
<TickerBar <TickerBar
v-if="ticker_html !== ''" v-if="ticker_html !== ''"
:content="ticker_html" :content="ticker_html"
color="primary" :color="ticker_color"
/> />
</v-layout> </v-layout>
</v-app> </v-app>
@ -81,6 +81,7 @@ export default class App extends Vue {
private dashboard_ip = "0.0.0.0"; private dashboard_ip = "0.0.0.0";
private ticker_html = "<p>changeme</p>"; private ticker_html = "<p>changeme</p>";
private ticker_color = "primary";
} }
</script> </script>