Created
July 24, 2014 14:08
-
-
Save mutewinter/0c86f25befa80629a2ff to your computer and use it in GitHub Desktop.
The missing page route for https://fnd.io
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Routes that should have country from before 2014-07-13. | |
PATHS_WITH_COUNTRY = [ | |
# Others | |
'search' | |
'charts' | |
'any' | |
'integrations' | |
'bookmarklets' | |
# Models | |
'album' | |
'artist' | |
'audiobook' | |
'author' | |
'book' | |
'compilation' | |
'ios-universal-app' | |
'ipad-app' | |
'iphone-app' | |
'mac-app' | |
'movie' | |
'music-video' | |
'podcast' | |
'podcast-episode' | |
'podcaster' | |
'software-developer' | |
'song' | |
'studio' | |
'tv-episode' | |
'tv-season' | |
'tv-show' | |
] | |
module.exports = App.MissingRoute = App.FndRoute.extend | |
beforeModel: (transition) -> | |
url = transition.intent.url | |
parts = url.split('/') | |
firstSegment = parts[1] | |
if PATHS_WITH_COUNTRY.contains(firstSegment) | |
defaultCountry = @get('session.defaultCountryId') | |
@transitionTo(parts.insertAt(1, defaultCountry).join('/')) | |
afterModel: (model, transition) -> | |
App.Logger.error "Missing route #{model?.missing}" | |
setupController: (controller) -> | |
controller.set('url', window.location.href) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment