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

View File

@@ -13,21 +13,21 @@ AUTHENTICATION:
* Authorization header - for API calls
- Customers CANNOT access admin or vendor routes
Routes:
- GET /shop/ → Shop homepage / product catalog
- GET /shop/products → Product catalog
- GET /shop/products/{id} → Product detail page
- GET /shop/categories/{slug} → Category products
- GET /shop/cart → Shopping cart
- GET /shop/checkout → Checkout process
- GET /shop/account/register → Customer registration
- GET /shop/account/login → Customer login
- GET /shop/account/dashboard → Customer dashboard (auth required)
- GET /shop/account/orders → Order history (auth required)
- GET /shop/account/orders/{id} → Order detail (auth required)
- GET /shop/account/profile → Customer profile (auth required)
- GET /shop/account/addresses → Address management (auth required)
- GET /shop/{slug} → Dynamic content pages (CMS): /about, /faq, /contact, etc.
Routes (all mounted at /shop/* or /vendors/{code}/shop/* prefix):
- GET / → Shop homepage / product catalog
- GET /products → Product catalog
- GET /products/{id} → Product detail page
- GET /categories/{slug} → Category products
- GET /cart → Shopping cart
- GET /checkout → Checkout process
- GET /account/register → Customer registration
- GET /account/login → Customer login
- GET /account/dashboard → Customer dashboard (auth required)
- GET /account/orders → Order history (auth required)
- GET /account/orders/{id} → Order detail (auth required)
- GET /account/profile → Customer profile (auth required)
- GET /account/addresses → Address management (auth required)
- GET /{slug} → Dynamic content pages (CMS): /about, /faq, /contact, etc.
"""
import logging
@@ -188,7 +188,7 @@ async def shop_products_page(request: Request, db: Session = Depends(get_db)):
)
@router.get("/shop/products/{product_id}", response_class=HTMLResponse, include_in_schema=False)
@router.get("/products/{product_id}", response_class=HTMLResponse, include_in_schema=False)
async def shop_product_detail_page(
request: Request,
product_id: int = Path(..., description="Product ID")
@@ -212,7 +212,7 @@ async def shop_product_detail_page(
)
@router.get("/shop/categories/{category_slug}", response_class=HTMLResponse, include_in_schema=False)
@router.get("/categories/{category_slug}", response_class=HTMLResponse, include_in_schema=False)
async def shop_category_page(
request: Request,
category_slug: str = Path(..., description="Category slug")
@@ -236,7 +236,7 @@ async def shop_category_page(
)
@router.get("/shop/cart", response_class=HTMLResponse, include_in_schema=False)
@router.get("/cart", response_class=HTMLResponse, include_in_schema=False)
async def shop_cart_page(request: Request):
"""
Render shopping cart page.
@@ -257,7 +257,7 @@ async def shop_cart_page(request: Request):
)
@router.get("/shop/checkout", response_class=HTMLResponse, include_in_schema=False)
@router.get("/checkout", response_class=HTMLResponse, include_in_schema=False)
async def shop_checkout_page(request: Request):
"""
Render checkout page.
@@ -278,7 +278,7 @@ async def shop_checkout_page(request: Request):
)
@router.get("/shop/search", response_class=HTMLResponse, include_in_schema=False)
@router.get("/search", response_class=HTMLResponse, include_in_schema=False)
async def shop_search_page(request: Request):
"""
Render search results page.
@@ -303,7 +303,7 @@ async def shop_search_page(request: Request):
# CUSTOMER ACCOUNT - PUBLIC ROUTES (No Authentication)
# ============================================================================
@router.get("/shop/account/register", response_class=HTMLResponse, include_in_schema=False)
@router.get("/account/register", response_class=HTMLResponse, include_in_schema=False)
async def shop_register_page(request: Request):
"""
Render customer registration page.
@@ -324,7 +324,7 @@ async def shop_register_page(request: Request):
)
@router.get("/shop/account/login", response_class=HTMLResponse, include_in_schema=False)
@router.get("/account/login", response_class=HTMLResponse, include_in_schema=False)
async def shop_login_page(request: Request):
"""
Render customer login page.
@@ -345,7 +345,7 @@ async def shop_login_page(request: Request):
)
@router.get("/shop/account/forgot-password", response_class=HTMLResponse, include_in_schema=False)
@router.get("/account/forgot-password", response_class=HTMLResponse, include_in_schema=False)
async def shop_forgot_password_page(request: Request):
"""
Render forgot password page.
@@ -370,8 +370,8 @@ async def shop_forgot_password_page(request: Request):
# CUSTOMER ACCOUNT - AUTHENTICATED ROUTES
# ============================================================================
@router.get("/shop/account/", response_class=RedirectResponse, include_in_schema=False)
async def shop_account_root():
@router.get("/account/", response_class=RedirectResponse, include_in_schema=False)
async def shop_account_root(request: Request):
"""
Redirect /shop/account/ to dashboard.
"""
@@ -384,10 +384,20 @@ async def shop_account_root():
}
)
return RedirectResponse(url="/shop/account/dashboard", status_code=302)
# Get base_url from context for proper redirect
vendor = getattr(request.state, 'vendor', None)
vendor_context = getattr(request.state, 'vendor_context', None)
access_method = vendor_context.get('detection_method', 'unknown') if vendor_context else 'unknown'
base_url = "/"
if access_method == "path" and vendor:
full_prefix = vendor_context.get('full_prefix', '/vendor/') if vendor_context else '/vendor/'
base_url = f"{full_prefix}{vendor.subdomain}/"
return RedirectResponse(url=f"{base_url}shop/account/dashboard", status_code=302)
@router.get("/shop/account/dashboard", response_class=HTMLResponse, include_in_schema=False)
@router.get("/account/dashboard", response_class=HTMLResponse, include_in_schema=False)
async def shop_account_dashboard_page(
request: Request,
current_user: User = Depends(get_current_customer_from_cookie_or_header),
@@ -413,7 +423,7 @@ async def shop_account_dashboard_page(
)
@router.get("/shop/account/orders", response_class=HTMLResponse, include_in_schema=False)
@router.get("/account/orders", response_class=HTMLResponse, include_in_schema=False)
async def shop_orders_page(
request: Request,
current_user: User = Depends(get_current_customer_from_cookie_or_header),
@@ -439,7 +449,7 @@ async def shop_orders_page(
)
@router.get("/shop/account/orders/{order_id}", response_class=HTMLResponse, include_in_schema=False)
@router.get("/account/orders/{order_id}", response_class=HTMLResponse, include_in_schema=False)
async def shop_order_detail_page(
request: Request,
order_id: int = Path(..., description="Order ID"),
@@ -466,7 +476,7 @@ async def shop_order_detail_page(
)
@router.get("/shop/account/profile", response_class=HTMLResponse, include_in_schema=False)
@router.get("/account/profile", response_class=HTMLResponse, include_in_schema=False)
async def shop_profile_page(
request: Request,
current_user: User = Depends(get_current_customer_from_cookie_or_header),
@@ -492,7 +502,7 @@ async def shop_profile_page(
)
@router.get("/shop/account/addresses", response_class=HTMLResponse, include_in_schema=False)
@router.get("/account/addresses", response_class=HTMLResponse, include_in_schema=False)
async def shop_addresses_page(
request: Request,
current_user: User = Depends(get_current_customer_from_cookie_or_header),
@@ -518,7 +528,7 @@ async def shop_addresses_page(
)
@router.get("/shop/account/wishlist", response_class=HTMLResponse, include_in_schema=False)
@router.get("/account/wishlist", response_class=HTMLResponse, include_in_schema=False)
async def shop_wishlist_page(
request: Request,
current_user: User = Depends(get_current_customer_from_cookie_or_header),
@@ -544,7 +554,7 @@ async def shop_wishlist_page(
)
@router.get("/shop/account/settings", response_class=HTMLResponse, include_in_schema=False)
@router.get("/account/settings", response_class=HTMLResponse, include_in_schema=False)
async def shop_settings_page(
request: Request,
current_user: User = Depends(get_current_customer_from_cookie_or_header),