diff --git a/app/initializers/global-variables.js b/app/initializers/global-variables.js new file mode 100644 index 0000000..c16d17e --- /dev/null +++ b/app/initializers/global-variables.js @@ -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 +}; diff --git a/app/pods/application/adapter.js b/app/pods/application/adapter.js index 2037ee8..e979dec 100644 --- a/app/pods/application/adapter.js +++ b/app/pods/application/adapter.js @@ -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 diff --git a/app/pods/application/template.hbs b/app/pods/application/template.hbs index 3d14835..486ad74 100644 --- a/app/pods/application/template.hbs +++ b/app/pods/application/template.hbs @@ -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"> diff --git a/app/pods/components/genus-name/component.js b/app/pods/components/genus-name/component.js index 1fb4f1f..bae8cb9 100644 --- a/app/pods/components/genus-name/component.js +++ b/app/pods/components/genus-name/component.js @@ -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(), }); diff --git a/app/pods/components/site-name/template.hbs b/app/pods/components/site-name/template.hbs new file mode 100644 index 0000000..a166fb9 --- /dev/null +++ b/app/pods/components/site-name/template.hbs @@ -0,0 +1 @@ +{{globals.genus}}.info diff --git a/app/pods/user/adapter.js b/app/pods/user/adapter.js index e4e2bd1..9e430e9 100644 --- a/app/pods/user/adapter.js +++ b/app/pods/user/adapter.js @@ -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, }); diff --git a/public/img/logo.png b/public/img/logo.png deleted file mode 100755 index f0eece7..0000000 Binary files a/public/img/logo.png and /dev/null differ diff --git a/tests/unit/initializers/global-variables-test.js b/tests/unit/initializers/global-variables-test.js new file mode 100644 index 0000000..e2aaa52 --- /dev/null +++ b/tests/unit/initializers/global-variables-test.js @@ -0,0 +1,23 @@ +import Ember from 'ember'; +import { initialize } from '../../../initializers/global-variables'; +import { module, test } from 'qunit'; + +var container, application; + +module('Unit | Initializer | global variables', { + beforeEach: function() { + Ember.run(function() { + application = Ember.Application.create(); + container = application.__container__; + application.deferReadiness(); + }); + } +}); + +// Replace this with your real tests. +test('it works', function(assert) { + initialize(container, application); + + // you would normally confirm the results of the initializer here + assert.ok(true); +}); diff --git a/tests/unit/pods/components/site-name/component-test.js b/tests/unit/pods/components/site-name/component-test.js new file mode 100644 index 0000000..2c5861f --- /dev/null +++ b/tests/unit/pods/components/site-name/component-test.js @@ -0,0 +1,19 @@ +import { moduleForComponent, test } from 'ember-qunit'; + +moduleForComponent('site-name', 'Unit | Component | site name', { + // Specify the other units that are required for this test + // needs: ['component:foo', 'helper:bar'], + unit: true +}); + +test('it renders', function(assert) { + assert.expect(2); + + // Creates the component instance + var component = this.subject(); + assert.equal(component._state, 'preRender'); + + // Renders the component to the page + this.render(); + assert.equal(component._state, 'inDOM'); +});