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

Side by Side Diff: chrome/browser/resources/md_downloads/vulcanize.py

Issue 1378993003: Vulcanize new Material Design downloads UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@vulcanize2
Patch Set: -crisper.html Created 5 years, 2 months 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
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import os
7 import subprocess
8 import sys
9 import tempfile
10
11
12 _HERE_PATH = os.path.join(os.path.dirname(__file__))
13
14 _HTML_IN_PATH = os.path.join(_HERE_PATH, 'downloads.html')
15 _HTML_OUT_PATH = os.path.join(_HERE_PATH, 'vulcanized.html')
16 _JS_OUT_PATH = os.path.join(_HERE_PATH, 'crisper.js')
17
18 _SRC_PATH = os.path.normpath(os.path.join(_HERE_PATH, '..', '..', '..', '..'))
19
20 _RESOURCES_PATH = os.path.join(_SRC_PATH, 'ui', 'webui', 'resources')
21
22 _CR_ELEMENTS_PATH = os.path.join(_RESOURCES_PATH, 'cr_elements')
23 _CSS_RESOURCES_PATH = os.path.join(_RESOURCES_PATH, 'css')
24 _HTML_RESOURCES_PATH = os.path.join(_RESOURCES_PATH, 'html')
25 _JS_RESOURCES_PATH = os.path.join(_RESOURCES_PATH, 'js')
26
27 _POLYMER_PATH = os.path.join(
28 _SRC_PATH, 'third_party', 'polymer', 'v1_0', 'components-chromium')
29 _WEB_ANIMATIONS_PATH = os.path.join(
30 _SRC_PATH, 'third_party', 'web-animations-js', 'sources')
31
32 _VULCANIZE_ARGS = [
33 '--exclude', 'crisper.js',
34 '--exclude', 'load_time_data.js',
35 '--exclude', 'strings.js',
36 '--exclude', 'text_defaults.css',
37 '--inline-css',
38 '--inline-scripts',
39 '--redirect', 'chrome://downloads/|%s' % _HERE_PATH,
40 '--redirect', 'chrome://resources/cr_elements/|%s' % _CR_ELEMENTS_PATH,
41 '--redirect', 'chrome://resources/css/|%s' % _CSS_RESOURCES_PATH,
42 '--redirect', 'chrome://resources/html/|%s' % _HTML_RESOURCES_PATH,
43 '--redirect', 'chrome://resources/js/|%s' % _JS_RESOURCES_PATH,
44 '--redirect', 'chrome://resources/polymer/v1_0/web-animations-js/|%s' % _WEB_A NIMATIONS_PATH,
45 '--redirect', 'chrome://resources/polymer/v1_0/|%s' % _POLYMER_PATH,
46 '--strip-comments',
47 ]
48
49 def main():
50 def _run_cmd(cmd_parts, stdout=None):
51 cmd = "'" + "' '".join(cmd_parts) + "'"
52 process = subprocess.Popen(
53 cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
54 stdout, stderr = process.communicate()
55
56 if stderr:
57 print >> sys.stderr, '%s failed: %s' % (cmd, stderr)
58 raise
59
60 return stdout
61
62 output = _run_cmd(['vulcanize'] + _VULCANIZE_ARGS + [_HTML_IN_PATH])
63
64 with tempfile.NamedTemporaryFile(mode='wt+', delete=False) as tmp:
65 tmp.write(output.replace(
66 '<include src="', '<include src="../../../../ui/webui/resources/js/'))
67
68 try:
69 _run_cmd(['crisper', '--source', tmp.name, '--html', _HTML_OUT_PATH,
70 '--js', _JS_OUT_PATH])
71 finally:
72 os.remove(tmp.name)
73
74
75 if __name__ == '__main__':
76 main()
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_downloads/manager.css ('k') | chrome/browser/resources/md_downloads/vulcanize_readme.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698