def serve_routes_concrete(pod, _request, _matched, **_kwargs): """Handle the request for routes.""" router = grow_router.Router(pod) router.use_simple() router.add_all(concrete=True, use_cache=False) routes = router.routes return RoutesDevHandlerHook._create_response(pod, routes, 'Pod Routes')
def get_routes(self): """Handle the request for routing and meta info.""" routes = {} # Read all of the routes in the routes. # TODO: Has to create a concrete routes each time. Not efficient. router = grow_router.Router(self.pod) router.use_simple() router.add_all(concrete=True) for path, node_info, _options in router.routes.nodes: if node_info.kind in ('doc', 'static'): routes[path] = { 'pod_path': node_info.meta['pod_path'], 'locale': node_info.meta.get('locale'), } self.data = { 'routes': routes, }
def serve_routes(pod, _request, _matched, **_kwargs): """Handle the request for routes.""" env = ui.create_jinja_env() template = env.get_template('views/base-reroute.html') router = grow_router.Router(pod) router.use_simple() router.add_all() kwargs = { 'pod': pod, 'partials': [{ 'partial': 'routes', 'routes': router.routes, }], 'title': 'Pod Routes', } content = template.render(kwargs) response = wrappers.Response(content) response.headers['Content-Type'] = 'text/html' return response
def setUp(self): self.dir_path = testing.create_test_pod_dir() self.pod = pods.Pod(self.dir_path, storage=storage.FileStorage) self.router = grow_router.Router(self.pod)
def router(self): """Router object for routing.""" return grow_router.Router(self)