Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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, |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
337 # generating the master translation. | 337 # generating the master translation. |
338 localedata = self._params["localedata"] | 338 localedata = self._params["localedata"] |
339 return jinja2.Markup(self.localize_string(name, default, localedata, html_es capes)) | 339 return jinja2.Markup(self.localize_string(name, default, localedata, html_es capes)) |
340 | 340 |
341 def get_string(self, name, page): | 341 def get_string(self, name, page): |
342 localedata = self._params["source"].read_locale(self._params["locale"], page ) | 342 localedata = self._params["source"].read_locale(self._params["locale"], page ) |
343 default = localedata[name] | 343 default = localedata[name] |
344 return jinja2.Markup(self.localize_string(name, default, localedata, html_es capes)) | 344 return jinja2.Markup(self.localize_string(name, default, localedata, html_es capes)) |
345 | 345 |
346 def get_page_content(self, page, locale=None): | 346 def get_page_content(self, page, locale=None): |
347 from utils import get_page_params | 347 from cms.utils import get_page_params |
Wladimir Palant
2015/04/06 19:14:30
That's an implicit relative import. From https://w
kzar
2015/04/07 14:43:56
Done.
| |
348 | 348 |
349 page, ext = os.path.splitext(page) | |
Wladimir Palant
2015/04/06 19:14:30
We never specify the format as part of the page. Y
kzar
2015/04/07 14:43:56
Done.
| |
350 if locale is None: | 349 if locale is None: |
351 locale = self._params["locale"] | 350 locale = self._params["locale"] |
352 params = get_page_params(self._params["source"], locale, page, ext[1:]) | 351 return get_page_params(self._params["source"], locale, page) |
353 return {k: params[k] for k in ("head", "body")} | |
354 | 352 |
355 def linkify(self, page, locale=None, **attrs): | 353 def linkify(self, page, locale=None, **attrs): |
356 if locale is None: | 354 if locale is None: |
357 locale = self._params["locale"] | 355 locale = self._params["locale"] |
358 | 356 |
359 locale, url = self._params["source"].resolve_link(page, locale) | 357 locale, url = self._params["source"].resolve_link(page, locale) |
360 return jinja2.Markup('<a%s>' % ''.join( | 358 return jinja2.Markup('<a%s>' % ''.join( |
361 ' %s="%s"' % (name, jinja2.escape(value)) for name, value in [ | 359 ' %s="%s"' % (name, jinja2.escape(value)) for name, value in [ |
362 ('href', url), | 360 ('href', url), |
363 ('hreflang', locale) | 361 ('hreflang', locale) |
(...skipping 17 matching lines...) Expand all Loading... | |
381 stack.pop() | 379 stack.pop() |
382 stack[-1]["subitems"].append(item) | 380 stack[-1]["subitems"].append(item) |
383 stack.append(item) | 381 stack.append(item) |
384 return structured | 382 return structured |
385 | 383 |
386 converters = { | 384 converters = { |
387 "html": RawConverter, | 385 "html": RawConverter, |
388 "md": MarkdownConverter, | 386 "md": MarkdownConverter, |
389 "tmpl": TemplateConverter, | 387 "tmpl": TemplateConverter, |
390 } | 388 } |
LEFT | RIGHT |