mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-24 12:31:10 -05:00
Add secret management guide, client-side performance monitoring, and search accessibility enhancements
- Introduced a comprehensive Secret Management Guide detailing best practices, secret classification, development setup, production management, rotation procedures, and emergency protocols. - Implemented a client-side performance monitoring script to track various metrics including page load performance, paint metrics, layout shifts, and memory usage. - Enhanced search accessibility with keyboard navigation support for search results, ensuring compliance with WCAG standards and improving user experience.
This commit is contained in:
@@ -1,15 +1,21 @@
|
||||
"""
|
||||
Local development settings for thrillwiki project.
|
||||
|
||||
This module extends base.py with development-specific configurations:
|
||||
- Debug mode enabled
|
||||
- Local memory cache (no Redis required)
|
||||
- Console email backend option
|
||||
- Development middleware (nplusone, debug toolbar)
|
||||
- Enhanced logging for debugging
|
||||
"""
|
||||
|
||||
from ..settings import database
|
||||
import logging
|
||||
from .base import *
|
||||
from .base import * # noqa: F401,F403
|
||||
|
||||
# Import database configuration
|
||||
DATABASES = database.DATABASES
|
||||
# =============================================================================
|
||||
# Development Settings
|
||||
# =============================================================================
|
||||
|
||||
# Development-specific settings
|
||||
DEBUG = True
|
||||
|
||||
# For local development, allow all hosts
|
||||
@@ -22,10 +28,18 @@ CSRF_TRUSTED_ORIGINS = [
|
||||
"https://beta.thrillwiki.com",
|
||||
]
|
||||
|
||||
# =============================================================================
|
||||
# GeoDjango Library Paths (macOS with Homebrew)
|
||||
# =============================================================================
|
||||
|
||||
GDAL_LIBRARY_PATH = "/opt/homebrew/lib/libgdal.dylib"
|
||||
GEOS_LIBRARY_PATH = "/opt/homebrew/lib/libgeos_c.dylib"
|
||||
|
||||
# Local cache configuration
|
||||
# =============================================================================
|
||||
# Local Cache Configuration
|
||||
# =============================================================================
|
||||
# Use local memory cache for development (no Redis required)
|
||||
|
||||
LOC_MEM_CACHE_BACKEND = "django.core.cache.backends.locmem.LocMemCache"
|
||||
|
||||
CACHES = {
|
||||
@@ -38,7 +52,7 @@ CACHES = {
|
||||
"sessions": {
|
||||
"BACKEND": LOC_MEM_CACHE_BACKEND,
|
||||
"LOCATION": "sessions-cache",
|
||||
"TIMEOUT": 86400, # 24 hours (same as SESSION_COOKIE_AGE)
|
||||
"TIMEOUT": 86400, # 24 hours
|
||||
"OPTIONS": {"MAX_ENTRIES": 5000},
|
||||
},
|
||||
"api": {
|
||||
@@ -53,16 +67,29 @@ CACHES = {
|
||||
CACHE_MIDDLEWARE_SECONDS = 1 # Very short cache for development
|
||||
CACHE_MIDDLEWARE_KEY_PREFIX = "thrillwiki_dev"
|
||||
|
||||
# Development email backend - Use ForwardEmail for actual email sending
|
||||
# EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" # Console for debugging
|
||||
EMAIL_BACKEND = "django_forwardemail.backends.ForwardEmailBackend" # Actual email sending
|
||||
# =============================================================================
|
||||
# Email Backend
|
||||
# =============================================================================
|
||||
# Use ForwardEmail for actual sending, or console for debugging
|
||||
|
||||
# Console backend for debugging (uncomment to use):
|
||||
# EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
||||
|
||||
# ForwardEmail backend for actual email sending:
|
||||
EMAIL_BACKEND = "django_forwardemail.backends.ForwardEmailBackend"
|
||||
|
||||
# =============================================================================
|
||||
# Security Settings (Relaxed for Development)
|
||||
# =============================================================================
|
||||
|
||||
# Security settings for development
|
||||
SECURE_SSL_REDIRECT = False
|
||||
SESSION_COOKIE_SECURE = False
|
||||
CSRF_COOKIE_SECURE = False
|
||||
|
||||
# Development monitoring tools
|
||||
# =============================================================================
|
||||
# Development Apps
|
||||
# =============================================================================
|
||||
|
||||
DEVELOPMENT_APPS = [
|
||||
# "silk", # Disabled for performance
|
||||
"nplusone.ext.django",
|
||||
@@ -70,36 +97,47 @@ DEVELOPMENT_APPS = [
|
||||
"widget_tweaks",
|
||||
]
|
||||
|
||||
# Add development apps if available
|
||||
# Add development apps if not already present
|
||||
for app in DEVELOPMENT_APPS:
|
||||
if app not in INSTALLED_APPS:
|
||||
INSTALLED_APPS.append(app)
|
||||
if app not in INSTALLED_APPS: # noqa: F405
|
||||
INSTALLED_APPS.append(app) # noqa: F405
|
||||
|
||||
# =============================================================================
|
||||
# Development Middleware
|
||||
# =============================================================================
|
||||
|
||||
# Development middleware
|
||||
DEVELOPMENT_MIDDLEWARE = [
|
||||
# "silk.middleware.SilkyMiddleware", # Disabled for performance
|
||||
"nplusone.ext.django.NPlusOneMiddleware",
|
||||
"core.middleware.performance_middleware.PerformanceMiddleware",
|
||||
"core.middleware.performance_middleware.QueryCountMiddleware",
|
||||
"core.middleware.nextjs.APIResponseMiddleware", # Add this
|
||||
"core.middleware.request_logging.RequestLoggingMiddleware", # Request logging
|
||||
# Note: PerformanceMiddleware and QueryCountMiddleware are already in base.py MIDDLEWARE
|
||||
"apps.core.middleware.nextjs.APIResponseMiddleware",
|
||||
"apps.core.middleware.request_logging.RequestLoggingMiddleware",
|
||||
]
|
||||
|
||||
# Add development middleware
|
||||
# Add development middleware if not already present
|
||||
for middleware in DEVELOPMENT_MIDDLEWARE:
|
||||
if middleware not in MIDDLEWARE:
|
||||
MIDDLEWARE.insert(1, middleware) # Insert after security middleware
|
||||
if middleware not in MIDDLEWARE: # noqa: F405
|
||||
MIDDLEWARE.insert(1, middleware) # noqa: F405
|
||||
|
||||
# =============================================================================
|
||||
# Debug Toolbar Configuration
|
||||
# =============================================================================
|
||||
|
||||
# Debug toolbar configuration
|
||||
INTERNAL_IPS = ["127.0.0.1", "::1"]
|
||||
|
||||
# Silk configuration disabled for performance
|
||||
# =============================================================================
|
||||
# NPlusOne Configuration
|
||||
# =============================================================================
|
||||
# Detects N+1 query issues during development
|
||||
|
||||
# NPlusOne configuration
|
||||
NPLUSONE_LOGGER = logging.getLogger("nplusone")
|
||||
NPLUSONE_LOG_LEVEL = logging.WARN
|
||||
|
||||
# Enhanced development logging
|
||||
# =============================================================================
|
||||
# Development Logging Configuration
|
||||
# =============================================================================
|
||||
# Extended logging for debugging with reduced noise
|
||||
|
||||
LOGGING = {
|
||||
"version": 1,
|
||||
"disable_existing_loggers": False,
|
||||
@@ -123,14 +161,14 @@ LOGGING = {
|
||||
},
|
||||
"file": {
|
||||
"class": "logging.handlers.RotatingFileHandler",
|
||||
"filename": BASE_DIR / "logs" / "thrillwiki.log",
|
||||
"filename": BASE_DIR / "logs" / "thrillwiki.log", # noqa: F405
|
||||
"maxBytes": 1024 * 1024 * 10, # 10MB
|
||||
"backupCount": 5,
|
||||
"formatter": "json",
|
||||
},
|
||||
"performance": {
|
||||
"class": "logging.handlers.RotatingFileHandler",
|
||||
"filename": BASE_DIR / "logs" / "performance.log",
|
||||
"filename": BASE_DIR / "logs" / "performance.log", # noqa: F405
|
||||
"maxBytes": 1024 * 1024 * 10, # 10MB
|
||||
"backupCount": 5,
|
||||
"formatter": "json",
|
||||
@@ -143,22 +181,22 @@ LOGGING = {
|
||||
"loggers": {
|
||||
"django": {
|
||||
"handlers": ["file"],
|
||||
"level": "WARNING", # Reduced from INFO
|
||||
"level": "WARNING",
|
||||
"propagate": False,
|
||||
},
|
||||
"django.db.backends": {
|
||||
"handlers": ["console"],
|
||||
"level": "WARNING", # Reduced from DEBUG
|
||||
"level": "WARNING",
|
||||
"propagate": False,
|
||||
},
|
||||
"thrillwiki": {
|
||||
"handlers": ["console", "file"],
|
||||
"level": "INFO", # Reduced from DEBUG
|
||||
"level": "INFO",
|
||||
"propagate": False,
|
||||
},
|
||||
"performance": {
|
||||
"handlers": ["performance"],
|
||||
"level": "WARNING", # Reduced from INFO
|
||||
"level": "WARNING",
|
||||
"propagate": False,
|
||||
},
|
||||
"query_optimization": {
|
||||
@@ -168,7 +206,7 @@ LOGGING = {
|
||||
},
|
||||
"nplusone": {
|
||||
"handlers": ["console"],
|
||||
"level": "ERROR", # Reduced from WARNING
|
||||
"level": "ERROR",
|
||||
"propagate": False,
|
||||
},
|
||||
"request_logging": {
|
||||
|
||||
Reference in New Issue
Block a user