feat: add catalog

This commit is contained in:
2024-08-16 00:59:56 +03:00
parent aae8bc8649
commit b3043c3c8c
11 changed files with 91 additions and 22 deletions

View File

@@ -7,6 +7,7 @@ from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
from gallery.sketch.schedule.api import ScheduleApi
from gallery.sketch.schedule.catalog import BUNDLE
from gallery.version import __version__
from ..common.util import TagType, TagUtil
@@ -23,12 +24,13 @@ def mount(app: FastAPI):
async def get_schedule_list(request: Request):
schedule_api: ScheduleApi = request.app.state.schedule_api
channels = await schedule_api.get_channels()
channels_data = BUNDLE.select_items(channels)
return templates.TemplateResponse(
request=request,
name="index.html",
context={
"version": __version__,
"channels": channels,
"channels": channels_data,
},
)

View File

@@ -28,9 +28,9 @@
</div>
</h3>
<ul class="app-list">
<li style="margin-bottom: 0.25rem;"><a href="schedule/tag/today">all</a></li>
<li style="margin-bottom: 0.25rem; font-weight: bold;"><a href="schedule/tag/today">Все</a></li>
{% for channel in channels %}
<li><a href="schedule/{{channel}}">{{channel}}</a></li>
<li><a href="schedule/{{channel.id}}">{{channel.name}}</a></li>
{% endfor %}
</ul>
</body>

View File

@@ -7,6 +7,7 @@ from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
from gallery.sketch.weather.api import WeatherApi
from gallery.sketch.weather.catalog import BUNDLE
from gallery.sketch.weather.mock import WEATHER_MOCK_DATA
from gallery.sketch.weather.model import WeatherResponse
from gallery.version import __version__
@@ -38,12 +39,13 @@ def mount(app: FastAPI):
async def get_weather_list(request: Request):
weather_api: WeatherApi = request.app.state.weather_api
locations = await weather_api.get_locations()
locations_data = BUNDLE.select_items(locations)
return templates.TemplateResponse(
request=request,
name="index.html",
context={
"version": __version__,
"locations": locations,
"locations": locations_data,
},
)

View File

@@ -29,7 +29,7 @@
</h3>
<ul class="app-list">
{% for location in locations %}
<li><a href="weather/{{location}}">{{location}}</a></li>
<li><a href="weather/{{location.id}}">{{location.name}}</a></li>
{% endfor %}
</ul>
</body>