Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: chrome/common/extensions/docs/server2/sidenav_data_source.py

Issue 68873003: Docserver: Serve docs out of src/ not src/chrome/common/extensions. This allows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix samples Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 import copy 5 import copy
6 import logging 6 import logging
7 7
8 from compiled_file_system import SingleFile 8 from compiled_file_system import SingleFile
9 from data_source import DataSource 9 from data_source import DataSource
10 from extensions_paths import JSON_TEMPLATES
10 from future import Gettable, Future 11 from future import Gettable, Future
11 from third_party.json_schema_compiler.json_parse import Parse 12 from third_party.json_schema_compiler.json_parse import Parse
12 from svn_constants import JSON_PATH
13 13
14 14
15 def _AddLevels(items, level): 15 def _AddLevels(items, level):
16 '''Add a 'level' key to each item in |items|. 'level' corresponds to how deep 16 '''Add a 'level' key to each item in |items|. 'level' corresponds to how deep
17 in |items| an item is. |level| sets the starting depth. 17 in |items| an item is. |level| sets the starting depth.
18 ''' 18 '''
19 for item in items: 19 for item in items:
20 item['level'] = level 20 item['level'] = level
21 if 'items' in item: 21 if 'items' in item:
22 _AddLevels(item['items'], level + 1) 22 _AddLevels(item['items'], level + 1)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 href = item.get('href') 71 href = item.get('href')
72 if href is not None and not href.startswith(('http://', 'https://')): 72 if href is not None and not href.startswith(('http://', 'https://')):
73 if not href.startswith('/'): 73 if not href.startswith('/'):
74 logging.warn('Paths in sidenav must be qualified. %s is not.' % href) 74 logging.warn('Paths in sidenav must be qualified. %s is not.' % href)
75 else: 75 else:
76 href = href.lstrip('/') 76 href = href.lstrip('/')
77 item['href'] = self._server_instance.base_path + href 77 item['href'] = self._server_instance.base_path + href
78 78
79 def Cron(self): 79 def Cron(self):
80 futures = [ 80 futures = [self._cache.GetFromFile('%s/%s_sidenav.json' %
81 self._cache.GetFromFile('%s/%s_sidenav.json' % (JSON_PATH, platform)) 81 (JSON_TEMPLATES, platform))
82 for platform in ('apps', 'extensions')] 82 for platform in ('apps', 'extensions')]
83 return Future(delegate=Gettable(lambda: [f.Get() for f in futures])) 83 return Future(delegate=Gettable(lambda: [f.Get() for f in futures]))
84 84
85 def get(self, key): 85 def get(self, key):
86 sidenav = copy.deepcopy(self._cache.GetFromFile( 86 sidenav = copy.deepcopy(self._cache.GetFromFile(
87 '%s/%s_sidenav.json' % (JSON_PATH, key)).Get()) 87 '%s/%s_sidenav.json' % (JSON_TEMPLATES, key)).Get())
88 _AddSelected(sidenav, self._server_instance.base_path + self._request.path) 88 _AddSelected(sidenav, self._server_instance.base_path + self._request.path)
89 return sidenav 89 return sidenav
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698