From 4d224762d254c7413899ff4c22bfb3f77d8eff90 Mon Sep 17 00:00:00 2001 From: Peter Farrell Date: Fri, 1 Aug 2014 05:12:09 -0500 Subject: [PATCH 1/2] Fixes #7 Added support for protocol relative, http and https URLs. --- easy_pdf/rendering.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/easy_pdf/rendering.py b/easy_pdf/rendering.py index a068dac..96645cb 100644 --- a/easy_pdf/rendering.py +++ b/easy_pdf/rendering.py @@ -31,7 +31,11 @@ def fetch_resources(uri, rel): :rtype: str :raises: :exc:`~easy_pdf.exceptions.UnsupportedMediaPathException` """ - if settings.STATIC_URL and uri.startswith(settings.STATIC_URL): + # For protocol relative, http and https URLs, we need to short circuit to skip + # path checking at the end of function + if uri.startswith('//') or uri.startswith('http://') or uri.startswith('https://'): + return uri + elif settings.STATIC_URL and uri.startswith(settings.STATIC_URL): path = os.path.join(settings.STATIC_ROOT, uri.replace(settings.STATIC_URL, "")) elif settings.MEDIA_URL and uri.startswith(settings.MEDIA_URL): path = os.path.join(settings.MEDIA_ROOT, uri.replace(settings.MEDIA_URL, "")) From 40087fddc687a58c4d0b51ca43226a5114d7f8d4 Mon Sep 17 00:00:00 2001 From: Peter Farrell Date: Fri, 1 Aug 2014 05:15:10 -0500 Subject: [PATCH 2/2] Remove doco about supporting local files only --- easy_pdf/rendering.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/easy_pdf/rendering.py b/easy_pdf/rendering.py index 96645cb..2cb9cf5 100644 --- a/easy_pdf/rendering.py +++ b/easy_pdf/rendering.py @@ -24,8 +24,6 @@ def fetch_resources(uri, rel): """ Retrieves embeddable resource from given ``uri``. - For now only local resources (images, fonts) are supported. - :param str uri: path or url to image or font resource :returns: path to local resource file. :rtype: str