Пример #1
0
def ios_builds(channel, builds=None):
    builds = builds or []
    link = firefox_ios.get_download_url(channel)
    builds.append({'os': 'ios',
                   'os_pretty': 'iOS',
                   'download_link': link})

    return builds
Пример #2
0
def ios_builds(channel, builds=None):
    builds = builds or []
    link = firefox_ios.get_download_url(channel)
    builds.append({'os': 'ios',
                   'os_pretty': 'iOS',
                   'download_link': link})

    return builds
Пример #3
0
def firefox_ios_url(ctx, ct_param=None):
    """
    Output a link to the Firefox for iOS download page on the Apple App Store
    taking locales into account.

    Use the locale from the current request. Check if the locale matches one of
    the Store's supported countries, return the localized page's URL or fall
    back to the default (English) page if not.

    The optional ct_param is a campaign value for the app analytics.

    Examples
    ========

    In Template
    -----------

        {{ firefox_ios_url() }}

    For en-US this would output:

        https://itunes.apple.com/us/app/apple-store/id989804926?pt=373246&mt=8

    For es-ES this would output:

        https://itunes.apple.com/es/app/apple-store/id989804926?pt=373246&mt=8

    For ja this would output:

        https://itunes.apple.com/jp/app/apple-store/id989804926?pt=373246&mt=8

    """
    locale = getattr(ctx['request'], 'locale', 'en-US')
    link = firefox_ios.get_download_url('release', locale)

    if ct_param:
        return link + '&ct=' + ct_param

    return link
Пример #4
0
def firefox_ios_url(ctx, ct_param=None):
    """
    Output a link to the Firefox for iOS download page on the Apple App Store
    taking locales into account.

    Use the locale from the current request. Check if the locale matches one of
    the Store's supported countries, return the localized page's URL or fall
    back to the default (English) page if not.

    The optional ct_param is a campaign value for the app analytics.

    Examples
    ========

    In Template
    -----------

        {{ firefox_ios_url() }}

    For en-US this would output:

        https://itunes.apple.com/us/app/apple-store/id989804926?pt=373246&mt=8

    For es-ES this would output:

        https://itunes.apple.com/es/app/apple-store/id989804926?pt=373246&mt=8

    For ja this would output:

        https://itunes.apple.com/jp/app/apple-store/id989804926?pt=373246&mt=8

    """
    locale = getattr(ctx['request'], 'locale', 'en-US')
    link = firefox_ios.get_download_url('release', locale)

    if ct_param:
        return link + '&ct=' + ct_param

    return link
Пример #5
0
def firefox_ios_url(ctx, ct_param=None):
    """
    Output a link to the Firefox for iOS download page on the Apple App Store
    taking locales into account.

    Use the locale from the current request. Check if the locale matches one of
    the Store's supported countries, return the localized page's URL or fall
    back to the default (English) page if not.

    The optional ct_param is a campaign value for the app analytics.

    Examples
    ========

    In Template
    -----------

        {{ firefox_ios_url() }}

    For en-US this would output:

        https://itunes.apple.com/us/app/firefox-private-safe-browser/id989804926

    For es-ES this would output:

        https://itunes.apple.com/es/app/firefox-private-safe-browser/id989804926

    For ja this would output:

        https://itunes.apple.com/jp/app/firefox-private-safe-browser/id989804926

    """
    locale = getattr(ctx["request"], "locale", "en-US")
    link = firefox_ios.get_download_url("release", locale)

    if ct_param:
        return link + "?ct=" + ct_param

    return link
Пример #6
0
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)

    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)

    # Gather data about the build for each platform
    builds = []

    if show_desktop:
        for plat_os, plat_os_pretty in firefox_desktop.platform_labels.iteritems():
            # Windows 64-bit builds are not available in Firefox 38 ESR
            # TODO: Remove this exception once 38 ESR reaches EOL on 2016-06-07
            if plat_os == 'win64' and channel == 'esr':
                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': plat_os_pretty,
                           'download_link': download_link,
                           'download_link_direct': download_link_direct})

    if show_android:
        builds = android_builds(channel, builds)

    if show_ios:
        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 = jingo.render_to_string(ctx['request'],
                                  'firefox/includes/download-button.html',
                                  data)
    return jinja2.Markup(html)
