From 9c6c1d5fa41991e413e0dbf77e20b17ef2d82f3b Mon Sep 17 00:00:00 2001 From: Lucas Messenger <1335960+layertwo@users.noreply.github.com> Date: Tue, 30 Dec 2025 16:49:58 -0500 Subject: [PATCH] feat(cli): add index generation command --- .kiro/specs/flight-map-generator/tasks.md | 6 +- src/connections/main.py | 23 ++++ src/connections/templates/index.html.j2 | 142 ++++++++++++++++------ 3 files changed, 134 insertions(+), 37 deletions(-) diff --git a/.kiro/specs/flight-map-generator/tasks.md b/.kiro/specs/flight-map-generator/tasks.md index ebe8f2c..4bb6923 100644 --- a/.kiro/specs/flight-map-generator/tasks.md +++ b/.kiro/specs/flight-map-generator/tasks.md @@ -56,19 +56,19 @@ This plan implements batch flight map generation with AWS CDK deployment for sta - **Property 10: HTML Link Correctness** - **Validates: Requirements 4.3** -- [ ] 4. Create HTML template +- [x] 4. Create HTML template - Create `src/connections/templates/index.html.j2` - Implement responsive grid layout - Add thumbnail previews with clickable links - Display map titles - _Requirements: 4.2, 4.3, 4.4_ -- [ ] 5. Add index generation CLI command or script +- [x] 5. Add index generation CLI command or script - Add command to generate index.html from output directory - Can be integrated into batch command or separate script - _Requirements: 4.1, 4.5_ -- [ ] 6. Checkpoint - Ensure all tests pass +- [x] 6. Checkpoint - Ensure all tests pass - Ensure all tests pass, ask the user if questions arise. - [ ] 7. Create CDK infrastructure diff --git a/src/connections/main.py b/src/connections/main.py index 56a82a8..6507909 100644 --- a/src/connections/main.py +++ b/src/connections/main.py @@ -1,9 +1,11 @@ import json import logging +from pathlib import Path import click from connections.batch import BatchProcessor +from connections.index import IndexGenerator from connections.map import FlightMap from connections.model import Flight, Flights @@ -46,5 +48,26 @@ def batch(input_directory: str, output_directory: str) -> None: click.echo("No flight maps were generated.") +@cli.command() +@click.option("-d", "--directory", type=click.Path(exists=True), required=True) +@click.option("-o", "--output", type=str, default=None) +def index(directory: str, output: str) -> None: + """Generate index.html from PNG files in a directory""" + generator = IndexGenerator() + maps = generator.scan_output_directory(directory) + + if not maps: + click.echo("No PNG files found in directory.") + return + + # Default output path is index.html in the same directory + if output is None: + output = str(Path(directory) / "index.html") + + generator.generate(maps=maps, output_path=output) + click.echo(f"Generated index page at {output}") + click.echo(f"Found {len(maps)} flight map(s)") + + if __name__ == "__main__": cli() diff --git a/src/connections/templates/index.html.j2 b/src/connections/templates/index.html.j2 index f4f1a3c..c56a045 100644 --- a/src/connections/templates/index.html.j2 +++ b/src/connections/templates/index.html.j2 @@ -3,7 +3,7 @@ - Flight Maps + Flight Connection Maps
-

Flight Maps

+
+

✈️ Flight Connection Maps

+

Explore your flight routes around the world

+
{% if maps %}
{% for map in maps %} {% endfor %}
{% else %} -

No flight maps found.

+
+

No flight maps found

+

Add some flight data to generate your first map!

+
{% endif %} + +