From cc89c32c30e94182fbcac2dff77dc6adb0c54750 Mon Sep 17 00:00:00 2001 From: Adam Wentz Date: Wed, 24 Sep 2014 10:29:59 -0500 Subject: [PATCH 1/2] Image.js: use protocol-relative urls --- betty/cropper/views.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/betty/cropper/views.py b/betty/cropper/views.py index 012d0cb..a7a0073 100644 --- a/betty/cropper/views.py +++ b/betty/cropper/views.py @@ -4,6 +4,7 @@ from django.http import Http404, HttpResponse, HttpResponseServerError, HttpResponseRedirect from django.shortcuts import render from django.views.decorators.cache import cache_control +from six.moves import urllib from .models import Image, Ratio from .utils.placeholder import placeholder @@ -25,12 +26,18 @@ def image_js(request): widths = settings.BETTY_WIDTHS if 0 not in widths: widths.append(0) + + betty_image_url = settings.BETTY_IMAGE_URL + # make the url protocol-relative + url_parts = list(urllib.parse.urlparse(betty_image_url)) + url_parts[0] = "" + betty_image_url = urllib.parse.urlunparse(url_parts) + if betty_image_url.endswith("/"): + betty_image_url = betty_image_url[:-1] context = { - "BETTY_IMAGE_URL": settings.BETTY_IMAGE_URL, + "BETTY_IMAGE_URL": betty_image_url, "BETTY_WIDTHS": sorted(widths) } - if context["BETTY_IMAGE_URL"].endswith("/"): - context["BETTY_IMAGE_URL"] = context["BETTY_IMAGE_URL"][:-1] BETTY_RATIOS = [] ratios_sorted = sorted(settings.BETTY_RATIOS, key=lambda r: Ratio(r).width / float(Ratio(r).height)) for ratio_string in ratios_sorted: From b72bbf878efc4daf5a703ea885380b7032e8c331 Mon Sep 17 00:00:00 2001 From: Adam Wentz Date: Wed, 24 Sep 2014 10:36:01 -0500 Subject: [PATCH 2/2] gitignore stuff generated by `betty-cropper init` --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 346945f..d4f41b2 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,6 @@ bin dist include .Python -.DS_Store \ No newline at end of file +.DS_Store +betty.conf.py +betty.db