mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 1125280 Part 1 build- Different suggestedsite tiles on first run for kidfox.r=gps
This commit is contained in:
parent
592689f35f
commit
7346aec254
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
@ -70,3 +70,17 @@ browser.suggestedsites.fxsupport.title=Firefox Help and Support
|
||||
browser.suggestedsites.fxsupport.url=https://support.mozilla.org/en-US/products/mobile
|
||||
browser.suggestedsites.fxsupport.bgcolor=#f37c00
|
||||
browser.suggestedsites.fxsupport.trackingid=631
|
||||
|
||||
browser.suggestedsites.restricted.list.0=restricted_fxsupport
|
||||
browser.suggestedsites.restricted.list.1=webmaker
|
||||
browser.suggestedsites.restricted.list.2=mozilla
|
||||
|
||||
browser.suggestedsites.restricted_fxsupport.title=Firefox Help and Support for Restricted Profiles
|
||||
browser.suggestedsites.restricted_fxsupport.url=https://support.mozilla.org/en-US/products/mobile
|
||||
browser.suggestedsites.restricted_fxsupport.bgcolor=#f37c00
|
||||
browser.suggestedsites.restricted_fxsupport.trackingid=000
|
||||
|
||||
browser.suggestedsites.webmaker.title=Learn the Web: Mozilla Webmaker
|
||||
browser.suggestedsites.webmaker.url=https://webmaker.org/
|
||||
browser.suggestedsites.webmaker.bgcolor=#f37c00
|
||||
browser.suggestedsites.webmaker.trackingid=000
|
||||
|
@ -11,9 +11,10 @@ This script follows these steps:
|
||||
(see srcdir option). Merge all properties into a single dict accounting for
|
||||
the priority of source directories.
|
||||
|
||||
2. Read the list of sites from the 'browser.suggestedsites.list.INDEX'
|
||||
properties with value of these keys being an identifier for each suggested site
|
||||
e.g. browser.suggestedsites.list.0=mozilla, browser.suggestedsites.list.1=fxmarketplace.
|
||||
2. Read the list of sites from the list 'browser.suggestedsites.list.INDEX' and
|
||||
'browser.suggestedsites.restricted.list.INDEX' properties with value of these keys
|
||||
being an identifier for each suggested site e.g. browser.suggestedsites.list.0=mozilla,
|
||||
browser.suggestedsites.list.1=fxmarketplace.
|
||||
|
||||
3. For each site identifier defined by the list keys, look for matching branches
|
||||
containing the respective properties i.e. url, title, etc. For example,
|
||||
@ -28,6 +29,7 @@ directory e.g. raw/suggestedsites.json, raw-pt-rBR/suggestedsites.json.
|
||||
from __future__ import absolute_import, print_function
|
||||
|
||||
import argparse
|
||||
import copy
|
||||
import json
|
||||
import sys
|
||||
import os
|
||||
@ -78,9 +80,6 @@ def main(args):
|
||||
|
||||
# Use reversed order so that the first srcdir has higher priority to override keys.
|
||||
properties = merge_properties('region.properties', reversed(opts.srcdir))
|
||||
names = properties.get_list('browser.suggestedsites.list')
|
||||
if opts.verbose:
|
||||
print('Reading {len} suggested sites: {names}'.format(len=len(names), names=names))
|
||||
|
||||
# Keep these two in sync.
|
||||
image_url_template = 'android.resource://%s/drawable/suggestedsites_{name}' % opts.android_package_name
|
||||
@ -89,26 +88,45 @@ def main(args):
|
||||
# Load properties corresponding to each site name and define their
|
||||
# respective image URL.
|
||||
sites = []
|
||||
for name in names:
|
||||
site = properties.get_dict('browser.suggestedsites.{name}'.format(name=name), required_keys=('title', 'url', 'bgcolor'))
|
||||
site['imageurl'] = image_url_template.format(name=name)
|
||||
sites.append(site)
|
||||
|
||||
# Now check for existence of an appropriately named drawable. If none
|
||||
# exists, throw. This stops a locale discovering, at runtime, that the
|
||||
# corresponding drawable was not added to en-US.
|
||||
if not opts.resources:
|
||||
continue
|
||||
resources = os.path.abspath(opts.resources)
|
||||
finder = FileFinder(resources)
|
||||
matches = [p for p, _ in finder.find(drawables_template.format(name=name))]
|
||||
if not matches:
|
||||
raise Exception("Could not find drawable in '{resources}' for '{name}'"
|
||||
.format(resources=resources, name=name))
|
||||
else:
|
||||
if opts.verbose:
|
||||
print("Found {len} drawables in '{resources}' for '{name}': {matches}"
|
||||
.format(len=len(matches), resources=resources, name=name, matches=matches))
|
||||
def add_names(names, defaults={}):
|
||||
for name in names:
|
||||
site = copy.deepcopy(defaults)
|
||||
site.update(properties.get_dict('browser.suggestedsites.{name}'.format(name=name), required_keys=('title', 'url', 'bgcolor')))
|
||||
site['imageurl'] = image_url_template.format(name=name)
|
||||
sites.append(site)
|
||||
|
||||
# Now check for existence of an appropriately named drawable. If none
|
||||
# exists, throw. This stops a locale discovering, at runtime, that the
|
||||
# corresponding drawable was not added to en-US.
|
||||
if not opts.resources:
|
||||
continue
|
||||
resources = os.path.abspath(opts.resources)
|
||||
finder = FileFinder(resources)
|
||||
matches = [p for p, _ in finder.find(drawables_template.format(name=name))]
|
||||
if not matches:
|
||||
raise Exception("Could not find drawable in '{resources}' for '{name}'"
|
||||
.format(resources=resources, name=name))
|
||||
else:
|
||||
if opts.verbose:
|
||||
print("Found {len} drawables in '{resources}' for '{name}': {matches}"
|
||||
.format(len=len(matches), resources=resources, name=name, matches=matches))
|
||||
|
||||
# We want the lists to be ordered for reproducibility. Each list has a
|
||||
# "default" JSON list item which will be extended by the properties read.
|
||||
lists = [
|
||||
('browser.suggestedsites.list', {}),
|
||||
('browser.suggestedsites.restricted.list', {'restricted': True}),
|
||||
]
|
||||
if opts.verbose:
|
||||
print('Reading {len} suggested site lists: {lists}'.format(len=len(lists), lists=[list_name for list_name, _ in lists]))
|
||||
|
||||
for (list_name, list_item_defaults) in lists:
|
||||
names = properties.get_list(list_name)
|
||||
if opts.verbose:
|
||||
print('Reading {len} suggested sites from {list}: {names}'.format(len=len(names), list=list_name, names=names))
|
||||
add_names(names, list_item_defaults)
|
||||
|
||||
|
||||
# FileAvoidWrite creates its parent directories.
|
||||
output = os.path.abspath(opts.output)
|
||||
|
Loading…
Reference in New Issue
Block a user