prefixing a root path too many times doesn't work
[objavi2.git] / objavi / config.py
blobd6258ebdbd30fd5bb6dca90caea7c77cc5aa173f
1 # Part of Objavi2, which makes pdf versions of FLOSSManuals books.
2 # This python module contains or encapsulates configuration and
3 # constant data.
5 # Copyright (C) 2009 Douglas Bagnall
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with this program; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 """This module contains constant values used to produce books.
22 """
23 #XXX eventually, read in a real config file.
24 #XXX Some of these values should be editable via an admin cgi script
26 #cgi scripts chdir here to escape htdocs
27 BASEDIR = ".."
29 #Not really configurable (72 pt per inch / 25.4 mm per inch)
30 POINT_2_MM = 25.4 / 72.0
31 MM_2_POINT = 72.0 / 25.4
32 INCH_2_POINT = 72
34 KEEP_TEMP_FILES = True
35 TMPDIR = 'htdocs/tmp'
37 LOGDIR = 'log'
38 REDIRECT_LOG = True
39 LOG_ROTATE_SIZE = 1000000
41 HTDOCS = 'htdocs'
42 BOOKI_BOOK_DIR = 'htdocs/booki-books'
43 BOOKI_BOOK_URL = '/booki-books'
45 BOOKI_SHARED_DIRECTORY = 'htdocs/shared'
46 BOOKI_SHARED_LONELY_USER_PREFIX = 'lonely-user-'
48 FIREFOX = 'firefox'
49 WKHTMLTOPDF = '/usr/local/bin/wkhtmltopdf-static'
50 WKHTMLTOPDF_EXTRA_COMMANDS = []
52 #use hacked version of wkhtmltopdf that writes outline to a file
53 USE_DUMP_OUTLINE = True
54 CONTENTS_DEPTH = 1
56 HTML2ODT = 'bin/html2odt'
58 #CGITB_DOMAINS = ('203.97.236.46', '202.78.240.7')
59 CGITB_DOMAINS = False
61 #bookland is used to make isbn barcodes
62 BOOKLAND = 'bookland/bookland'
64 # how many pages to number in one pdfedit process (which has
65 # exponential memory leak)
66 PDFEDIT_MAX_PAGES = 40
68 #keep book lists around for this time without refetching
69 BOOK_LIST_CACHE = 3600 * 2
70 CACHE_DIR = 'cache'
72 #for twiki import
73 TOC_URL = "http://%s/pub/%s/_index/TOC.txt"
74 CHAPTER_URL = "http://%s/bin/view/%s/%s?skin=text"
76 PUBLISH_DIR = 'htdocs/books'
78 HTML_PUBLISH_DIR = 'htdocs/published'
79 TEMPLATING_REPLACED_ELEMENT = 'content-goes-here'
80 TEMPLATING_MENU_ELEMENT = 'menu-goes-here'
81 TEMPLATING_BOOK_TITLE_ELEMENT = 'book-title-goes-here'
82 TEMPLATING_CHAPTER_TITLE_ELEMENT = 'chapter-title-goes-here'
83 TEMPLATING_CONTENTS_ID = 'main-content'
84 #TEMPLATING_DEFAULT_TEMPLATE = 'templates/templating_template.html'
85 TEMPLATING_DEFAULT_TEMPLATE = 'templates/templating_template_flossmanuals.html'
87 TEMPLATING_INDEX_FIRST = 'first'
88 TEMPLATING_INDEX_CONTENTS = 'contents'
89 TEMPLATING_INDEX_MODES = { # contents file, first file
90 TEMPLATING_INDEX_FIRST: ('contents.html', 'index.html'),
91 TEMPLATING_INDEX_CONTENTS: ('index.html', None),
94 TAR_TEMPLATED_HTML = True
96 POLL_NOTIFY_PATH = 'htdocs/progress/%s.txt'
97 #POLL_NOTIFY_URL = 'http://%(HTTP_HOST)s/progress/%(bookname)s.txt'
99 ZIP_URLS = {
100 'TWiki': 'http://%(HTTP_HOST)s/booki-twiki-gateway.cgi?server=%(server)s&book=%(book)s&mode=zip',
101 'Booki': 'http://%(server)s/export/%(book)s/export',
102 'Archive': 'http://%(HTTP_HOST)s/espri.cgi?mode=zip&book=%(book)s',
105 DEFAULT_SERVER = 'en.flossmanuals.net'
106 DEFAULT_SIZE = 'COMICBOOK'
107 DEFAULT_ENGINE = 'webkit'
109 BOOKIZIP_MIMETYPE = "application/x-booki+zip"
111 RTL_SCRIPTS = ['persian', 'arabic', 'hebrew', 'urdu']
113 USE_CACHED_IMAGES = False
115 #Normally, Book objects try to shutdown subprocesses and clean up temp
116 #files when they __exit__. This flag makes them try when they __del__
117 #too (i.e. when they are garbage collected).
118 TRY_BOOK_CLEANUP_ON_DEL = False
120 LOCALHOST = 'localhost'
122 LANGUAGE_CSS = {
123 'en': {None: '/static/en.flossmanuals.net.css',
124 'web': '/static/en.flossmanuals.net-web.css',
125 'newspaper': '/static/en.flossmanuals.net-newspaper.css',
126 'openoffice': '/static/en.flossmanuals.net-openoffice.css',
128 'my': {None: '/static/my.flossmanuals.net.css',}
131 SERVER_DEFAULTS = {
132 'booki.flossmanuals.net': {
133 'css-book': '/static/en.flossmanuals.net.css',
134 'css-web': '/static/en.flossmanuals.net-web.css',
135 'css-newspaper': '/static/en.flossmanuals.net-newspaper.css',
136 'css-openoffice': '/static/en.flossmanuals.net-openoffice.css',
137 'lang': 'en',
138 'dir': 'LTR',
139 'toc-encoding': None,
140 'display': False,
141 'interface': 'Booki',
142 'toc_header': 'Table of Contents',
144 'booki.cc': {
145 'css-book': '/static/en.flossmanuals.net.css',
146 'css-web': '/static/en.flossmanuals.net-web.css',
147 'css-newspaper': '/static/en.flossmanuals.net-newspaper.css',
148 'css-openoffice': '/static/en.flossmanuals.net-openoffice.css',
149 'lang': 'en',
150 'dir': 'LTR',
151 'toc-encoding': None,
152 'display': False,
153 'interface': 'Booki',
154 'toc_header': 'Table of Contents',
156 'archive.org': {
157 'css-book': '/static/en.flossmanuals.net.css',
158 'css-web': '/static/en.flossmanuals.net-web.css',
159 'css-newspaper': '/static/en.flossmanuals.net-newspaper.css',
160 'css-openoffice': '/static/en.flossmanuals.net-openoffice.css',
161 'lang': 'en',
162 'dir': 'LTR',
163 'toc-encoding': None,
164 'display': False,
165 'interface': 'Archive',
166 'toc_header': 'Table of Contents',
168 LOCALHOST: {
169 'css-book': '/static/en.flossmanuals.net.css',
170 'css-web': '/static/en.flossmanuals.net-web.css',
171 'css-newspaper': '/static/en.flossmanuals.net-newspaper.css',
172 'css-openoffice': '/static/en.flossmanuals.net-openoffice.css',
173 'lang': 'en',
174 'dir': 'LTR',
175 'toc-encoding': 'iso-8859-1',
176 'display': False,
177 'interface': 'local',
178 'toc_header': 'Table of Contents',
180 'en.flossmanuals.net': {
181 'css-book': '/static/en.flossmanuals.net.css',
182 'css-web': '/static/en.flossmanuals.net-web.css',
183 'css-newspaper': '/static/en.flossmanuals.net-newspaper.css',
184 'css-openoffice': '/static/en.flossmanuals.net-openoffice.css',
185 'lang': 'en',
186 'dir': 'LTR',
187 'toc-encoding': None,
188 'display': True,
189 'interface': 'TWiki',
190 'toc_header': 'Table of Contents',
192 'fi.flossmanuals.net': {
193 'css-book': '/static/en.flossmanuals.net.css',
194 'css-web': '/static/en.flossmanuals.net-web.css',
195 'css-newspaper': '/static/en.flossmanuals.net-newspaper.css',
196 'css-openoffice': '/static/en.flossmanuals.net-openoffice.css',
197 'lang': 'fi',
198 'dir': 'LTR',
199 'toc-encoding': None,
200 'display': True,
201 'interface': 'TWiki',
202 'toc_header': 'Table of Contents',
204 'fr.flossmanuals.net': {
205 'css-book': '/static/fr.flossmanuals.net.css',
206 'css-web': '/static/fr.flossmanuals.net-web.css',
207 'css-newspaper': '/static/fr.flossmanuals.net-newspaper.css',
208 'css': '/static/fr.flossmanuals.net.css',
209 'css-openoffice': '/static/fr.flossmanuals.net-openoffice.css',
210 'lang': 'fr',
211 'dir': 'LTR',
212 'toc-encoding': 'iso-8859-1',
213 'display': True,
214 'interface': 'TWiki',
215 'toc_header': 'Table of Contents',
217 'translate.flossmanuals.net': {
218 'css-book': None, #'/static/translate.flossmanuals.net.css',
219 'css-web': None, #'/static/translate.flossmanuals.net-web.css',
220 'css-newspaper': None, #'/static/translate.flossmanuals.net-newspaper.css',
221 'css': None, #'/static/translate.flossmanuals.net.css',
222 'css-openoffice': None, #'/static/translate.flossmanuals.net-openoffice.css',
223 'lang': None,
224 'dir': 'auto',
225 'toc-encoding': 'iso-8859-1',
226 'display': True,
227 'interface': 'TWiki',
228 'toc_header': 'Table of Contents',
230 'nl.flossmanuals.net': {
231 'css-book': '/static/nl.flossmanuals.net.css',
232 'css-web': '/static/nl.flossmanuals.net-web.css',
233 'css-newspaper': '/static/nl.flossmanuals.net-newspaper.css',
234 'css': '/static/nl.flossmanuals.net.css',
235 'css-openoffice': '/static/nl.flossmanuals.net-openoffice.css',
236 'lang': 'nl',
237 'dir': 'LTR',
238 'toc-encoding': 'iso-8859-1',
239 'display': True,
240 'interface': 'TWiki',
241 'toc_header': 'Table of Contents',
243 'bn.flossmanuals.net': {
244 'css-book': '/static/bn.flossmanuals.net.css',
245 'css-web': '/static/bn.flossmanuals.net-web.css',
246 'css-newspaper': '/static/bn.flossmanuals.net-newspaper.css',
247 'css': '/static/bn.flossmanuals.net.css',
248 'css-openoffice': '/static/bn.flossmanuals.net-openoffice.css',
249 'lang': 'bn',
250 'dir': 'LTR',
251 'toc-encoding': 'iso-8859-1',
252 'display': True,
253 'interface': 'TWiki',
254 'toc_header': 'Table of Contents',
256 'fa.flossmanuals.net': {
257 'css-book': '/static/fa.flossmanuals.net.css',
258 'css-web': '/static/fa.flossmanuals.net-web.css',
259 'css-newspaper': '/static/fa.flossmanuals.net-newspaper.css',
260 'css': '/static/fa.flossmanuals.net.css',
261 'css-openoffice': '/static/fa.flossmanuals.net-openoffice.css',
262 'lang': 'fa',
263 'dir': 'RTL',
264 'toc-encoding': 'iso-8859-1',
265 'display': True,
266 'interface': 'TWiki',
267 'toc_header': 'Table of Contents',
271 if 'booki.cc' in SERVER_DEFAULTS:
272 SERVER_DEFAULTS['www.booki.cc'] = SERVER_DEFAULTS['booki.cc']
275 LANGUAGE_DIR = {
276 "ar": 'RTL', # arabic (many variants)
277 "dv": 'RTL', # dhivehi, maldives islands
278 "fa": 'RTL', # farsi
279 #"ha": 'RTL', # hausa, west africa, particularly niger and nigeria
280 "he": 'RTL', # hebrew
281 "ps": 'RTL', # pashto
282 "ur": 'RTL', # urdu, pakistan
283 "yi": 'RTL', # yiddish, israel
286 # uncomment a debug mode to get messages about that topic.
287 DEBUG_MODES = (
288 #'STARTUP',
289 #'INDEX',
290 #'PDFEDIT',
291 #'PDFGEN',
292 #'HTMLGEN',
294 DEBUG_ALL = False
296 #convert all sizes to points
297 PAPER_SIZES = [(s, x * MM_2_POINT, y * MM_2_POINT) for s, x, y in (
298 ("A5", 148, 210),
299 #("B5", 176, 250),
300 ("A4", 210, 297),
301 #("B4", 250, 353),
302 ("A3", 297, 420),
303 #("B3", 353, 500),
304 ("A2", 420, 594),
305 #("B2", 500, 707),
306 ("A1", 594, 841),
307 #("B1", 707, 1000),
308 ("A0", 841, 1189),
309 ("B0", 1000, 1414),
312 # margins are BASE_MARGIN + PROPORTIONAL_MARGIN * min(width, height)
313 BASE_MARGIN = 22
314 PROPORTIONAL_MARGIN = 0.04
315 # gutter is BASE_GUTTER + PROPORTIONAL_GUTTER * width
316 BASE_GUTTER = 15
317 PROPORTIONAL_GUTTER = 0.011
319 PAGE_EXTREMA = {
320 'page_width': (1, 1000, MM_2_POINT),
321 'page_height': (1, 1414, MM_2_POINT), #can't be bigger than biggest PAPER_SIZE
322 'gutter': (-1000, 1000, MM_2_POINT),
323 'top_margin': (0, 1500, MM_2_POINT),
324 'side_margin': (0, 1500, MM_2_POINT),
325 'bottom_margin': (0, 1500, MM_2_POINT),
326 "columns": (1, 12, 1),
327 "column_margin": (0, 1000, MM_2_POINT),
330 PAGE_NUMBER_SIZE = 11 #XXX this is not used by pdfedit! (ie, it is a guess)
332 PAGE_SIZE_DATA = {
333 'COMICBOOK': {'pointsize': ((6.625 * 72), (10.25 * 72)), 'class': "lulu"},
334 "POCKET": {'pointsize': (4.25 * 72, 6.875 * 72), 'class': "lulu"},
336 "USLETTER": {'pointsize': (8.5 * 72, 11 * 72), 'class': "lulu"},
337 "USTRADE": {'pointsize': (6 * 72, 9 * 72), 'class': "lulu"},
338 "LANDSCAPE9x7": {'pointsize': (9 * 72, 7 * 72), 'class': "lulu"},
339 "SQUARE7.5": {'pointsize': (7.5 * 72, 7.5 * 72), 'class': "lulu"},
340 "ROYAL": {'pointsize': (6.139 * 72, 9.21 * 72), 'class': "lulu"},
341 "CROWNQUARTO": {'pointsize': (7.444 * 72, 9.681 * 72), 'class': "lulu"},
342 "SQUARE8.5": {'pointsize': (8.5 * 72, 8.5 * 72), 'class': "lulu"},
344 "A5": {'pointsize': (148 * MM_2_POINT, 210 * MM_2_POINT), 'class': "lulu iso"},
345 "A4": {'pointsize': (210 * MM_2_POINT, 297 * MM_2_POINT), 'class': "lulu iso"},
346 "A3 (NZ Tabloid)": {'pointsize': (297 * MM_2_POINT, 420 * MM_2_POINT), 'class': 'iso newspaper'},
347 "A2 (NZ Broadsheet)": {'pointsize': (420 * MM_2_POINT, 594 * MM_2_POINT), 'class': 'iso newspaper'},
348 "A1": {'pointsize': (594 * MM_2_POINT, 841 * MM_2_POINT), 'class': 'iso'},
349 "B4": {'pointsize': (250 * MM_2_POINT, 353 * MM_2_POINT), 'class': 'iso'},
350 "B3": {'pointsize': (353 * MM_2_POINT, 500 * MM_2_POINT), 'class': 'iso'},
351 "B2": {'pointsize': (500 * MM_2_POINT, 707 * MM_2_POINT), 'class': 'iso'},
352 "B1": {'pointsize': (707 * MM_2_POINT, 1000 * MM_2_POINT), 'class': 'iso'},
354 "UK Tabloid": {'pointsize': (11 * INCH_2_POINT, 17 * INCH_2_POINT), 'class': 'newspaper'},
355 "UK Broadsheet": {'pointsize': (18 * INCH_2_POINT, 24 * INCH_2_POINT), 'class': 'newspaper'},
356 "US Broadsheet": {'pointsize': (15 * INCH_2_POINT, 22.75 * INCH_2_POINT), 'class': 'newspaper'},
357 "Berliner" : {'pointsize': (315 * MM_2_POINT, 470 * MM_2_POINT), 'class': 'newspaper'},
358 "Foolscap (F4)": {'pointsize': (210 * MM_2_POINT, 330 * MM_2_POINT)},
360 "Oamaru Broadsheet":{'pointsize': (382 * MM_2_POINT, 540 * MM_2_POINT), 'class': 'newspaper'},
361 "Oamaru Tabloid": {'pointsize': (265 * MM_2_POINT, 380 * MM_2_POINT), 'class': 'newspaper'},
363 #ODT printable 380x560
364 #Aucklander 360x260
365 #Dominion 376x540
367 "custom": {'class': "custom"},
370 MIN_COLUMN_WIDTH = (110 * MM_2_POINT)
372 ENGINES = {
373 'webkit' : [],
374 #'gecko' : [],
377 INSIDE_FRONT_COVER_TEMPLATE = 'templates/inside-front-cover.%s.html'
378 END_MATTER_TEMPLATE = 'templates/end_matter.%s.html'
380 FONT_LIST_INCLUDE = 'cache/font-list.inc'
381 FONT_LIST_URL = '/font-list.cgi.pdf'
382 FONT_EXAMPLE_SCRIPT_DIR = 'templates/font-list'
384 # for the license field, with a view to making it a drop down.
385 LICENSES = {
386 'GPL': 'http://www.gnu.org/licenses/gpl.txt',
387 'GPLv2': 'http://www.gnu.org/licenses/gpl-2.0.txt',
388 'GPLv2+': 'http://www.gnu.org/licenses/gpl-2.0.txt',
389 'GPLv3': 'http://www.gnu.org/licenses/gpl-3.0.txt',
390 'GPLv3+': 'http://www.gnu.org/licenses/gpl-3.0.txt',
391 'LGPL': 'http://www.gnu.org/licenses/lgpl.txt',
392 'LGPLv2.1': 'http://www.gnu.org/licenses/lgpl-2.1.txt',
393 'LGPLv3': 'http://www.gnu.org/licenses/lgpl-3.0.txt',
394 'BSD': 'http://www.debian.org/misc/bsd.license',
395 'public domain': None,
396 'MIT': 'http://www.opensource.org/licenses/mit-license.html',
397 'Artistic': 'http://dev.perl.org/licenses/artistic.html',
398 'CC-BY': 'http://creativecommons.org/licenses/by/3.0/',
399 'CC-BY-SA': 'http://creativecommons.org/licenses/by-sa/3.0/',
402 DEFAULT_LICENSE = 'GPLv2+'
404 CGI_MODES = { # arguments are: (publication, extension, mimetype)
405 'book': (True, '.pdf', "application/pdf"),
406 'newspaper': (True, '.pdf', "application/pdf"),
407 'web': (True, '.pdf', "application/pdf"),
408 #XX stop openoffice for now: it doesn't work anyway
409 #'openoffice': (True, '.odt', "application/vnd.oasis.opendocument.text"),
410 'booklist': (False, None, None),
411 'css': (False, None, None),
412 'form': (False, None, None),
413 'epub': (True, '.epub', "application/epub+zip"),
414 'bookizip': (True, '.zip', BOOKIZIP_MIMETYPE),
415 'templated_html': (True, '', 'text/html'),
416 # 'templated_html_zip': (True, '.zip', 'application/zip'),
419 PUBLIC_CGI_MODES = tuple(k for k, v in CGI_MODES.items() if v[0])
421 FORM_TEMPLATE = 'templates/form.html'
422 PROGRESS_ASYNC_TEMPLATE = 'templates/progress-async.html'
423 PROGRESS_TEMPLATE = 'templates/progress.html'
424 ASYNC_TEMPLATE = 'templates/async.txt'
425 ARCHIVE_TEMPLATE = 'templates/archive.txt'
426 NOWHERE_TEMPLATE = 'templates/nowhere.txt'
428 CGI_METHODS = ('sync', 'async', 'poll')
430 #used by objavi-async
431 CGI_DESTINATIONS = {
432 'archive.org': {'sync': (ARCHIVE_TEMPLATE, 'text/plain; charset=utf-8'),
433 'async': (ARCHIVE_TEMPLATE, 'text/plain; charset=utf-8'),
434 'poll': (None, None),
435 'default': 'sync',
437 'download': {'sync': (None, None),
438 'async': (ASYNC_TEMPLATE, 'text/plain; charset=utf-8'),
439 'poll': (None, None),
440 'default': 'sync',
442 'html': {'sync': (PROGRESS_TEMPLATE, 'text/html; charset=utf-8'),
443 'async': (ASYNC_TEMPLATE, 'text/plain; charset=utf-8'),
444 'poll': (PROGRESS_ASYNC_TEMPLATE, 'text/html; charset=utf-8'),
445 'default': 'sync',
447 'nowhere': {'sync': (NOWHERE_TEMPLATE, 'text/plain; charset=utf-8'),
448 'async': (NOWHERE_TEMPLATE, 'text/plain; charset=utf-8'),
449 'poll': (ASYNC_TEMPLATE, 'text/plain; charset=utf-8'),
450 'default': 'sync',
454 DEFAULT_CGI_DESTINATION = 'html'
457 FORM_INPUTS = (
458 # input, name, input type, contents key, CSS classes, extra text
459 ("server", "FLOSS Manuals server", "select", "server_options", "", ""),
460 ("book", "Manual", "select", "book_options", "", ""),
461 ("title", "Book title", "input[type=text]", None, "", ""),
462 ("mode", "Document type", "select", "pdf_types", "openoffice", ""),
464 ("license", "License", "select", "licenses", "advanced", ""),
465 ("isbn", "ISBN", "input[type=text]", None, "advanced", "(13 digits)"),
466 ("toc_header", "Table of Contents header", "input[type=text]", None, "advanced", ""),
468 ("booksize", "Page size", "select", "size_options", "advanced", '(Size compatibility: <span class="lulu">Lulu</span>, <span class="newspaper">newspapers</span>, <span class="iso">ISO standards</span>)'),
469 ("page_width", "Page width", "input[type=text]", None, "advanced booksize numeric-field", ""),
470 ("page_height", "Page height", "input[type=text]", None, "advanced booksize numeric-field", ""),
472 ("top_margin", "Top margin", "input[type=text]", None, "advanced margins numeric-field", ""),
473 ("side_margin", "Side margin", "input[type=text]", None, "advanced margins numeric-field", ""),
474 ("bottom_margin", "Bottom margin", "input[type=text]", None, "advanced margins numeric-field", ""),
475 ("gutter", "Gutter", "input[type=text]", None, "advanced margins numeric-field", ""),
477 ("columns", "Columns", "input[type=text]", None, "advanced columns numeric-field", ""),
478 ("column_margin", "Column margin", "input[type=text]", None, "advanced columns numeric-field", ""),
480 ("grey_scale", "Grey-scale", "input[type=checkbox]", 'yes', "advanced", "(for black and white printing)"),
482 #("css_customise", "Customise CSS", "input[type=checkbox]", None, "advanced", "Enter a URL or "),
483 ("css-url", "CSS URL", "input[type=text][disabled]", "css_url", "advanced css-url openoffice", ""),
484 ("font_list", "Available fonts", "ul", "font_list", "advanced css-custom openoffice", ""),
485 ("font_links", "Font examples", "ul", "font_links", "advanced css-custom openoffice", ""),
486 ("css", "CSS", "textarea", "css", "advanced css-custom openoffice", ""),
488 ("rotate", "Rotate pages for binding", "input[type=checkbox]", 'yes', "advanced", "(for RTL books on LTR printing presses, and vice versa)."),
490 ("html_template", "HTML Template", "textarea", None, "advanced ", ""),
492 #("engine", "Layout engine", "select", "engines", "advanced", ""),
493 #("header", "Header Text", "input[type=text]", None, "advanced", ""),
494 ("max-age", "Use cached data", "input[type=text]", None, "advanced numeric-field", "(younger than this many minutes)."),
495 ("booki-group", "Booki group", "input[type=text]", None, "advanced", "Pretend the book belongs to this Booki group"),
496 ("booki-user", "Booki user", "input[type=text]", None, "advanced", "Pretend the book belongs to this Booki user"),
497 #("destination", "Use cached data", "input[type=text]", None, "advanced", "(younger than this many minutes)."),
500 FORM_ELEMENT_TYPES = {
501 'input[type=text]' : '<input type="text" id="%(id)s" name="%(id)s" value="%(val)s" />',
502 'input[type=text][disabled]' : '<input type="text" disabled="disabled" id="%(id)s" name="%(id)s" value="%(val)s" />',
503 'input[type=checkbox]' : '<input type="checkbox" id="%(id)s" name="%(id)s" value="%(val)s" />',
504 'textarea' : '<textarea id="%(id)s" name="%(id)s">%(val)s</textarea>',
505 'select': '<select id="%(id)s" name="%(id)s">%(val)s</select>',
506 'ul': '<ul id="%(id)s">%(val)s</ul>',
509 FINISHED_MESSAGE = 'FINISHED'
511 PROGRESS_POINTS = (
512 ("start", "wake up", PUBLIC_CGI_MODES),
513 ("fetch_zip", "Load data", PUBLIC_CGI_MODES),
514 ("__init__", "Initialise the book", PUBLIC_CGI_MODES),
515 ("load_book", "Fetch the book", ('book', 'newspaper', 'web', 'openoffice')),
516 ("add_css", "Add css", ('book', 'newspaper', 'web', 'openoffice')),
517 ("add_section_titles", "Add section titles", ('book', 'newspaper', 'web', 'openoffice')),
518 ("make_epub", "Make the epub file", ('epub',)),
519 ("make_oo_doc", "Make the OpenOffice document", ('openoffice',)),
520 ("generate_pdf", "Generate the main pdf", ('book', 'newspaper', 'web')),
521 ("extract_pdf_outline", "Find page numbers", ('book',)),
522 ("reshape_pdf", "Cut pages to size", ('book', 'newspaper',)),
523 #('make_body_pdf', "Generate the main pdf", ('book', 'newspaper', 'web')),
524 ("number_pdf", "Number pages", ('book', 'newspaper',)),
525 ("make_contents", "Calculate Table of Contents", ('book',)),
526 ("make_preamble_pdf", "Generate preamble pdf", ('book',)),
527 ('make_end_matter_pdf', "Generate end matter pdf", ('book',)),
528 ("concatenated_pdfs", "concatenate the pdfs", ('book',)),
529 ("make_templated_html", "Make templated HTML", ('templated_html',)),
530 #("publish_pdf", "Publish the pdf", ('book', 'newspaper', 'web')),
531 (FINISHED_MESSAGE, "Finished!", PUBLIC_CGI_MODES),
534 #XML namespace stuff
535 DCNS = "{http://purl.org/dc/elements/1.1/}"
536 DC = "http://purl.org/dc/elements/1.1/"
537 FM = "http://booki.cc/"
538 XHTMLNS = '{http://www.w3.org/1999/xhtml}'
539 XHTML = 'http://www.w3.org/1999/xhtml'
541 S3_SECRET = '/home/douglas/s3.archive.org-secret'
542 S3_ACCESSKEY = '/home/douglas/s3.archive.org-accesskey'
544 #When it is necessary to creat a navpoint ID, use this string.
545 NAVPOINT_ID_TEMPLATE = 'chapter%s'
547 CLAIM_UNAUTHORED = False
549 IMG_CACHE = 'cache/images/'
551 USE_IMG_CACHE_ALWAYS_HOSTS = ['objavi.halo.gen.nz']
552 USE_ZIP_CACHE_ALWAYS_HOSTS = ['objavi.halo.gen.nz']
554 IGNORABLE_TWIKI_BOOKS = ('Main', 'TWiki', 'PR', 'Trash', 'Sandbox',
555 'Floss', 'Publish', 'Remix', 'Snippets')
557 WHITESPACE_AND_NULL = ''.join(chr(_x) for _x in range(33))
559 #how big to let epub chapters get before splitting?
560 #sony reader has 100k compressed/300k uncompressed limit, but lets leave room to move.
561 EPUB_COMPRESSED_SIZE_MAX = 70000
562 EPUB_FILE_SIZE_MAX = 200000
564 #used to identify marker tags in html
565 MARKER_CLASS_SPLIT = "espri-marker-name-clash-with-no-one--split"
566 MARKER_CLASS_INFO = "espri-marker-name-clash-with-no-one--info"
568 if __name__ == '__main__':
569 print ', '.join(x for x in globals().keys() if not x.startswith('_'))