| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 if length > 0: | 91 if length > 0: |
| 92 # Need to preserve line numbers for jinja2 tracebacks | 92 # Need to preserve line numbers for jinja2 tracebacks |
| 93 cutoff = m.end() if m else length | 93 cutoff = m.end() if m else length |
| 94 source = '\n' * source.count('\n', 0, cutoff) + source[cutoff:] | 94 source = '\n' * source.count('\n', 0, cutoff) + source[cutoff:] |
| 95 |
| 95 return metadata, source | 96 return metadata, source |
| 96 | 97 |
| 97 | 98 |
| 98 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, |
| 99 localized_string_callback=None): | 100 localized_string_callback=None): |
| 100 from cms.converters import converters | 101 from cms.converters import converters |
| 101 | 102 |
| 102 # 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 |
| 103 if format is None: | 104 if format is None: |
| 104 for format in converters.iterkeys(): | 105 for format in converters.iterkeys(): |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 return params | 167 return params |
| 167 | 168 |
| 168 | 169 |
| 169 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, |
| 170 localized_string_callback=None): | 171 localized_string_callback=None): |
| 171 from cms.converters import TemplateConverter | 172 from cms.converters import TemplateConverter |
| 172 | 173 |
| 173 params = get_page_params(source, locale, page, format, site_url_override, | 174 params = get_page_params(source, locale, page, format, site_url_override, |
| 174 localized_string_callback) | 175 localized_string_callback) |
| 175 return TemplateConverter(*params['templatedata'], params=params)() | 176 return TemplateConverter(*params['templatedata'], params=params)() |
| LEFT | RIGHT |