Skip to content

Commit

Permalink
Tag v0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSapin committed Sep 14, 2012
1 parent 2188077 commit b51a33f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
6 changes: 3 additions & 3 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Version 0.2
~~~~~~~~~~~

Not released yet.
Released on 2012-07-23.

Add URL dispatcher and make Flask-WeasyPrint do the right thing with
apps that use subdomains.
Add URL dispatchers and make Flask-WeasyPrint do the right thing with
apps that use subdomains (when the ``SERVER_NAME`` config is set).


Version 0.1
Expand Down
8 changes: 4 additions & 4 deletions flask_weasyprint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from werkzeug.wrappers import Response


VERSION = '0.1'
VERSION = '0.2'
__all__ = ['VERSION', 'make_flask_url_dispatcher', 'make_url_fetcher',
'HTML', 'CSS', 'render_pdf']

Expand Down Expand Up @@ -91,7 +91,7 @@ def make_url_fetcher(dispatcher=None,
You generally don’t need to call this directly.
If ``dispatcher`` is not provided, :func:`make_flask_url_dispatcher`
is called to get on. This requires a request context.
is called to get one. This requires a request context.
Otherwise, it must be a callable that take an URL and return either
``None`` or a ``(wsgi_callable, base_url, path)`` tuple. For None
Expand Down Expand Up @@ -184,8 +184,8 @@ def render_pdf(html, stylesheets=None, download_filename=None):
:meth:`~weasyprint.HTML.write_pdf`
:param download_filename:
If provided, the ``Content-Disposition`` header is set so that most
web browser will show the "Save as…" dialog with the value a default
filename.
web browser will show the "Save as…" dialog with the value as the
default filename.
:returns: a :class:`flask.Response` object.
"""
Expand Down
7 changes: 4 additions & 3 deletions flask_weasyprint/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ def index():

@app.route('/foo/')
def document_html():
return render_template('document.html',
data=[42, 27.3, 63], labels=['Lorem', 'ipsum', 'sit'])
return render_template(
'document.html', data=[42, 27.3, 63], labels=['Lorem', 'ipsum', 'sit'])


@app.route('/foo/graph')
def graph():
svg = render_template('graph.svg',
svg = render_template(
'graph.svg',
# Turn ?data=3,2,1&labels=A,B,C into
# [(0, ('A', 3, color0)), (1, ('B', 2, color1)), (2, ('C', 1, color2))]
series=enumerate(zip(
Expand Down
5 changes: 4 additions & 1 deletion flask_weasyprint/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import io
import struct
import unittest
import urlparse

import cairo
from flask import Flask, redirect, request, json, jsonify
Expand Down Expand Up @@ -85,6 +84,7 @@ def test_png(self):
assert image.get_height() == 794
stride = image.get_stride()
data = image.get_data()

def get_pixel(x, y):
# cairo stores 32bit unsigned integers in *native* endianness
uint32, = struct.unpack_from('=L', data, y * stride + x * 4)
Expand All @@ -93,15 +93,18 @@ def get_pixel(x, y):
rgb = uint32 & 0xffffff
assert alpha == 0xff
return '#%06X' % (rgb)

colors = [get_pixel(x, 320) for x in [180, 280, 380]]
assert colors == app.config['GRAPH_COLORS']
assert data[:4] == b'\x00\x00\x00\x00' # Pixel (0, 0) is transparent

def test_redirects(self):
app = Flask(__name__)

def add_redirect(old_url, new_url):
app.add_url_rule(
old_url, 'redirect_' + old_url, lambda: redirect(new_url))

add_redirect('/a', '/b')
add_redirect('/b', '/c')
add_redirect('/c', '/d')
Expand Down

0 comments on commit b51a33f

Please sign in to comment.