Spaces:
Running
Running
File size: 6,145 Bytes
f1ce0e5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
#!/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()
|