Skip to content

Commit

Permalink
Merge pull request #4519 from craigcook/bug-1319244-test-developer-se…
Browse files Browse the repository at this point in the history
…arch

[bug 1319244] Test developer and general search
  • Loading branch information
pmac committed Dec 15, 2016
2 parents d962ef4 + 9b36263 commit a99d303
Show file tree
Hide file tree
Showing 22 changed files with 256 additions and 34 deletions.
14 changes: 14 additions & 0 deletions bedrock/base/templates/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

{% extends "base-resp.html" %}

{% from 'macros.html' import google_custom_search with context %}

{% block gtm_page_id %}data-gtm-page-id="404"{% endblock %}

{% block page_title %}{{ _('404: Page Not Found') }}{% endblock %}
Expand All @@ -13,6 +15,18 @@
{% stylesheet 'page_not_found' %}
{% endblock %}

{% block js %}
{% if LANG.startswith('en-') and switch('mozorg-search-general') %}
{% javascript 'custom-search' %}
{% endif %}
{% endblock %}

{% block site_header_unwrapped %}
{% if LANG.startswith('en-') and switch('mozorg-search-general') %}
{{ google_custom_search(settings.GOOG_CUSTOM_SEARCH_TYPES['general'], 'moz-search-general', _('Internet Health'), _('Volunteer, Events, Add-ons, Firefox, Internet Health')) }}
{% endif %}
{% endblock %}

{% block content %}
<div id="main-feature">
<div id="error-content">
Expand Down
10 changes: 0 additions & 10 deletions bedrock/base/templates/includes/google-search-activist.html

This file was deleted.

24 changes: 24 additions & 0 deletions bedrock/base/templates/macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -474,3 +474,27 @@ <h2 class="thank-you hidden">{{ _('Your download link was sent.') }}</h2>
</footer>
</section>
{%- endmacro %}


