| 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 HTML_TOP = ''' | 5 import collections |
| 6 <!-- | |
| 7 Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 8 Use of this source code is governed by a BSD-style license that can be | |
| 9 found in the LICENSE file. | |
| 10 --> | |
| 11 | 6 |
| 12 <!DOCTYPE html> | 7 import easy_template |
| 13 <html> | |
| 14 <head> | |
| 15 <style type="text/css"> | |
| 16 dt { | |
| 17 font-weight: bold; | |
| 18 } | |
| 19 dd { | |
| 20 margin-bottom: 12pt; | |
| 21 width: 800px; | |
| 22 } | |
| 23 </style> | |
| 24 <link href="http://code.google.com/css/codesite.css" rel="stylesheet" | |
| 25 type="text/css" /> | |
| 26 <title>Native Client Examples</title> | |
| 27 </head> | |
| 28 <body> | |
| 29 <h1>Native Client Examples</h1> | |
| 30 <dd><p>This page lists all of the examples available in the most recent Native | |
| 31 Client SDK bundle. Each example is designed to teach a few specific Native | |
| 32 Client programming concepts. You will need to setup the build environment | |
| 33 including a path to 'make' which can be found in the 'tools' directory for | |
| 34 Windows, and the variable NACL_SDK_ROOT which points to one of the pepper | |
| 35 bundles found under the SDK install location. Calling make from the examples | |
| 36 directory will build all the projects, while calling make from an individual | |
| 37 example directory will build only that example. | |
| 38 </p></dd> | |
| 39 ''' | |
| 40 | |
| 41 HTML_END = ''' | |
| 42 </body> | |
| 43 </html> | |
| 44 ''' | |
| 45 | |
| 46 SECTIONS = { | |
| 47 'API': """ | |
| 48 <h3>Common APIs</h3> | |
| 49 <dd><p>The following set of examples illustrate various Pepper APIs including | |
| 50 audio, 2D, 3D, file I/O, input and urls.</p></dd> | |
| 51 """, | |
| 52 'Concepts': """ | |
| 53 <h3>Common Concepts</h3> | |
| 54 <dd><p>The following set of examples illustrate various common concepts such as | |
| 55 showing load progress, using Shared Objects (dynamic libraries), | |
| 56 mulithreading...</p></dd> | |
| 57 """, | |
| 58 'Tools': """ | |
| 59 <h3>Using the Tools</h3> | |
| 60 <dd><p>The following "hello_world" examples, show the basic outline of a | |
| 61 several types of Native Client applications. The simplest, "Hello World Stdio" | |
| 62 uses several provided libraries to simplify startup and provides a | |
| 63 simplified make showing a single build configuration. The other examples in | |
| 64 this SDK however, are designed to build and run with multiple toolsets, build | |
| 65 configurations, etc... | |
| 66 making the build much more complex. In all cases we are using <a | |
| 67 href="http://www.gnu.org/software/make/manual/make.html">GNU Make</a>. | |
| 68 See the link for further information. | |
| 69 </p></dd> | |
| 70 """, | |
| 71 } | |
| 72 | |
| 73 | 8 |
| 74 class LandingPage(object): | 9 class LandingPage(object): |
| 75 def __init__(self): | 10 def __init__(self): |
| 76 self.section_list = ['Tools', 'API', 'Concepts'] | 11 self.section_list = ['Tools', 'API', 'Concepts'] |
| 77 self.section_map = {} | 12 self.section_map = collections.defaultdict(list) |
| 78 for section in self.section_list: | |
| 79 self.section_map[section] = [] | |
| 80 | 13 |
| 81 def _ExampleDescription(self, index_path, title, details, focus): | 14 def GeneratePage(self, template_path): |
| 82 return ''' | 15 with open(template_path) as src: |
| 83 <dt><a href="%s/index.html">%s</a></dt> | 16 template = src.read() |
| 84 <dd>%s | 17 template_dict = { 'section_map': self.section_map } |
| 85 <p>Teaching focus: %s</p> | 18 return easy_template.RunTemplateString(template, template_dict) |
| 86 </dd> | |
| 87 ''' % (index_path, title, details, focus) | |
| 88 | |
| 89 def _GenerateSection(self, section): | |
| 90 out = SECTIONS[section] | |
| 91 for desc in self.section_map[section]: | |
| 92 index_path = desc['NAME'] | |
| 93 title = desc['TITLE'] | |
| 94 details = desc['DESC'] | |
| 95 focus = desc['FOCUS'] | |
| 96 out += self._ExampleDescription(index_path, title, details, focus) | |
| 97 return out | |
| 98 | |
| 99 def GeneratePage(self): | |
| 100 out = HTML_TOP | |
| 101 for section in self.section_list: | |
| 102 out += self._GenerateSection(section) | |
| 103 out += HTML_END | |
| 104 return out | |
| 105 | 19 |
| 106 def AddDesc(self, desc): | 20 def AddDesc(self, desc): |
| 107 group = desc['GROUP'] | 21 group = desc['GROUP'] |
| 108 assert group in self.section_list | 22 assert group in self.section_list |
| 109 self.section_map[group].append(desc) | 23 self.section_map[group].append(desc) |
| 110 | |
| OLD | NEW |