Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, |
2 # Copyright (C) 2006-present eyeo GmbH | 2 # Copyright (C) 2006-present eyeo GmbH |
3 # | 3 # |
4 # Adblock Plus is free software: you can redistribute it and/or modify | 4 # Adblock Plus is free software: you can redistribute it and/or modify |
5 # it under the terms of the GNU General Public License version 3 as | 5 # it under the terms of the GNU General Public License version 3 as |
6 # published by the Free Software Foundation. | 6 # published by the Free Software Foundation. |
7 # | 7 # |
8 # Adblock Plus is distributed in the hope that it will be useful, | 8 # Adblock Plus is distributed in the hope that it will be useful, |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 for line in text.splitlines(True): | 81 for line in text.splitlines(True): |
82 if not re.search(r'^\s*[\w\-]+\s*=', line): | 82 if not re.search(r'^\s*[\w\-]+\s*=', line): |
83 break | 83 break |
84 name, value = line.split('=', 1) | 84 name, value = line.split('=', 1) |
85 value = value.strip() | 85 value = value.strip() |
86 if value.startswith('[') and value.endswith(']'): | 86 if value.startswith('[') and value.endswith(']'): |
87 value = [element.strip() for element in value[1:-1].split(',')] | 87 value = [element.strip() for element in value[1:-1].split(',')] |
88 metadata[name.strip()] = value | 88 metadata[name.strip()] = value |
89 length += len(line) | 89 length += len(line) |
90 | 90 |
91 # Need to preserve line numbers for jinja2 tracebacks | 91 if length > 0: |
92 cutoff = m.end() if m else length | 92 # Need to preserve line numbers for jinja2 tracebacks |
93 return metadata, '\n' * source.count('\n', 0, cutoff) + source[cutoff:] | 93 cutoff = m.end() if m else length |
Sebastian Noack
2018/03/26 02:57:48
I just noticed one more edge case, if there is an
Vasily Kuznetsov
2018/03/26 09:24:28
Good catch, Sebastian! It probably makes sense to
Jon Sonesen
2018/03/28 03:01:36
Perhaps a test case should be added as well to cov
rosie
2018/03/31 21:09:28
I've implemented Sebastian's suggestion and it wor
Sebastian Noack
2018/03/31 22:07:35
So default.tmpl is empty, and empty.tmpl is not. T
Vasily Kuznetsov
2018/04/03 14:29:19
I suppose we can say that it ended up being so for
rosie
2018/04/18 02:35:32
Acknowledged.
| |
94 source = '\n' * source.count('\n', 0, cutoff) + source[cutoff:] | |
95 | |
96 return metadata, source | |
94 | 97 |
95 | 98 |
96 def get_page_params(source, locale, page, format=None, site_url_override=None, | 99 def get_page_params(source, locale, page, format=None, site_url_override=None, |
97 localized_string_callback=None): | 100 localized_string_callback=None): |
98 from cms.converters import converters | 101 from cms.converters import converters |
99 | 102 |
100 # Guess page format if omitted, but default to Markdown for friendlier excep tions | 103 # Guess page format if omitted, but default to Markdown for friendlier excep tions |
101 if format is None: | 104 if format is None: |
102 for format in converters.iterkeys(): | 105 for format in converters.iterkeys(): |
103 if source.has_page(page, format): | 106 if source.has_page(page, format): |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 return params | 167 return params |
165 | 168 |
166 | 169 |
167 def process_page(source, locale, page, format=None, site_url_override=None, | 170 def process_page(source, locale, page, format=None, site_url_override=None, |
168 localized_string_callback=None): | 171 localized_string_callback=None): |
169 from cms.converters import TemplateConverter | 172 from cms.converters import TemplateConverter |
170 | 173 |
171 params = get_page_params(source, locale, page, format, site_url_override, | 174 params = get_page_params(source, locale, page, format, site_url_override, |
172 localized_string_callback) | 175 localized_string_callback) |
173 return TemplateConverter(*params['templatedata'], params=params)() | 176 return TemplateConverter(*params['templatedata'], params=params)() |
LEFT | RIGHT |