mirror of
https://github.com/wahyd4/links.git
synced 2026-08-09 05:06:16 +10:00
Rebase
This commit is contained in:
+41
-39
@@ -21,22 +21,13 @@ INSTALLED_APPS = [
|
||||
'simplemde',
|
||||
'markdown', # 只需要基本的markdown包
|
||||
'invest',
|
||||
'netscan',
|
||||
'nginxmon',
|
||||
'routermon',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'core.urls'
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'core.middleware.CustomLocaleMiddleware', # 替换原来的 LocaleMiddleware
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||
]
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
@@ -48,6 +39,7 @@ TEMPLATES = [
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'core.context_processors.build_info',
|
||||
],
|
||||
},
|
||||
},
|
||||
@@ -57,7 +49,8 @@ TEMPLATES = [
|
||||
|
||||
# 添加以下基本设置(如果尚未存在)
|
||||
SECRET_KEY = 'your-secret-key-here' # 请更改为一个安全的随机值
|
||||
DEBUG = True
|
||||
|
||||
DEBUG = os.environ.get('DEBUG', 'True').lower() in ('true', '1', 'yes')
|
||||
ALLOWED_HOSTS = ['*']
|
||||
|
||||
# 数据库设置(使用默认的SQLite配置)
|
||||
@@ -114,6 +107,24 @@ STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
||||
|
||||
CSRF_TRUSTED_ORIGINS = os.environ.get('CSRF_TRUSTED_ORIGINS', 'http://localhost:8000').split(',')
|
||||
|
||||
# Redis cache
|
||||
REDIS_URL = os.environ.get('REDIS_URL', 'redis://192.168.1.2:6379/0')
|
||||
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django_redis.cache.RedisCache',
|
||||
'LOCATION': REDIS_URL,
|
||||
'OPTIONS': {
|
||||
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
||||
},
|
||||
'TIMEOUT': 300,
|
||||
}
|
||||
}
|
||||
|
||||
# Store sessions in Redis instead of the database
|
||||
SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
|
||||
SESSION_CACHE_ALIAS = 'default'
|
||||
|
||||
# SimpleMDE 配置
|
||||
SIMPLEMDE_OPTIONS = {
|
||||
'placeholder': 'Type here...',
|
||||
@@ -129,6 +140,12 @@ MEDIA_ROOT = os.path.join(BASE_DIR, 'data', 'media')
|
||||
|
||||
MUSIC_ROOT = os.path.join(BASE_DIR, 'data', 'music')
|
||||
|
||||
# File uploads folder — override via FILE_UPLOADS_FOLDER env var.
|
||||
# Defaults to ~/Downloads locally; set to /uploads on k8s.
|
||||
FILE_UPLOADS_FOLDER = os.environ.get('FILE_UPLOADS_FOLDER', os.path.expanduser('~/Downloads'))
|
||||
IMAGES_FOLDER = os.environ.get('IMAGES_FOLDER', os.path.expanduser('~/Pictures'))
|
||||
|
||||
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
@@ -150,15 +167,6 @@ LOGGING = {
|
||||
},
|
||||
}
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
'DEFAULT_RENDERER_CLASSES': [
|
||||
'rest_framework.renderers.JSONRenderer',
|
||||
],
|
||||
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
|
||||
'PAGE_SIZE': 10,
|
||||
'UNAUTHENTICATED_USER': None, # 添加这行
|
||||
}
|
||||
|
||||
LANGUAGE_URL_MAP = {
|
||||
'en': 'en',
|
||||
'zh-hans': 'zh',
|
||||
@@ -178,6 +186,7 @@ LOCALE_INDEPENDENT_PATHS = [
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'core.middleware.CustomLocaleMiddleware', # 使用自定义中间件
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
@@ -191,6 +200,8 @@ REST_FRAMEWORK = {
|
||||
'DEFAULT_RENDERER_CLASSES': [
|
||||
'rest_framework.renderers.JSONRenderer',
|
||||
],
|
||||
'DEFAULT_AUTHENTICATION_CLASSES': [],
|
||||
'DEFAULT_PERMISSION_CLASSES': [],
|
||||
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
|
||||
'PAGE_SIZE': 10,
|
||||
'UNAUTHENTICATED_USER': None,
|
||||
@@ -218,21 +229,12 @@ R2_CUSTOM_DOMAIN = os.environ.get('R2_CUSTOM_DOMAIN')
|
||||
CRAWL4AI_API_URL = os.environ.get('CRAWL4AI_API_URL', 'https://crawl-api.junv.cc')
|
||||
CRAWL4AI_ENABLED = os.environ.get('CRAWL4AI_ENABLED', 'True').lower() in ('true', '1', 'yes')
|
||||
|
||||
# For debugging
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'handlers': {
|
||||
'console': {
|
||||
'class': 'logging.StreamHandler',
|
||||
'level': 'DEBUG',
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
'links': {
|
||||
'handlers': ['console'],
|
||||
'level': 'DEBUG',
|
||||
'propagate': True,
|
||||
},
|
||||
},
|
||||
# Build metadata (injected at Docker image build time)
|
||||
BUILD_TIME = os.environ.get('BUILD_TIME', '')
|
||||
BUILD_VERSION = os.environ.get('BUILD_VERSION', '')
|
||||
|
||||
LOGGING['loggers']['links'] = {
|
||||
'handlers': ['console'],
|
||||
'level': 'DEBUG',
|
||||
'propagate': False,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user