| 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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 for page_name, _format in self._params['source'].list_pages(): | 467 for page_name, _format in self._params['source'].list_pages(): |
| 468 data, filename = self._params['source'].read_page(page_name, | 468 data, filename = self._params['source'].read_page(page_name, |
| 469 _format) | 469 _format) |
| 470 page_data = utils.extract_page_metadata(data)[0] | 470 page_data = utils.extract_page_metadata(data)[0] |
| 471 page_data.setdefault('page', page_name) | 471 page_data.setdefault('page', page_name) |
| 472 if self.filter_metadata(filters, page_data) is True: | 472 if self.filter_metadata(filters, page_data) is True: |
| 473 return_data.append(page_data) | 473 return_data.append(page_data) |
| 474 return return_data | 474 return return_data |
| 475 | 475 |
| 476 def filter_metadata(self, filters, metadata): | 476 def filter_metadata(self, filters, metadata): |
| 477 # if only the page key is in the metadata then there | |
| 478 # was no user defined metadata | |
| 479 if metadata.keys() == ['page']: | |
| 480 return False | |
| 481 if filters is None: | 477 if filters is None: |
| 482 return True | 478 return True |
| 483 for filter_name, filter_value in filters.items(): | 479 for filter_name, filter_value in filters.items(): |
| 484 if filter_name not in metadata: | 480 if filter_name not in metadata: |
| 485 return False | 481 return False |
| 486 if isinstance(metadata[filter_name], list): | 482 if isinstance(metadata[filter_name], list): |
| 487 if isinstance(filter_value, basestring): | 483 if isinstance(filter_value, basestring): |
| 488 filter_value = [filter_value] | 484 filter_value = [filter_value] |
| 489 for option in filter_value: | 485 for option in filter_value: |
| 490 if str(option) not in metadata[filter_name]: | 486 if str(option) not in metadata[filter_name]: |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 stack[-1]['subitems'].append(item) | 524 stack[-1]['subitems'].append(item) |
| 529 stack.append(item) | 525 stack.append(item) |
| 530 return structured | 526 return structured |
| 531 | 527 |
| 532 | 528 |
| 533 converters = { | 529 converters = { |
| 534 'html': RawConverter, | 530 'html': RawConverter, |
| 535 'md': MarkdownConverter, | 531 'md': MarkdownConverter, |
| 536 'tmpl': TemplateConverter, | 532 'tmpl': TemplateConverter, |
| 537 } | 533 } |
| OLD | NEW |