feat: implement vendor landing pages with multi-template support and fix shop routing

Major improvements to shop URL routing and vendor landing page system:

## Landing Page System
- Add template field to ContentPage model for flexible landing page designs
- Create 4 landing page templates: default, minimal, modern, and full
- Implement smart root handler to serve landing pages or redirect to shop
- Add create_landing_page.py script for easy landing page management
- Support both domain/subdomain and path-based vendor access
- Add comprehensive landing page documentation

## Route Fixes
- Fix duplicate /shop prefix in shop_pages.py routes
- Correct product detail page routing (was /shop/shop/products/{id})
- Update all shop routes to work with router prefix mounting
- Remove unused public vendor endpoints (/api/v1/public/vendors)

## Template Link Corrections
- Fix all shop template links to include /shop/ prefix
- Update breadcrumb 'Home' links to point to vendor root (landing page)
- Update header navigation 'Home' link to point to vendor root
- Correct CMS page links in footer navigation
- Fix account, cart, and error page navigation links

## Navigation Architecture
- Establish two-tier navigation: landing page (/) and shop (/shop/)
- Document complete navigation flow and URL hierarchy
- Support for vendors with or without landing pages (auto-redirect fallback)
- Consistent breadcrumb and header navigation behavior

## Documentation
- Add vendor-landing-pages.md feature documentation
- Add navigation-flow.md with complete URL hierarchy
- Update shop architecture docs with error handling section
- Add orphaned docs to mkdocs.yml navigation
- Document multi-access routing patterns

## Database
- Migration f68d8da5315a: add template field to content_pages table
- Support template values: default, minimal, modern, full

This establishes a complete landing page system allowing vendors to have
custom marketing homepages separate from their e-commerce shop, with
flexible template options and proper navigation hierarchy.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-23 00:10:45 +01:00
parent d85a68f175
commit b7bf505a61
26 changed files with 1967 additions and 242 deletions

222
scripts/create_landing_page.py Executable file
View File

@@ -0,0 +1,222 @@
#!/usr/bin/env python3
"""
Create Landing Page for Vendor
This script creates a landing page for a vendor with the specified template.
Usage: python scripts/create_landing_page.py
"""
import sys
from pathlib import Path
# Add project root to path
sys.path.insert(0, str(Path(__file__).parent.parent))
from sqlalchemy.orm import Session
from app.core.database import SessionLocal
from models.database.vendor import Vendor
from models.database.content_page import ContentPage
from datetime import datetime, timezone
def create_landing_page(
vendor_subdomain: str,
template: str = "default",
title: str = None,
content: str = None
):
"""
Create a landing page for a vendor.
Args:
vendor_subdomain: Vendor subdomain (e.g., 'wizamart')
template: Template to use (default, minimal, modern, full)
title: Page title (defaults to vendor name)
content: HTML content (optional)
"""
db: Session = SessionLocal()
try:
# Find vendor
vendor = db.query(Vendor).filter(
Vendor.subdomain == vendor_subdomain
).first()
if not vendor:
print(f"❌ Vendor '{vendor_subdomain}' not found!")
return False
print(f"✅ Found vendor: {vendor.name} (ID: {vendor.id})")
# Check if landing page already exists
existing = db.query(ContentPage).filter(
ContentPage.vendor_id == vendor.id,
ContentPage.slug == "landing"
).first()
if existing:
print(f"⚠️ Landing page already exists (ID: {existing.id})")
print(f" Current template: {existing.template}")
# Update it
existing.template = template
existing.title = title or existing.title
if content:
existing.content = content
existing.is_published = True
existing.updated_at = datetime.now(timezone.utc)
db.commit()
print(f"✅ Updated landing page with template: {template}")
else:
# Create new landing page
landing_page = ContentPage(
vendor_id=vendor.id,
slug="landing",
title=title or f"Welcome to {vendor.name}",
content=content or f"""
<h2>About {vendor.name}</h2>
<p>{vendor.description or 'Your trusted shopping destination for quality products.'}</p>
<h3>Why Choose Us?</h3>
<ul>
<li><strong>Quality Products:</strong> Carefully curated selection</li>
<li><strong>Fast Shipping:</strong> Quick delivery to your door</li>
<li><strong>Great Service:</strong> Customer satisfaction guaranteed</li>
</ul>
<h3>Our Story</h3>
<p>We've been serving customers since 2020, providing exceptional products and service.
Our mission is to make online shopping easy, enjoyable, and reliable.</p>
""",
content_format="html",
template=template,
meta_description=f"Shop at {vendor.name} for quality products and great service",
is_published=True,
published_at=datetime.now(timezone.utc),
show_in_footer=False,
show_in_header=False,
display_order=0
)
db.add(landing_page)
db.commit()
db.refresh(landing_page)
print(f"✅ Created landing page (ID: {landing_page.id})")
print(f" Template: {template}")
print(f" Title: {landing_page.title}")
# Print access URLs
print("\n📍 Access your landing page at:")
print(f" Path-based: http://localhost:8000/vendors/{vendor.subdomain}/")
print(f" Shop page: http://localhost:8000/vendors/{vendor.subdomain}/shop/")
return True
except Exception as e:
print(f"❌ Error: {e}")
db.rollback()
return False
finally:
db.close()
def list_vendors():
"""List all vendors in the system."""
db: Session = SessionLocal()
try:
vendors = db.query(Vendor).filter(Vendor.is_active == True).all()
if not vendors:
print("❌ No active vendors found!")
return
print("\n📋 Active Vendors:")
print("=" * 60)
for vendor in vendors:
print(f"{vendor.name}")
print(f" Subdomain: {vendor.subdomain}")
print(f" Code: {vendor.vendor_code}")
# Check if has landing page
landing = db.query(ContentPage).filter(
ContentPage.vendor_id == vendor.id,
ContentPage.slug == "landing"
).first()
if landing:
print(f" Landing Page: ✅ ({landing.template})")
else:
print(f" Landing Page: ❌ None")
print()
finally:
db.close()
def show_templates():
"""Show available templates."""
print("\n🎨 Available Templates:")
print("=" * 60)
templates = [
("default", "Clean professional layout with 3-column quick links"),
("minimal", "Ultra-simple centered design with single CTA"),
("modern", "Full-screen hero with animations and features"),
("full", "Maximum features with split-screen hero and stats")
]
for name, desc in templates:
print(f"{name:<10} - {desc}")
print()
if __name__ == "__main__":
print("\n" + "=" * 60)
print(" VENDOR LANDING PAGE CREATOR")
print("=" * 60)
# List vendors
list_vendors()
# Show templates
show_templates()
# Interactive creation
print("📝 Create Landing Page")
print("-" * 60)
vendor_subdomain = input("Enter vendor subdomain (e.g., wizamart): ").strip()
if not vendor_subdomain:
print("❌ Vendor subdomain is required!")
sys.exit(1)
print("\nAvailable templates: default, minimal, modern, full")
template = input("Enter template (default): ").strip() or "default"
if template not in ["default", "minimal", "modern", "full"]:
print(f"⚠️ Invalid template '{template}', using 'default'")
template = "default"
title = input("Enter page title (optional, press Enter to use default): ").strip()
print("\n🚀 Creating landing page...")
print("-" * 60)
success = create_landing_page(
vendor_subdomain=vendor_subdomain,
template=template,
title=title if title else None
)
if success:
print("\n✅ SUCCESS! Landing page is ready.")
print("\n💡 Try different templates:")
print(f" python scripts/create_landing_page.py")
print(f" # Then choose: minimal, modern, or full")
else:
print("\n❌ Failed to create landing page")
sys.exit(1)