download links in book text
[wolnelektury.git] / wolnelektury / settings.py
1 # -*- coding: utf-8 -*-
2 # Django settings for wolnelektury project.
3 from os import path
4
5 PROJECT_DIR = path.abspath(path.dirname(__file__))
6
7 DEBUG = False
8 TEMPLATE_DEBUG = DEBUG
9 MAINTENANCE_MODE = False
10
11 ADMINS = [
12     # ('Your Name', 'your_email@domain.com'),
13 ]
14
15 MANAGERS = ADMINS
16
17 DATABASES = {
18     'default': {
19         'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
20         'NAME': path.join(PROJECT_DIR, 'dev.db'), # Or path to database file if using sqlite3.
21         'USER': '',                      # Not used with sqlite3.
22         'PASSWORD': '',                  # Not used with sqlite3.
23         'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
24     }
25 }
26
27
28 # Local time zone for this installation. Choices can be found here:
29 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
30 # although not all choices may be available on all operating systems.
31 # If running in a Windows environment this must be set to the same as your
32 # system time zone.
33 TIME_ZONE = 'Europe/Warsaw'
34
35 # Language code for this installation. All choices can be found here:
36 # http://www.i18nguy.com/unicode/language-identifiers.html
37 LANGUAGE_CODE = 'pl'
38
39 gettext = lambda s: s
40
41 LANGUAGES = tuple(sorted([
42     ('pl', u'polski'),
43     ('de', u'Deutsch'),
44     ('en', u'English'),
45     ('lt', u'lietuvių'),
46     ('fr', u'français'),
47     ('ru', u'русский'),
48     ('es', u'español'),
49     ('uk', u'українська'),
50 ], key=lambda x: x[0]))
51
52
53 SITE_ID = 1
54
55 # If you set this to False, Django will make some optimizations so as not
56 # to load the internationalization machinery.
57 USE_I18N = True
58
59 # Absolute path to the directory that holds media.
60 # Example: "/home/media/media.lawrence.com/"
61 MEDIA_ROOT = path.join(PROJECT_DIR, '../media/')
62 STATIC_ROOT = path.join(PROJECT_DIR, 'static/')
63 SEARCH_INDEX = path.join(MEDIA_ROOT, 'search/')
64
65 # URL that handles the media served from MEDIA_ROOT. Make sure to use a
66 # trailing slash if there is a path component (optional in other cases).
67 # Examples: "http://media.lawrence.com", "http://example.com/media/"
68 MEDIA_URL = '/media/'
69 STATIC_URL = '/static/'
70
71 # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
72 # trailing slash.
73 # Examples: "http://foo.com/media/", "/media/".
74 ADMIN_MEDIA_PREFIX = '/admin-media/'
75
76 # Make this unique, and don't share it with anybody.
77
78 # List of callables that know how to import templates from various sources.
79 TEMPLATE_LOADERS = [
80     'django.template.loaders.filesystem.Loader',
81     'django.template.loaders.app_directories.Loader',
82 #     'django.template.loaders.eggs.Loader',
83 ]
84
85 TEMPLATE_CONTEXT_PROCESSORS = (
86     'django.contrib.auth.context_processors.auth',
87     'django.core.context_processors.debug',
88     'django.core.context_processors.i18n',
89     'django.core.context_processors.media',
90     'django.core.context_processors.request',
91     'wolnelektury.context_processors.extra_settings',
92     'search.context_processors.search_form',
93 )
94
95 MIDDLEWARE_CLASSES = [
96     'django.middleware.cache.UpdateCacheMiddleware',
97     'django.middleware.common.CommonMiddleware',
98     'django.contrib.sessions.middleware.SessionMiddleware',
99     'django.contrib.auth.middleware.AuthenticationMiddleware',
100     'django.middleware.doc.XViewMiddleware',
101     'pagination.middleware.PaginationMiddleware',
102     'django.middleware.locale.LocaleMiddleware',
103     'piwik.django.middleware.PiwikMiddleware',
104     'maintenancemode.middleware.MaintenanceModeMiddleware',
105     'django.middleware.common.CommonMiddleware',
106     'django.middleware.cache.FetchFromCacheMiddleware',
107 ]
108
109 ROOT_URLCONF = 'wolnelektury.urls'
110
111 TEMPLATE_DIRS = [
112     path.join(PROJECT_DIR, 'templates'),
113 ]
114
115 LOGIN_URL = '/uzytkownicy/zaloguj/'
116
117 LOGIN_REDIRECT_URL = '/'
118
119 INSTALLED_APPS = [
120     # external
121     'django.contrib.auth',
122     'django.contrib.contenttypes',
123     'django.contrib.sessions',
124     'django.contrib.sites',
125     'django.contrib.admin',
126     'django.contrib.admindocs',
127     'pagination',
128     'piston',
129     'piwik.django',
130     'rosetta',
131     'south',
132     'sorl.thumbnail',
133     'djcelery',
134     'djkombu',
135     #    'django_nose',
136
137     # included
138     'compress',
139     'modeltranslation',
140
141     # our
142     'ajaxable',
143     'api',
144     'catalogue',
145     'chunks',
146     'dictionary',
147     'infopages',
148     'lesmianator',
149     'lessons',
150     'newtagging',
151     'opds',
152     'pdcounter',
153     'reporting',
154     'sponsors',
155     'stats',
156     'suggest',
157     'picture',
158     'search',
159     'social',
160 ]
161
162 CACHES = {
163     'default': {
164         'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
165         'LOCATION': [
166             '127.0.0.1:11211',
167         ]
168     },
169     'permanent': {
170         'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
171         'TIMEOUT': 2419200,
172         'LOCATION': [
173             '127.0.0.1:11211',
174         ]
175     },
176     'api': {
177         'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
178         'LOCATION': path.join(PROJECT_DIR, 'django_cache/'),
179         'KEY_PREFIX': 'api',
180         'TIMEOUT': 86400,
181     },
182 }
183 CACHE_MIDDLEWARE_ANONYMOUS_ONLY=True
184
185 # CSS and JavaScript file groups
186 COMPRESS_CSS = {
187     'all': {
188         #'source_filenames': ('css/master.css', 'css/jquery.autocomplete.css', 'css/master.plain.css', 'css/facelist_2-0.css',),
189         'source_filenames': [
190             'css/jquery.countdown.css', 
191
192             'css/base.css',
193             'css/cite.css',
194             'css/header.css',
195             'css/main_page.css',
196             'css/dialogs.css',
197             'css/picture_box.css',
198             'css/book_box.css',
199             'css/catalogue.css',
200             'css/sponsors.css',
201             'css/logo.css',
202
203             'css/social/shelf_tags.css',
204             'css/ui-lightness/jquery-ui-1.8.16.custom.css',
205         ],
206         'output_filename': 'css/all.min?.css',
207     },
208     'ie': {
209         'source_filenames': [
210             'css/ie.css',
211         ],
212         'output_filename': 'css/ie.min?.css',
213     },
214     'book': {
215         'source_filenames': [
216             'css/logo.css',
217             'css/master.book.css',
218         ],
219         'output_filename': 'css/book.min?.css',
220     },
221     'player': {
222         'source_filenames': [
223             'jplayer/jplayer.blue.monday.css', 
224         ],
225         'output_filename': 'css/player.min?.css',
226     },
227     'simple': {
228         'source_filenames': ('css/simple.css',),
229         'output_filename': 'css/simple.min?.css',
230     },
231 }
232
233 COMPRESS_JS = {
234     'base': {
235         'source_filenames': (
236             'js/jquery.cycle.min.js',
237             'js/jquery.jqmodal.js',
238             'js/jquery.form.js',
239             'js/jquery.countdown.js', 'js/jquery.countdown-pl.js',
240             'js/jquery.countdown-de.js', 'js/jquery.countdown-uk.js',
241             'js/jquery.countdown-es.js', 'js/jquery.countdown-lt.js',
242             'js/jquery.countdown-ru.js', 'js/jquery.countdown-fr.js',
243
244             'js/jquery-ui-1.8.16.custom.min.js',
245
246             'js/locale.js',
247             'js/dialogs.js',
248             'js/sponsors.js',
249             'js/base.js',
250             'js/pdcounter.js',
251
252             'js/search.js',
253             ),
254         'output_filename': 'js/base?.min.js',
255     },
256     'player': {
257         'source_filenames': [
258             'jplayer/jquery.jplayer.min.js', 
259             'jplayer/jplayer.playlist.min.js', 
260             'js/player.js', 
261         ],
262         'output_filename': 'js/player.min?.js',
263     },
264     'book': {
265         'source_filenames': ('js/jquery.eventdelegation.js', 'js/jquery.scrollto.js', 'js/jquery.highlightfade.js', 'js/book.js',),
266         'output_filename': 'js/book?.min.js',
267     },
268     'book_ie': {
269         'source_filenames': ('js/ierange-m2.js',),
270         'output_filename': 'js/book_ie?.min.js',
271     }
272
273 }
274
275 COMPRESS_VERSION = True
276 COMPRESS_CSS_FILTERS = None
277
278 THUMBNAIL_QUALITY = 95
279 THUMBNAIL_EXTENSION = 'png'
280
281 THUMBNAIL_PROCESSORS = (
282     # Default processors
283     'sorl.thumbnail.processors.colorspace',
284     'sorl.thumbnail.processors.autocrop',
285     'sorl.thumbnail.processors.scale_and_crop',
286     'sorl.thumbnail.processors.filters',
287     # Custom processors
288     'sponsors.processors.add_padding',
289 )
290
291 TRANSLATION_REGISTRY = "wolnelektury.translation"
292
293
294 # seconds until a changes appears in the changes api
295 API_WAIT = 10
296
297 # limit number of filtering tags
298 MAX_TAG_LIST = 6
299
300 NO_BUILD_EPUB = False
301 NO_BUILD_TXT = False
302 NO_BUILD_PDF = False
303 NO_BUILD_MOBI = True
304 NO_SEARCH_INDEX = False
305
306 ALL_EPUB_ZIP = 'wolnelektury_pl_epub'
307 ALL_PDF_ZIP = 'wolnelektury_pl_pdf'
308 ALL_MOBI_ZIP = 'wolnelektury_pl_mobi'
309
310 CATALOGUE_DEFAULT_LANGUAGE = 'pol'
311 PUBLISH_PLAN_FEED = 'http://redakcja.wolnelektury.pl/documents/track/editor-proofreading/'
312
313 PAGINATION_INVALID_PAGE_RAISES_404 = True
314
315 import djcelery
316 djcelery.setup_loader()
317
318 BROKER_BACKEND = "djkombu.transport.DatabaseTransport"
319 BROKER_HOST = "localhost"
320 BROKER_PORT = 5672
321 BROKER_USER = "guest"
322 BROKER_PASSWORD = "guest"
323 BROKER_VHOST = "/"
324
325 CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
326
327 # Load localsettings, if they exist
328 try:
329     from localsettings import *
330 except ImportError:
331     pass
332