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

Side by Side Diff: tools/grit/grit/format/html_inline.py

Issue 66041: This adds link[rel=icon] elements to the DOM UI html files for downloads and ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/history.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Flattens a HTML file by inlining its external resources. 6 """Flattens a HTML file by inlining its external resources.
7 7
8 This is a small script that takes a HTML file, looks for src attributes 8 This is a small script that takes a HTML file, looks for src attributes
9 and inlines the specified file, producing one HTML file with no external 9 and inlines the specified file, producing one HTML file with no external
10 dependencies. 10 dependencies.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 """Helper function to provide SrcInline with the base file path""" 91 """Helper function to provide SrcInline with the base file path"""
92 return SrcInline(src_match, input_filepath, distribution) 92 return SrcInline(src_match, input_filepath, distribution)
93 93
94 # TODO(glen): Make this regex not match src="" text that is not inside a tag 94 # TODO(glen): Make this regex not match src="" text that is not inside a tag
95 flat_text = re.sub('src="(?P<filename>[^"\']*)"', 95 flat_text = re.sub('src="(?P<filename>[^"\']*)"',
96 SrcReplace, 96 SrcReplace,
97 ReadFile(input_filename)) 97 ReadFile(input_filename))
98 98
99 # TODO(glen): Make this regex not match url('') that is not inside a style 99 # TODO(glen): Make this regex not match url('') that is not inside a style
100 flat_text = re.sub('background:[ ]*url\(\'(?P<filename>[^"\']*)\'', 100 flat_text = re.sub('background:[ ]*url\(\'(?P<filename>[^"\']*)\'',
101 SrcReplace, 101 SrcReplace,
102 flat_text) 102 flat_text)
103
104 flat_text = re.sub('<link rel="icon".+?href="(?P<filename>[^"\']*)"',
105 SrcReplace,
106 flat_text)
103 107
104 out_file = open(output_filename, 'wb') 108 out_file = open(output_filename, 'wb')
105 out_file.writelines(flat_text) 109 out_file.writelines(flat_text)
106 out_file.close() 110 out_file.close()
107 111
108 def main(): 112 def main():
109 if len(sys.argv) <= 2: 113 if len(sys.argv) <= 2:
110 print "Flattens a HTML file by inlining its external resources.\n" 114 print "Flattens a HTML file by inlining its external resources.\n"
111 print "html_inline.py inputfile outputfile" 115 print "html_inline.py inputfile outputfile"
112 else: 116 else:
113 InlineFile(sys.argv[1], sys.argv[2]) 117 InlineFile(sys.argv[1], sys.argv[2])
114 118
115 if __name__ == '__main__': 119 if __name__ == '__main__':
116 main() 120 main()
117
OLDNEW
« no previous file with comments | « chrome/browser/resources/history.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698