OLD | NEW |
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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 for filter_name, filter_value in filters.items(): | 544 for filter_name, filter_value in filters.items(): |
545 if filter_name not in metadata: | 545 if filter_name not in metadata: |
546 return False | 546 return False |
547 if isinstance(metadata[filter_name], list): | 547 if isinstance(metadata[filter_name], list): |
548 if isinstance(filter_value, basestring): | 548 if isinstance(filter_value, basestring): |
549 filter_value = [filter_value] | 549 filter_value = [filter_value] |
550 for option in filter_value: | 550 for option in filter_value: |
551 if str(option) not in metadata[filter_name]: | 551 if str(option) not in metadata[filter_name]: |
552 return False | 552 return False |
553 elif filter_value != metadata[filter_name]: | 553 elif filter_value != metadata[filter_name]: |
554 return False | 554 return False |
555 return True | 555 return True |
556 | 556 |
557 def get_canonical_url(self, page): | 557 def get_canonical_url(self, page): |
558 """Return canonical URL for the page (without locale code)""" | 558 """Return canonical URL for the page (without locale code)""" |
559 try: | 559 try: |
560 base_url = self._params['site_url'] | 560 base_url = self._params['site_url'] |
561 except KeyError: | 561 except KeyError: |
562 raise Exception('You must configure `siteurl` to use' | 562 raise Exception('You must configure `siteurl` to use' |
563 '`get_canonical_url()`') | 563 '`get_canonical_url()`') |
564 | 564 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 if self.page_has_locale(page, locale) or redirect: | 599 if self.page_has_locale(page, locale) or redirect: |
600 return self._params['source'].resolve_link(page, locale)[1] | 600 return self._params['source'].resolve_link(page, locale)[1] |
601 raise Exception('{} does not exist in {}'.format(page, locale)) | 601 raise Exception('{} does not exist in {}'.format(page, locale)) |
602 | 602 |
603 | 603 |
604 converters = { | 604 converters = { |
605 'html': RawConverter, | 605 'html': RawConverter, |
606 'md': MarkdownConverter, | 606 'md': MarkdownConverter, |
607 'tmpl': TemplateConverter, | 607 'tmpl': TemplateConverter, |
608 } | 608 } |
OLD | NEW |