1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
|
"""
# Django settings for Dicoweb project.
#
# This file is part of GNU Dico.
# Copyright (C) 2008-2010, 2012-2014, 2023 Wojciech Polak
#
# GNU Dico is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# GNU Dico is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Dico. If not, see <https://www.gnu.org/licenses/>.
"""
import os
SITE_ROOT = '/usr/share/dicoweb'
BASE_DIR = SITE_ROOT
DEBUG = False
ALLOWED_HOSTS = [
'localhost',
'127.0.0.1',
]
ADMINS = (
('Dico Admin', 'root@localhost'),
)
MANAGERS = ADMINS
SITE_ID = 1
USE_I18N = True
# Directories where Django looks for translation files.
LOCALE_PATHS = (
os.path.join(SITE_ROOT, 'locale'),
)
TIME_ZONE = 'UTC'
USE_TZ = True
LANGUAGE_CODE = 'en-us'
LANGUAGE_COOKIE_NAME = 'dicoweb_lang'
SESSION_COOKIE_NAME = 'dicoweb_sid'
SESSION_ENGINE = 'django.contrib.sessions.backends.file'
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
# Caching, see https://docs.djangoproject.com/en/dev/topics/cache/#topics-cache
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
# 'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache',
'LOCATION': '127.0.0.1:11211',
'KEY_PREFIX': 'dicoweb',
},
}
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/var/www/example.com/static/"
STATIC_ROOT = '/var/lib/dicoweb/passenger/public/static'
# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/static/'
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
# on Debian you can use /etc/dicoweb/assets to add assets and override dicoweb.{js,css} if needed
# (order matters, keep the /etc path first)
STATICFILES_DIRS = (
'/etc/dicoweb/assets',
os.path.join(SITE_ROOT, 'assets'),
)
try:
with open('/etc/dicoweb/secret_key') as f:
SECRET_KEY = f.read().strip()
except IOError:
print("/etc/dicoweb/secret_key is missing or unreadable")
exit(1)
MIDDLEWARE = [
'django.middleware.cache.UpdateCacheMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.gzip.GZipMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
]
ROOT_URLCONF = 'dicoweb.urls'
WSGI_APPLICATION = 'dicoweb.wsgi.application'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
# on Debian you can use /etc/dicoweb/templates to override web templates
'DIRS': [
os.path.join(SITE_ROOT, '/etc/dicoweb/templates'),
os.path.join(SITE_ROOT, 'templates'),
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
],
},
},
]
INSTALLED_APPS = (
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.staticfiles',
'dicoweb',
)
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See https://docs.djangoproject.com/en/dev/topics/logging/ for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
#
# Dicoweb specific settings.
#
DICT_SERVERS = ('localhost',)
DICT_TIMEOUT = 10
# Optional ONERROR dict controls what to do if certain errors occur.
# So far, only one key is defined:
#
# UNSUPPORTED_CONTENT_TYPE
# Specifies action to take if a DEFINE request returns article in
# unsupported content type (with OPTION MIME enabled).
# Value is a dict. The only mandatory key is 'action', indicating what
# action to take. Rest of keys depend on its value as shown in the table
# below:
#
# 'action': 'delete':
# The offending article will be removed, as if the server has
# never returned it. This can lead to inconsistencies where
# headwords returned by MATCH will not be returned by DEFINE.
# No additional keys are required.
#
# 'action': 'replace':
# The offending content will be replaced with the value of the
# 'message' key. Keys:
# 'message': Text to use as a replacement [mandatory]
# 'format_html': Boolean indicating whether to treat the text as HTML.
# Optional. Defaults to False.
#
# 'action': 'display':
# Display the result anyway. Additional key:
# 'format_html': Boolean indicating whether to treat the article as
# HTML.
# Optional. Defaults to False.
#
ONERROR = {
'UNSUPPORTED_CONTENT_TYPE': {
'action': 'replace',
'message': 'Article cannot be displayed due to unsupported content type',
'format_html': False,
}
}
|