Files
boc/landvex-site/build_site.py
T

82 lines
3.7 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
"""Build Landvex site with all articles"""
import json
import glob
from datetime import datetime
# Hämta alla artiklar
files = glob.glob('/home/bernt/.openclaw/workspace/projects/landvex/20-automation/intag/kandidatposter-2026-07-08*.json')
all_articles = []
for f in files:
with open(f) as fh:
data = json.load(fh)
all_articles.extend(data.get('kandidater', []))
print(f"Found {len(all_articles)} articles")
# Bygg HTML
html = f'''<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Landvex — Infrastructure Intelligence</title>
<style>
* {{ margin: 0; padding: 0; box-sizing: border-box; }}
body {{ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f5f5f7; color: #1d1d1f; }}
.header {{ background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%); color: white; padding: 60px 20px; text-align: center; }}
.header h1 {{ font-size: 48px; font-weight: 700; margin-bottom: 16px; }}
.header p {{ font-size: 20px; opacity: 0.9; max-width: 600px; margin: 0 auto; }}
.stats {{ display: flex; justify-content: center; gap: 40px; padding: 40px 20px; background: white; border-bottom: 1px solid #e5e5e7; }}
.stat {{ text-align: center; }}
.stat-number {{ font-size: 36px; font-weight: 700; color: #0071e3; }}
.stat-label {{ font-size: 14px; color: #86868b; margin-top: 4px; }}
.articles {{ max-width: 1200px; margin: 40px auto; padding: 0 20px; }}
.articles h2 {{ font-size: 28px; margin-bottom: 24px; }}
.article-grid {{ display: grid; grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); gap: 20px; }}
.article-card {{ background: white; border-radius: 16px; padding: 24px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); transition: transform 0.2s; }}
.article-card:hover {{ transform: translateY(-4px); }}
.article-domain {{ font-size: 12px; font-weight: 600; color: #0071e3; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }}
.article-title {{ font-size: 18px; font-weight: 600; margin-bottom: 8px; line-height: 1.3; }}
.article-desc {{ font-size: 14px; color: #86868b; line-height: 1.5; }}
.article-meta {{ margin-top: 16px; font-size: 12px; color: #c4c4c4; }}
.footer {{ text-align: center; padding: 40px; color: #86868b; font-size: 14px; }}
</style>
</head>
<body>
<div class="header">
<h1>Landvex</h1>
<p>Infrastructure Intelligence — Global decisions, local insights</p>
</div>
<div class="stats">
<div class="stat"><div class="stat-number">{len(all_articles)}</div><div class="stat-label">Articles</div></div>
<div class="stat"><div class="stat-number">29</div><div class="stat-label">AAMOS Accounts</div></div>
<div class="stat"><div class="stat-number">4</div><div class="stat-label">AI Agents</div></div>
</div>
<div class="articles">
<h2>Latest Articles</h2>
<div class="article-grid">
'''
# Lägg till artiklar
for art in reversed(all_articles[-50:]):
post = art.get('post', {})
namn = post.get('namn', {})
titel = namn.get('en', namn.get('sv', 'Untitled'))
desc = post.get('identitet', {}).get('beskrivning', '')[:150] + '...'
doman = post.get('doman', 'ANL')
html += f'<div class="article-card"><div class="article-domain">{doman}</div>'
html += f'<div class="article-title">{titel}</div>'
html += f'<div class="article-desc">{desc}</div>'
html += f'<div class="article-meta">ID: {art.get("kandidat_id", "")}</div></div>\n'
html += f'''</div></div>
<div class="footer"><p>Landvex — Built with AAMOS + AI | Updated {datetime.now().strftime("%Y-%m-%d %H:%M UTC")}</p></div>
</body></html>'''
with open('public/index.html', 'w') as f:
f.write(html)
print(f'✅ Site built with {len(all_articles)} articles')