Skip to content

Commit

Permalink
Merge pull request #8 from nypublicradio/brian-legacy-cleanup
Browse files Browse the repository at this point in the history
Legacy Cleanup
  • Loading branch information
Brian Whitton authored Jan 11, 2017
2 parents 47adbf3 + db44212 commit 0def215
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 23 deletions.
3 changes: 2 additions & 1 deletion app/channel/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export default Route.extend(PlayParamMixin, {
});
},
setupController(controller, model) {
let { navSlug } = this.paramsFor(`${this.routeName}.well`);
let { page_params = '' } = this.paramsFor(`${this.routeName}.page`);
let [navSlug] = page_params.split('/');
controller.setProperties({
channelType: this.routeName,
navRoot: get(this, 'listingSlug'),
Expand Down
24 changes: 12 additions & 12 deletions app/components/site-chrome/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,23 @@
{{/if}}
</li>

{{#link-to 'stream' tagName='li' href=false class="list-item list-item--nav" }}
{{#link-to 'stream' tagName='li' href=false class="list-item list-item--nav"}}
{{link-to 'All Streams' 'stream' class="inherit" preventDefault=false}}
{{/link-to}}

{{#link-to 'schedule' current-when="schedule.date" tagName='li' href="false" class="list-item list-item--nav" }}
{{#link-to 'schedule' current-when="schedule.date" tagName='li' href=false class="list-item list-item--nav"}}
{{link-to 'Schedule' 'schedule' class="inherit" preventDefault=false}}
{{/link-to}}

{{#link-to 'shows' current-when="shows show" tagName="li" href=false class="list-item list-item--nav" }}
{{#link-to 'shows' current-when="shows show" tagName="li" href=false class="list-item list-item--nav"}}
{{link-to 'Shows' 'shows' class="inherit" preventDefault=false}}
{{/link-to}}

{{#link-to 'topics' current-when='topics tag' tagName='li' href="false" class="list-item list-item--nav" }}
{{#link-to 'topics' current-when='topics tag' tagName='li' href=false class="list-item list-item--nav"}}
{{link-to 'Topics' 'topics' class="inherit" preventDefault=false}}
{{/link-to}}

{{#link-to 'discover.start' current-when="discover" tagName='li' href="false" class="list-item list-item--nav"}}
{{#link-to 'discover.start' current-when="discover" tagName='li' href=false class="list-item list-item--nav"}}
{{#link-to 'discover.start' class="inherit" preventDefault=false}}
<span class="new">NEW!</span>
Discover
Expand All @@ -134,18 +134,18 @@

{{#unless media.isLargeAndUp}}

{{#link-to 'djangorendered' 'search/' tagName='li' href=false class="list-item list-item--nav" }}
{{#link-to 'djangorendered' 'search/' tagName='li' href=false class="list-item list-item--nav"}}
{{link-to 'Search' 'djangorendered' 'search/' class="inherit" preventDefault=false}}
{{/link-to}}

{{#if features.autoplayPrefs}}
{{#link-to 'settings' tagName='li' href=false class="list-item list-item--nav" }}
{{#link-to 'settings' tagName='li' href=false class="list-item list-item--nav"}}
{{link-to 'Settings' 'settings' class="inherit" preventDefault=false}}
{{/link-to}}
{{/if}}

{{#if session.isAuthenticated}}
{{#link-to 'djangorendered' 'users/me' tagName='li' href="false" class="list-item list-item--nav" }}
{{#link-to 'djangorendered' 'users/me' tagName='li' href=false class="list-item list-item--nav"}}
{{link-to "My Account" 'djangorendered' 'users/me' class="inherit" preventDefault=false}}
{{/link-to}}

Expand All @@ -154,7 +154,7 @@
</li>

{{else}}
{{#link-to 'login' tagName='li' href="false" class="list-item list-item--nav" }}
{{#link-to 'login' tagName='li' href=false class="list-item list-item--nav"}}
{{link-to 'Sign In' 'login' class="inherit" preventDefault=false}}
{{/link-to}}

Expand All @@ -175,21 +175,21 @@
<ul class="list list--noborder flush alignright">
{{!-- <div class="h5 text--heavy alignright"> --}}
{{#if features.autoplayPrefs}}
{{#link-to 'settings' tagName='li' href=false class="list-item list-item--nav" }}
{{#link-to 'settings' tagName='li' href=false class="list-item list-item--nav"}}
{{link-to 'Settings' 'settings' class="inherit" preventDefault=false}}
{{/link-to}}
{{/if}}

{{#if session.isAuthenticated}}
{{#link-to 'djangorendered' 'users/me' tagName='li' href="false" class="list-item list-item--nav" }}
{{#link-to 'djangorendered' 'users/me' tagName='li' href=false class="list-item list-item--nav"}}
{{link-to "My Account" 'djangorendered' 'users/me' class="inherit" preventDefault=false}}
{{/link-to}}

<li class="list-item list-item--nav">
<button class="btn--blank" data-test-selector="logout" {{action 'logout'}}>Sign Out</button>
</li>
{{else}}
{{#link-to 'login' tagName='li' href="false" class="list-item list-item--nav" }}
{{#link-to 'login' tagName='li' href=false class="list-item list-item--nav"}}
{{link-to "Sign In" 'login' class="inherit" preventDefault=false}}
{{/link-to}}
{{/if}}
Expand Down
2 changes: 1 addition & 1 deletion app/instance-initializers/link-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default {

let { routeName, params, queryParams } = router.recognize(href);
router.transitionTo(routeName, params, queryParams);
preventDefault.bind(event);
preventDefault.bind(event)();
return false;
} else if (isExternal && !Ember.testing) {
$target.attr('target', '_blank');
Expand Down
10 changes: 5 additions & 5 deletions app/lib/compat-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ export function beforeTeardown(/* element, page */) {
window.googletag.destroySlots();
}

// toggle_menu_v2.js sets classes way up on <html>, so we may need to clear them.
$('html')
.removeClass('navigation-open')
.removeClass('subnavigation-open');

// player.js listens for a storage event with a handler defined on the wnyc object,
// which is triggered by logic outside of Ember; unbind to avoid throwing errors
$(window).off('unload storage');

// the whats on widget only runs on the homepage but sets up an interval that
// continues to run. cancel it here so it doesn't run in unsafe contexts
let timeoutId = get(window, 'wnyc.apis.whatsOnToday.update.updateTimeoutId');
clearInterval(timeoutId);

// The mailchimp popup signup form is badly behaved -- it insists on
// being the only AMD loader on the page. So here we clear it away
Expand Down
5 changes: 4 additions & 1 deletion app/lib/is-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ export default function isJavascript(scriptTag) {
// TODO: add a console warning if the script tag doesn't have an attribute?
// seems like it's required for some parts of ember consumption
let type = scriptTag.attributes.type ? scriptTag.attributes.type.value : 'text/javascript';
return /(?:application|text)\/(deferred-)?javascript/i.test(type);
// guard against chrome-extension:// scripts
let badSrc = scriptTag.src && !scriptTag.src.match(/^http|^(\.)?\//);

return !badSrc && /(?:application|text)\/(deferred-)?javascript/i.test(type);
}
9 changes: 9 additions & 0 deletions app/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Ember from 'ember';
import service from 'ember-service/inject';
import PlayParamMixin from 'wnyc-web-client/mixins/play-param';
import rsvp from 'rsvp';
import { beforeTeardown } from 'wnyc-web-client/lib/compat-hooks';
const { hash } = rsvp;
const { get } = Ember;

Expand All @@ -24,5 +25,13 @@ export default Ember.Route.extend(PlayParamMixin, {
page: path,
title
});
},

actions: {
willTransition() {
this._super(...arguments);
beforeTeardown();
return true;
}
}
});
5 changes: 4 additions & 1 deletion app/services/raven.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ export default RavenLogger.extend({
this._super(...arguments);
},

captureMessage(/* message */) {
captureMessage(message, object) {
if (object.extra && object.extra.status === 404) {
return;
}
return this._super(...arguments);
},

Expand Down
3 changes: 1 addition & 2 deletions app/styles/_animations.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ body:not(.ember-application):not([data-testing]):not(.simplified_wrapper):not(.c
}

body {
> #full-page-viewport-wrapper,
> #navigation-menu {
> #site {
display: none;
}
}
Expand Down
30 changes: 30 additions & 0 deletions tests/acceptance/viewing-show-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,36 @@ test('using a nav-link', function(assert) {
});
});

test('visiting directly to a nav link url', function(assert) {
let apiResponse = server.create('api-response', {
id: 'shows/foo/episodes/1',
teaseList: server.createList('story', 10)
});
server.create('api-response', {
id: 'shows/foo/next-link/1',
teaseList: server.createList('story', 1, {title: 'Story Title'})
});

let show = server.create('show', {
id: 'shows/foo/',
linkroll: [
{navSlug: 'episodes', title: 'Episodes'},
{navSlug: 'next-link', title: 'Next Link'}
],
apiResponse
});

server.create('django-page', {id: show.id});

djangoPage
.bootstrap(show)
.visit({id: 'shows/foo/next-link/'});

andThen(() => {
assert.equal(findWithAssert('nav li.is-active > a').text(), 'Next Link');
});
});

test('null social links should not break page', function(assert) {
let apiResponse = server.create('api-response', {
id: 'shows/foo/recent_stories/1',
Expand Down

0 comments on commit 0def215

Please sign in to comment.