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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 if self.has_localizable_file(default_locale, page): | 49 if self.has_localizable_file(default_locale, page): |
50 if not self.has_localizable_file(locale, page): | 50 if not self.has_localizable_file(locale, page): |
51 locale = default_locale | 51 locale = default_locale |
52 elif self.has_page(page): | 52 elif self.has_page(page): |
53 if not self.has_locale(locale, page): | 53 if not self.has_locale(locale, page): |
54 locale = default_locale | 54 locale = default_locale |
55 elif self.has_page(alternative_page): | 55 elif self.has_page(alternative_page): |
56 if not self.has_locale(locale, alternative_page): | 56 if not self.has_locale(locale, alternative_page): |
57 locale = default_locale | 57 locale = default_locale |
| 58 elif self.has_static(page): |
| 59 locale = None |
58 else: | 60 else: |
59 logging.warning('Link to %s cannot be resolved', page) | 61 logging.warning('Link to %s cannot be resolved', page) |
60 | 62 |
61 parts = page.split('/') | 63 parts = page.split('/') |
62 if parts[-1] == default_page: | 64 if parts[-1] == default_page: |
63 page = '/'.join(parts[:-1]) | 65 page = '/'.join(parts[:-1]) |
64 | 66 if locale: |
65 path = '/%s/%s' % (locale, page) | 67 path = '/{}/{}'.format(locale, page) |
66 return locale, urlparse.urlunparse(parsed[0:2] + (path,) + parsed[3:]) | 68 return locale, urlparse.urlunparse(parsed[0:2] + (path,) + parsed[3:
]) |
| 69 return locale, '/' + page |
67 | 70 |
68 def read_config(self): | 71 def read_config(self): |
69 configdata = self.read_file('settings.ini')[0] | 72 configdata = self.read_file('settings.ini')[0] |
70 config = ConfigParser.SafeConfigParser() | 73 config = ConfigParser.SafeConfigParser() |
71 config.readfp(StringIO(configdata)) | 74 config.readfp(StringIO(configdata)) |
72 return config | 75 return config |
73 | 76 |
74 def exec_file(self, filename): | 77 def exec_file(self, filename): |
75 source, filename = self.read_file(filename) | 78 source, filename = self.read_file(filename) |
76 code = compile(source, filename, 'exec') | 79 code = compile(source, filename, 'exec') |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 'resolve_link', | 448 'resolve_link', |
446 'read_config', | 449 'read_config', |
447 'read_template', | 450 'read_template', |
448 'read_locale', | 451 'read_locale', |
449 'read_include', | 452 'read_include', |
450 'exec_file', | 453 'exec_file', |
451 ]: | 454 ]: |
452 setattr(source, fname, _memoize(getattr(source, fname))) | 455 setattr(source, fname, _memoize(getattr(source, fname))) |
453 | 456 |
454 return source | 457 return source |
OLD | NEW |