Global injection
This commit is contained in:
parent
c70dd933c5
commit
559c0a3d9f
9 changed files with 76 additions and 9 deletions
19
app/initializers/global-variables.js
Normal file
19
app/initializers/global-variables.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
import Ember from 'ember';
|
||||
import config from '../config/environment';
|
||||
|
||||
var globals = Ember.Object.extend({
|
||||
genus: config.genus,
|
||||
apiURL: config.apiURL,
|
||||
});
|
||||
|
||||
export function initialize(container, application) {
|
||||
application.register('global:variables', globals, {singleton: true});
|
||||
application.inject('controller', 'globals', 'global:variables');
|
||||
application.inject('component', 'globals', 'global:variables');
|
||||
application.inject('adapter', 'globals', 'global:variables');
|
||||
}
|
||||
|
||||
export default {
|
||||
name: 'global-variables',
|
||||
initialize: initialize
|
||||
};
|
|
@ -1,10 +1,13 @@
|
|||
import DS from 'ember-data';
|
||||
import Ember from 'ember';
|
||||
import config from '../../config/environment';
|
||||
|
||||
export default DS.RESTAdapter.extend({
|
||||
namespace: 'api/' + config.genus,
|
||||
host: config.apiURL,
|
||||
namespace: function() {
|
||||
return 'api/' + this.get('globals.genus');
|
||||
}.property(),
|
||||
host: function() {
|
||||
return this.get('globals.apiURL');
|
||||
}.property(),
|
||||
coalesceFindRequests: true,
|
||||
ajaxError: function(jqXHR) {
|
||||
// http://stackoverflow.com/a/24027443
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div class="flakes-navigation">
|
||||
{{#link-to 'index' class='logo'}}
|
||||
<img src="img/logo.png" width="120">
|
||||
{{site-name}}
|
||||
{{/link-to}}
|
||||
{{#if session.isAuthenticated}}
|
||||
<ul>
|
||||
|
@ -36,7 +36,7 @@
|
|||
<div class="flakes-content">
|
||||
<div class="flakes-mobile-top-bar">
|
||||
<a href="" class="logo-wrap">
|
||||
<img src="img/logo.png" height="30px">
|
||||
{{site-name}}
|
||||
</a>
|
||||
<a href="" class="navigation-expand-target">
|
||||
<img src="img/navigation-expand-target.png" height="26px">
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import Ember from 'ember';
|
||||
import config from '../../../config/environment';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
tagName: 'em',
|
||||
genus: config.genus.capitalize(),
|
||||
genus: function() {
|
||||
return this.get('globals.genus').capitalize();
|
||||
}.property(),
|
||||
});
|
||||
|
|
1
app/pods/components/site-name/template.hbs
Normal file
1
app/pods/components/site-name/template.hbs
Normal file
|
@ -0,0 +1 @@
|
|||
{{globals.genus}}.info
|
|
@ -1,8 +1,9 @@
|
|||
import DS from 'ember-data';
|
||||
import config from '../../config/environment';
|
||||
|
||||
export default DS.RESTAdapter.extend({
|
||||
namespace: 'api',
|
||||
host: config.apiURL,
|
||||
host: function() {
|
||||
return this.get('globals.apiURL');
|
||||
}.property(),
|
||||
coalesceFindRequests: true,
|
||||
});
|
||||
|
|
Reference in a new issue