mirror of
https://github.com/kennethreitz-archive/django-mediasync.git
synced 2026-06-05 23:40:18 +00:00
Beginning work on SSL awareness.
This commit is contained in:
committed by
Jeremy Carbaugh
parent
d865311c32
commit
c762976327
@@ -25,6 +25,7 @@ class BaseClient(object):
|
||||
self.media_root = self._settings.get('MEDIA_ROOT', getattr(settings, 'MEDIA_ROOT', ''))
|
||||
|
||||
def media_url(self):
|
||||
# TODO: PATCH THIS FOR SSL
|
||||
if self.serve_remote:
|
||||
url = self.remote_media_url()
|
||||
else:
|
||||
|
||||
@@ -37,6 +37,7 @@ class Client(BaseClient):
|
||||
self._entries[entry.key] = entry.etag.strip('"')
|
||||
|
||||
def remote_media_url(self):
|
||||
# TODO: PATCH THIS FOR SSL
|
||||
url = (self.aws_bucket_cname and "http://%s" or "http://%s.s3.amazonaws.com") % self.aws_bucket
|
||||
if self.aws_prefix:
|
||||
url = "%s/%s" % (url, self.aws_prefix)
|
||||
|
||||
@@ -33,6 +33,33 @@ def mkpath(url, path, filename=None):
|
||||
# media stuff
|
||||
#
|
||||
|
||||
def do_media_url2(parser, token):
|
||||
print "RAW", token.split_contents()
|
||||
tokens = token.split_contents()
|
||||
|
||||
if len(tokens) > 1:
|
||||
# Tag only takes one argument. Discard the rest. Also, first and
|
||||
# last characters are quotes when a string is passed, lop those off.
|
||||
url_str = tokens[1][1:-1]
|
||||
else:
|
||||
url_str = None
|
||||
|
||||
return MediaUrlNode(url_str)
|
||||
register.tag('media_url2', do_media_url2)
|
||||
|
||||
class MediaUrlNode(template.Node):
|
||||
def __init__(self, url_str):
|
||||
self.url_str = url_str
|
||||
def render(self, context):
|
||||
is_secure = context['request'].is_secure()
|
||||
print "CONTEXT", is_secure
|
||||
|
||||
if not self.url_str:
|
||||
print "RVAL", MEDIA_URL
|
||||
return MEDIA_URL
|
||||
print "RVAL", mkpath(MEDIA_URL, self.url_str, is_secure=is_secure)
|
||||
return mkpath(MEDIA_URL, self.url_str, is_secure=is_secure)
|
||||
|
||||
@register.simple_tag
|
||||
def media_url(path=None):
|
||||
if not path:
|
||||
|
||||
Reference in New Issue
Block a user