The EnergyMixer application is "partitioned" into question sets, each
containing a number of questions which may be answered by a user in order
to design their scenario. Each question set has a name
matching the
subdomain to which it is deployed. For example:
"mixer" #=> mixer.et-model.com
"gasmixer" #=> gasmixer.et-model.com
Firstly, copy the sample configuration file "config/config.sample.yml" to "config/config.yml".
As EnergyMixer determines which question set is to be shown depending on the subdomain you use, you must set up Pow to mimic this behaviour. In the OS X terminal, go to the EnergyMixer directory then:
ln -s `pwd` ~/Library/Application\ Support/Pow/Hosts/mixer.mixer
ln -s `pwd` ~/Library/Application\ Support/Pow/Hosts/gasmixer.mixer
The EnergyMixer will now be available at http://mixer.mixer.dev/ and http://gasmixer.mixer.dev/, with the "mixer" and "gasmixer" question sets respectively.
In config.yml you will find the configuration for the application. This file is split into two sections: an "application" section, whose setting apply to all partitions, and separate configurations which apply to each partition.
standalone
– When true, all outbound links and remote scripts (such as
Google Analytics) are disabled. Used on offline instances (conference
laptops).
local_proxy
– Uses Rack to set up a local proxy to ETengine at the URL
specified by the "api_proxy_url" setting. This is used to provide access to
ETengine for old browsers which do not support Cross-Origin Resource
Sharing. It is not required in production, since Nginx will handle this more
efficiently.
host_name
– This is important! Without a host name, the links in
e-mails will not be correct.
locales
– This should be an array of two-character locales which are
available to visitors. The first entry will be the default locale.
For example: locales: ['nl', 'en']
indicates that Dutch and English
translations are available, and that Dutch should be the default.
A single instance of the EnergyMixer application is used to run both the
mixer.et-model.com and gasmixer.et-model.com websites. Merge your changes into
the "production" branch, then run cap production deploy
.
Be careful with configuration data: your local "config/config.yml" is not copied to the server. Instead, the file is stored on the server in "/u/apps/energymixer/shared/config/config.yml". Capistrano will take care of creating the appropriate symlinks after deploying.
The application caches the current scenario. To clear the cache, log in to the admin section and click "Reset Cache". Alternatively, fire up the Rails console:
$ cd /u/apps/energymixer/current
$ bin/rails console production
irb(main):001:0> Rails.cache.clear
irb(main):002:0> exit
The QuestionSet class has a method related to this cache:
QuestionSet.current_scenario
which returns the cached value if available, and
goes to ETEngine for the values if not.
Each partition can be customised with it's own views; controllers will prepend "app/views/{partition.name}. This means that any view in that directory (including layouts) will be rendered if available. Otherwise the default view will be used.