Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: cms/converters.py

Issue 5148261828526080: Issue 2119 - Add get_page_content template function. (Closed)
Left Patch Set: Created April 5, 2015, 12:03 p.m.
Right Patch Set: Use .iterkeys() instead of .keys() Created April 8, 2015, 9:31 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | cms/utils.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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
kzar 2015/04/05 12:10:12 (I import this here as we have a circular dependen
Sebastian Noack 2015/04/05 12:50:17 This is usually an indicator, that something is wr
kzar 2015/04/05 13:25:08 I thought about that, and maybe I'm wrong, but I t
Sebastian Noack 2015/04/05 13:30:33 Cyclic dependencies aren't great. However, the log
348 348
349 page, format = page.rsplit(".") 349 if locale is None:
Sebastian Noack 2015/04/05 12:50:17 I suppose you forgot the second argument to .rspli
kzar 2015/04/05 13:25:08 Done.
350 params = get_page_params(self._params["source"], locale, page, format) 350 locale = self._params["locale"]
kzar 2015/04/05 12:10:12 (I'm unsure if I should pass self._params["site_ur
Sebastian Noack 2015/04/05 12:50:17 Shouldn't you fallback to self._params["locale"] i
kzar 2015/04/05 13:25:08 Done.
351 return params["head"], params["body"] 351 return get_page_params(self._params["source"], locale, page)
Sebastian Noack 2015/04/05 12:50:17 I would rather return a dict here, to make the cal
kzar 2015/04/05 13:25:08 Done.
352 352
353 def linkify(self, page, locale=None, **attrs): 353 def linkify(self, page, locale=None, **attrs):
354 if locale is None: 354 if locale is None:
355 locale = self._params["locale"] 355 locale = self._params["locale"]
356 356
357 locale, url = self._params["source"].resolve_link(page, locale) 357 locale, url = self._params["source"].resolve_link(page, locale)
358 return jinja2.Markup('<a%s>' % ''.join( 358 return jinja2.Markup('<a%s>' % ''.join(
359 ' %s="%s"' % (name, jinja2.escape(value)) for name, value in [ 359 ' %s="%s"' % (name, jinja2.escape(value)) for name, value in [
360 ('href', url), 360 ('href', url),
361 ('hreflang', locale) 361 ('hreflang', locale)
(...skipping 17 matching lines...) Expand all
379 stack.pop() 379 stack.pop()
380 stack[-1]["subitems"].append(item) 380 stack[-1]["subitems"].append(item)
381 stack.append(item) 381 stack.append(item)
382 return structured 382 return structured
383 383
384 converters = { 384 converters = {
385 "html": RawConverter, 385 "html": RawConverter,
386 "md": MarkdownConverter, 386 "md": MarkdownConverter,
387 "tmpl": TemplateConverter, 387 "tmpl": TemplateConverter,
388 } 388 }
LEFTRIGHT
« no previous file | cms/utils.py » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld