example/README.md
# Ember-Prerender Example Project #
This is an example Ember.js project that demonstrates how
ember-prerender works.
## How does it work? ##
A custom initializer in **_app/initializers/ember-prerender.js_** registers custom XContentReady and XPushState events. It listens for an XPushState event with a 'url' parameter and transitions to that URL when the event is received.
A mixin in **_app/mixins/ember-prerender.js_** gets added to the routes in **_app/routes/*_** which dispatches the XContentReady event when Ember.js has finished transitioning to the route and any promises have been resolved. Promises may be returned by the optional willComplete method in your controllers if there is something on the page that get loaded after the route's model(s).
You'll also find an initializer and mixin used for updating the page title, meta tags, and prerender status code. Meta tag values are generated by the controllers in **_app/controllers/*_** and the properties from parent controllers are inhereted by their children.
Other files to check out are **_app/router.js_** and **_app/templates/*_**.
The rest of the project is from the default template project built with ember-cli by running `ember new App`.
## Getting Started ##
To build, run, and test this project, please install ember-cli, bower,
and ember-prerender:
npm install -g ember-cli
npm install -g bower
npm install -g ember-prerender
Once you've downloaded the dependencies, clone this repository and run the following:
cd example
npm install
bower install
## Running ##
First, view the project in your browser:
ember server
In your browser, open [http://localhost:4200](http://localhost:4200) to view the Javascript version of the site.
To render the project with ember-prerender, keep "ember server" running
and type:
ember-prerender ember-prerender-config.js
In your browser, open [http://localhost:3000](http://localhost:3000) to view the static html version of the site
The example project includes three routes, an index at /, an AJAX page at /dynamic, and a 404 page at any other url (e.g. /foo).
## Caveats ##
Ember-prerender expects your Ember app to be located at window.App. This could be a configuration option if there's demand for it.