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

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

Issue 102593005: Clean patch with DCC static content (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: bumped versions of cron and app, so running server won't update Created 7 years 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 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 extensions_paths import PRIVATE_TEMPLATES 5 from extensions_paths import PRIVATE_TEMPLATES
6 from file_system import FileNotFoundError 6 from file_system import FileNotFoundError
7 7
8 8
9 class TableOfContentsRenderer(object): 9 class TableOfContentsRenderer(object):
10 '''Renders a table of contents pulled from a list of DocumentSections 10 '''Renders a table of contents pulled from a list of DocumentSections
(...skipping 18 matching lines...) Expand all
29 try: 29 try:
30 table_of_contents_template = self._templates.GetFromFile(path).Get() 30 table_of_contents_template = self._templates.GetFromFile(path).Get()
31 except FileNotFoundError: 31 except FileNotFoundError:
32 return '', ['%s not found' % path] 32 return '', ['%s not found' % path]
33 33
34 def make_toc_items(entries): 34 def make_toc_items(entries):
35 return [{ 35 return [{
36 'attributes': [(key, val) for key, val in entry.attributes.iteritems() 36 'attributes': [(key, val) for key, val in entry.attributes.iteritems()
37 if key != 'id'], 37 if key != 'id'],
38 'link': entry.attributes.get('id', ''), 38 'link': entry.attributes.get('id', ''),
39 'hideInTOC': entry.attributes.get('hideintoc', None)!=None,
not at google - send to devlin 2013/12/13 23:03:47 this CL is pretty large and I can't patch it in, s
Renato Mangini (chromium) 2013/12/17 20:32:33 Done. I wasn't aware of the title="" trick
39 'subheadings': make_toc_items(entry.entries), 40 'subheadings': make_toc_items(entry.entries),
40 'title': entry.name, 41 'title': entry.name,
41 } for entry in entries] 42 } for entry in entries]
42 43
43 toc_items = [] 44 toc_items = []
44 for section in sections: 45 for section in sections:
45 items_for_section = make_toc_items(section.structure) 46 items_for_section = make_toc_items(section.structure)
46 if toc_items and items_for_section: 47 if toc_items and items_for_section:
47 items_for_section[0]['separator'] = True 48 items_for_section[0]['separator'] = True
48 toc_items.extend(items_for_section) 49 toc_items.extend(items_for_section)
49 50
50 return self._template_renderer.Render( 51 return self._template_renderer.Render(
51 self._templates.GetFromFile( 52 self._templates.GetFromFile(
52 '%s/table_of_contents.html' % PRIVATE_TEMPLATES).Get(), 53 '%s/table_of_contents.html' % PRIVATE_TEMPLATES).Get(),
53 None, # no request 54 None, # no request
54 data_sources=('partials'), 55 data_sources=('partials'),
55 additional_context={'items': toc_items}) 56 additional_context={'items': toc_items})
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698