Files
homepage.veen.world/app/utils/compute_card_classes.py
Kevin Veen-Birkenbach 252b50d2a7 feat: migrate to pyproject.toml, add test suites, split CI workflows
- Replace requirements.txt with pyproject.toml for modern Python packaging
- Add unit, integration, lint and security test suites under tests/
- Add utils/export_runtime_requirements.py and utils/check_hadolint_sarif.py
- Split monolithic CI into reusable lint.yml, security.yml and tests.yml
- Refactor ci.yml to orchestrate reusable workflows; publish on semver tag only
- Modernize Dockerfile: pin python:3.12-slim, install via pyproject.toml
- Expand Makefile with lint, security, test and CI targets
- Add test-e2e via act with portfolio container stop/start around run
- Fix navbar_logo_visibility.spec.js: win.fullscreen() → win.enterFullscreen()
- Set use_reloader=False in app.run() to prevent double-start in CI
- Add app/core.* and build artifacts to .gitignore
- Fix apt-get → sudo apt-get in tests.yml e2e job
- Fix pip install --ignore-installed to handle stale act cache

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-29 23:03:09 +02:00

43 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
def compute_card_classes(cards):
num_cards = len(cards)
lg_classes = []
if num_cards < 3:
if num_cards == 2:
lg_classes = ["col-lg-6", "col-lg-6"]
else:
lg_classes = ["col-lg-12"]
elif num_cards % 4 == 0:
lg_classes = ["col-lg-3"] * num_cards
elif num_cards % 3 == 0:
lg_classes = ["col-lg-4"] * num_cards
elif num_cards % 2 == 0:
lg_classes = ["col-lg-6"] * num_cards
else:
# For complex cases (e.g., 5, 7, 11) Ensure at least 3 per row
for i in range(num_cards):
if num_cards % 4 == 3:
if i < 3:
lg_classes.append("col-lg-4")
else:
lg_classes.append("col-lg-3")
elif num_cards % 4 == 1:
if i < 2:
lg_classes.append("col-lg-6")
elif i < 5:
lg_classes.append("col-lg-4")
else:
lg_classes.append("col-lg-3")
elif num_cards % 3 == 2:
if i < 2:
lg_classes.append("col-lg-6")
else:
lg_classes.append("col-lg-4")
# Use a full-width last card on medium screens only when the total count is odd.
md_classes = []
for i in range(num_cards):
if num_cards % 2 == 0 or i < num_cards - 1:
md_classes.append("col-md-6")
else:
md_classes.append("col-md-12")
return lg_classes, md_classes