Пример #7
0
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)
Пример #8
0
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)
Пример #9
0
def download_firefox(ctx,
                     channel='release',
                     small=False,
                     icon=True,
                     platform='all',
                     dom_id=None,
                     locale=None,
                     simple=False,
                     force_direct=False,
                     force_full_installer=False,
                     force_funnelcake=False,
                     check_old_fx=False):
    """ Output a "download firefox" button.

    :param ctx: context from calling template.
    :param channel: name of channel: 'release', 'beta' or 'alpha'.
    :param small: Display the small button if True.
    :param icon: Display the Fx icon on the button if True.
    :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 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.
    :param check_old_fx: Checks to see if the user is on an old version of
            Firefox and, if true, changes the button text from 'Free Download'
            to 'Update your Firefox'. Must be used in conjunction with
            'simple' param being true.
    :return: The button html.
    """
    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)

    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)

    # Gather data about the build for each platform
    builds = []

    if show_desktop:
        for plat_os, plat_os_pretty in firefox_desktop.platform_labels.iteritems(
        ):
            # Windows 64-bit builds are currently available only on the Aurora
            # and Beta channel
            if plat_os == 'win64' and channel not in ['alpha', 'beta']:
                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': plat_os_pretty,
                'download_link': download_link,
                'download_link_direct': download_link_direct
            })

    if show_android:
        builds = android_builds(channel, builds)

    if show_ios:
        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,
        'small': small,
        'simple': simple,
        'channel': alt_channel,
        'show_desktop': show_desktop,
        'show_android': show_android,
        'show_ios': show_ios,
        'icon': icon,
        'check_old_fx': check_old_fx and simple,
    }

    html = jingo.render_to_string(ctx['request'],
                                  'firefox/includes/download-button.html',
                                  data)
    return jinja2.Markup(html)
Пример #10
0
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)
Пример #11
0
def download_firefox(ctx, channel='release', small=False, icon=True,
                     platform='all', dom_id=None, locale=None, simple=False,
                     force_direct=False, force_full_installer=False,
                     force_funnelcake=False, check_old_fx=False):
    """ Output a "download firefox" button.

    :param ctx: context from calling template.
    :param channel: name of channel: 'release', 'beta' or 'alpha'.
    :param small: Display the small button if True.
    :param icon: Display the Fx icon on the button if True.
    :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 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.
    :param check_old_fx: Checks to see if the user is on an old version of
            Firefox and, if true, changes the button text from 'Free Download'
            to 'Update your Firefox'. Must be used in conjunction with
            'simple' param being true.
    :return: The button html.
    """
    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)

    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)

    # Gather data about the build for each platform
    builds = []

    if show_desktop:
        for plat_os, plat_os_pretty in firefox_desktop.platform_labels.iteritems():
            # Windows 64-bit builds are not available on the ESR channel yet
            if plat_os == 'win64' and channel in ['esr', 'esr_next']:
                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': plat_os_pretty,
                           'download_link': download_link,
                           'download_link_direct': download_link_direct})

    if show_android:
        builds = android_builds(channel, builds)

    if show_ios:
        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,
        'small': small,
        'simple': simple,
        'channel': alt_channel,
        'show_desktop': show_desktop,
        'show_android': show_android,
        'show_ios': show_ios,
        'icon': icon,
        'check_old_fx': check_old_fx and simple,
    }

    html = jingo.render_to_string(ctx['request'],
                                  'firefox/includes/download-button.html',
                                  data)
    return jinja2.Markup(html)
Пример #12
0
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)
Пример #13
0
def ios_builds(channel, builds=None):
    builds = builds or []
    link = firefox_ios.get_download_url(channel)
    builds.append({"os": "ios", "os_pretty": "iOS", "download_link": link})

    return builds
Пример #14
0
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)