Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions src/safe_family/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

from datetime import timedelta

from flask import Flask, jsonify
from flask import Flask, jsonify, session
from sqlalchemy.exc import SQLAlchemyError

from config.logging import setup_logging
from config.settings import settings
from src.safe_family.api.routes import api_bp
from src.safe_family.auto_git.auto_git import auto_git_bp
from src.safe_family.core.auth import auth_bp
from src.safe_family.core.auth import auth_bp, get_current_username
from src.safe_family.core.extensions import db, jwt, mail
from src.safe_family.core.models import User
from src.safe_family.rules.scheduler import schedule_rules_bp
Expand Down Expand Up @@ -38,6 +39,26 @@ def _require_strong_secret(name: str, value: str | None) -> None:
raise RuntimeError(msg)


def inject_nav_user() -> dict:
"""Give the top bar the logged-in user's name, initial and admin flag."""
if not session.get("access_token"):
return {"nav_user": None}
try:
user = get_current_username()
except SQLAlchemyError:
return {"nav_user": None}
if user is None:
return {"nav_user": None}
name = (user.username or "").strip()
return {
"nav_user": {
"name": name,
"initial": name[:1].upper() or "?",
"is_admin": user.role == "admin",
},
}


def create_app():
"""Create and configure the Flask application."""
_require_strong_secret("FLASK_APP_SECRET_KEY", settings.APP_SECRET_KEY)
Expand Down Expand Up @@ -72,6 +93,8 @@ def inject_motto() -> dict:
"""Inject the app motto into all templates."""
return {"motto": settings.APP_MOTTO}

app.context_processor(inject_nav_user)

app.register_blueprint(root_bp)
app.register_blueprint(notes_bp)
app.register_blueprint(blog_bp)
Expand Down
249 changes: 249 additions & 0 deletions src/safe_family/static/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -1365,3 +1365,252 @@ td form button {
.codehilite .nf, .codehilite .fm, .codehilite .nc { color: #d2a8ff; }
.codehilite .nb, .codehilite .bp, .codehilite .nd { color: #ffa657; }
.codehilite .o, .codehilite .p { color: #e6edf3; }

/* Recipes (Sheet section) */
/* Two classes: base.html's inline styles (loaded after this file) reset
.card-header margins. */
.card-header.recipe-section-header {
margin-top: 3rem;
}

.recipe-page {
max-width: 72rem;
margin: 0 auto;
}

.recipe-toolbar {
display: flex;
justify-content: space-between;
align-items: center;
gap: 12px;
flex-wrap: wrap;
margin-block: 12px;
}

.recipe-back {
color: var(--sf-ink-muted);
text-decoration: none;
}

.recipe-back:hover {
color: var(--sf-accent);
}

.recipe-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
gap: 20px;
}

.recipe-card {
display: flex;
flex-direction: column;
overflow: hidden;
border: 1px solid var(--sf-border);
border-radius: var(--sf-radius);
background: var(--sf-surface);
color: var(--sf-ink);
text-decoration: none;
transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.recipe-card:hover {
transform: translateY(-2px);
box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.recipe-card-img {
width: 100%;
aspect-ratio: 4 / 3;
object-fit: cover;
display: block;
background: var(--sf-accent-soft);
}

.recipe-card-img--empty {
display: flex;
align-items: center;
justify-content: center;
font-size: 3rem;
}

.recipe-card-body {
display: flex;
flex-direction: column;
gap: 8px;
padding: 14px 16px 16px;
}

.recipe-card-title {
font-family: var(--sf-display);
font-size: 1.2rem;
font-weight: 700;
line-height: 1.3;
}

.recipe-card-summary {
color: var(--sf-ink-muted);
font-size: 0.92rem;
line-height: 1.5;
}

.recipe-meta {
display: flex;
flex-wrap: wrap;
gap: 4px 14px;
font-size: 0.82rem;
color: var(--sf-ink-muted);
}

.recipe-tags {
display: flex;
flex-wrap: wrap;
gap: 6px;
}

.recipe-tag {
font-size: 0.75rem;
padding: 2px 10px;
border-radius: 999px;
background: var(--sf-accent-soft);
color: var(--sf-accent);
}

.recipe-detail {
padding: 0;
overflow: hidden;
}

.recipe-hero {
display: grid;
grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 48rem) {
.recipe-hero {
grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
}
}

.recipe-hero-img {
width: 100%;
height: 100%;
max-height: 22rem;
aspect-ratio: 4 / 3;
object-fit: cover;
display: block;
background: var(--sf-accent-soft);
}

.recipe-hero-text {
display: flex;
flex-direction: column;
justify-content: center;
gap: 10px;
padding: 24px clamp(16px, 4vw, 32px);
}

.recipe-title {
font-family: var(--sf-display);
font-size: clamp(1.6rem, 4vw, 2.2rem);
font-weight: 700;
line-height: 1.2;
color: var(--sf-ink);
}

.recipe-summary {
color: var(--sf-ink-muted);
line-height: 1.6;
}

.recipe-columns {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 28px;
padding: 24px clamp(16px, 4vw, 32px) 32px;
border-top: 1px solid var(--sf-border);
}

@media (min-width: 48rem) {
.recipe-columns {
grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
}
}

.recipe-section-title {
font-family: var(--sf-display);
font-size: 1.2rem;
font-weight: 700;
margin-bottom: 12px;
color: var(--sf-ink);
}

.recipe-ingredients {
display: flex;
flex-direction: column;
gap: 8px;
}

.recipe-ingredients label {
display: flex;
align-items: flex-start;
gap: 10px;
cursor: pointer;
font-size: 1rem;
line-height: 1.5;
color: var(--sf-ink);
}

.recipe-ingredients input {
width: 1.1rem;
height: 1.1rem;
margin-top: 0.2em;
flex-shrink: 0;
accent-color: var(--sf-accent);
}

.recipe-ingredients input:checked + span {
color: var(--sf-ink-dim);
text-decoration: line-through;
}

.recipe-steps {
counter-reset: recipe-step;
display: flex;
flex-direction: column;
gap: 14px;
}

.recipe-steps li {
counter-increment: recipe-step;
position: relative;
padding-left: 2.4rem;
line-height: 1.6;
color: var(--sf-ink);
}

.recipe-steps li::before {
content: counter(recipe-step);
position: absolute;
left: 0;
top: 0;
width: 1.7rem;
height: 1.7rem;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.85rem;
font-weight: 700;
background: var(--sf-accent);
color: #fff;
}

.recipe-notes {
margin-top: 18px;
padding: 12px 14px;
border-left: 3px solid var(--sf-accent);
border-radius: var(--sf-radius-sm);
background: var(--sf-accent-soft);
color: var(--sf-ink);
}
29 changes: 29 additions & 0 deletions src/safe_family/static/recipes/tomato-egg-stir-fry.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading