summaryrefslogtreecommitdiffstats
path: root/remoting/webapp
diff options
context:
space:
mode:
authorgarykac@chromium.org <garykac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-25 13:58:04 +0000
committergarykac@chromium.org <garykac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-25 13:58:04 +0000
commit95489038b3e9b16a0d8092482470ea9ddc68f8c1 (patch)
tree008d6f4b6f0d5f18cd3c115eb365f8529fc894dd /remoting/webapp
parent8bb3039caba57d01d4c17bb613a713ffd32129a0 (diff)
downloadchromium_src-95489038b3e9b16a0d8092482470ea9ddc68f8c1.zip
chromium_src-95489038b3e9b16a0d8092482470ea9ddc68f8c1.tar.gz
chromium_src-95489038b3e9b16a0d8092482470ea9ddc68f8c1.tar.bz2
Update Chromoting's build-html to check for extra/missing templates.
dialog_client.html was missing from the template list and the old build did not report an error. This change requires that he expected list of templates be passed to the HTML generator script so that it can be verified that all the dependencies are specified. This also moves the dialog_client template into the main template so that we include everything directly from template_main.html. This also removes some end-tag comments that are no longer needed since the structure can be more easily seen. BUG= Review URL: https://codereview.chromium.org/176013002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253155 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/webapp')
-rwxr-xr-xremoting/webapp/build-html.py57
-rw-r--r--remoting/webapp/html/dialog_client.html32
-rw-r--r--remoting/webapp/html/dialog_client_connect_failed.html9
-rw-r--r--remoting/webapp/html/dialog_client_connecting.html11
-rw-r--r--remoting/webapp/html/template_main.html31
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&hellip;</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>