See license.md for license information.
The SPARKS project contains all the built code needed to run the project locally. However, because the application uses XHR requests to load the application files, most browsers will require a local server, such as Apache, to be serving the site.
In order to load the example activities in the /activities folder, the local server needs to simply serve the SPARKS directory.
To serve the main set of authored activities, the path /sparks-activities/ needs to proxy to the contents of the sparks-activities repository (github.com/concord-consortium/sparks-activities). This can be done by pointing to a local checkout, or to the gh-pages branch hosted at concord-consortium.github.io/sparks-activities/.
We’ve supplied a simple Ruby rack server configuration for running locally.
The Rack server also proxies database requests for the full activity set available on github here: concord-consortium.github.io/sparks-activities/
The following will start up a local server using rack running on port 9292 (after installing the development dependencies listed below):
bin/rackup server.ru
You can then open the index page here: localhost:9292/index.html
Alternatively, if you can run Apache on your system, you can set up the local server by modifying the file proxy/apache.conf.sample with your information (modify the paths at the bottom of the file to point to the location of your local sparks directory), and then save the file as apache.conf (i.e. remove the .sample from the file name). You can then start a local Apache server by running
apachectl -f "`pwd`/proxy/apache.conf" -k start
Now you will be able to navigate to the html files in the project by pointing your browser to
http://localhost:1234 http://localhost:1234/activities.html http://localhost:1234/activities.html#local/rlc-draggable // local, does not require internet connection http://localhost:1234/activities.html#series-interpretive // requires proxy
Sparks uses the Ruby gem Sprockets (getsprockets.org) to manage the javascript code. Sprockets combines the individual JS files into a single file per activity.
The build system has been tested on Ruby 1.8.7 and 1.9.3.
We use [RVM](rvm.io/rvm/install/) to install and manage different versions of Ruby and sets of Ruby gems used in different projects.
In the instructions below I assume Ruby 1.9.3 is being used:
Setup rvm to use Ruby 1.9.3 and a gemset named sparks.
rvm use 1.9.3 rvm gemset create sparks echo "rvm use 1.9.3@sparks" > .rvmrc cd .
Install bundler and the necessary gems
gem install bundler bundle install --binstubs
Build using sprockets, from top folder
bin/rake
“rake” will need to be called each time a Javascript file is changed … unless you use Guard (see next sections).
Start [Guard](github.com/guard/guard) to automatically build client-breadboard-activity.js whenever changes are made to the files in app/ or lib/
bin/guard
*Note: The tests are currently out of date.*
This application is mostly tested using JSPEC. You can install JSPEC with
gem install jspec
To run the tests on the command line with Rhino:
// optinally run bin/rake to rebuild the files cd tests/jspec java -jar spec/support/js.jar -opt -1 spec/rhino-terminal.js // or just run cd tests/jspec ./test.sh
To run the tests in the browser, visit
http://localhost:1234/tests/jspec/spec/dom.html
Note that some of the tests, ‘Measuring breadboard components with QUCS’ and ‘Using multimeter with mock Flash connection’ require a response from the QUCS applications. The rest should run fine as long as the code has been built (section 1 above).
The majority of the application can be found in app/. The application is written in an MVC pattern, and the folders follow suit, except for the circuit components, whose model objects can all be found in /app/circuit.
The models generally define object classes. Most objects (pages, sections, etc) are instances of these classes.
The views generally return a jQuery object representing the view of the particular model object. The parent view is generally responsible for embedding the jQuery object onto the page.
Demo activity JSON files can be found in the /activities folder.
The circuit calculations are performed by the Circuit Solver library (github.com/concord-consortium/circuit-solver)