Skip to content

Commit

Permalink
[fix bug 1397519] Firefox home page Quantum redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgibson authored and jpetto committed Nov 8, 2017
1 parent 0e74e9f commit dcb4930
Show file tree
Hide file tree
Showing 47 changed files with 2,423 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ indent_size = 4
[*.html]
indent_size = 2

[*.svg]
indent_size = 2

[*.yml]
indent_size = 2

Expand Down
390 changes: 390 additions & 0 deletions bedrock/firefox/templates/firefox/hub/home-quantum.html

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions bedrock/firefox/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -975,3 +975,51 @@ def test_send_tabs_experiment_other_locales(self, render_mock):
req,
'firefox/features/send-tabs.html'
)


@patch('bedrock.firefox.views.l10n_utils.render')
class TestFirefoxHubPage(TestCase):
@patch('bedrock.firefox.views.switch', Mock(return_value=False))
def test_hub_pre_57(self, render_mock):
view = views.FirefoxHubView.as_view()
req = RequestFactory().get('/firefox/')
req.locale = 'en-US'
view(req)
template = render_mock.call_args[0][1]
eq_(template, ['firefox/hub/home.html'])

@patch('bedrock.firefox.views.switch', Mock(return_value=True))
def test_hub_post_57(self, render_mock):
view = views.FirefoxHubView.as_view()
req = RequestFactory().get('/firefox/')
req.locale = 'en-US'
view(req)
template = render_mock.call_args[0][1]
eq_(template, ['firefox/hub/home-quantum.html'])

@patch('bedrock.firefox.views.switch', Mock(return_value=True))
@patch.object(views, 'lang_file_is_active', lambda *x: False)
def test_hub_not_translated(self, render_mock):
view = views.FirefoxHubView.as_view()
req = RequestFactory().get('/firefox/')
req.locale = 'de'
view(req)
template = render_mock.call_args[0][1]
eq_(template, ['firefox/hub/home.html'])


class TestFirefoxDesktopPageRedirect(TestCase):
@patch('bedrock.firefox.views.switch', Mock(return_value=False))
def test_desktop_pre_57(self):
view = views.FirefoxProductDesktopView.as_view()
req = RequestFactory().get('/en-US/firefox/desktop/')
resp = view(req)
eq_(resp.status_code, 200)

@patch('bedrock.firefox.views.switch', Mock(return_value=True))
def test_desktop_post_57(self):
view = views.FirefoxProductDesktopView.as_view()
req = RequestFactory().get('/en-US/firefox/desktop/')
resp = view(req)
eq_(resp.status_code, 301)
ok_(resp.url.endswith('/en-US/firefox/'))
19 changes: 18 additions & 1 deletion bedrock/firefox/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,15 @@ class FirefoxProductDesktopView(BlogPostsView):
blog_tags = ['browser', 'featured']
template_name = 'firefox/products/desktop.html'

def render_to_response(self, context, **response_kwargs):
if switch('firefox-57-release'):
return HttpResponsePermanentRedirect(reverse('firefox'))
else:
return l10n_utils.render(self.request,
self.get_template_names(),
context,
**response_kwargs)


class FirefoxProductAndroidView(BlogPostsView):
blog_posts_limit = 3
Expand Down Expand Up @@ -775,7 +784,15 @@ class FirefoxHubView(BlogPostsView):
blog_posts_template_variable = 'articles'
blog_slugs = 'firefox'
blog_tags = ['home']
template_name = 'firefox/hub/home.html'

def get_template_names(self):
locale = l10n_utils.get_locale(self.request)

if switch('firefox-57-release') and lang_file_is_active('firefox/hub/home-quantum', locale):
template_name = 'firefox/hub/home-quantum.html'
else:
template_name = 'firefox/hub/home.html'
return [template_name]


def FirefoxProductDeveloperView(request):
Expand Down
18 changes: 18 additions & 0 deletions bedrock/settings/static_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,12 @@
),
'output_filename': 'css/experiment_send_tabs-bundle.css',
},
'firefox-hub-quantum': {
'source_filenames': (
'css/firefox/hub/home-quantum.scss',
),
'output_filename': 'css/firefox-hub-quantum-bundle.css',
},
'firefox-interest-dashboard': {
'source_filenames': (
'css/firefox/family-nav.less',
Expand Down Expand Up @@ -1322,6 +1328,18 @@
),
'output_filename': 'js/firefox_developer_whatsnew-bundle.js',
},
'firefox-hub-quantum': {
'source_filenames': (
'js/libs/jquery.waypoints.min.js',
'js/libs/jquery.waypoints-sticky.min.js',
'js/hubs/sub-nav.js',
'js/base/mozilla-smoothscroll.js',
'js/base/mozilla-video-poster.js',
'js/firefox/quantum/features-scroller.js',
'js/firefox/home.js',
),
'output_filename': 'js/firefox-hub-quantum-bundle.js',
},
'firefox_new_scene1': {
'source_filenames': (
'js/base/mozilla-modal.js',
Expand Down
Loading

0 comments on commit dcb4930

Please sign in to comment.