Created
April 20, 2017 14:04
-
-
Save michalsnik/3e6d9aa7cf83d304cbfb31c3c95aeda8 to your computer and use it in GitHub Desktop.
route-lang
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
import Ember from 'ember'; | |
import loadInitializers from 'ember-load-initializers'; | |
import Resolver from './resolver'; | |
import config from './config/environment'; | |
import RouteAliasResolver from 'ember-route-alias/mixins/route-alias-resolver'; | |
const { Application } = Ember; | |
Ember.MODEL_FACTORY_INJECTIONS = true; | |
const App = Application.extend({ | |
modulePrefix: config.modulePrefix, | |
podModulePrefix: config.podModulePrefix, | |
Resolver: Resolver.extend(RouteAliasResolver), | |
}); | |
loadInitializers(App, config.modulePrefix); | |
export default App; |
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
import Ember from 'ember'; | |
const { computed, get } = Ember; | |
export default Ember.LinkComponent.extend({ | |
qualifiedRouteName: computed('targetRouteName', '_routing.currentState', function() { | |
let params = get(this, 'params').slice(); | |
let lastParam = params[params.length - 1]; | |
if (lastParam && lastParam.isQueryParams) { | |
params.pop(); | |
} | |
let onlyQueryParamsSupplied = params.length === 0; | |
if (onlyQueryParamsSupplied) { | |
return get(this, '_routing.currentRouteName'); | |
} | |
const currentRouteName = get(this, '_routing.currentState.emberRouter.currentRouteName'); | |
const lang = currentRouteName.split('.')[0]; | |
if (['en', 'de'].indexOf(lang) > -1) { | |
return get(this, 'targetRouteName').replace('app.', `${lang}.`); | |
} | |
return get(this, 'targetRouteName'); | |
}), | |
}); |
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
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
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
import Ember from 'ember'; | |
import config from './config/environment'; | |
const Router = Ember.Router.extend({ | |
location: 'none', | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
this.route('app', { path: '/' }, function() { | |
this.route('news', function() { | |
this.route('details', { path: ':news_id' }); | |
}); | |
}); | |
this.alias('en', '/en', 'app'); | |
this.alias('de', '/de', 'app'); | |
}); | |
export default Router; |
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
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model(params) { | |
return params.news_id; | |
} | |
}); |
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
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model() { | |
return [{ | |
id: 1, | |
title: 'lorem', | |
}, { | |
id: 2, | |
title: 'lorem', | |
}, { | |
id: 3, | |
title: 'dolor', | |
}]; | |
} | |
}); |
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
{ | |
"version": "0.12.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.12.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0" | |
}, | |
"addons": { | |
"ember-data": "2.12.1", | |
"ember-route-alias": "0.1.5" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment