def latest_notes(request, product='firefox', platform=None, channel=None): if not platform: platform = 'desktop' if not channel: channel = 'release' if channel in ['aurora', 'developer']: channel = 'alpha' if channel == 'organizations': channel = 'esr' if product == 'thunderbird': version = thunderbird_desktop.latest_version(channel) elif platform == 'android': version = firefox_android.latest_version(channel) elif platform == 'ios': version = firefox_ios.latest_version(channel) else: version = firefox_desktop.latest_version(channel) if channel == 'beta': version = re.sub(r'b\d+$', 'beta', version) if channel == 'esr': version = re.sub(r'esr$', '', version) dir = 'auroranotes' if channel == 'alpha' else 'releasenotes' path = [product, version, dir] locale = getattr(request, 'locale', None) if product == 'firefox' and platform != 'desktop': path.insert(1, platform) if locale: path.insert(0, locale) return HttpResponseRedirect('/' + '/'.join(path) + '/')
def latest_sysreq(request, channel, product): if product == 'firefox' and channel == 'developer': channel = 'alpha' if channel == 'organizations': channel = 'esr' if product == 'thunderbird': version = thunderbird_desktop.latest_version(channel) elif product == 'mobile': version = firefox_android.latest_version(channel) elif product == 'ios': version = firefox_ios.latest_version(channel) else: version = firefox_desktop.latest_version(channel) if channel == 'beta': version = re.sub(r'b\d+$', 'beta', version) if channel == 'esr': version = re.sub(r'^(\d+).+', r'\1.0', version) dir = 'system-requirements' path = [product, version, dir] locale = getattr(request, 'locale', None) if locale: path.insert(0, locale) return HttpResponseRedirect('/' + '/'.join(path) + '/')
def android_builds(channel, builds=None): builds = builds or [] variations = OrderedDict([ ('api-9', 'Gingerbread'), ('api-15', 'Ice Cream Sandwich+'), ('x86', 'x86'), ]) if channel == 'alpha': version = int(firefox_android.latest_version('alpha').split('.', 1)[0]) for type, arch_pretty in variations.iteritems(): # Android Gingerbread (2.3) is no longer supported as of Firefox 48 if version >= 48 and type == 'api-9': continue link = firefox_android.get_download_url('alpha', type) builds.append({'os': 'android', 'os_pretty': 'Android', 'os_arch_pretty': 'Android %s' % arch_pretty, 'arch': 'x86' if type == 'x86' else 'armv7up %s' % type, 'arch_pretty': arch_pretty, 'download_link': link}) else: link = firefox_android.get_download_url(channel) builds.append({'os': 'android', 'os_pretty': 'Android', 'download_link': link}) return builds
def android_builds(channel, builds=None): builds = builds or [] variations = OrderedDict([ ('api-9', 'Gingerbread'), ('api-15', 'Ice Cream Sandwich+'), ('x86', 'x86'), ]) if channel in ['alpha', 'nightly']: version = int(firefox_android.latest_version(channel).split('.', 1)[0]) for type, arch_pretty in variations.iteritems(): # Android Gingerbread (2.3) is no longer supported as of Firefox 48 if version >= 48 and type == 'api-9': continue link = firefox_android.get_download_url(channel, type) builds.append({ 'os': 'android', 'os_pretty': 'Android', 'os_arch_pretty': 'Android %s' % arch_pretty, 'arch': 'x86' if type == 'x86' else 'armv7up %s' % type, 'arch_pretty': arch_pretty, 'download_link': link }) else: link = firefox_android.get_download_url(channel) builds.append({ 'os': 'android', 'os_pretty': 'Android', 'download_link': link }) return builds
def download_firefox(ctx, channel='release', platform='all', dom_id=None, locale=None, force_direct=False, force_full_installer=False, force_funnelcake=False, alt_copy=None, button_color='green'): """ Output a "download firefox" button. :param ctx: context from calling template. :param channel: name of channel: 'release', 'beta' or 'alpha'. :param platform: Target platform: 'desktop', 'android', 'ios', or 'all'. :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. :param alt_copy: Specifies alternate copy to use for download buttons. :param button_color: color of download button. Default to 'green'. """ show_desktop = platform in ['all', 'desktop'] show_android = platform in ['all', 'android'] show_ios = platform in ['all', 'ios'] alt_channel = '' if channel == 'release' else channel locale = locale or get_locale(ctx['request']) funnelcake_id = ctx.get('funnelcake_id', False) dom_id = dom_id or 'download-button-%s-%s' % ( 'desktop' if platform == 'all' else platform, channel) # Gather data about the build for each platform builds = [] if show_desktop: l_version = firefox_desktop.latest_builds(locale, channel) if l_version: version, platforms = l_version else: locale = 'en-US' version, platforms = firefox_desktop.latest_builds('en-US', channel) for plat_os, plat_os_pretty in firefox_desktop.platform_labels.iteritems(): os_pretty = plat_os_pretty # Firefox Nightly: The Windows stub installer is now universal, # automatically detecting a 32-bit and 64-bit desktop, so the # win64-specific entry can be skipped. if channel == 'nightly': if plat_os == 'win': os_pretty = 'Windows 32/64-bit' if plat_os == 'win64': continue # Fallback to en-US if this plat_os/version isn't available # for the current locale _locale = locale if plat_os_pretty in platforms else 'en-US' # And generate all the info download_link = firefox_desktop.get_download_url( channel, 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 get_download_url again with the same args download_link_direct = False else: download_link_direct = firefox_desktop.get_download_url( channel, 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': os_pretty, 'download_link': download_link, 'download_link_direct': download_link_direct}) if show_android: version = firefox_android.latest_version(channel) builds = android_builds(channel, builds) if show_ios: version = firefox_ios.latest_version(channel) builds.append({'os': 'ios', 'os_pretty': 'iOS', 'download_link': firefox_ios.get_download_url()}) # Get the native name for current locale langs = firefox_desktop.languages locale_name = langs[locale]['native'] if locale in langs else locale # Firefox 49+ requires OS X 10.9 Mavericks and later mavericks_required = show_desktop and int(version.split('.', 1)[0]) >= 49 data = { 'locale_name': locale_name, 'version': version, 'product': 'firefox-%s' % platform, 'builds': builds, 'id': dom_id, 'channel': alt_channel, 'show_desktop': show_desktop, 'show_android': show_android, 'show_ios': show_ios, 'alt_copy': alt_copy, 'button_color': button_color, 'mavericks_required': mavericks_required, } html = render_to_string('firefox/includes/download-button.html', data, request=ctx['request']) return jinja2.Markup(html)
def download_firefox(ctx, channel='release', platform='all', dom_id=None, locale=None, force_direct=False, force_full_installer=False, force_funnelcake=False, alt_copy=None, button_color='button-green', locale_in_transition=False): """ Output a "download firefox" button. :param ctx: context from calling template. :param channel: name of channel: 'release', 'beta', 'alpha', or 'nightly'. :param platform: Target platform: 'desktop', 'android', 'ios', or 'all'. :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. :param alt_copy: Specifies alternate copy to use for download buttons. :param button_color: color of download button. Default to 'button-green'. """ show_desktop = platform in ['all', 'desktop'] show_android = platform in ['all', 'android'] show_ios = platform in ['all', 'ios'] alt_channel = '' if channel == 'release' else channel locale = locale or get_locale(ctx['request']) funnelcake_id = ctx.get('funnelcake_id', False) dom_id = dom_id or 'download-button-%s-%s' % ( 'desktop' if platform == 'all' else platform, channel) # Gather data about the build for each platform builds = [] if show_desktop: version = firefox_desktop.latest_version(channel) builds = desktop_builds(channel, builds, locale, force_direct, force_full_installer, force_funnelcake, funnelcake_id, locale_in_transition) if show_android: version = firefox_android.latest_version(channel) builds = android_builds(channel, builds) if show_ios: version = firefox_ios.latest_version(channel) builds.append({ 'os': 'ios', 'os_pretty': 'iOS', 'download_link': firefox_ios.get_download_url() }) # Get the native name for current locale langs = firefox_desktop.languages locale_name = langs[locale]['native'] if locale in langs else locale data = { 'locale_name': locale_name, 'version': version, 'product': 'firefox-%s' % platform, 'builds': builds, 'id': dom_id, 'channel': alt_channel, 'show_desktop': show_desktop, 'show_android': show_android, 'show_ios': show_ios, 'alt_copy': alt_copy, 'button_color': button_color, } html = render_to_string('firefox/includes/download-button.html', data, request=ctx['request']) return jinja2.Markup(html)
def download_firefox(ctx, channel='release', platform='all', dom_id=None, locale=None, force_direct=False, force_full_installer=False, force_funnelcake=False, alt_copy=None, button_color='green'): """ Output a "download firefox" button. :param ctx: context from calling template. :param channel: name of channel: 'release', 'beta' or 'alpha'. :param platform: Target platform: 'desktop', 'android', 'ios', or 'all'. :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. :param alt_copy: Specifies alternate copy to use for download buttons. :param button_color: color of download button. Default to 'green'. """ show_desktop = platform in ['all', 'desktop'] show_android = platform in ['all', 'android'] show_ios = platform in ['all', 'ios'] alt_channel = '' if channel == 'release' else channel locale = locale or get_locale(ctx['request']) funnelcake_id = ctx.get('funnelcake_id', False) dom_id = dom_id or 'download-button-%s-%s' % ( 'desktop' if platform == 'all' else platform, channel) # Gather data about the build for each platform builds = [] if show_desktop: l_version = firefox_desktop.latest_builds(locale, channel) if l_version: version, platforms = l_version else: locale = 'en-US' version, platforms = firefox_desktop.latest_builds( 'en-US', channel) for plat_os, plat_os_pretty in firefox_desktop.platform_labels.iteritems( ): os_pretty = plat_os_pretty # Firefox Nightly: The Windows stub installer is now universal, # automatically detecting a 32-bit and 64-bit desktop, so the # win64-specific entry can be skipped. if channel == 'nightly': if plat_os == 'win': os_pretty = 'Windows 32/64-bit' if plat_os == 'win64': continue # Fallback to en-US if this plat_os/version isn't available # for the current locale _locale = locale if plat_os_pretty in platforms else 'en-US' # And generate all the info download_link = firefox_desktop.get_download_url( channel, 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 get_download_url again with the same args download_link_direct = False else: download_link_direct = firefox_desktop.get_download_url( channel, 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': os_pretty, 'download_link': download_link, 'download_link_direct': download_link_direct }) if show_android: version = firefox_android.latest_version(channel) builds = android_builds(channel, builds) if show_ios: version = firefox_ios.latest_version(channel) builds.append({ 'os': 'ios', 'os_pretty': 'iOS', 'download_link': firefox_ios.get_download_url() }) # Get the native name for current locale langs = firefox_desktop.languages locale_name = langs[locale]['native'] if locale in langs else locale # Firefox 49+ requires OS X 10.9 Mavericks and later mavericks_required = show_desktop and int(version.split('.', 1)[0]) >= 49 data = { 'locale_name': locale_name, 'version': version, 'product': 'firefox-%s' % platform, 'builds': builds, 'id': dom_id, 'channel': alt_channel, 'show_desktop': show_desktop, 'show_android': show_android, 'show_ios': show_ios, 'alt_copy': alt_copy, 'button_color': button_color, 'mavericks_required': mavericks_required, } html = render_to_string('firefox/includes/download-button.html', data, request=ctx['request']) return jinja2.Markup(html)
def download_firefox( ctx, channel="release", platform="all", dom_id=None, locale=None, force_direct=False, force_full_installer=False, force_funnelcake=False, alt_copy=None, button_class="mzp-t-xl", locale_in_transition=False, download_location=None, ): """Output a "download firefox" button. :param ctx: context from calling template. :param channel: name of channel: 'release', 'beta', 'alpha', or 'nightly'. :param platform: Target platform: 'desktop', 'android', 'ios', or 'all'. :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. :param alt_copy: Specifies alternate copy to use for download buttons. :param button_class: Classes to add to the download button, contains size mzp-t-xl by default :param locale_in_transition: Include the page locale in transitional download link. :param download_location: Specify the location of download button for GA reporting: 'primary cta', 'nav', 'sub nav', or 'other'. """ show_desktop = platform in ["all", "desktop"] show_android = platform in ["all", "android"] show_ios = platform in ["all", "ios"] alt_channel = "" if channel == "release" else channel locale = locale or get_locale(ctx["request"]) funnelcake_id = ctx.get("funnelcake_id", False) dom_id = dom_id or f"download-button-{'desktop' if platform == 'all' else platform}-{channel}" # Gather data about the build for each platform builds = [] if show_desktop: version = firefox_desktop.latest_version(channel) builds = desktop_builds(channel, builds, locale, force_direct, force_full_installer, force_funnelcake, funnelcake_id, locale_in_transition) if show_android: version = firefox_android.latest_version(channel) builds = android_builds(channel, builds) if show_ios: version = firefox_ios.latest_version(channel) builds.append({ "os": "ios", "os_pretty": "iOS", "download_link": firefox_ios.get_download_url() }) # Get the native name for current locale langs = firefox_desktop.languages locale_name = langs[locale]["native"] if locale in langs else locale data = { "locale_name": locale_name, "version": version, "product": f"firefox-{platform}", "builds": builds, "id": dom_id, "channel": alt_channel, "show_desktop": show_desktop, "show_android": show_android, "show_ios": show_ios, "alt_copy": alt_copy, "button_class": button_class, "download_location": download_location, "fluent_l10n": ctx["fluent_l10n"], } html = render_to_string("firefox/includes/download-button.html", data, request=ctx["request"]) return jinja2.Markup(html)
def download_firefox(ctx, channel='release', platform='all', dom_id=None, locale=None, force_direct=False, force_full_installer=False, force_funnelcake=False, alt_copy=None, button_color='button-green'): """ Output a "download firefox" button. :param ctx: context from calling template. :param channel: name of channel: 'release', 'beta', 'alpha', or 'nightly'. :param platform: Target platform: 'desktop', 'android', 'ios', or 'all'. :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. :param alt_copy: Specifies alternate copy to use for download buttons. :param button_color: color of download button. Default to 'button-green'. """ show_desktop = platform in ['all', 'desktop'] show_android = platform in ['all', 'android'] show_ios = platform in ['all', 'ios'] alt_channel = '' if channel == 'release' else channel locale = locale or get_locale(ctx['request']) funnelcake_id = ctx.get('funnelcake_id', False) dom_id = dom_id or 'download-button-%s-%s' % ( 'desktop' if platform == 'all' else platform, channel) # Gather data about the build for each platform builds = [] if show_desktop: version = firefox_desktop.latest_version(channel) builds = desktop_builds(channel, builds, locale, force_direct, force_full_installer, force_funnelcake, funnelcake_id) if show_android: version = firefox_android.latest_version(channel) builds = android_builds(channel, builds) if show_ios: version = firefox_ios.latest_version(channel) builds.append({'os': 'ios', 'os_pretty': 'iOS', 'download_link': firefox_ios.get_download_url()}) # Get the native name for current locale langs = firefox_desktop.languages locale_name = langs[locale]['native'] if locale in langs else locale # Firefox 49+ requires OS X 10.9 Mavericks and later mavericks_required = show_desktop and int(version.split('.', 1)[0]) >= 49 data = { 'locale_name': locale_name, 'version': version, 'product': 'firefox-%s' % platform, 'builds': builds, 'id': dom_id, 'channel': alt_channel, 'show_desktop': show_desktop, 'show_android': show_android, 'show_ios': show_ios, 'alt_copy': alt_copy, 'button_color': button_color, 'mavericks_required': mavericks_required, } html = render_to_string('firefox/includes/download-button.html', data, request=ctx['request']) return jinja2.Markup(html)