feat: add platform homepage and content management system with improved UI
Implemented a comprehensive CMS for managing platform homepage and content pages: - Platform homepage manager with template selection (default, minimal, modern) - Content pages CRUD with platform defaults and vendor overrides - Sidebar navigation for Content Management section - Dedicated API endpoints for creating, updating, deleting pages - Template support for customizable homepage layouts - Header/footer navigation integration for content pages - Comprehensive documentation for platform homepage setup - Migration script for creating initial platform pages UI improvements: - Fixed action buttons styling in content pages table to match design system - Added proper hover states, rounded corners, and better contrast - Increased button size and padding for better usability 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
132
main.py
132
main.py
@@ -272,6 +272,138 @@ async def vendor_root_path(vendor_code: str, request: Request, db: Session = Dep
|
||||
# No landing page - redirect to shop
|
||||
return RedirectResponse(url=f"/vendors/{vendor_code}/shop/", status_code=302)
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# PLATFORM PUBLIC PAGES (Platform Homepage, About, FAQ, etc.)
|
||||
# ============================================================================
|
||||
logger.info("Registering platform public page routes:")
|
||||
logger.info(" - / (platform homepage)")
|
||||
logger.info(" - /{slug} (platform content pages: /about, /faq, /terms, /contact)")
|
||||
|
||||
|
||||
@app.get("/", response_class=HTMLResponse, include_in_schema=False)
|
||||
async def platform_homepage(request: Request, db: Session = Depends(get_db)):
|
||||
"""
|
||||
Platform homepage at localhost:8000 or platform.com
|
||||
|
||||
Looks for CMS page with slug='platform_homepage' (vendor_id=NULL)
|
||||
Falls back to default static template if not found.
|
||||
"""
|
||||
from app.services.content_page_service import content_page_service
|
||||
|
||||
logger.debug("[PLATFORM] Homepage requested")
|
||||
|
||||
# Try to load platform homepage from CMS
|
||||
homepage = content_page_service.get_page_for_vendor(
|
||||
db,
|
||||
slug="platform_homepage",
|
||||
vendor_id=None, # Platform-level page
|
||||
include_unpublished=False
|
||||
)
|
||||
|
||||
# Load header and footer navigation
|
||||
header_pages = content_page_service.list_pages_for_vendor(
|
||||
db,
|
||||
vendor_id=None,
|
||||
header_only=True,
|
||||
include_unpublished=False
|
||||
)
|
||||
|
||||
footer_pages = content_page_service.list_pages_for_vendor(
|
||||
db,
|
||||
vendor_id=None,
|
||||
footer_only=True,
|
||||
include_unpublished=False
|
||||
)
|
||||
|
||||
if homepage:
|
||||
# Use template selection from CMS
|
||||
template_name = homepage.template or "default"
|
||||
template_path = f"platform/homepage-{template_name}.html"
|
||||
|
||||
logger.info(f"[PLATFORM] Rendering CMS homepage with template: {template_path}")
|
||||
|
||||
return templates.TemplateResponse(
|
||||
template_path,
|
||||
{
|
||||
"request": request,
|
||||
"page": homepage,
|
||||
"header_pages": header_pages,
|
||||
"footer_pages": footer_pages,
|
||||
}
|
||||
)
|
||||
else:
|
||||
# Fallback to default static template
|
||||
logger.info("[PLATFORM] No CMS homepage found, using default template")
|
||||
|
||||
return templates.TemplateResponse(
|
||||
"platform/homepage-default.html",
|
||||
{
|
||||
"request": request,
|
||||
"header_pages": header_pages,
|
||||
"footer_pages": footer_pages,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@app.get("/{slug}", response_class=HTMLResponse, include_in_schema=False)
|
||||
async def platform_content_page(
|
||||
request: Request,
|
||||
slug: str,
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
"""
|
||||
Platform content pages: /about, /faq, /terms, /contact, etc.
|
||||
|
||||
Loads content from CMS with slug (vendor_id=NULL for platform pages).
|
||||
Returns 404 if page not found.
|
||||
|
||||
This route MUST be defined LAST to avoid conflicts with other routes.
|
||||
"""
|
||||
from app.services.content_page_service import content_page_service
|
||||
|
||||
logger.debug(f"[PLATFORM] Content page requested: /{slug}")
|
||||
|
||||
# Load page from CMS
|
||||
page = content_page_service.get_page_for_vendor(
|
||||
db,
|
||||
slug=slug,
|
||||
vendor_id=None, # Platform pages only
|
||||
include_unpublished=False
|
||||
)
|
||||
|
||||
if not page:
|
||||
logger.warning(f"[PLATFORM] Content page not found: {slug}")
|
||||
raise HTTPException(status_code=404, detail=f"Page not found: {slug}")
|
||||
|
||||
# Load header and footer navigation
|
||||
header_pages = content_page_service.list_pages_for_vendor(
|
||||
db,
|
||||
vendor_id=None,
|
||||
header_only=True,
|
||||
include_unpublished=False
|
||||
)
|
||||
|
||||
footer_pages = content_page_service.list_pages_for_vendor(
|
||||
db,
|
||||
vendor_id=None,
|
||||
footer_only=True,
|
||||
include_unpublished=False
|
||||
)
|
||||
|
||||
logger.info(f"[PLATFORM] Rendering content page: {page.title} (/{slug})")
|
||||
|
||||
return templates.TemplateResponse(
|
||||
"platform/content-page.html",
|
||||
{
|
||||
"request": request,
|
||||
"page": page,
|
||||
"header_pages": header_pages,
|
||||
"footer_pages": footer_pages,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
logger.info("=" * 80)
|
||||
|
||||
# Log all registered routes
|
||||
|
||||
Reference in New Issue
Block a user