X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/60c3eb6ecbe5c000aa4d24344e85d2ed00d8983c..ddf91891d57294b4fbf52ac5fb55b4f0e71e8781:/src/catalogue/views.py diff --git a/src/catalogue/views.py b/src/catalogue/views.py index 6782e5369..267d9b40a 100644 --- a/src/catalogue/views.py +++ b/src/catalogue/views.py @@ -365,7 +365,14 @@ def _no_diacritics_regexp(query): def unicode_re_escape(query): """ Unicode-friendly version of re.escape """ - return re.sub(r'(?u)(\W)', r'\\\1', query) + s = list(query) + for i, c in enumerate(query): + if re.match(r'(?u)(\W)', c) and re.match(r'[\x00-\x7e]', c): + if c == "\000": + s[i] = "\\000" + else: + s[i] = "\\" + c + return query[:0].join(s) def _word_starts_with(name, prefix): @@ -621,6 +628,7 @@ class CustomPDFFormView(AjaxableFormView): form_class = forms.CustomPDFForm title = ugettext_lazy('Download custom PDF') submit = ugettext_lazy('Download') + template = 'catalogue/custom_pdf_form.html' honeypot = True def __call__(self, *args, **kwargs): @@ -777,3 +785,17 @@ def collections(request): 'objects': objects, 'best': best, }) + + +def ridero_cover(request, slug): + from librarian.cover import make_cover + wldoc = Book.objects.get(slug=slug).wldocument() + cover = make_cover(wldoc.book_info, width=980, bleed=20, format='PNG') + response = HttpResponse(content_type="image/png") + cover.save(response) + return response + + +def get_isbn(request, book_format, slug): + book = Book.objects.get(slug=slug) + return HttpResponse(book.extra_info.get('isbn_%s' % book_format))