| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 from HTMLParser import HTMLParser | 5 from HTMLParser import HTMLParser |
| 6 import logging | 6 import logging |
| 7 import os | 7 import os |
| 8 import re | 8 import re |
| 9 | 9 |
| 10 from extensions_paths import INTROS_TEMPLATES, ARTICLES_TEMPLATES | 10 from extensions_paths import INTROS_TEMPLATES, ARTICLES_TEMPLATES |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 self._cache = server_instance.compiled_fs_factory.Create( | 88 self._cache = server_instance.compiled_fs_factory.Create( |
| 89 server_instance.host_file_system_provider.GetTrunk(), | 89 server_instance.host_file_system_provider.GetTrunk(), |
| 90 self._MakeIntro, | 90 self._MakeIntro, |
| 91 IntroDataSource) | 91 IntroDataSource) |
| 92 self._ref_resolver = server_instance.ref_resolver_factory.Create() | 92 self._ref_resolver = server_instance.ref_resolver_factory.Create() |
| 93 | 93 |
| 94 def _MakeIntro(self, intro_path, intro): | 94 def _MakeIntro(self, intro_path, intro): |
| 95 # Guess the name of the API from the path to the intro. | 95 # Guess the name of the API from the path to the intro. |
| 96 api_name = os.path.splitext(intro_path.split('/')[-1])[0] | 96 api_name = os.path.splitext(intro_path.split('/')[-1])[0] |
| 97 intro_with_links = self._ref_resolver.ResolveAllLinks( | 97 intro_with_links = self._ref_resolver.ResolveAllLinks( |
| 98 intro, namespace=api_name) | 98 intro, self._request, namespace=api_name) |
| 99 | 99 |
| 100 # TODO(kalman): In order to pick up every header tag, and therefore make a | 100 # TODO(kalman): In order to pick up every header tag, and therefore make a |
| 101 # complete TOC, the render context of the Handlebar needs to be passed | 101 # complete TOC, the render context of the Handlebar needs to be passed |
| 102 # through to here. Even if there were a mechanism to do this it would | 102 # through to here. Even if there were a mechanism to do this it would |
| 103 # break caching; we'd need to do the TOC parsing *after* rendering the full | 103 # break caching; we'd need to do the TOC parsing *after* rendering the full |
| 104 # template, and that would probably be expensive. | 104 # template, and that would probably be expensive. |
| 105 intro_parser = _IntroParser() | 105 intro_parser = _IntroParser() |
| 106 intro_parser.feed( | 106 intro_parser.feed( |
| 107 self._template_renderer.Render(Handlebar(intro_with_links), | 107 self._template_renderer.Render(Handlebar(intro_with_links), |
| 108 self._request, | 108 self._request, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 131 except FileNotFoundError: | 131 except FileNotFoundError: |
| 132 continue | 132 continue |
| 133 # Not found. Do the first operation again so that we get a stack trace - we | 133 # Not found. Do the first operation again so that we get a stack trace - we |
| 134 # know that it'll fail. | 134 # know that it'll fail. |
| 135 get_from_base_path(base_paths[0]) | 135 get_from_base_path(base_paths[0]) |
| 136 raise AssertionError() | 136 raise AssertionError() |
| 137 | 137 |
| 138 def Cron(self): | 138 def Cron(self): |
| 139 # TODO(kalman): Walk through the intros and articles directory. | 139 # TODO(kalman): Walk through the intros and articles directory. |
| 140 return Future(value=()) | 140 return Future(value=()) |
| OLD | NEW |