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
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update demo
  • Loading branch information
nigma committed Feb 23, 2017
commit 337f2953993dd98dae22ece0441f7d0095a4e51f
60 changes: 39 additions & 21 deletions demo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/env python
#-*- coding: utf-8 -*-
# coding=utf-8

"""
Demo script. Run:
Expand All @@ -9,13 +9,13 @@

from __future__ import absolute_import, division, print_function, unicode_literals

import os
import logging
import os

logging.basicConfig()
logging.basicConfig(level=logging.DEBUG)

from django.conf import settings
from django.conf.urls import patterns, url
from django.conf.urls import url
from django.core.wsgi import get_wsgi_application
from django.utils.timezone import now as tznow

Expand All @@ -25,41 +25,59 @@
def rel(*path):
return os.path.abspath(
os.path.join(os.path.dirname(__file__), *path)
).replace("\\", "/")
).replace('\\', '/')


if not settings.configured:
settings.configure(
DEBUG=True,
TIMEZONE="UTC",
INSTALLED_APPS=["easy_pdf"],
TEMPLATE_DIRS=[rel("tests", "templates")],
STATIC_ROOT=os.path.abspath(rel("tests", "static")),
TIMEZONE='UTC',
INSTALLED_APPS=['easy_pdf'],
TEMPLATES=[
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [rel('tests', 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
],
STATIC_ROOT=os.path.abspath(rel('tests', 'static')),
STATIC_URL='/static/',
ROOT_URLCONF=basename,
WSGI_APPLICATION="{}.application".format(basename),
WSGI_APPLICATION='{}.application'.format(basename),
)

from easy_pdf.views import PDFTemplateView


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

base_url = 'file://{}/'.format(settings.STATIC_ROOT)

def get_context_data(self, **kwargs):
return super(HelloPDFView, self).get_context_data(
pagesize="A4",
title="Hi there!",
return super(DemoPDFView, self).get_context_data(
pagesize='A4',
title='Hi there!',
today=tznow(),
**kwargs
)

urlpatterns = patterns("",
url(r"^$", HelloPDFView.as_view())
)

application = get_wsgi_application()
urlpatterns = [
url(r'^$', DemoPDFView.as_view())
]

application = get_wsgi_application()

if __name__ == "__main__":
if __name__ == '__main__':
from django.core.management import call_command
call_command("runserver", "8000")

call_command('runserver', '0.0.0.0:8000')