mirror of
https://github.com/kevinveenbirkenbach/homepage.veen.world.git
synced 2025-07-06 11:05:13 +02:00
Implemented Nasa Picture of the day
This commit is contained in:
parent
d0f8d7d172
commit
64db9a4e6a
21
app/app.py
21
app/app.py
@ -1,6 +1,7 @@
|
||||
import os
|
||||
from flask import Flask, render_template
|
||||
import yaml
|
||||
import requests
|
||||
from utils.configuration_resolver import ConfigurationResolver
|
||||
from utils.cache_manager import CacheManager
|
||||
from utils.compute_card_classes import compute_card_classes
|
||||
@ -22,6 +23,9 @@ def load_config(app):
|
||||
with open("config.yaml", "r") as f:
|
||||
config = yaml.safe_load(f)
|
||||
|
||||
if config.get("nasa_api_key"):
|
||||
app.config["NASA_API_KEY"] = config["nasa_api_key"]
|
||||
|
||||
resolver = ConfigurationResolver(config)
|
||||
resolver.resolve_links()
|
||||
app.config.update(resolver.get_config())
|
||||
@ -56,6 +60,20 @@ def index():
|
||||
"""Render the main index page."""
|
||||
cards = app.config["cards"]
|
||||
lg_classes, md_classes = compute_card_classes(cards)
|
||||
# fetch NASA APOD URL only if key present
|
||||
apod_bg = None
|
||||
api_key = app.config.get("NASA_API_KEY")
|
||||
if api_key:
|
||||
resp = requests.get(
|
||||
"https://api.nasa.gov/planetary/apod",
|
||||
params={"api_key": api_key}
|
||||
)
|
||||
if resp.ok:
|
||||
data = resp.json()
|
||||
# only use if it's an image
|
||||
if data.get("media_type") == "image":
|
||||
apod_bg = data.get("url")
|
||||
|
||||
return render_template(
|
||||
"pages/index.html.j2",
|
||||
cards=cards,
|
||||
@ -63,7 +81,8 @@ def index():
|
||||
navigation=app.config["navigation"],
|
||||
platform=app.config["platform"],
|
||||
lg_classes=lg_classes,
|
||||
md_classes=md_classes
|
||||
md_classes=md_classes,
|
||||
apod_bg=apod_bg
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -1,5 +1,6 @@
|
||||
---
|
||||
accounts:
|
||||
nasa_api_key: YOUR_REAL_KEY_HERE
|
||||
name: Online Presence
|
||||
description: Discover my online presence.
|
||||
icon:
|
||||
|
@ -70,7 +70,6 @@ h3.card-title {
|
||||
|
||||
/* Footer styles */
|
||||
.footer {
|
||||
margin-top: 12px;
|
||||
text-align: center;
|
||||
font-size: 0.7em;
|
||||
}
|
||||
@ -97,7 +96,7 @@ div#navbarNavfooter li.nav-item {
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
main {
|
||||
main, footer, header, nav {
|
||||
position: relative;
|
||||
box-shadow:
|
||||
/* Inner shadow */
|
||||
@ -108,3 +107,28 @@ main {
|
||||
-10px 0 10px -10px rgba(0, 0, 0, 0.3); /* Left outer shadow */
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
header{
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
header,
|
||||
footer {
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
top: 0;
|
||||
margin: 0;
|
||||
z-index: 1030;
|
||||
background-color: var(--bs-light);
|
||||
}
|
||||
|
||||
/* at the end of default.css */
|
||||
body::before {
|
||||
content: "";
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(255, 255, 255, 0.75);
|
||||
pointer-events: none;
|
||||
z-index: -1;
|
||||
}
|
||||
|
@ -19,12 +19,6 @@
|
||||
transition: all 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
nav.navbar.menu-header {
|
||||
border-bottom-left-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
|
||||
nav.navbar.menu-footer {
|
||||
border-top-left-radius: 0;
|
||||
border-top-right-radius: 0;
|
||||
nav.navbar {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
@ -17,13 +17,21 @@
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/default.css') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/custom_scrollbar.css') }}">
|
||||
</head>
|
||||
<body>
|
||||
<body
|
||||
{% if apod_bg %}
|
||||
style="
|
||||
background-image: url('{{ apod_bg }}');
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
background-attachment: fixed;
|
||||
"
|
||||
{% endif %}
|
||||
>
|
||||
<div class="container">
|
||||
<header class="header">
|
||||
<img src="{{platform.logo.cache}}" alt="logo"/>
|
||||
<h1>{{platform.titel}}</h1>
|
||||
<h2>{{platform.subtitel}}</h2>
|
||||
<br />
|
||||
</header>
|
||||
{% set menu_type = "header" %}
|
||||
{% include "moduls/navigation.html.j2"%}
|
||||
|
Loading…
x
Reference in New Issue
Block a user