Example #1
0
def desktop_builds(channel, builds=None, locale=None, force_direct=False,
                   force_full_installer=False, force_funnelcake=False,
                   funnelcake_id=False):
    builds = builds or []

    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})

    return builds
Example #2
0
def desktop_builds(channel, builds=None, locale=None, force_direct=False,
                   force_full_installer=False, force_funnelcake=False,
                   funnelcake_id=False):
    builds = builds or []

    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

        # 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})

    return builds
Example #3
0
def download_firefox_thanks(ctx,
                            dom_id=None,
                            locale=None,
                            alt_copy=None,
                            button_class=None,
                            locale_in_transition=False,
                            download_location=None):
    """ Output a simple "download firefox" button that only points to /download/thanks/

    :param ctx: context from calling template.
    :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 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'.
    """

    channel = 'release'
    locale = locale or get_locale(ctx['request'])
    funnelcake_id = ctx.get('funnelcake_id', False)
    dom_id = dom_id or 'download-button-thanks'
    transition_url = '/firefox/download/thanks/'
    version = firefox_desktop.latest_version(channel)

    # if there's a funnelcake param in the page URL e.g. ?f=123
    if funnelcake_id:
        # include param in transitional URL e.g. /firefox/download/thanks/?f=123
        transition_url += '?f=%s' % funnelcake_id

    if locale_in_transition:
        transition_url = '/%s%s' % (locale, transition_url)

    download_link_direct = firefox_desktop.get_download_url(
        channel,
        version,
        'win',
        locale,
        force_direct=True,
        force_full_installer=False,
        force_funnelcake=False,
        funnelcake_id=funnelcake_id,
    )

    data = {
        'id': dom_id,
        'transition_url': transition_url,
        'download_link_direct': download_link_direct,
        '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-thanks.html',
                            data,
                            request=ctx['request'])
    return jinja2.Markup(html)
Example #4
0
def download_firefox_thanks(ctx,
                            dom_id=None,
                            locale=None,
                            alt_copy=None,
                            button_class=None,
                            locale_in_transition=False,
                            download_location=None):
    """Output a simple "download firefox" button that only points to /download/thanks/

    :param ctx: context from calling template.
    :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 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'.
    """

    channel = "release"
    locale = locale or get_locale(ctx["request"])
    funnelcake_id = ctx.get("funnelcake_id", False)
    dom_id = dom_id or "download-button-thanks"
    transition_url = "/firefox/download/thanks/"
    version = firefox_desktop.latest_version(channel)

    # if there's a funnelcake param in the page URL e.g. ?f=123
    if funnelcake_id:
        # include param in transitional URL e.g. /firefox/download/thanks/?f=123
        transition_url += f"?f={funnelcake_id}"

    if locale_in_transition:
        transition_url = f"/{locale}{transition_url}"

    download_link_direct = firefox_desktop.get_download_url(
        channel,
        version,
        "win",
        locale,
        force_direct=True,
        force_full_installer=False,
        force_funnelcake=False,
        funnelcake_id=funnelcake_id,
    )

    data = {
        "id": dom_id,
        "transition_url": transition_url,
        "download_link_direct": download_link_direct,
        "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-thanks.html",
                            data,
                            request=ctx["request"])
    return jinja2.Markup(html)
Example #5
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)
Example #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)

    # 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)
Example #7
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)
Example #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='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)
Example #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' 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']
    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)

    # 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-android' if platform == 'android' else 'firefox',
        'builds': builds,
        'id': dom_id,
        'small': small,
        'simple': simple,
        'channel': alt_channel,
        'show_android': show_android,
        'show_desktop': show_desktop,
        '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)
Example #10
0
def desktop_builds(
    channel,
    builds=None,
    locale=None,
    force_direct=False,
    force_full_installer=False,
    force_funnelcake=False,
    funnelcake_id=False,
    locale_in_transition=False,
    classified=False,
):
    builds = builds or []

    l_version = firefox_desktop.latest_builds(locale, channel)

    # Developer Edition is now based on the Beta channel, so the build list
    # should be generated from the Beta locales.
    if channel == "alpha":
        l_version = firefox_desktop.latest_builds(locale, "beta")

    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.platforms(
            channel, classified):

        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":
                continue
            if plat_os == "win64":
                plat_os = "win"
                os_pretty = "Windows 32/64-bit"

        # 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,
            locale_in_transition=locale_in_transition,
        )

        # 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
        })

    return builds
Example #11
0
def desktop_builds(channel,
                   builds=None,
                   locale=None,
                   force_direct=False,
                   force_full_installer=False,
                   force_funnelcake=False,
                   funnelcake_id=False,
                   locale_in_transition=False,
                   classified=False):
    builds = builds or []

    l_version = firefox_desktop.latest_builds(locale, channel)

    # Developer Edition is now based on the Beta channel, so the build list
    # should be generated from the Beta locales.
    if channel == 'alpha':
        l_version = firefox_desktop.latest_builds(locale, 'beta')

    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.platforms(
            channel, classified):
        # only include sha1 builds for release channel
        if plat_os == 'winsha1' and channel != 'release':
            continue

        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':
                continue
            if plat_os == 'win64':
                plat_os = 'win'
                os_pretty = 'Windows 32/64-bit'

        # 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,
            locale_in_transition=locale_in_transition,
        )

        # 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
        })

    return builds
Example #12
0
def desktop_builds(channel, builds=None, locale=None, force_direct=False,
                   force_full_installer=False, force_funnelcake=False,
                   funnelcake_id=False, locale_in_transition=False):
    builds = builds or []

    l_version = firefox_desktop.latest_builds(locale, channel)

    # Developer Edition is now based on the Beta channel, so the build list
    # should be generated from the Beta locales.
    if channel == 'alpha':
        l_version = firefox_desktop.latest_builds(locale, 'beta')

    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():
        # only include sha1 builds for release channel
        if plat_os == 'winsha1' and channel != 'release':
            continue

        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

        # 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,
            locale_in_transition=locale_in_transition,
        )

        # 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})

    return builds