# Epic 5: Site Maintenance & Automation ## Epic Goal To automate recurring site-level maintenance tasks that occur post-deployment, ensuring sites remain current and well-maintained without manual intervention. ## Rationale After initial content deployment, sites require ongoing maintenance tasks such as updating homepages with new articles, refreshing navigation, and managing site-level pages. These tasks are: - **Recurring**: Need to run regularly (daily, weekly, etc.) - **Post-Deployment**: Occur after articles are published - **Site-Level Scope**: Operate on the entire site rather than individual articles - **Future Growth**: Foundation for additional maintenance automation (sitemaps, RSS feeds, etc.) By automating these tasks, we reduce manual overhead and ensure sites stay fresh and properly organized as content grows. ## Stories ### Story 5.1: Automated Homepage Index Generator **As a site administrator**, I want the system to automatically generate and update the index.html page for each deployed site based on its articles, so that visitors see an up-to-date homepage without manual intervention. **Goal**: Automatically generate/update the `index.html` page for each deployed site based on its articles. **Trigger**: Scheduled script (e.g., daily cron job) **Functionality**: - Loop through all `site_deployments` records - Query articles associated with each site - Check for existing `index.html` in `site_pages` table - Support two modes: - **Custom Template Mode**: Use `homepage_template.html` with placeholders like `{{article_list}}`, `{{site_name}}`, etc. - **Auto-Generation Mode**: Generate a complete index.html from scratch using site configuration - Configuration options: - `--max-articles`: Limit number of articles to display - `--order-by`: Sort articles (newest, oldest, alphabetical, etc.) - `--template`: Specify custom template path - Store generated `index.html` in `site_pages` table - Track `last_homepage_update` timestamp on `SiteDeployment` model - Integration with deployment logic: - Save to database - Push to Bunny.net (or configured CDN) - Update deployment timestamp **Acceptance Criteria**: - Script can be run manually or scheduled - Successfully generates index.html for all active sites - Handles both custom template and auto-generation modes - Properly integrates with existing deployment infrastructure - Updates database timestamps for tracking - Logs all operations for debugging and monitoring - Gracefully handles errors (missing templates, deployment failures, etc.)