Left: | ||
Right: |
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 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
586 for item in flat: | 586 for item in flat: |
587 while stack[-1]['level'] >= item['level']: | 587 while stack[-1]['level'] >= item['level']: |
588 stack.pop() | 588 stack.pop() |
589 stack[-1]['subitems'].append(item) | 589 stack[-1]['subitems'].append(item) |
590 stack.append(item) | 590 stack.append(item) |
591 return structured | 591 return structured |
592 | 592 |
593 def page_has_locale(self, page, locale): | 593 def page_has_locale(self, page, locale): |
594 return self._params['source'].has_locale(locale, page) | 594 return self._params['source'].has_locale(locale, page) |
595 | 595 |
596 def get_page_url(self, page, locale=None, redirect=False): | 596 def get_page_url(self, page, locale=None, redirect=False): |
Vasily Kuznetsov
2019/01/14 13:29:27
The redirect argument is great, but it's not descr
rhowell
2019/01/14 14:56:47
Done.
| |
597 if not locale: | 597 if not locale: |
598 locale = self._params['locale'] | 598 locale = self._params['locale'] |
599 if self.page_has_locale(page, locale): | 599 if self.page_has_locale(page, locale) or redirect: |
Vasily Kuznetsov
2019/01/14 13:29:27
Since the body of this if is the same as that of t
rhowell
2019/01/14 14:56:47
Yeah, I agree. Done.
| |
600 return self._params['source'].resolve_link(page, locale)[1] | |
601 if redirect: | |
602 return self._params['source'].resolve_link(page, locale)[1] | 600 return self._params['source'].resolve_link(page, locale)[1] |
603 raise Exception('{} does not exist in {}'.format(page, locale)) | 601 raise Exception('{} does not exist in {}'.format(page, locale)) |
604 | 602 |
605 | 603 |
606 converters = { | 604 converters = { |
607 'html': RawConverter, | 605 'html': RawConverter, |
608 'md': MarkdownConverter, | 606 'md': MarkdownConverter, |
609 'tmpl': TemplateConverter, | 607 'tmpl': TemplateConverter, |
610 } | 608 } |
LEFT | RIGHT |