{% macro google_custom_search(search_type, type_class, default_term, term_list) %}
{#
Parameters -
search_type: The 'cx' hash for the specific custom search configuration, defined in settings/base.py
Example: settings.GOOG_CUSTOM_SEARCH_TYPES['general']
Defaults to general search.

search_class: A class added to the bar for use as a style hook to customize the presentation.

term_list: A comma separated list of suggested terms displayed in a loop via JS.

default_term: A static suggested term to avoid an empty label if JS fails. This should
usually be the same as the last term in the list (last to avoid clumsy repetition
when JS kicks in to start the cycle).
#}
<aside id="moz-search" class="moz-search {{ search_class }}" data-terms="{{ term_list }}" data-search-type="{% if search_type %}{{ search_type }}{% else %}{{ settings.GOOG_CUSTOM_SEARCH_TYPES['general'] }}{% endif %}">
<div class="content">
<label class="search-label" for="gsc-i-id1"><span class="search-label-prefix">{{ _('Search Mozilla:') }}</span> <span class="search-label-term">{{ default_term }}</span></label>
<gcse:search gname="mozsearch"></gcse:search>
</div>
</aside>
{%- endmacro %}
2 changes: 2 additions & 0 deletions bedrock/firefox/templates/firefox/channel/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
</ul>
</nav>
</div>

{% block search %}{% endblock %}
</header>
{% endblock %}

Expand Down
20 changes: 20 additions & 0 deletions bedrock/firefox/templates/firefox/channel/desktop.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,29 @@

{% extends "firefox/channel/base.html" %}

{% from 'macros.html' import google_custom_search with context %}

{% add_lang_files "firefox/channel/index" %}

{% block experiments %}
{% if LANG.startswith('en-') and switch('mozorg-search-developer') %}
{% javascript 'experiment-search-developer' %}
{% endif %}
{% endblock %}

{% block page_desc %}{{_('Download and test the latest Firefox for desktop features with Developer Edition, Beta and Nightly builds.')}}{% endblock %}

{#- This will appear as <meta property="og:description"> which can be used for social share -#}
{% block page_og_desc %}{{ self.page_desc() }}{% endblock %}

{% block body_id %}platform-desktop{% endblock %}

{% block search %}
{% if version == 'b' and switch('mozorg-search-developer') %}
{{ google_custom_search(settings.GOOG_CUSTOM_SEARCH_TYPES['developer'], 'moz-search-developer', _('Virtual Reality'), _('Internet of Things, Add-ons, Events, JavaScript Help, Virtual Reality')) }}
{% endif %}
{% endblock %}

{% block channels %}
<section id="beta" class="channel">
<div class="container">
Expand Down Expand Up @@ -86,3 +100,9 @@ <h2>{{_('Nightly')}}</h2>
</footer>
</section>
{% endblock %}

{% block js %}
{% if LANG.startswith('en-') and switch('mozorg-search-developer') %}
{% javascript 'custom-search' %}
{% endif %}
{% endblock %}
18 changes: 18 additions & 0 deletions bedrock/firefox/templates/firefox/developer.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

{% extends "firefox/base-resp.html" %}

{% from 'macros.html' import google_custom_search with context %}

{% block page_title_prefix %}{% endblock %}
{% block page_title %}{{_('Firefox Developer Edition')}}{% endblock %}
{% block page_favicon %}{{ static('img/firefox/developer/favicon.png') }}{% endblock %}
Expand All @@ -26,8 +28,18 @@ <h2>{{ high_res_img('firefox/developer/title.png', {'alt': _('Firefox Developer
{% stylesheet 'firefox_developer' %}
{% endblock %}

{% block experiments %}
{% if LANG.startswith('en-') and switch('mozorg-search-developer') %}
{% javascript 'experiment-search-developer' %}
{% endif %}
{% endblock %}

{% block js %}
{% javascript 'firefox_developer' %}

{% if version == 'b' and switch('mozorg-search-developer') %}
{% javascript 'custom-search' %}
{% endif %}
{% endblock %}

{% block site_header_share %}
Expand All @@ -36,6 +48,12 @@ <h2>{{ high_res_img('firefox/developer/title.png', {'alt': _('Firefox Developer
{{ share_cta(_('Share'), share_urls, share_text, 'spread-firefox-developer', 'sky mini') }}
{% endblock %}

{% block site_header_unwrapped %}
{% if version == 'b' and switch('mozorg-search-developer') %}
{{ google_custom_search(settings.GOOG_CUSTOM_SEARCH_TYPES['developer'], 'moz-search-developer', _('Virtual Reality'), _('Internet of Things, Add-ons, Events, JavaScript Help, Virtual Reality')) }}
{% endif %}
{% endblock %}

{% block content %}

<section class="intro container">
Expand Down
4 changes: 2 additions & 2 deletions bedrock/firefox/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
url(r'^firefox/(?:%s/)?(?:%s/)?all/$' % (platform_re, channel_re),
views.all_downloads, name='firefox.all'),
page('firefox/accounts', 'firefox/accounts.html'),
page('firefox/channel/desktop', 'firefox/channel/desktop.html'),
url(r'^firefox/channel/desktop', views.channel_desktop, name='firefox.channel.desktop'),
page('firefox/channel/android', 'firefox/channel/android.html'),
page('firefox/channel/ios', 'firefox/channel/ios.html'),
page('firefox/desktop', 'firefox/desktop/index.html'),
page('firefox/desktop/fast', 'firefox/desktop/fast.html'),
page('firefox/desktop/customize', 'firefox/desktop/customize.html'),
page('firefox/desktop/tips', 'firefox/desktop/tips.html'),
page('firefox/desktop/trust', 'firefox/desktop/trust.html'),
page('firefox/developer', 'firefox/developer.html'),
url(r'^firefox/developer', views.developer, name='firefox.developer'),
page('firefox/features', 'firefox/features.html'),
page('firefox/geolocation', 'firefox/geolocation.html'),
page('firefox/interest-dashboard', 'firefox/interest-dashboard.html'),
Expand Down
20 changes: 20 additions & 0 deletions bedrock/firefox/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,26 @@ def sync(request):
return l10n_utils.render(request, 'firefox/sync.html', {'version': version})


def channel_desktop(request):
locale = l10n_utils.get_locale(request)
version = request.GET.get('v', None)

if (locale != 'en-US' or version != 'b'):
version = None

return l10n_utils.render(request, 'firefox/channel/desktop.html', {'version': version})


def developer(request):
locale = l10n_utils.get_locale(request)
version = request.GET.get('v', None)

if (locale != 'en-US' or version != 'b'):
version = None

return l10n_utils.render(request, 'firefox/developer.html', {'version': version})


def ios_testflight(request):
# no country field, so no need to send locale
newsletter_form = NewsletterFooterForm('ios-beta-test-flight', '')
Expand Down
6 changes: 4 additions & 2 deletions bedrock/foundation/templates/foundation/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@

{% extends "foundation/base-resp.html" %}

{% from 'macros.html' import google_custom_search with context %}

{% block page_title %}{{ _('The Mozilla Foundation') }}{% endblock %}

{% set body_id = "index" %}

{% block js %}
{% if LANG.startswith('en-') and switch('mozorg-search-activist') %}
{% javascript 'search-activist' %}
{% javascript 'custom-search' %}
{% endif %}
{% endblock %}

{% block search %}
{% if LANG.startswith('en-') and switch('mozorg-search-activist') %}
{% include 'includes/google-search-activist.html' %}
{{ google_custom_search(settings.GOOG_CUSTOM_SEARCH_TYPES['activist'], 'moz-search-activist', _('Cybersecurity'), _('Net Neutrality, Encryption, Surveillance, Copyright Law, Cybersecurity')) }}
{% endif %}
{% endblock %}

Expand Down
7 changes: 5 additions & 2 deletions bedrock/mozorg/templates/mozorg/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

{% extends "mozorg/base-resp.html" %}

{% from 'macros.html' import google_custom_search with context %}

{% block page_title %}{{ _('Get to know Mozilla') }}{% endblock %}
{% block body_id %}about{% endblock %}
{% block body_class %}sand{% endblock %}
Expand All @@ -22,16 +24,17 @@
{% javascript 'about_video' %}

{% if LANG.startswith('en-') and switch('mozorg-search-activist') %}
{% javascript 'search-activist' %}
{% javascript 'custom-search' %}
{% endif %}
{% endblock %}

{% block content %}
<main>
<header class="page-header">
{% if LANG.startswith('en-') and switch('mozorg-search-activist') %}
{% include 'includes/google-search-activist.html' %}
{{ google_custom_search(settings.GOOG_CUSTOM_SEARCH_TYPES['activist'], 'moz-search-activist', _('Cybersecurity'), _('Net Neutrality, Encryption, Surveillance, Copyright Law, Cybersecurity')) }}
{% endif %}

<h1><span class="content">{{ _('Get to know Mozilla') }}</span></h1>
</header>

Expand Down
7 changes: 4 additions & 3 deletions bedrock/mozorg/templates/mozorg/about/manifesto.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
{% else %}
{#- Show the redesigned landing page -#}

{% from 'macros.html' import twitter_share_url, share_cta with context %}
{% extends 'mozorg/base-resp.html' %}

{% from 'macros.html' import twitter_share_url, share_cta, google_custom_search with context %}

{% block page_title %}{{ _('The Mozilla Manifesto') }}{% endblock %}
{% block page_title_suffix %}{% endblock %}
{% block page_desc %}{{ _('These are the principles that guide our mission to promote openness, innovation & opportunity on the Web.') }}{% endblock %}
Expand Down Expand Up @@ -59,7 +60,7 @@ <h1 itemprop="name">{{ self.page_title() }}</h1>
</header>

{% if LANG.startswith('en-') and switch('mozorg-search-activist') %}
{% include 'includes/google-search-activist.html' %}
{{ google_custom_search(settings.GOOG_CUSTOM_SEARCH_TYPES['activist'], 'moz-search-activist', _('Cybersecurity'), _('Net Neutrality, Encryption, Surveillance, Copyright Law, Cybersecurity')) }}
{% endif %}

<div id="main-content">
Expand Down Expand Up @@ -334,7 +335,7 @@ <h2>{{ _('Learn more about…') }}</h2>
{% javascript 'manifesto' %}

{% if LANG.startswith('en-') and switch('mozorg-search-activist') %}
{% javascript 'search-activist' %}
{% javascript 'custom-search' %}
{% endif %}
{% endblock %}

Expand Down
12 changes: 12 additions & 0 deletions bedrock/mozorg/templates/mozorg/contribute/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@

{% extends "mozorg/contribute/contribute-base.html" %}

{% from 'macros.html' import google_custom_search with context %}

{% block page_title %}
{{ _('Volunteer Opportunities at Mozilla') }}
{% endblock %}

{% block body_id %}landing{% endblock %}

{% block site_header_unwrapped %}
{% if LANG.startswith('en-') and switch('mozorg-search-general') %}
{{ google_custom_search(settings.GOOG_CUSTOM_SEARCH_TYPES['general'], 'moz-search-general', _('Internet Health'), _('Volunteer, Events, Add-ons, Firefox, Internet Health')) }}
{% endif %}
{% endblock %}

{% block contrib_nav_cta %}{% endblock %}

{% block contrib_page_title %}{{ _('Volunteer with Mozilla!') }}{% endblock %}
Expand Down Expand Up @@ -153,4 +161,8 @@ <h2 class="section-title">{{ _('Not ready to dive in just yet?') }}</h2>
{% block js %}
{% javascript 'contribute-base' %}
{% javascript 'contribute-landing' %}

{% if LANG.startswith('en-') and switch('mozorg-search-general') %}
{% javascript 'custom-search' %}
{% endif %}
{% endblock %}
10 changes: 10 additions & 0 deletions bedrock/mozorg/templates/mozorg/technology.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

{% extends "base-pebbles.html" %}

{% from 'macros.html' import google_custom_search with context %}

{% block page_title %}
{{ _('We’re opening up a whole new Internet.') }}
{% endblock %}
Expand All @@ -21,6 +23,10 @@

{% block site_header %}
{% include 'mozorg/home/includes/nav.html' %}

{% if LANG.startswith('en-') and switch('mozorg-search-developer') %}
{{ google_custom_search(settings.GOOG_CUSTOM_SEARCH_TYPES['developer'], 'moz-search-developer', _('Virtual Reality'), _('Internet of Things, Add-ons, Events, JavaScript Help, Virtual Reality')) }}
{% endif %}
{% endblock %}

{% block content %}
Expand Down Expand Up @@ -159,4 +165,8 @@ <h3><a rel="external" href="{{ article.link }}">{{ article.blog_title }}</a></h3

{% block js %}
{% javascript 'technology' %}

{% if LANG.startswith('en-') and switch('mozorg-search-developer') %}
{% javascript 'custom-search' %}
{% endif %}
{% endblock %}
7 changes: 7 additions & 0 deletions bedrock/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1273,5 +1273,12 @@ def lazy_email_backend():
# support older browsers (mainly Safari)
CSP_FRAME_SRC = CSP_CHILD_SRC

# Bug 1319244 - testing cross-site search
GOOG_CUSTOM_SEARCH_TYPES = {
'general': '014783244707853607354:ifn1iyzxd1a',
'developer': '014783244707853607354:s-9zxgjd2o0',
'activist': '014783244707853607354:bbpl3emdsii',
}

if config('SWITCH_FLASHTALKING', default=DEV, cast=bool):
CSP_IMG_SRC += ('servedby.flashtalking.com',)
Loading

0 comments on commit a99d303

Please sign in to comment.