Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
File size: 10,159 Bytes
e59d91d | 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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | ---
sidebar_position: 8
---
# Ground News-Style Homepage Redesign
## Overview
The homepage has been redesigned to follow the Ground News pattern with trending topics, a featured hero story, and a news grid layout. This creates a more engaging, content-forward experience while maintaining search functionality.
## What Changed
### 1. Trending Topics Bar
Two rows of trending topics at the top of the page with **+ icons** to subscribe/follow:
**First Row:**
- World Press Freedom Day π°
- Business & Markets πΌ
- Artificial Intelligence π€
- Health & Medicine βοΈ
- Premier League β½
- Soccer β½
**Second Row:**
- Baseball βΎ
- Donald Trump ποΈ
- IPL π
- Social Media π±
- Trump Administration πΊπΈ
- "Follow Topics" button
Each topic:
- Has an emoji icon
- Shows + sign on hover
- Clickable to search that topic
- Professional pill-shaped design
### 2. Featured Hero Story
Large banner with:
- **1200x600px hero image** with overlay
- **Gradient background** from black to transparent
- **Large headline** overlay (3-5xl text)
- **Subtitle** with context
- **Category badge** (top left)
- **Hover effects** (image opacity, text color)
Example:
```
Category: Civic Engagement
Title: "World Press Freedom Day: 43,726 Nonprofits Fighting for Transparency"
Subtitle: "How local journalism and civic organizations are tracking government decisions..."
```
### 3. Top Stories Grid
3-column responsive grid with 6 story cards:
- **Small image** (400x300px) for each story
- **Topic badge** overlay on image
- **Story title** (2-line max with line-clamp)
- **Hover effects** (shadow, scale, color change)
Topics covered:
- Artificial Intelligence
- Health & Medicine
- Sports & Recreation
- Social Media
- Business Development
- Government Transparency
### 4. Search Section (Moved Lower)
The original search interface is now in a collapsible section lower on the page:
- Still has both tabs (Search Topics, Find My Community)
- Maintains all functionality
- More subdued background (gray instead of white)
- Search-forward β Content-forward shift
## Technical Implementation
### New Icons Added
```typescript
import {
PlusIcon, // For "subscribe/follow" buttons
BellIcon, // For "Follow Topics" button
FireIcon // For "Trending" indicator
} from '@heroicons/react/24/outline'
```
### Data Structures
**TRENDING_TOPICS array:**
```typescript
{
name: string, // "World Press Freedom Day"
icon: string, // "π°"
category: string // "Global"
}
```
**FEATURED_STORY object:**
```typescript
{
title: string,
subtitle: string,
image: string, // URL to hero image
category: string,
link: string // Internal route
}
```
**TOP_STORIES array:**
```typescript
{
title: string,
topic: string, // Displayed as badge
image: string, // 400x300px thumbnail
link: string
}
```
### Styling Features
1. **Trending Bar:**
- `bg-gray-50 border-b` for subtle separation
- Pill-shaped buttons with `rounded-full`
- Hover state with `border-primary-500`
2. **Hero Banner:**
- `h-[500px]` fixed height
- `bg-gradient-to-t from-black` for text readability
- `group-hover:opacity-50` for image
- `group-hover:text-primary-300` for headline
3. **Story Cards:**
- `hover:shadow-lg` for elevation
- `group-hover:scale-105` on images
- `line-clamp-2` for title truncation
## Image Generation
### New Script: `scripts/media/generate_topic_images.py`
Generates professional banner and square images for topics using Google Gemini AI.
**Features:**
- AI-powered color scheme generation
- Banner images (1200x600px)
- Square thumbnails (400x400px)
- Gradient backgrounds
- Smart text wrapping
- Batch processing
**Usage:**
```bash
# Single topic
python scripts/media/generate_topic_images.py --topic "World Press Freedom Day"
# Batch from file
python scripts/media/generate_topic_images.py --topics-file topics.txt
# Default trending topics
python scripts/media/generate_topic_images.py
```
**Requirements:**
- Google Gemini API key in `.env`: `GEMINI_API_KEY=your_key`
- Auto-installs: `google-generativeai`, `pillow`, `requests`
**Output:**
```
data/media/topics/
βββ world_press_freedom_day_banner.png (1200x600)
βββ world_press_freedom_day_square.png (400x400)
βββ artificial_intelligence_banner.png
βββ artificial_intelligence_square.png
βββ metadata.json (color schemes, paths)
```
### Color Scheme Generation
Gemini analyzes each topic and suggests:
- **Primary color**: Main gradient start
- **Secondary color**: Gradient end
- **Text color**: High contrast for readability
- **Background color**: Base tone
- **Reasoning**: Why these colors fit the topic
Examples:
- **Politics**: Professional blues (#2563EB) and reds
- **Health**: Calming greens and blues
- **Technology**: Modern purples (#7C3AED) and blues
- **Sports**: Energetic oranges and reds
## Using Generated Images
### Update Homepage Data
Replace placeholder Unsplash images with generated ones:
```typescript
const FEATURED_STORY = {
title: 'World Press Freedom Day...',
image: '/images/topics/world_press_freedom_day_banner.png', // β Use generated
// ...
}
const TOP_STORIES = [
{
title: 'AI Policy Tracking...',
image: '/images/topics/artificial_intelligence_square.png', // β Use generated
// ...
}
]
```
### Integration Steps
1. **Generate images:**
```bash
cd /home/developer/projects/open-navigator
source .venv/bin/activate
python scripts/media/generate_topic_images.py
```
2. **Copy to frontend:**
```bash
mkdir -p frontend/public/images/topics
cp data/media/topics/*.png frontend/public/images/topics/
```
3. **Update Home.tsx:**
- Change image URLs from `https://images.unsplash.com/...`
- To `/images/topics/{topic}_square.png` or `{topic}_banner.png`
4. **Rebuild:**
```bash
cd frontend && npm run build
```
## Benefits
### User Experience
1. **Content Discovery**: Users see trending topics immediately
2. **Visual Engagement**: Large hero image draws attention
3. **Quick Navigation**: Click topics to search instantly
4. **Personalization**: + buttons suggest following/subscribing
5. **Familiar Pattern**: Matches news aggregators users know
### Technical Benefits
1. **SEO**: Content-forward design better for crawlers
2. **Performance**: Images lazy-load below fold
3. **Flexibility**: Easy to update trending topics
4. **Branding**: Custom generated images (no stock photo licenses)
5. **Accessibility**: High contrast, semantic HTML
## Future Enhancements
### Phase 2: Dynamic Content
- [ ] Pull trending topics from actual search data
- [ ] Featured story from latest government decisions
- [ ] Top stories from recent meeting minutes
- [ ] Real-time topic popularity tracking
### Phase 3: Personalization
- [ ] User can follow/subscribe to topics
- [ ] Save "+ Follow" state to user preferences
- [ ] Customized feed based on followed topics
- [ ] Email/push notifications for followed topics
### Phase 4: Advanced Image Generation
- [ ] Use Imagen 2 when available in Gemini API
- [ ] Real-time image generation on topic creation
- [ ] Video thumbnails from meeting recordings
- [ ] Animated topic badges (WebP/GIF)
## Design Inspiration
Based on [Ground News](https://ground.news):
- Trending topics bar at top
- Large hero story with image overlay
- Grid of smaller story cards
- Clean, professional news aesthetic
- Content-first approach
## Migration Notes
### Breaking Changes
- None! Search functionality preserved
- Existing routes still work
- All components intact
### Deprecations
- None
### Backward Compatibility
- 100% compatible
- Search moved lower but fully functional
- All existing links work
## Examples
### Before (Search-First)
```
+----------------------------------+
| Open Navigator |
| Search box (prominent) |
| Tabs: Search / Location |
| Quick topic pills |
| Stats section |
+----------------------------------+
```
### After (Content-First)
```
+----------------------------------+
| Trending: [Topic] [Topic] [+] |
| [Topic] [Topic] [Topic] [+] |
+----------------------------------+
| [HERO IMAGE WITH HEADLINE] |
| Large featured story |
+----------------------------------+
| Top Stories Grid |
| [img] [img] [img] |
| Story Story Story |
+----------------------------------+
| Search Section (collapsible) |
| Features Grid |
| Stats |
+----------------------------------+
```
## Testing
### Manual Tests
1. **Trending Topics**
- Click each topic β should navigate to search
- Hover β should show border/background change
- + icon β should be visible
2. **Hero Banner**
- Image loads correctly
- Text is readable over image
- Hover effects work
- Link goes to correct search
3. **Story Grid**
- All 6 stories display
- Images load
- Topic badges visible
- Hover effects (shadow, scale)
4. **Search Still Works**
- Both tabs functional
- Location lookup works
- Search results correct
### Automated Tests
Build verification:
```bash
cd frontend
npx tsc --noEmit # TypeScript check
npm run build # Vite build
```
## Deployment
### HuggingFace Spaces
No changes needed! Same deployment process:
```bash
./packages/hosting/scripts/huggingface/safe-deploy.sh
```
The Docker build will include:
- Updated Home.tsx
- Generated topic images (if copied to frontend/public)
- All existing functionality
### Local Development
```bash
./start-all.sh # Starts all 3 services
# Visit http://localhost:5173
```
## Resources
- **Script**: `scripts/media/generate_topic_images.py`
- **README**: `scripts/media/README.md`
- **Component**: `frontend/src/pages/Home.tsx`
- **Icons**: Heroicons 24 outline
- **Images**: Unsplash (placeholder) β Generated (production)
## Questions?
See [scripts/media/README.md](../../../scripts/media/README.md) for image generation details.
|