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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 locale, page = path.split('/', 1) | 60 locale, page = path.split('/', 1) |
61 else: | 61 else: |
62 locale, page = path, '' | 62 locale, page = path, '' |
63 | 63 |
64 default_page = source.read_config().get('general', 'defaultpage') | 64 default_page = source.read_config().get('general', 'defaultpage') |
65 alternative_page = '/'.join([page, default_page]).lstrip('/') | 65 alternative_page = '/'.join([page, default_page]).lstrip('/') |
66 | 66 |
67 for format in converters.iterkeys(): | 67 for format in converters.iterkeys(): |
68 for p in (page, alternative_page): | 68 for p in (page, alternative_page): |
69 if source.has_page(p, format): | 69 if source.has_page(p, format): |
70 return (p, process_page(source, locale, p, format, 'http://%s:%d
' % (address, port))) | 70 site_url = 'http://{}:{}'.format(address, port) |
| 71 return (p, process_page(source, locale, p, format, site_url)) |
71 if source.has_localizable_file(locale, page): | 72 if source.has_localizable_file(locale, page): |
72 return (page, source.read_localizable_file(locale, page)) | 73 return (page, source.read_localizable_file(locale, page)) |
73 | 74 |
74 return (None, None) | 75 return (None, None) |
75 | 76 |
76 | 77 |
77 def has_conflicting_pages(page): | 78 def has_conflicting_pages(page): |
78 pages = [p for p, _ in source.list_pages()] | 79 pages = [p for p, _ in source.list_pages()] |
79 pages.extend(source.list_localizable_files()) | 80 pages.extend(source.list_localizable_files()) |
80 | 81 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 return app(environ, start_response) | 164 return app(environ, start_response) |
164 except Exception as e: | 165 except Exception as e: |
165 return show_error(start_response, '500 Internal Server Error
', | 166 return show_error(start_response, '500 Internal Server Error
', |
166 uri=environ.get('PATH_INFO'), error=e) | 167 uri=environ.get('PATH_INFO'), error=e) |
167 | 168 |
168 server = make_server(host, port, wrapper, ThreadedWSGIServer) | 169 server = make_server(host, port, wrapper, ThreadedWSGIServer) |
169 print ' * Running on http://%s:%i/' % server.server_address | 170 print ' * Running on http://%s:%i/' % server.server_address |
170 server.serve_forever() | 171 server.serve_forever() |
171 | 172 |
172 run(address, port, handler, use_reloader=True, use_debugger=True) | 173 run(address, port, handler, use_reloader=True, use_debugger=True) |
OLD | NEW |