Left: | ||
Right: |
OLD | NEW |
---|---|
1 # coding: utf-8 | 1 # coding: utf-8 |
2 | 2 |
3 # This file is part of the Adblock Plus web scripts, | 3 # This file is part of the Adblock Plus web scripts, |
4 # Copyright (C) 2006-2015 Eyeo GmbH | 4 # Copyright (C) 2006-2015 Eyeo GmbH |
5 # | 5 # |
6 # Adblock Plus is free software: you can redistribute it and/or modify | 6 # Adblock Plus is free software: you can redistribute it and/or modify |
7 # it under the terms of the GNU General Public License version 3 as | 7 # it under the terms of the GNU General Public License version 3 as |
8 # published by the Free Software Foundation. | 8 # published by the Free Software Foundation. |
9 # | 9 # |
10 # Adblock Plus is distributed in the hope that it will be useful, | 10 # Adblock Plus is distributed in the hope that it will be useful, |
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 # GNU General Public License for more details. | 13 # GNU General Public License for more details. |
14 # | 14 # |
15 # You should have received a copy of the GNU General Public License | 15 # You should have received a copy of the GNU General Public License |
16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 |
18 from cms.converters import converters, TemplateConverter | 18 from cms.converters import converters, TemplateConverter |
19 | 19 |
20 def get_page_params(source, locale, page, format=None, site_url_override=None): | 20 def get_page_params(source, locale, page, format=None, site_url_override=None, |
21 record_default_strings=None): | |
Wladimir Palant
2015/07/08 23:11:09
Nit: This should be record_default_string as the c
kzar
2015/07/11 19:21:18
Done.
| |
21 # Guess page format if omitted, but default to Markdown for friendlier excepti ons | 22 # Guess page format if omitted, but default to Markdown for friendlier excepti ons |
22 if format is None: | 23 if format is None: |
23 for format in converters.iterkeys(): | 24 for format in converters.iterkeys(): |
24 if source.has_page(page, format): | 25 if source.has_page(page, format): |
25 break | 26 break |
26 else: | 27 else: |
27 format = "md" | 28 format = "md" |
28 | 29 |
29 params = { | 30 params = { |
30 "source": source, | 31 "source": source, |
31 "template": "default", | 32 "template": "default", |
32 "locale": locale, | 33 "locale": locale, |
33 "page": page, | 34 "page": page, |
34 "pagedata": source.read_page(page, format), | 35 "pagedata": source.read_page(page, format), |
35 "config": source.read_config(), | 36 "config": source.read_config(), |
37 "record_default_strings": record_default_strings, | |
36 } | 38 } |
37 | 39 |
38 localefile = page | 40 localefile = page |
39 if params["config"].has_option("locale_overrides", page): | 41 if params["config"].has_option("locale_overrides", page): |
40 localefile = params["config"].get("locale_overrides", page) | 42 localefile = params["config"].get("locale_overrides", page) |
41 params["localedata"] = source.read_locale(params["locale"], localefile) | 43 params["localedata"] = source.read_locale(params["locale"], localefile) |
42 | 44 |
43 if params["config"].has_option("general", "siteurl"): | 45 if params["config"].has_option("general", "siteurl"): |
44 if site_url_override: | 46 if site_url_override: |
45 params["site_url"] = site_url_override | 47 params["site_url"] = site_url_override |
(...skipping 24 matching lines...) Expand all Loading... | |
70 | 72 |
71 params["head"], params["body"] = converter() | 73 params["head"], params["body"] = converter() |
72 if converter.total_translations > 0: | 74 if converter.total_translations > 0: |
73 params["translation_ratio"] = (1 - | 75 params["translation_ratio"] = (1 - |
74 float(converter.missing_translations) / converter.total_translations) | 76 float(converter.missing_translations) / converter.total_translations) |
75 else: | 77 else: |
76 params["translation_ratio"] = 1 | 78 params["translation_ratio"] = 1 |
77 | 79 |
78 return params | 80 return params |
79 | 81 |
80 def process_page(source, locale, page, format=None, site_url_override=None): | 82 def process_page(source, locale, page, format=None, site_url_override=None, |
83 record_default_strings=None): | |
81 return TemplateConverter( | 84 return TemplateConverter( |
82 get_page_params(source, locale, page, format, site_url_override), | 85 get_page_params(source, locale, page, format, |
86 site_url_override, record_default_strings), | |
83 key="templatedata" | 87 key="templatedata" |
84 )() | 88 )() |
OLD | NEW |