Mercurial > public > sg101
comparison core/management/commands/ssl_images.py @ 870:ee56c8c8cf98
More WIP on ssl_images management command and tests.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Mon, 15 Dec 2014 21:16:47 -0600 |
parents | 64a5acb83937 |
children | 6900040df0f8 |
comparison
equal
deleted
inserted
replaced
869:63209e53f3aa | 870:ee56c8c8cf98 |
---|---|
22 | 22 |
23 | 23 |
24 LOGFILE = os.path.join(settings.PROJECT_PATH, 'logs', 'ssl_images.log') | 24 LOGFILE = os.path.join(settings.PROJECT_PATH, 'logs', 'ssl_images.log') |
25 logger = logging.getLogger(__name__) | 25 logger = logging.getLogger(__name__) |
26 | 26 |
27 IMAGE_LINK_RE = re.compile(markdown.inlinepatterns.IMAGE_LINK_RE) | 27 IMAGE_LINK_RE = re.compile(markdown.inlinepatterns.IMAGE_LINK_RE, re.UNICODE) |
28 IMAGE_REF_RE = re.compile(markdown.inlinepatterns.IMAGE_REFERENCE_RE) | 28 IMAGE_REF_RE = re.compile(markdown.inlinepatterns.IMAGE_REFERENCE_RE, re.UNICODE) |
29 | 29 |
30 SG101_HOSTS = set(['www.surfguitar101.com', 'surfguitar101.com']) | 30 SG101_HOSTS = set(['www.surfguitar101.com', 'surfguitar101.com']) |
31 MODEL_CHOICES = ['comments', 'posts'] | 31 MODEL_CHOICES = ['comments', 'posts'] |
32 | 32 |
33 quit_flag = False | 33 quit_flag = False |
52 # TODO | 52 # TODO |
53 return src | 53 return src |
54 | 54 |
55 | 55 |
56 def replace_image_markup(match): | 56 def replace_image_markup(match): |
57 src_parts = match.group(9).split() | 57 src_parts = match.group(8).split() |
58 if src_parts: | 58 if src_parts: |
59 src = src_parts[0] | 59 src = src_parts[0] |
60 if src[0] == "<" and src[-1] == ">": | 60 if src[0] == "<" and src[-1] == ">": |
61 src = src[1:-1] | 61 src = src[1:-1] |
62 else: | 62 else: |
63 src = '' | 63 src = '' |
64 | 64 |
65 title = '' | 65 title = '' |
66 if len(src_parts) > 1: | 66 if len(src_parts) > 1: |
67 title = " ".join(src_parts[1:]) | 67 title = " ".join(src_parts[1:]) |
68 alt = match.group(2) | 68 alt = match.group(1) |
69 | 69 |
70 new_src = '' | 70 new_src = '' |
71 if src: | 71 if src: |
72 r = urlparse.urlparse(src) | 72 r = urlparse.urlparse(src) |
73 if r.scheme == 'http': | 73 if r.scheme == 'http': |