def android_builds(build, builds=None): builds = builds or [] android_link = settings.GOOGLE_PLAY_FIREFOX_LINK variations = { 'api-9': 'Gingerbread', 'api-11': 'Honeycomb+ ARMv7', 'x86': 'x86', } if build.lower() == 'beta': android_link = android_link.replace('org.mozilla.firefox', 'org.mozilla.firefox_beta') if build == 'aurora': for type, arch_pretty in variations.items(): link = (download_urls['aurora-android-%s' % type] % mobile_details.latest_version('aurora')) builds.append({'os': 'os_android', 'os_pretty': 'Android', 'os_arch_pretty': 'Android %s' % arch_pretty, 'arch': 'x86' if type == 'x86' else 'armv7 %s' % type, 'arch_pretty': arch_pretty, 'download_link': link}) if build != 'aurora': builds.append({'os': 'os_android', 'os_pretty': 'Android', 'download_link': android_link}) return builds
def android_builds(build, builds=None): builds = builds or [] android_link = settings.GOOGLE_PLAY_FIREFOX_LINK if build == 'beta': android_link = android_link.replace('org.mozilla.firefox', 'org.mozilla.firefox_beta') if build == 'aurora': for arch_pretty in ['ARMv7', 'x86']: arch = arch_pretty.lower() link = (download_urls['aurora-android-%s' % arch] % mobile_details.latest_version('aurora')) builds.append({'os': 'os_android', 'os_pretty': 'Android', 'os_arch_pretty': 'Android %s' % arch_pretty, 'arch': arch, 'arch_pretty': arch_pretty, 'download_link': link}) if build != 'aurora': builds.append({'os': 'os_android', 'os_pretty': 'Android', 'download_link': android_link}) return builds
def android_builds(build, builds=None): builds = builds or [] android_link = settings.GOOGLE_PLAY_FIREFOX_LINK if build.lower() == 'beta': android_link = android_link.replace('org.mozilla.firefox', 'org.mozilla.firefox_beta') if build == 'aurora': for arch_pretty in ['ARMv7', 'x86']: arch = arch_pretty.lower() link = (download_urls['aurora-android-%s' % arch] % mobile_details.latest_version('aurora')) builds.append({'os': 'os_android', 'os_pretty': 'Android', 'os_arch_pretty': 'Android %s' % arch_pretty, 'arch': arch, 'arch_pretty': arch_pretty, 'download_link': link}) if build != 'aurora': builds.append({'os': 'os_android', 'os_pretty': 'Android', 'download_link': android_link}) return builds
def get_latest_version(product='firefox', channel='release'): if channel == 'organizations': channel = 'esr' if product == 'mobile': return mobile_details.latest_version(channel) else: return firefox_details.latest_version(channel)
def get_latest_version(product='firefox', channel='release'): if channel == 'organizations': channel = 'esr' if product == 'mobile': return mobile_details.latest_version(channel) else: return firefox_details.latest_version(channel)
def get_latest_version(product="firefox", channel="release"): if channel == "organizations": channel = "esr" if product == "mobile": return mobile_details.latest_version(channel) else: return firefox_details.latest_version(channel)
def android_builds(build, builds=None): builds = builds or [] android_link = settings.GOOGLE_PLAY_FIREFOX_LINK variations = { 'api-9': 'Gingerbread', 'api-11': 'Honeycomb+ ARMv7', 'x86': 'x86', } if build.lower() == 'beta': android_link = android_link.replace('org.mozilla.firefox', 'org.mozilla.firefox_beta') if build == 'aurora': for type, arch_pretty in variations.items(): link = (download_urls['aurora-android-%s' % type] % mobile_details.latest_version('aurora')) builds.append({ 'os': 'os_android', 'os_pretty': 'Android', 'os_arch_pretty': 'Android %s' % arch_pretty, 'arch': 'x86' if type == 'x86' else 'armv7 %s' % type, 'arch_pretty': arch_pretty, 'download_link': link }) if build != 'aurora': builds.append({ 'os': 'os_android', 'os_pretty': 'Android', 'download_link': android_link }) return builds
from bedrock.firefox.firefox_details import firefox_details, mobile_details from lib.l10n_utils import get_locale download_urls = { 'transition': '/{locale}/products/download.html', 'direct': 'https://download.mozilla.org/', 'aurora': 'https://ftp.mozilla.org/pub/mozilla.org/firefox/' 'nightly/latest-mozilla-aurora', 'aurora-l10n': 'https://ftp.mozilla.org/pub/mozilla.org/firefox/' 'nightly/latest-mozilla-aurora-l10n', 'aurora-mobile': 'https://ftp.mozilla.org/pub/mozilla.org/mobile/' 'nightly/latest-mozilla-aurora-android/en-US/' 'fennec-%s.en-US.android-arm.apk' % mobile_details.latest_version('aurora'), } def latest_version(locale, channel='release'): """Return build info for a locale and channel. :param locale: locale string of the build :param channel: channel of the build: release, beta, or aurora :return: dict or None """ all_builds = (firefox_details.firefox_primary_builds, firefox_details.firefox_beta_builds) version = firefox_details.latest_version(channel) for builds in all_builds:
download_urls = { 'transition': '/{locale}/products/download.html', 'direct': 'https://download.mozilla.org/', 'aurora': 'https://ftp.mozilla.org/pub/mozilla.org/firefox/' 'nightly/latest-mozilla-aurora', 'aurora-l10n': 'https://ftp.mozilla.org/pub/mozilla.org/firefox/' 'nightly/latest-mozilla-aurora-l10n', 'aurora-mobile': 'https://ftp.mozilla.org/pub/mozilla.org/mobile/' 'nightly/latest-mozilla-aurora-android/en-US/' 'fennec-%s.en-US.android-arm.apk' % mobile_details.latest_version('aurora'), } def latest_version(locale, channel='release'): """Return build info for a locale and channel. :param locale: locale string of the build :param channel: channel of the build: release, beta, or aurora :return: dict or None """ all_builds = (firefox_details.firefox_primary_builds, firefox_details.firefox_beta_builds) version = firefox_details.latest_version(channel) for builds in all_builds:
def download_firefox( ctx, build="release", small=False, icon=True, mobile=None, dom_id=None, locale=None, force_direct=False, force_full_installer=False, force_funnelcake=False, ): """ Output a "download firefox" button. :param ctx: context from calling template. :param build: name of build: 'release', 'beta' or 'aurora'. :param small: Display the small button if True. :param icon: Display the Fx icon on the button if True. :param mobile: Display the android download button if True, the desktop button only if False, and by default (None) show whichever is appropriate for the user's system. :param dom_id: Use this string as the id attr on the element. :param locale: The locale of the download. Default to locale of request. :param force_direct: Force the download URL to be direct. :param force_full_installer: Force the installer download to not be the stub installer (for aurora). :param force_funnelcake: Force the download version for en-US Windows to be 'latest', which bouncer will translate to the funnelcake build. :return: The button html. """ alt_build = "" if build == "release" else build platform = "mobile" if mobile else "desktop" locale = locale or get_locale(ctx["request"]) funnelcake_id = ctx.get("funnelcake_id", False) dom_id = dom_id or "download-button-%s-%s" % (platform, build) l_version = latest_version(locale, build) if l_version: version, platforms = l_version else: locale = "en-US" version, platforms = latest_version("en-US", build) # Gather data about the build for each platform builds = [] if not mobile: for plat_os in ["Windows", "Linux", "Linux 64", "OS X"]: # Fallback to en-US if this plat_os/version isn't available # for the current locale _locale = locale if plat_os not in platforms: _locale = "en-US" # Special case for the Japanese version for Mac if plat_os == "OS X" and _locale == "ja": _locale = "ja-JP-mac" # Normalize the platform os name plat_os = "os_%s" % plat_os.lower().replace(" ", "") plat_os_pretty = { "os_osx": "Mac OS X", "os_windows": "Windows", "os_linux": "Linux", "os_linux64": "Linux 64-bit", }[plat_os] # And generate all the info download_link = make_download_link( "firefox", build, version, plat_os, _locale, force_direct=force_direct, force_full_installer=force_full_installer, force_funnelcake=force_funnelcake, funnelcake_id=funnelcake_id, ) # If download_link_direct is False the data-direct-link attr # will not be output, and the JS won't attempt the IE popup. if force_direct: # no need to run make_download_link again with the same args download_link_direct = False else: download_link_direct = make_download_link( "firefox", build, version, plat_os, _locale, force_direct=True, force_full_installer=force_full_installer, force_funnelcake=force_funnelcake, funnelcake_id=funnelcake_id, ) if download_link_direct == download_link: download_link_direct = False builds.append( { "os": plat_os, "os_pretty": plat_os_pretty, "download_link": download_link, "download_link_direct": download_link_direct, } ) if mobile is not False: android_link = settings.GOOGLE_PLAY_FIREFOX_LINK if build == "beta": android_link = android_link.replace("org.mozilla.firefox", "org.mozilla.firefox_beta") if build == "aurora": for arch_pretty in ["ARMv7", "ARMv6", "x86"]: arch = arch_pretty.lower() link = download_urls["aurora-android-%s" % arch] % mobile_details.latest_version("aurora") builds.append( { "os": "os_android", "os_pretty": "Android", "os_arch_pretty": "Android %s" % arch_pretty, "arch": arch, "arch_pretty": arch_pretty, "download_link": link, } ) if build != "aurora": builds.append({"os": "os_android", "os_pretty": "Android", "download_link": android_link}) # Get the native name for current locale langs = firefox_details.languages locale_name = langs[locale]["native"] if locale in langs else locale data = { "locale_name": locale_name, "version": version, "product": "firefox-mobile" if mobile else "firefox", "builds": builds, "id": dom_id, "small": small, "build": alt_build, "show_mobile": mobile is not False, "show_desktop": mobile is not True, "icon": icon, } html = jingo.render_to_string(ctx["request"], "mozorg/download_firefox_button.html", data) return jinja2.Markup(html)
def download_firefox(ctx, build='release', small=False, icon=True, mobile=None, dom_id=None, locale=None, force_direct=False, force_full_installer=False, force_funnelcake=False): """ Output a "download firefox" button. :param ctx: context from calling template. :param build: name of build: 'release', 'beta' or 'aurora'. :param small: Display the small button if True. :param icon: Display the Fx icon on the button if True. :param mobile: Display the android download button if True, the desktop button only if False, and by default (None) show whichever is appropriate for the user's system. :param dom_id: Use this string as the id attr on the element. :param locale: The locale of the download. Default to locale of request. :param force_direct: Force the download URL to be direct. :param force_full_installer: Force the installer download to not be the stub installer (for aurora). :param force_funnelcake: Force the download version for en-US Windows to be 'latest', which bouncer will translate to the funnelcake build. :return: The button html. """ alt_build = '' if build == 'release' else build platform = 'mobile' if mobile else 'desktop' locale = locale or get_locale(ctx['request']) funnelcake_id = ctx.get('funnelcake_id', False) dom_id = dom_id or 'download-button-%s-%s' % (platform, build) l_version = latest_version(locale, build) if l_version: version, platforms = l_version else: locale = 'en-US' version, platforms = latest_version('en-US', build) # Gather data about the build for each platform builds = [] if not mobile: for plat_os in ['Windows', 'Linux', 'Linux 64', 'OS X']: # Fallback to en-US if this plat_os/version isn't available # for the current locale _locale = locale if plat_os not in platforms: _locale = 'en-US' # Special case for the Japanese version for Mac if plat_os == 'OS X' and _locale == 'ja': _locale = 'ja-JP-mac' # Normalize the platform os name plat_os = 'os_%s' % plat_os.lower().replace(' ', '') plat_os_pretty = { 'os_osx': 'Mac OS X', 'os_windows': 'Windows', 'os_linux': 'Linux', 'os_linux64': 'Linux 64-bit', }[plat_os] # And generate all the info download_link = make_download_link( 'firefox', build, version, plat_os, _locale, force_direct=force_direct, force_full_installer=force_full_installer, force_funnelcake=force_funnelcake, funnelcake_id=funnelcake_id, ) # If download_link_direct is False the data-direct-link attr # will not be output, and the JS won't attempt the IE popup. if force_direct: # no need to run make_download_link again with the same args download_link_direct = False else: download_link_direct = make_download_link( 'firefox', build, version, plat_os, _locale, force_direct=True, force_full_installer=force_full_installer, force_funnelcake=force_funnelcake, funnelcake_id=funnelcake_id, ) if download_link_direct == download_link: download_link_direct = False builds.append({ 'os': plat_os, 'os_pretty': plat_os_pretty, 'download_link': download_link, 'download_link_direct': download_link_direct }) if mobile is not False: android_link = settings.GOOGLE_PLAY_FIREFOX_LINK if build == 'beta': android_link = android_link.replace('org.mozilla.firefox', 'org.mozilla.firefox_beta') if build == 'aurora': for arch_pretty in ['ARMv7', 'x86']: arch = arch_pretty.lower() link = (download_urls['aurora-android-%s' % arch] % mobile_details.latest_version('aurora')) builds.append({ 'os': 'os_android', 'os_pretty': 'Android', 'os_arch_pretty': 'Android %s' % arch_pretty, 'arch': arch, 'arch_pretty': arch_pretty, 'download_link': link }) if build != 'aurora': builds.append({ 'os': 'os_android', 'os_pretty': 'Android', 'download_link': android_link }) # Get the native name for current locale langs = firefox_details.languages locale_name = langs[locale]['native'] if locale in langs else locale data = { 'locale_name': locale_name, 'version': version, 'product': 'firefox-mobile' if mobile else 'firefox', 'builds': builds, 'id': dom_id, 'small': small, 'build': alt_build, 'show_mobile': mobile is not False, 'show_desktop': mobile is not True, 'icon': icon, } html = jingo.render_to_string(ctx['request'], 'mozorg/download_firefox_button.html', data) return jinja2.Markup(html)
def download_firefox(ctx, build='release', small=False, icon=True, mobile=None, dom_id=None, locale=None, simple=False, force_direct=False, force_full_installer=False, force_funnelcake=False): """ Output a "download firefox" button. :param ctx: context from calling template. :param build: name of build: 'release', 'beta' or 'aurora'. :param small: Display the small button if True. :param icon: Display the Fx icon on the button if True. :param mobile: Display the android download button if True, the desktop button only if False, and by default (None) show whichever is appropriate for the user's system. :param dom_id: Use this string as the id attr on the element. :param locale: The locale of the download. Default to locale of request. :param simple: Display button with text only if True. Will not display icon or privacy/what's new/systems & languages links. Can be used in conjunction with 'small'. :param force_direct: Force the download URL to be direct. :param force_full_installer: Force the installer download to not be the stub installer (for aurora). :param force_funnelcake: Force the download version for en-US Windows to be 'latest', which bouncer will translate to the funnelcake build. :return: The button html. """ alt_build = '' if build == 'release' else build platform = 'mobile' if mobile else 'desktop' locale = locale or get_locale(ctx['request']) funnelcake_id = ctx.get('funnelcake_id', False) dom_id = dom_id or 'download-button-%s-%s' % (platform, build) l_version = latest_version(locale, build) if l_version: version, platforms = l_version else: locale = 'en-US' version, platforms = latest_version('en-US', build) # Gather data about the build for each platform builds = [] if not mobile: for plat_os in ['Windows', 'Linux', 'Linux 64', 'OS X']: # Fallback to en-US if this plat_os/version isn't available # for the current locale _locale = locale if plat_os not in platforms: _locale = 'en-US' # Special case for the Japanese version for Mac if plat_os == 'OS X' and _locale == 'ja': _locale = 'ja-JP-mac' # Normalize the platform os name plat_os = 'os_%s' % plat_os.lower().replace(' ', '') plat_os_pretty = { 'os_osx': 'Mac OS X', 'os_windows': 'Windows', 'os_linux': 'Linux', 'os_linux64': 'Linux 64-bit', }[plat_os] # And generate all the info download_link = make_download_link( 'firefox', build, version, plat_os, _locale, force_direct=force_direct, force_full_installer=force_full_installer, force_funnelcake=force_funnelcake, funnelcake_id=funnelcake_id, ) # If download_link_direct is False the data-direct-link attr # will not be output, and the JS won't attempt the IE popup. if force_direct: # no need to run make_download_link again with the same args download_link_direct = False else: download_link_direct = make_download_link( 'firefox', build, version, plat_os, _locale, force_direct=True, force_full_installer=force_full_installer, force_funnelcake=force_funnelcake, funnelcake_id=funnelcake_id, ) if download_link_direct == download_link: download_link_direct = False builds.append({'os': plat_os, 'os_pretty': plat_os_pretty, 'download_link': download_link, 'download_link_direct': download_link_direct}) if mobile is not False: android_link = settings.GOOGLE_PLAY_FIREFOX_LINK if build == 'beta': android_link = android_link.replace('org.mozilla.firefox', 'org.mozilla.firefox_beta') if build == 'aurora': for arch_pretty in ['ARMv7', 'x86']: arch = arch_pretty.lower() link = (download_urls['aurora-android-%s' % arch] % mobile_details.latest_version('aurora')) builds.append({'os': 'os_android', 'os_pretty': 'Android', 'os_arch_pretty': 'Android %s' % arch_pretty, 'arch': arch, 'arch_pretty': arch_pretty, 'download_link': link}) if build != 'aurora': builds.append({'os': 'os_android', 'os_pretty': 'Android', 'download_link': android_link}) # Get the native name for current locale langs = firefox_details.languages locale_name = langs[locale]['native'] if locale in langs else locale data = { 'locale_name': locale_name, 'version': version, 'product': 'firefox-mobile' if mobile else 'firefox', 'builds': builds, 'id': dom_id, 'small': small, 'simple': simple, 'build': alt_build, 'show_mobile': mobile is not False, 'show_desktop': mobile is not True, 'icon': icon, } html = jingo.render_to_string(ctx['request'], 'mozorg/download_firefox_button.html', data) return jinja2.Markup(html)