Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch rendering backend to WeasyPrint #34

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3a779a5
Update dev version number
nigma Feb 22, 2017
37f9a3b
Change requirements to use WeasyPrint instead of xhtml2pdf
nigma Feb 22, 2017
ceaadea
Add docker build for demo app
nigma Feb 22, 2017
cbde0cb
Update base template
nigma Feb 22, 2017
92f5b1e
Update demo html template
nigma Feb 22, 2017
6b7740e
Split test script into project and app modules
nigma Feb 22, 2017
8ba0eb2
Add django app config
nigma Feb 22, 2017
657e935
Update base template
nigma Feb 23, 2017
3d0bb3c
Switch rendering backend to WeasyPrint and general improvements
nigma Feb 23, 2017
eba318e
Update readme and docs
nigma Feb 23, 2017
337f295
Update demo
nigma Feb 23, 2017
fcd6641
Add docker demo build
nigma Feb 23, 2017
879e93c
Update docs
nigma Feb 23, 2017
3a4b469
Use dict instead of Context/RequestContext as template context
nigma Feb 23, 2017
3bf5a36
Update docs links
nigma Mar 8, 2017
7ba728c
Update requirements
nigma Apr 5, 2017
f082b95
Remove unused exceptions module
nigma Apr 5, 2017
b673620
Add flake8 and mypy checks
nigma Apr 5, 2017
d432d85
Deploy Heroku demo app with Docker
nigma Apr 5, 2017
68ae28d
Annotate types
nigma Apr 5, 2017
602034a
Update docs
nigma Apr 14, 2017
67f81b7
Change demo server to gunicorn
nigma Apr 14, 2017
d1e7d15
Port changes from master branch (9850802)
nigma Apr 19, 2017
38d2cb6
Update docs layout and requirements
nigma Apr 19, 2017
6b51547
Set image name in docker-compose
nigma Apr 19, 2017
495f77a
Update docs template
nigma Apr 20, 2017
a10b55d
Prepare 0.2.0-dev1 release
nigma Apr 20, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Created by .ignore support plugin (hsz.mobi)
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
*.manifest
*.spec
pip-log.txt
pip-delete-this-directory.txt
htmlcov/
.tox/
*.mo
*.pot
*.log
docs/_build/
.env
.idea
/docs
.dockerignore
.gitattributes
.gitignore
docker-compose.yml
Dockerfile
18 changes: 9 additions & 9 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ little bit helps, and credit will always be given.
You can contribute in many ways:

Types of Contributions
----------------------
======================

Report Bugs
~~~~~~~~~~~
-----------

Report bugs at https://github.com/nigma/django-easy-pdf/issues.

Expand All @@ -22,26 +22,26 @@ If you are reporting a bug, please include:
* Detailed steps to reproduce the bug.

Fix Bugs
~~~~~~~~
--------

Look through the GitHub issues for bugs. Anything tagged with "bug"
is open to whoever wants to implement it.

Implement Features
~~~~~~~~~~~~~~~~~~
------------------

Look through the GitHub issues for features. Anything tagged with "feature"
is open to whoever wants to implement it.

Write Documentation
~~~~~~~~~~~~~~~~~~~
-------------------

django-easy-pdf could always use more documentation, whether as part of the
official django-easy-pdf docs, in docstrings, or even on the web in blog posts,
articles, and such.

Submit Feedback
~~~~~~~~~~~~~~~
---------------

The best way to send feedback is to file an issue at https://github.com/nigma/django-easy-pdf/issues.

Expand All @@ -53,7 +53,7 @@ If you are proposing a feature:
are welcome :)

Get Started!
------------
============

Ready to contribute? Here's how to set up `django-easy-pdf` for local development.

Expand Down Expand Up @@ -89,14 +89,14 @@ To get flake8, just pip install them into your virtualenv.
7. Submit a pull request through the GitHub website.

Pull Request Guidelines
-----------------------
=======================

