diff options
Diffstat (limited to 'remoting/webapp')
-rwxr-xr-x | remoting/webapp/build-html.py | 57 | ||||
-rw-r--r-- | remoting/webapp/html/dialog_client.html | 32 | ||||
-rw-r--r-- | remoting/webapp/html/dialog_client_connect_failed.html | 9 | ||||
-rw-r--r-- | remoting/webapp/html/dialog_client_connecting.html | 11 | ||||
-rw-r--r-- | remoting/webapp/html/template_main.html | 31 |
5 files changed, 88 insertions, 52 deletions
diff --git a/remoting/webapp/build-html.py b/remoting/webapp/build-html.py index ccf0a82..4b9a027 100755 --- a/remoting/webapp/build-html.py +++ b/remoting/webapp/build-html.py @@ -31,14 +31,35 @@ class HtmlChecker(HTMLParser): class GenerateWebappHtml: - def __init__(self, js_files): + def __init__(self, template_files, js_files): self.js_files = js_files + self.templates_expected = set() + for template in template_files: + self.templates_expected.add(os.path.basename(template)) + + self.templates_found = set() + def includeJavascript(self, output): for js_path in sorted(self.js_files): js_file = os.path.basename(js_path) output.write(' <script src="' + js_file + '"></script>\n') + def verifyTemplateList(self): + """Verify that all the expected templates were found.""" + if self.templates_expected > self.templates_found: + extra = self.templates_expected - self.templates_found + print 'Extra templates specified:', extra + return False + return True + + def validateTemplate(self, template_path): + template = os.path.basename(template_path) + if template in self.templates_expected: + self.templates_found.add(template) + return True + return False + def processTemplate(self, output, template_file, indent): with open(template_file, 'r') as input: first_line = True @@ -61,7 +82,12 @@ class GenerateWebappHtml: r'^(\s*)<meta-include src="(.+)"\s*/>\s*$', line) if m: - self.processTemplate(output, m.group(2), indent + len(m.group(1))) + prefix = m.group(1) + template_name = m.group(2) + if not self.validateTemplate(template_name): + error('Found template not in list of expected templates: %s' % + template_name) + self.processTemplate(output, template_name, indent + len(prefix)) continue m = re.match(r'^\s*<meta-include type="javascript"\s*/>\s*$', line) @@ -76,10 +102,14 @@ class GenerateWebappHtml: def show_usage(): - print 'Usage: %s <output-file> <input-template> <js-file>+' % sys.argv[0] + print ('Usage: %s <output-file> <input-template> ' + '[--templates <template-files...>] ' + '[--js <js-files...>]' % sys.argv[0]) + print 'where:' print ' <output-file> Path to HTML output file' print ' <input-template> Path to input template' - print ' <js-file> One or more Javascript files to include in HTML output' + print ' <template-files> The html template files used by <input-template>' + print ' <js-files> The Javascript files to include in HTML <head>' def main(): @@ -89,13 +119,28 @@ def main(): out_file = sys.argv[1] main_template_file = sys.argv[2] - js_files = sys.argv[3:] + + template_files = [] + js_files = [] + for arg in sys.argv[3:]: + if arg == '--js' or arg == '--template': + arg_type = arg + elif arg_type == '--js': + js_files.append(arg) + elif arg_type == '--template': + template_files.append(arg) + else: + error('Unrecognized argument: %s' % arg) # Generate the main HTML file from the templates. with open(out_file, 'w') as output: - gen = GenerateWebappHtml(js_files) + gen = GenerateWebappHtml(template_files, js_files) gen.processTemplate(output, main_template_file, 0) + # Verify that all the expected templates were found. + if not gen.verifyTemplateList(): + error('Extra templates specified') + # Verify that the generated HTML file is valid. with open(out_file, 'r') as input: parser = HtmlChecker() diff --git a/remoting/webapp/html/dialog_client.html b/remoting/webapp/html/dialog_client.html deleted file mode 100644 index eedea18..0000000 --- a/remoting/webapp/html/dialog_client.html +++ /dev/null @@ -1,32 +0,0 @@ -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<div id="client-dialog" - class="kd-modaldialog" - data-ui-mode="home.client"> - - <meta-include src="webapp/html/dialog_client_unconnected.html"/> - - <div data-ui-mode="home.client.connecting" class="box"> - <span class="waiting prominent" - i18n-content="FOOTER_CONNECTING"></span> - <div class="box-spacer"></div> - <button id="cancel-connect-button" i18n-content="CANCEL"></button> - </div> <!-- client.connecting --> - - <meta-include src="webapp/html/dialog_client_host_needs_upgrade.html"/> - - <meta-include src="webapp/html/dialog_client_pin_prompt.html"/> - - <meta-include src="webapp/html/dialog_client_third_party_auth.html"/> - - <div data-ui-mode="home.client.connect-failed" - class="message"> - <span id="connect-error-message" class="error-state"></span> - </div> <!-- client.connect-failed --> - - <meta-include src="webapp/html/dialog_client_session_finished.html"/> - -</div> <!-- client-dialog --> diff --git a/remoting/webapp/html/dialog_client_connect_failed.html b/remoting/webapp/html/dialog_client_connect_failed.html new file mode 100644 index 0000000..18e00f3 --- /dev/null +++ b/remoting/webapp/html/dialog_client_connect_failed.html @@ -0,0 +1,9 @@ +<!-- +Copyright 2014 The Chromium Authors. All rights reserved. +Use of this source code is governed by a BSD-style license that can be +found in the LICENSE file. +--> +<div data-ui-mode="home.client.connect-failed" + class="message"> + <span id="connect-error-message" class="error-state"></span> +</div> diff --git a/remoting/webapp/html/dialog_client_connecting.html b/remoting/webapp/html/dialog_client_connecting.html new file mode 100644 index 0000000..ef38881 --- /dev/null +++ b/remoting/webapp/html/dialog_client_connecting.html @@ -0,0 +1,11 @@ +<!-- +Copyright 2014 The Chromium Authors. All rights reserved. +Use of this source code is governed by a BSD-style license that can be +found in the LICENSE file. +--> +<div data-ui-mode="home.client.connecting" class="box"> + <span class="waiting prominent" + i18n-content="FOOTER_CONNECTING"></span> + <div class="box-spacer"></div> + <button id="cancel-connect-button" i18n-content="CANCEL"></button> +</div> diff --git a/remoting/webapp/html/template_main.html b/remoting/webapp/html/template_main.html index 7db84fc..d7d455e 100644 --- a/remoting/webapp/html/template_main.html +++ b/remoting/webapp/html/template_main.html @@ -27,7 +27,7 @@ found in the LICENSE file. hidden, but are shown appropriately when the mode changes. --> <section id="loading-mode" data-ui-mode=""> <em>Loading…</em> - </section> <!-- loading-mode --> + </section> <div id="daemon-plugin-container"></div> <div id="host-plugin-container"></div> @@ -37,14 +37,11 @@ found in the LICENSE file. <div class="inset" data-ui-mode="home" hidden> <meta-include src="webapp/html/ui_header.html"/> - <meta-include src="webapp/html/butterbar.html"/> - <meta-include src="webapp/html/ui_it2me.html"/> - <meta-include src="webapp/html/ui_me2me.html"/> - </div> <!-- inset --> + </div> <meta-include src="webapp/html/dialog_auth.html"/> @@ -59,19 +56,26 @@ found in the LICENSE file. <div class="box-spacer"></div> <meta-include src="webapp/html/dialog_token_refresh_failed.html"/> - <meta-include src="webapp/html/dialog_host_setup.html"/> - <meta-include src="webapp/html/dialog_host_install.html"/> - <meta-include src="webapp/html/dialog_host.html"/> - <meta-include src="webapp/html/dialog_client.html"/> + <div id="client-dialog" + class="kd-modaldialog" + data-ui-mode="home.client"> - <meta-include src="webapp/html/dialog_connection_history.html"/> + <meta-include src="webapp/html/dialog_client_unconnected.html"/> + <meta-include src="webapp/html/dialog_client_connecting.html"/> + <meta-include src="webapp/html/dialog_client_host_needs_upgrade.html"/> + <meta-include src="webapp/html/dialog_client_pin_prompt.html"/> + <meta-include src="webapp/html/dialog_client_third_party_auth.html"/> + <meta-include src="webapp/html/dialog_client_connect_failed.html"/> + <meta-include src="webapp/html/dialog_client_session_finished.html"/> - <meta-include src="webapp/html/dialog_confirm_host_delete.html"/> + </div> + <meta-include src="webapp/html/dialog_connection_history.html"/> + <meta-include src="webapp/html/dialog_confirm_host_delete.html"/> <meta-include src="webapp/html/dialog_manage_pairings.html"/> <div class="box-spacer"></div> @@ -84,13 +88,12 @@ found in the LICENSE file. hidden> <meta-include src="webapp/html/toolbar.html"/> - <meta-include src="webapp/html/client_plugin.html"/> - </div> <!-- session-mode --> + </div> <div id="statistics" dir="ltr" class="selectable" hidden> - </div> <!-- statistics --> + </div> </body> </html> |