| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
`bytes` takes no additional args in python2 unlike it's taking
an encoding in python3.
Unidecode returns a unicode string in python3 and a bytestring
in python2 which, I believe, was the main cause of error #71.
Now, regardless of whether unidecode is included, all strings
passing through http_quote will be encoded to ascii which should
fix both issues.
Also included is a fix for a failing test when unidecode is used.
Unidecode's `_unidecode` function ignores characters greater
than 0xefff, which '\xe2\x99\xa5' (the heart symbol) is. This
caused users with unidecode to fail '.pdf' was produced rather
than the expected '?.pdf'.
|
|\
| |
| | |
Extract logic from views
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The logic was coupled with the views which made things difficult
to reuse if you wanted to use the pdf generation somehwere else
than in a view.
With this patch, the logic has been moved to `utils.py` and should
be more easy to reuse.
Tests have been adapted and made compatible with django > 1.7
|
|\ \
| | |
| | | |
fix: Problem with filename
|
| | |
| | |
| | | |
fix https://github.com/incuna/django-wkhtmltopdf/issues/71
|
| | | |
|
| |/
|/| |
|
|\ \
| | |
| | | |
Skip absolute path substitution where STATIC or MEDIA URL are empty or None
|
| | |
| | |
| | |
| | |
| | | |
Root cause of this issue is in python3 / mod_wsgi. See: https://github.com/GrahamDumpleton/mod_wsgi/issues/85
This patch detects if there is something screwy with fileno() and simply skips setting stderr if there is to avoid the AttributeError that occurs otherwise. Pull https://github.com/incuna/django-wkhtmltopdf/pull/40 fixed this same issue when it arose for python 2.7, but the nature of the issue seems to have shifted, making it trickier to detect that the fileno() method cannot be called.
|
| |/
| |
| |
| | |
STATIC_URL or MEDIA_URL settings default to '' and None
These default values cause the url match and replace algorithm to insert the *_ROOT setting in EVERY quoted string!!
|
|/
|
|
| |
accounts for quotes and escapes.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|\
| |
| | |
Removed extra slashes so the local file paths work in Windows.
|
| | |
|
|/ |
|
| |
|
|
|
|
|
|
| |
Since we PDFTemplateResponse renders templates, and Django uses UTF-8
to do the rendering, we can safely assume that the result is in
UTF-8.
|
| |
|
| |
|
| |
|
|
|
|
| |
Implicit position arguments for str.format() are a 2.7ism.
|
|
|
|
|
|
| |
This is most usefully set to {'DISPLAY': ':1'} in production. This
allows wkhtmltopdf access to a specific X headless server, since the
server will not be running under X.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
MEDIA_URL and STATIC_URL used to be set only in get_context_data(),
but there are apps such as staticfiles and Django Compressor where
this won't work well.
Instead, they need to be overridden at the settings level, not at the
context level. This allows template context processors to populate a
RequestContext with the right values.
In addition, MEDIA_URL and STATIC_URL are now overridden as file://
URLs, based on MEDIA_ROOT and STATIC_ROOT. This allows developers to
access these views in runserver, against their current codebase. It
also means faster access for wkhtmltopdf, since the files are stored
locally.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before, command-line arguments were class-based. Unfortunately, this
means that you cannot add new command-line arguments without
subclassing.
Instead, PDFTemplateView.cmd_options is a dictionary of all
command-line arguments. PDFTemplateView.as_view(cmd_options={...}) now
works as expected.
!!!! WARNING !!!!
cmd_options is now empty, leaving wkhtmltopdf with its default
behaviour. Explicitly add the options you want. Existing subclasses of
PDFTemplateView will now break, but a PendingDeprecationWarning will be
issued. Margins will now be wkhtmltopdf's default of 10mm.
PdfTemplateView contains a compatibility shim with the old default
values for margins and orientation.
|
|
|
|
|
|
|
|
|
| |
PDFTemplateResponse is like TemplateResponse in that it does dynamic
rendering of a template on the fly.
PDFTemplateView has a much smaller implementation, relying on
PDFTemplateResponse to do the rendering for it. It also knows about
the standard TemplateResponse when it needs to render the HTML version.
|
|
|
|
|
|
|
| |
* Now matches HttpResponse in function signature.
* Modern Django content_type/mimetype handling.
* Sanitizes and quotes filenames in Content-Disposition header.
* Tests.
|
| |
|
|
|
|
| |
This allows overriding this configuration option at run-time.
|
|
|
|
|
|
| |
The API for wkhtmltopdf has changed. Long arguments that take no
parameters now use True and not the empty string. In addition,
argument-parameters may now be Unicode.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
It's not obvious what template_to_temp_file is doing with its undefined arguments.
The Zen of Python states:
Explicit is better than implicit.
Readability counts.
An alternative solution would be to rename the function to loader_render_to_tempfile or similar,
but this fix is more backwards-compatible.
|
|
|
|
|
|
| |
Use a PdfResponse to deal with the headers and response type.
Make the margin_* and filename variables instance variables on the view
with sane defaults.
|
|
|
|
|
| |
Fix a spelling mistake
Wrap a particularly long line
|
|
|
|
|
| |
Replace old style file open and close with a `with` block for clarity
and it's error handling.
|
| |
|
| |
|
| |
|
|
|