Before you submit a pull request, check that it meets these guidelines:

1. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in README.rst.
2. The pull request should work for Python 2.7, and 3.3 (if there are compatible
2. The pull request should work for Python 2.7, and 3.4+ (if there are compatible
3rd party packages available). Check
https://travis-ci.org/nigma/django-easy-pdf/pull_requests
and make sure that the tests pass for all supported Python versions.
53 changes: 53 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
FROM python:3.6

LABEL github="https://github.com/nigma/django-easy-pdf"

ENV PYTHONUNBUFFERED 1
ENV LANG=en_US.UTF-8
ENV PIP_NO_CACHE_DIR off
ENV PIP_DISABLE_PIP_VERSION_CHECK on

RUN mkdir -p /app /app/docs
WORKDIR /app

RUN set -eux \
&& DEPS=' \
bash \
gettext \
libcairo2 \
libffi-dev \
libpango1.0-0 \
libpangoft2-1.0-0 \
libgdk-pixbuf2.0-0 \
libxml2-dev \
libxslt1-dev \
shared-mime-info \
fontconfig \
libfontconfig1 \
' \
&& apt-get update \
&& apt-get install -y --no-install-recommends $DEPS \
&& rm -rf /var/lib/apt/lists/*

COPY requirements.txt /app/
COPY requirements-dev.txt /app/
COPY docs/requirements.txt /app/docs/

RUN set -eux \
&& pip3 install --no-cache-dir -U pip setuptools wheel

RUN set -eux \
&& pip3 install --no-cache-dir --timeout 1000 -r requirements.txt -r requirements-dev.txt \
&& pip3 install --no-cache-dir --timeout 1000 -r docs/requirements.txt

#RUN mkdir -p ~/.fonts ~/.local/share/fonts
#COPY tests/static/fonts/* ~/.fonts/

EXPOSE 8000

COPY . /app/

RUN adduser --system django
USER django

CMD gunicorn --bind=0.0.0.0:$PORT --preload -w 3 demo:application
10 changes: 10 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
History
-------

0.2.0 (xxx)
++++++++++++++++++

* Switched rendering backend to WeasyPrint

0.1.1 (2017-04-19)
++++++++++++++++++

* Update for Django 1.11 and Python 3

0.1.0 (2014-01-24)
++++++++++++++++++

Expand Down
76 changes: 76 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
.PHONY: all help clean clean-build clean-pyc demo lint mypy test test-all docs release sdist dist upload docker-build docker-demo docker-shell

all: docker-demo

help:
@echo "clean-build - remove build artifacts"
@echo "clean-pyc - remove Python file artifacts"
@echo "lint - check style with flake8"
@echo "mypy - check types with mypy"
@echo "test - run tests quickly with the default Python"
@echo "testall - run tests on every Python version with tox"
@echo "docs - generate Sphinx HTML documentation, including API docs"
@echo "sdist - package"
@echo "dist - package sdist and wheel"
@echo "upload - upload to PyPI"
@echo "release - package and upload a release"
@echo "docker-demo - build and run demo using Docker image"

clean: clean-build clean-pyc

clean-build:
rm -fr build/
rm -fr dist/
rm -fr *.egg-info

clean-pyc:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +

lint:
flake8 easy_pdf tests

mypy:
mypy --ignore-missing-imports --strict-optional easy_pdf tests --verbose

test:
python runtests.py

test-all:
tox

docs:
$(MAKE) -C docs clean
$(MAKE) -C docs html
sphinx-build -b linkcheck ./docs _build/
sphinx-build -b html ./docs _build/

release: lint test docs clean dist upload

sdist: clean
python setup.py sdist
ls -l dist

dist: clean
python setup.py sdist bdist_wheel

upload:
twine upload -s dist/*

demo:
python demo.py

# Docker workflow

docker-build:
docker build -t django-easy-pdf .

docker-demo: docker-build
docker run --rm -it -p 8000:8000 -v `pwd`/easy_pdf:/app/easy_pdf -v `pwd`/docs:/app/docs -v `pwd`/dist:/app/dist -v `pwd`/tests:/app/tests django-easy-pdf make demo

docker-shell: docker-build
docker run --rm -it -v `pwd`/easy_pdf:/app/easy_pdf -v `pwd`/docs:/app/docs -v `pwd`/dist:/app/dist -v `pwd`/tests:/app/tests django-easy-pdf bash

docker-%: docker-build
docker run --rm -it -v `pwd`/easy_pdf:/app/easy_pdf -v `pwd`/docs:/app/docs -v `pwd`/dist:/app/dist -v `pwd`/tests:/app/tests django-easy-pdf make $*
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

41 changes: 24 additions & 17 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
django-easy-pdf
===============
Django PDF rendering
====================

Django PDF rendering, the easy way.

.. image:: https://pypip.in/v/django-easy-pdf/badge.png
.. image:: https://img.shields.io/pypi/v/django-easy-pdf.svg
:target: https://pypi.python.org/pypi/django-easy-pdf/
:alt: Latest Version

.. image:: https://pypip.in/d/django-easy-pdf/badge.png
.. image:: https://img.shields.io/badge/wheel-yes-green.svg
:target: https://pypi.python.org/pypi/django-easy-pdf/
:alt: Downloads

.. image:: https://pypip.in/license/django-easy-pdf/badge.png
:alt: Wheel
.. image:: https://img.shields.io/pypi/l/django-easy-pdf.svg
:target: https://pypi.python.org/pypi/django-easy-pdf/
:alt: License

Expand All @@ -35,8 +33,8 @@ to render PDFs in the backend outside the request scope
Quickstart
----------

1. Include ``django-easy-pdf``, ``xhtml2pdf>=0.0.6`` and ``reportlab>=2.7,<3``
in your ``requirements.txt`` file.
1. Include ``django-easy-pdf>=0.2.0`` and ``WeasyPrint>=0.34`` in your ``requirements.txt`` file
and install necessary system packages.

2. Add ``easy_pdf`` to ``INSTALLED_APPS``.

Expand All @@ -57,26 +55,34 @@ Quickstart
from easy_pdf.views import PDFTemplateView

class HelloPDFView(PDFTemplateView):
template_name = "hello.html"
template_name = 'hello.html'

4. You can also use a mixin to output PDF from Django generic views:

.. code-block:: python

class PDFUserDetailView(PDFTemplateResponseMixin, DetailView):
model = get_user_model()
template_name = 'user_detail.html'

Documentation
-------------

The full documentation is at `django-easy-pdf.rtfd.org <http://django-easy-pdf.rtfd.org>`_.
The full documentation is at `django-easy-pdf.readthedocs.io <https://django-easy-pdf.readthedocs.io/en/develop/>`_.

A live demo is at `easy-pdf.herokuapp.com <https://easy-pdf.herokuapp.com/>`_.
You can run it locally after installing dependencies by running ``python demo.py``
script from the cloned repository.
script from the cloned repository or through Docker with ``make demo``.


Dependencies
------------

``django-easy-pdf`` depends on:

- ``django>=1.5.1``
- ``xhtml2pdf>=0.0.6``
- ``reportlab>=2.7,<3``
- ``django>=1.10``
- ``WeasyPrint>=0.34``
- ``WeasyPrint`` dependencies (https://weasyprint.readthedocs.io/en/latest/install.html)


License
Expand All @@ -89,7 +95,8 @@ Other Resources
---------------

- GitHub repository - https://github.com/nigma/django-easy-pdf
- PyPi Package site - http://pypi.python.org/pypi/django-easy-pdf
- PyPi Package site - https://pypi.python.org/pypi/django-easy-pdf
- Docs - https://django-easy-pdf.readthedocs.io/en/develop/


Commercial Support
Expand Down
Loading