feat: add home link

This commit is contained in:
2024-08-15 23:59:15 +03:00
parent 320fbbcaa5
commit ab8b760f93
15 changed files with 174 additions and 36 deletions

View File

@@ -1,9 +1,37 @@
from pathlib import Path
from typing import NamedTuple
from fastapi import FastAPI
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
from gallery.version import __version__
class Section(NamedTuple):
link: str
title: str
SECTIONS = [
Section("weather", "Погода"),
Section("schedule", "Телепрограмма"),
]
def mount(app: FastAPI):
base_dir = Path(__file__).parent
app.mount("/static/common", StaticFiles(directory=base_dir / "static"))
templates = Jinja2Templates(directory=base_dir / "templates")
@app.get("/", response_class=HTMLResponse)
async def get_section_list(request: Request):
return templates.TemplateResponse(
request=request,
name="index.html",
context={
"version": __version__,
"sections": SECTIONS,
},
)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -52,6 +52,33 @@ app
align-items: center;
}
.app-header {
width: 100%;
display: flex;
flex-direction: row;
}
.app-title {
display: flex;
justify-content: center;
flex-grow: 1;
}
.app-link-home > * {
margin-left: 2rem;
width: 2rem;
height: 2rem;
background-image: url("/static/common/gallery.png");
background-size: contain;
}
.icon {
display: inline-block;
width: 2rem;
height: 2rem;
background-size: contain;
}
ul.app-list {
list-style: none;
}
@@ -61,7 +88,8 @@ ul.app-list > li {
}
ul.app-list > li > a {
display: block;
display: flex;
gap: 0.25rem;
padding: 0.5rem 2rem;
text-decoration: none;
color: inherit;

View File

@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible"
content="ie=edge">
<title>Информация</title>
<link rel="stylesheet"
href="/static/common/style.css?v={{version}}">
<link rel="icon"
href="/static/common/favicon.ico?v={{version}}"
type="image/x-icon">
</head>
<body class="app-container">
<h3 class="app-header">
<a class="app-link-home"
href="/">
<div></div>
</a>
<div class="app-title">
<span>Информация</span>
</div>
</h3>
<ul class="app-list">
{% for section in sections %}
<li>
<a href="{{section.link}}">
<span class="icon"
style="background-image: url(/static/{{section.link}}/{{section.link}}.png);"></span>
<span>{{section.title}}</span>
</a>
</li>
{% endfor %}
</ul>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -1,3 +1,7 @@
tr {
border-bottom: 1px solid lightgray;
}
td {
text-align: left;
}

View File

@@ -13,12 +13,17 @@
<link rel="stylesheet"
href="/static/schedule/style.css?v={{version}}">
<link rel="icon"
href="/static/common/favicon.ico"
href="/static/schedule/favicon.ico?v={{version}}"
type="image/x-icon">
</head>
<body class="app-container">
<h3>
<h3 class="app-header">
<a class="app-link-home"
href="/">
<div></div>
</a>
<div class="app-title">
<a class="button {{'disabled' if response.date == datetime.date.today() else ''}}"
href="../tag/{{tag_util.create_tag('day', response.date, -1)}}">⬅️</a>
<a class="button"
@@ -26,6 +31,7 @@
<span>{{response.channel.name}} | {{response.date.strftime('%a, %d %B %Y')}}</span>
<a class="button"
href="../tag/{{tag_util.create_tag('day', response.date, 1)}}">➡️</a>
</div>
</h3>
<table>

View File

@@ -13,12 +13,22 @@
<link rel="stylesheet"
href="/static/schedule/style.css?v={{version}}">
<link rel="icon"
href="/static/common/favicon.ico"
href="/static/schedule/favicon.ico?v={{version}}"
type="image/x-icon">
</head>
<body class="app-container">
<h3 class="app-header">
<a class="app-link-home"
href="/">
<div></div>
</a>
<div class="app-title">
<span>Телепрограмма</span>
</div>
</h3>
<ul class="app-list">
<li style="margin-bottom: 0.25rem;"><a href="schedule/tag/today">all</a></li>
{% for channel in channels %}
<li><a href="schedule/{{channel}}">{{channel}}</a></li>
{% endfor %}

View File

@@ -13,19 +13,25 @@
<link rel="stylesheet"
href="/static/schedule/style.css?v={{version}}">
<link rel="icon"
href="/static/common/favicon.ico"
href="/static/schedule/favicon.ico?v={{version}}"
type="image/x-icon">
</head>
<body class="app-container">
<h3>
<h3 class="app-header">
<a class="app-link-home"
href="/">
<div></div>
</a>
<div class="app-title">
<a class="button {{'disabled' if response.date == datetime.date.today() else ''}}"
href="../tag/{{tag_util.create_tag('day', response.date, -1)}}">⬅️</a>
<a class="button"
href="../..">⬆️</a>
<span>Прямые трансляции | {{response.date.strftime('%a, %d %B %Y')}}</span>
href="..">⬆️</a>
<span>{{'Прямые трансляции' if live else 'Программа'}} | {{response.date.strftime('%a, %d %B %Y')}}</span>
<a class="button"
href="../tag/{{tag_util.create_tag('day', response.date, 1)}}">➡️</a>
</div>
</h3>
<table class="{{'live' if live else ''}}">

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

@@ -13,11 +13,20 @@
<link rel="stylesheet"
href="/static/weather/style.css?v={{version}}">
<link rel="icon"
href="/static/common/favicon.ico"
href="/static/weather/favicon.ico?v={{version}}"
type="image/x-icon">
</head>
<body class="app-container">
<h3 class="app-header">
<a class="app-link-home"
href="/">
<div></div>
</a>
<div class="app-title">
<span>Погода</span>
</div>
</h3>
<ul class="app-list">
{% for location in locations %}
<li><a href="weather/{{location}}">{{location}}</a></li>

View File

@@ -13,12 +13,17 @@
<link rel="stylesheet"
href="/static/weather/style.css?v={{version}}">
<link rel="icon"
href="/static/common/favicon.ico"
href="/static/weather/favicon.ico?v={{version}}"
type="image/x-icon">
</head>
<body class="app-container">
<h3>
<h3 class="app-header">
<a class="app-link-home"
href="/">
<div></div>
</a>
<div class="app-title">
{% if response.period == 'day' %}
<a class="button {{'disabled' if response.date == datetime.date.today() else ''}}"
href="../tag/{{tag_util.create_tag('day', response.date, -1)}}">⬅️</a>
@@ -31,6 +36,7 @@
{% if response.period == 'days' %}
<span>{{response.location}} | {{response.date.strftime('%a, %d %B %Y')}}</span>
{% endif %}
</div>
</h3>
<table>
<tbody>