Skip to content

Instantly share code, notes, and snippets.

@mutewinter
Created July 24, 2014 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mutewinter/0c86f25befa80629a2ff to your computer and use it in GitHub Desktop.
Save mutewinter/0c86f25befa80629a2ff to your computer and use it in GitHub Desktop.
The missing page route for https://fnd.io
# 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