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

Delta Between Two Patch Sets: cms/converters.py

Issue 29933596: Issue 5333 - Allow cms to generate relative pages (Closed) Base URL: https://hg.adblockplus.org/cms/
Left Patch Set: Address comments on PS5 Created Nov. 8, 2018, 8:04 p.m.
Right Patch Set: Add documentation, remove extraneous global Created Nov. 9, 2018, 8:16 p.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 | « cms/bin/generate_static_pages.py ('k') | 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 # 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 ) 299 )
300 300
301 def process_links(self, text): 301 def process_links(self, text):
302 def make_relative(base_url, target): 302 def make_relative(base_url, target):
303 if not target.startswith('/'): 303 if not target.startswith('/'):
304 # Links to an external resource 304 # Links to an external resource
305 return target 305 return target
306 return relpath(target, base_url.rsplit('/', 1)[0]) 306 return relpath(target, base_url.rsplit('/', 1)[0])
307 307
308 def process_link(match): 308 def process_link(match):
309 # if 'rel_path' in match.groups():
Vasily Kuznetsov 2018/11/09 10:53:27 You also forgot this one. Sorry, I haven't marked
rhowell 2018/11/09 17:18:36 Oops! I've added `grep -R ipdb` to my checklist be
310 # import ipdb; ipdb.set_trace()
311 pre, attr, url, post = match.groups() 309 pre, attr, url, post = match.groups()
312 url = jinja2.Markup(url).unescape() 310 url = jinja2.Markup(url).unescape()
313 311
314 locale, new_url = ( 312 locale, new_url = (
315 self._params['source'] 313 self._params['source']
316 .resolve_link(url, self._params['locale'])) 314 .resolve_link(url, self._params['locale']))
317 315
318 if new_url is not None: 316 if new_url is not None:
319 url = new_url 317 url = new_url
320 if attr == 'href': 318 if attr == 'href':
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 'linkify': self.linkify, 437 'linkify': self.linkify,
440 'toclist': self.toclist, 438 'toclist': self.toclist,
441 } 439 }
442 440
443 globals = { 441 globals = {
444 'get_string': self.get_string, 442 'get_string': self.get_string,
445 'has_string': self.has_string, 443 'has_string': self.has_string,
446 'get_page_content': self.get_page_content, 444 'get_page_content': self.get_page_content,
447 'get_pages_metadata': self.get_pages_metadata, 445 'get_pages_metadata': self.get_pages_metadata,
448 'get_canonical_url': self.get_canonical_url, 446 'get_canonical_url': self.get_canonical_url,
449 'relative': self._params['relative'],
450 } 447 }
451 448
452 for dirname, dictionary in [('filters', filters), 449 for dirname, dictionary in [('filters', filters),
453 ('globals', globals)]: 450 ('globals', globals)]:
454 for filename in self._params['source'].list_files(dirname): 451 for filename in self._params['source'].list_files(dirname):
455 root, ext = os.path.splitext(filename) 452 root, ext = os.path.splitext(filename)
456 if ext.lower() != '.py': 453 if ext.lower() != '.py':
457 continue 454 continue
458 455
459 path = os.path.join(dirname, filename) 456 path = os.path.join(dirname, filename)
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 stack[-1]['subitems'].append(item) 589 stack[-1]['subitems'].append(item)
593 stack.append(item) 590 stack.append(item)
594 return structured 591 return structured
595 592
596 593
597 converters = { 594 converters = {
598 'html': RawConverter, 595 'html': RawConverter,
599 'md': MarkdownConverter, 596 'md': MarkdownConverter,
600 'tmpl': TemplateConverter, 597 'tmpl': TemplateConverter,
601 } 598 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld