def book_preview_absolute_url(book, size='x148'):
    """
    Returns a correctly formatted absolute_url in order to print a book preview.
    """
    if not book:
        url = get_model_for_paperpage().get_page_under_construction_preview_url(size=size)
    else:
        url = book.get_preview_absolute_url(size=size)
    return conditional_escape(url)
def publication_preview_absolute_url(publication, size='x148'):
    """
    Returns a correctly formatted absolute_url in order to print a publication preview.
    """
    if not publication:
        # publication.get_preview_absolute_url knows how to handle a publication
        # with no PaperPage attached, but here we don't even have a Publication,
        # so take a shortcut and use PaperPage.get_page_under_construction_preview_url
        url = get_model_for_paperpage().get_page_under_construction_preview_url(size=size)
    else:
        url = publication.get_preview_absolute_url(size=size)
    return conditional_escape(url)
Beispiel #3
0
def reader_page_resized(request, *args, **kwargs):
    # FIXME handle different formats, size, cropping.
    paperpage_model = get_model_for_paperpage()
    page = get_object_or_404(paperpage_model, pk=int(kwargs['id']))
    rval, detail = PaperPageThumbnail(page).generate_thumbnail(request.GET.get('size', 'x500'))
        
    if rval == PaperPageThumbnail.P_ERROR_BAD: # Something is wrong with the arguments
        return HttpResponseBadRequest(str(detail))
    elif rval == PaperPageThumbnail.P_ERROR_OS: # Something is wrong with the command used to generate the thumbnail. Bad file maybe ?
        return HttpResponseServerError(str(detail))
    else:
        filename = detail
        
    # Return the file
    return HttpResponseXFile(filename)