| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Simple Markdown browser for a Git checkout.""" | 6 """Simple Markdown browser for a Git checkout.""" |
| 7 from __future__ import print_function | 7 from __future__ import print_function |
| 8 | 8 |
| 9 import SimpleHTTPServer | 9 import SimpleHTTPServer |
| 10 import SocketServer | 10 import SocketServer |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 123 |
| 124 # strip off the repo and branch info, if present, for compatibility | 124 # strip off the repo and branch info, if present, for compatibility |
| 125 # with gitiles. | 125 # with gitiles. |
| 126 if path.startswith('/chromium/src/+/master'): | 126 if path.startswith('/chromium/src/+/master'): |
| 127 path = path[len('/chromium/src/+/master'):] | 127 path = path[len('/chromium/src/+/master'):] |
| 128 | 128 |
| 129 full_path = os.path.realpath(os.path.join(self.server.top_level, path[1:])) | 129 full_path = os.path.realpath(os.path.join(self.server.top_level, path[1:])) |
| 130 | 130 |
| 131 if not full_path.startswith(self.server.top_level): | 131 if not full_path.startswith(self.server.top_level): |
| 132 self._DoUnknown() | 132 self._DoUnknown() |
| 133 elif path == '/doc.css': | 133 elif path in ('/base.css', '/doc.css', '/prettify.css'): |
| 134 self._DoCSS('doc.css') | 134 self._DoCSS(path[1:]) |
| 135 elif not os.path.exists(full_path): | 135 elif not os.path.exists(full_path): |
| 136 self._DoNotFound() | 136 self._DoNotFound() |
| 137 elif path.lower().endswith('.md'): | 137 elif path.lower().endswith('.md'): |
| 138 self._DoMD(path) | 138 self._DoMD(path) |
| 139 elif os.path.exists(full_path + '/README.md'): | 139 elif os.path.exists(full_path + '/README.md'): |
| 140 self._DoMD(path + '/README.md') | 140 self._DoMD(path + '/README.md') |
| 141 else: | 141 else: |
| 142 self._DoUnknown() | 142 self._DoUnknown() |
| 143 | 143 |
| 144 def _DoMD(self, path): | 144 def _DoMD(self, path): |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 contents.text = 'Contents' | 263 contents.text = 'Contents' |
| 264 contents.tail = '\n' | 264 contents.tail = '\n' |
| 265 toc_aux = ElementTree.SubElement(toc_node, 'div', {'class': 'toc-aux'}) | 265 toc_aux = ElementTree.SubElement(toc_node, 'div', {'class': 'toc-aux'}) |
| 266 toc_aux.text = '\n' | 266 toc_aux.text = '\n' |
| 267 toc_aux.append(ul_with_the_desired_toc_entries) | 267 toc_aux.append(ul_with_the_desired_toc_entries) |
| 268 toc_aux.tail = '\n' | 268 toc_aux.tail = '\n' |
| 269 | 269 |
| 270 | 270 |
| 271 if __name__ == '__main__': | 271 if __name__ == '__main__': |
| 272 sys.exit(main(sys.argv[1:])) | 272 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |