Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: packagerSafari.py

Issue 29326188: Issue 3039 - Generate qunit/index.html based on metadata (Closed)
Left Patch Set: Created Sept. 9, 2015, 3:35 p.m.
Right Patch Set: Avoid hardcoding "Adblock Plus", instead use basename Created Sept. 9, 2015, 4:28 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « packagerChrome.py ('k') | testIndex.html.tmpl » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This Source Code Form is subject to the terms of the Mozilla Public 3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this 4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 6
7 import os 7 import os
8 import re 8 import re
9 import json 9 import json
10 import ConfigParser 10 import ConfigParser
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 allowAllDomains=allowAllDomains, 86 allowAllDomains=allowAllDomains,
87 allowSecurePages=allowSecurePages, 87 allowSecurePages=allowSecurePages,
88 startScripts=(get_optional('contentScripts', 'document_start') or '').split( ), 88 startScripts=(get_optional('contentScripts', 'document_start') or '').split( ),
89 endScripts=(get_optional('contentScripts', 'document_end') or '').split(), 89 endScripts=(get_optional('contentScripts', 'document_end') or '').split(),
90 menus=parse_section('menus', 2), 90 menus=parse_section('menus', 2),
91 toolbarItems=parse_section('toolbar_items'), 91 toolbarItems=parse_section('toolbar_items'),
92 popovers=parse_section('popovers'), 92 popovers=parse_section('popovers'),
93 developerIdentifier=params.get('developerIdentifier') 93 developerIdentifier=params.get('developerIdentifier')
94 ).encode('utf-8') 94 ).encode('utf-8')
95 95
96 def createBackgroundPage(params):
97 template = getTemplate('background.html.tmpl', autoEscape=True)
98 return template.render(
99 backgroundScripts=params['metadata'].get(
100 'general', 'backgroundScripts'
101 ).split()
102 ).encode('utf-8')
103
104 def createInfoModule(params): 96 def createInfoModule(params):
105 template = getTemplate('safariInfo.js.tmpl') 97 template = getTemplate('safariInfo.js.tmpl')
106 return template.render(params).encode('utf-8') 98 return template.render(params).encode('utf-8')
107 99
108 def fixAbsoluteUrls(files): 100 def fixAbsoluteUrls(files):
109 for filename, content in files.iteritems(): 101 for filename, content in files.iteritems():
110 if os.path.splitext(filename)[1].lower() == '.html': 102 if os.path.splitext(filename)[1].lower() == '.html':
111 files[filename] = re.sub( 103 files[filename] = re.sub(
112 r'(<[^<>]*?\b(?:href|src)\s*=\s*["\']?)\/+', 104 r'(<[^<>]*?\b(?:href|src)\s*=\s*["\']?)\/+',
113 r'\1' + '/'.join(['..'] * filename.count('/') + ['']), 105 r'\1' + '/'.join(['..'] * filename.count('/') + ['']),
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 243
252 if metadata.has_section('preprocess'): 244 if metadata.has_section('preprocess'):
253 files.preprocess( 245 files.preprocess(
254 [f for f, _ in metadata.items('preprocess')], 246 [f for f, _ in metadata.items('preprocess')],
255 {'needsExt': True} 247 {'needsExt': True}
256 ) 248 )
257 249
258 if metadata.has_section('import_locales'): 250 if metadata.has_section('import_locales'):
259 importGeckoLocales(params, files) 251 importGeckoLocales(params, files)
260 252
253 if metadata.has_option('general', 'testScripts'):
254 files['qunit/index.html'] = createScriptPage(params, 'testIndex.html.tmpl',
255 ('general', 'testScripts'))
256
261 if keyFile: 257 if keyFile:
262 certs, key = get_certificates_and_key(keyFile) 258 certs, key = get_certificates_and_key(keyFile)
263 params['developerIdentifier'] = get_developer_identifier(certs) 259 params['developerIdentifier'] = get_developer_identifier(certs)
264 260
265 files['lib/info.js'] = createInfoModule(params) 261 files['lib/info.js'] = createInfoModule(params)
266 files['background.html'] = createScriptPage(params, 'background.html.tmpl', 262 files['background.html'] = createScriptPage(params, 'background.html.tmpl',
267 ('general', 'backgroundScripts')) 263 ('general', 'backgroundScripts'))
268 files['Info.plist'] = createManifest(params, files) 264 files['Info.plist'] = createManifest(params, files)
269 265
270 fixAbsoluteUrls(files) 266 fixAbsoluteUrls(files)
271 267
272 dirname = metadata.get('general', 'basename') + '.safariextension' 268 dirname = metadata.get('general', 'basename') + '.safariextension'
273 for filename in files.keys(): 269 for filename in files.keys():
274 files[os.path.join(dirname, filename)] = files.pop(filename) 270 files[os.path.join(dirname, filename)] = files.pop(filename)
275 271
276 if not devenv and keyFile: 272 if not devenv and keyFile:
277 createSignedXarArchive(outFile, files, certs, key) 273 createSignedXarArchive(outFile, files, certs, key)
278 else: 274 else:
279 files.zip(outFile) 275 files.zip(outFile)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld