Files
nginx-serve/start_book_catalog.sh
Edward Langley 9132d7485d Add book catalog example with global/local template system
Features:
- Global template configuration (sqlite_global_templates directive)
- Template path resolution relative to location
- Automatic template loading from directories
- Local templates override global templates
- Content handler installation via directive setter

Book Catalog Example:
- Complete working example with 10 technical books
- SQLite database with setup script
- 4 browseable pages (all, programming, databases, computer-science)
- Shared global templates (header, footer, book_card partial)
- Category-specific local templates with unique theming
- Responsive gradient UI design
- Working navigation and filtering

Configuration:
- sqlite_global_templates: HTTP main-level directive for shared templates
- sqlite_template: Location-level directive (sets content handler)
- Template resolution: {doc_root}{uri}/{template_name}
- All .hbs files in directories auto-loaded as partials

Technical improvements:
- Fixed content handler setup (not phase handler)
- Proper HttpModuleMainConf and HttpModuleLocationConf traits
- Template directory scanning and registration
- Error handling with debug logging
2025-11-15 14:52:39 -08:00

38 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Quick start script for the book catalog example
set -e
echo "📚 Starting Book Catalog..."
echo ""
# Check if database exists
if [ ! -f "book_catalog.db" ]; then
echo "Database not found. Running setup..."
./setup_book_catalog.sh
echo ""
fi
# Check if module is built
if [ ! -f "target/debug/libnginx_test.dylib" ]; then
echo "Module not built. Building..."
direnv exec "$PWD" cargo build
echo ""
fi
# Start nginx
echo "Starting nginx on http://localhost:8080"
./ngx_src/nginx-1.28.0/objs/nginx -c conf/book_catalog.conf -p .
echo ""
echo "✅ Book Catalog is running!"
echo ""
echo "Visit:"
echo " • http://localhost:8080/books/all - All books"
echo " • http://localhost:8080/books/programming - Programming books"
echo " • http://localhost:8080/books/databases - Database books"
echo " • http://localhost:8080/books/computer-science - CS books"
echo ""
echo "To stop: ./ngx_src/nginx-1.28.0/objs/nginx -s stop -c conf/book_catalog.conf -p ."