Spaces:
Running
Running
| #!/usr/bin/env python3 | |
| """Script to update all category HTML pages with Font Awesome and navigation bar.""" | |
| import re | |
| from pathlib import Path | |
| # Define category pages and their active nav items | |
| CATEGORIES = { | |
| 'pocs.html': 'POCs', | |
| 'system-prompts.html': 'System Prompts', | |
| 'frameworks.html': 'Frameworks', | |
| 'claude-code.html': 'Claude Code', | |
| 'mcp.html': 'MCP', | |
| 'gemini.html': 'Gemini', | |
| 'automation.html': 'Automation', | |
| 'context.html': 'Context', | |
| 'utilities.html': 'Utilities', | |
| 'documentation.html': 'Docs', | |
| 'miscellaneous.html': 'More' | |
| } | |
| # Subtitles for each category | |
| SUBTITLES = { | |
| 'pocs.html': 'Proof of concepts for AI systems and workflows', | |
| 'system-prompts.html': 'System prompts for configuring AI assistants and agents', | |
| 'frameworks.html': 'Frameworks, tools, and utilities for AI development', | |
| 'claude-code.html': 'Projects built with and for Claude Code CLI', | |
| 'mcp.html': 'Model Context Protocol servers and implementations', | |
| 'gemini.html': 'Projects leveraging Google\'s Gemini AI', | |
| 'automation.html': 'N8N workflows and automation tools', | |
| 'context.html': 'Context repositories and prompt collections', | |
| 'utilities.html': 'Standalone tools and utility applications', | |
| 'documentation.html': 'Documentation projects and resource indexes', | |
| 'miscellaneous.html': 'Various AI experiments and unique projects' | |
| } | |
| NAV_BAR = ''' <nav class="top-nav"> | |
| <div class="container"> | |
| <div class="nav-links"> | |
| <a href="index.html"><i class="fas fa-home"></i> Home</a> | |
| <a href="demos.html"{demos_active}><i class="fas fa-flask"></i> Demos</a> | |
| <a href="pocs.html"{pocs_active}><i class="fas fa-lightbulb"></i> POCs</a> | |
| <a href="system-prompts.html"{system_prompts_active}><i class="fas fa-cog"></i> System Prompts</a> | |
| <a href="frameworks.html"{frameworks_active}><i class="fas fa-toolbox"></i> Frameworks</a> | |
| <a href="claude-code.html"{claude_code_active}><i class="fas fa-terminal"></i> Claude Code</a> | |
| <a href="mcp.html"{mcp_active}><i class="fas fa-plug"></i> MCP</a> | |
| <a href="gemini.html"{gemini_active}><i class="fas fa-star"></i> Gemini</a> | |
| <a href="automation.html"{automation_active}><i class="fas fa-sync"></i> Automation</a> | |
| <a href="context.html"{context_active}><i class="fas fa-book"></i> Context</a> | |
| <a href="utilities.html"{utilities_active}><i class="fas fa-wrench"></i> Utilities</a> | |
| <a href="documentation.html"{documentation_active}><i class="fas fa-file-alt"></i> Docs</a> | |
| <a href="miscellaneous.html"{miscellaneous_active}><i class="fas fa-ellipsis-h"></i> More</a> | |
| </div> | |
| </div> | |
| </nav>''' | |
| def update_page(file_path: Path, active_nav: str, subtitle: str): | |
| """Update a single category page.""" | |
| content = file_path.read_text() | |
| # Add Font Awesome if not present | |
| if 'font-awesome' not in content: | |
| content = content.replace( | |
| '<link rel="stylesheet" href="style.css">', | |
| '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">\n <link rel="stylesheet" href="style.css">' | |
| ) | |
| # Update header structure | |
| header_pattern = r'<header>.*?</header>' | |
| new_header = f'''<header> | |
| <div class="container"> | |
| <div class="header-top"> | |
| <h1>AI Projects Index</h1> | |
| <div class="header-links"> | |
| <a href="https://github.com/danielrosehill" target="_blank"><i class="fab fa-github"></i> GitHub</a> | |
| <a href="https://danielrosehill.com" target="_blank"><i class="fas fa-globe"></i> Website</a> | |
| </div> | |
| </div> | |
| <p class="subtitle">{subtitle}</p> | |
| </div> | |
| </header>''' | |
| content = re.sub(header_pattern, new_header, content, flags=re.DOTALL) | |
| # Create navigation with active state | |
| active_states = { | |
| 'demos_active': ' class="active"' if active_nav == 'Demos' else '', | |
| 'pocs_active': ' class="active"' if active_nav == 'POCs' else '', | |
| 'system_prompts_active': ' class="active"' if active_nav == 'System Prompts' else '', | |
| 'frameworks_active': ' class="active"' if active_nav == 'Frameworks' else '', | |
| 'claude_code_active': ' class="active"' if active_nav == 'Claude Code' else '', | |
| 'mcp_active': ' class="active"' if active_nav == 'MCP' else '', | |
| 'gemini_active': ' class="active"' if active_nav == 'Gemini' else '', | |
| 'automation_active': ' class="active"' if active_nav == 'Automation' else '', | |
| 'context_active': ' class="active"' if active_nav == 'Context' else '', | |
| 'utilities_active': ' class="active"' if active_nav == 'Utilities' else '', | |
| 'documentation_active': ' class="active"' if active_nav == 'Docs' else '', | |
| 'miscellaneous_active': ' class="active"' if active_nav == 'More' else '' | |
| } | |
| nav_html = NAV_BAR.format(**active_states) | |
| # Add navigation after header if not present | |
| if '<nav class="top-nav">' not in content: | |
| content = content.replace('</header>', f'</header>\n\n{nav_html}') | |
| else: | |
| # Replace existing nav | |
| nav_pattern = r'<nav class="top-nav">.*?</nav>' | |
| content = re.sub(nav_pattern, nav_html, content, flags=re.DOTALL) | |
| # Remove old back link | |
| content = re.sub(r'<a href="index.html" class="back-link">← Back to Index</a>\s*', '', content) | |
| file_path.write_text(content) | |
| print(f"Updated {file_path.name}") | |
| def main(): | |
| """Update all category pages.""" | |
| script_dir = Path(__file__).parent | |
| for filename, active_nav in CATEGORIES.items(): | |
| file_path = script_dir / filename | |
| if file_path.exists(): | |
| subtitle = SUBTITLES.get(filename, '') | |
| update_page(file_path, active_nav, subtitle) | |
| else: | |
| print(f"Warning: {filename} not found") | |
| print("\nAll pages updated successfully!") | |
| if __name__ == '__main__': | |
| main() | |