Skip to content

Commit

Permalink
update reame
Browse files Browse the repository at this point in the history
  • Loading branch information
gottfrois committed Oct 27, 2013
1 parent e16d47e commit 92aa017
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 73 deletions.
82 changes: 19 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Key features:

1. Install the gem by adding the following in your `Gemfile`:

gem 'dashing-rails'
gem 'dashing-rails'

2. Install puma server by adding the following in your `Gemfile`:

Expand All @@ -47,17 +47,17 @@ Key features:

$ rails g dashing:install

5. Restart your server (must be a multi threaded server - See [Requirements](https://github.com/gottfrois/dashing-rails#requirements))
5. Start redis server:

$ puma
$ redis-server

6. Start redis server:
6. Open `config/development.rb` and add:

$ redis-server
config.allow_concurrency = true

7. Open `config/development.rb` and add:
7. Start your server (must be a multi threaded server - See [Requirements](https://github.com/gottfrois/dashing-rails#requirements))

config.allow_concurrency = true
$ rails s

8. Point your browser at [http://0.0.0.0:9292/dashing/dashboards](http://0.0.0.0:9292/dashing/dashboards) and have fun!

Expand All @@ -70,7 +70,8 @@ Every new Dashing project comes with sample widgets & sample dashboards for you

* `app/views/dashing/dashboards` — One .erb file for each dashboard that contains the layout for the widgets.
* `app/jobs` — Your ruby jobs for fetching data (e.g for calling third party APIs like twitter).
* `app/views/dashing/widgets` — All the html/css/coffee for individual widgets.
* `app/assets/javascripts/dashing/widgets/` — One folder with widget's name containing a JS file.
* * `app/assets/stylesheets/dashing/widgets/` — One folder with widget's name containing a CSS file.
* `app/views/layouts/dashing/` — All your custom layouts where your dashboards and widgets will be included.

## Getting Data Into Your Widgets
Expand All @@ -84,11 +85,11 @@ Dashing uses [rufus-scheduler](http://rufus.rubyforge.org/rufus-scheduler/) to s
Example:

# :first_in sets how long it takes before the job is first run. In this case, it is run immediately
Dashing.scheduler.every '1m', :first_in => 0 do |job|
Dashing.scheduler.every '1m', first_in: 0 do |job|
Dashing.send_event('karma', { current: rand(1000) })
end

This job will run every minute, and will send a random number to ALL widgets that have `data-id` set to 'karma'.
This job will run every minute, and will send a random number to ALL widgets that have `data-id` set to `"karma"`.

You send data using the following method:

Expand Down Expand Up @@ -130,11 +131,11 @@ Your widgets can be updated directly over HTTP. Post the data you want in json t

Example:

curl -d '{ "auth_token": "YOUR_AUTH_TOKEN", "current": 100 }' http://0.0.0.0:9292/dashing/widgets/karma
curl -d '{ "auth_token": "YOUR_AUTH_TOKEN", "current": 100 }' http://locahost:3000/dashing/widgets/karma

or

HTTParty.post('http://0.0.0.0:9292/dashing/widgets/karma',
HTTParty.post('http://locahost:3000/dashing/widgets/karma',
body: { auth_token: "YOUR_AUTH_TOKEN", current: 1000 }.to_json)

#### Dasboards
Expand All @@ -143,75 +144,30 @@ The `reload` action provided by [Shopify Dashing](http://shopify.github.io/dashi

## Additional Resources

Check out the [wiki](https://github.com/gottfrois/dashing-rails/wiki) for interesting tips such as hosting on Heroku, or adding authentication.
Check out the [wiki](https://github.com/gottfrois/dashing-rails/wiki) for interesting tips such as hosting on Heroku, adding authentication or adding custom widgets.

For more information on Dashboards and Widgets HTML/CSS/JS, please read [Shopify Dashing documentation](http://shopify.github.io/dashing).
## Custom Widgets

Be sure to look at the [list of third party widgets](https://github.com/Shopify/dashing/wiki/Additional-Widgets).
Want more awesome Widgets? Go checkout the [list of all Dashing-Rails compatible Widgets](https://github.com/gottfrois/dashing-rails/wiki)!

## Browser Compatibility

Tested in Chrome, Safari 6+, and Firefox 15+.

Does not work in Internet Explorer because it relies on [Server Sent Events](http://www.html5rocks.com/en/tutorials/eventsource/basics/).

## Heroku

Setting Dashing-rails on Heroku is pretty simple:

1. Create a new app:

heroku apps:create example
2. Add [RedisToGo](https://devcenter.heroku.com/articles/redistogo) addon to heroku's app:

heroku addons:add redistogo
3. Add [PostgresSQL](https://devcenter.heroku.com/articles/heroku-postgresql) addon to heroku's app (this is up to you):

heroku addons:add heroku-postgresql:dev
4. Add `puma` to your `Gemfile`:

gem 'puma'
5. Create a new `Procfile` for you application:

web: bundle exec puma -p $PORT -e $RACK_ENV -t 0:5

6. Tell Dashing-rails how to you the Heroku's redis connection by setting redis credentials in `config/initializers/dashing.rb`:

config.redis_host = URI.parse(ENV["REDISTOGO_URL"]).host
config.redis_port = URI.parse(ENV["REDISTOGO_URL"]).port
config.redis_password = URI.parse(ENV["REDISTOGO_URL"]).password
7. Commit and Push to heroku:

git commit -m "configure dashing to work on heroku"
git push heroku master

8. That's it! Visit [http://your_app.herokuapp.com/dashing/dashboards](http://dashing-rails-demo.herokuapp.com/dashing/dashboards)

You can checkout the following application on [Github](https://github.com/gottfrois/dashing-rails-demo) running on [Heroku](http://dashing-rails-demo.herokuapp.com/dashing/dashboards)

*`puma -t 0:5` lets you configure the number of threads you want puma to run on.*

## Contributors

[Shopify Dashing official page](http://shopify.github.io/dashing/)

[Dashing-rails contributors](https://github.com/gottfrois/dashing-rails/contributors)

[Shopify Dashing contributors](https://github.com/Shopify/dashing/graphs/contributors)
* [Shopify Dashing official page](http://shopify.github.io/dashing/)
* [Dashing-rails contributors](https://github.com/gottfrois/dashing-rails/contributors)
* [Shopify Dashing contributors](https://github.com/Shopify/dashing/graphs/contributors)

All contributions are more than welcome; especially new widgets!

Please add spec to your Pull Requests and run them using:

rake

You can use the following [demo application](https://github.com/gottfrois/dashing-rails-demo) to test dashing-rails in development.

## License

Dashing is released under the [MIT license](https://github.com/Shopify/dashing/blob/master/MIT-LICENSE)
5 changes: 0 additions & 5 deletions app/controllers/dashing/widgets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,9 @@ def withdet_path
end

def prepend_view_paths
prepend_view_path engine_view_path
prepend_view_path main_app_view_path
end

def engine_view_path
Dashing::Engine.root.join('app', 'views', 'dashing', 'widgets')
end

def main_app_view_path
Rails.root.join(Dashing.config.widgets_views_path)
end
Expand Down
12 changes: 7 additions & 5 deletions lib/dashing/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ module Dashing
class Engine < ::Rails::Engine
isolate_namespace Dashing

config.assets.paths << Dashing::Engine.root.join('app', 'assets', 'fonts', 'dashing')
config.assets.paths << Dashing::Engine.root.join('app', 'assets', 'javascripts', 'dashing')
config.assets.paths << Dashing::Engine.root.join('app', 'assets', 'stylesheets', 'dashing')
config.assets.paths << Dashing.config.widgets_js_path
config.assets.paths << Dashing.config.widgets_css_path
config.assets.paths.unshift Dashing::Engine.root.join('app', 'assets', 'fonts', 'dashing')
config.assets.paths.unshift Dashing::Engine.root.join('app', 'assets', 'javascripts', 'dashing')
config.assets.paths.unshift Dashing::Engine.root.join('app', 'assets', 'stylesheets', 'dashing')
config.assets.paths.unshift Dashing.config.widgets_js_path
config.assets.paths.unshift Dashing.config.widgets_css_path

config.paths['app/views'].unshift Dashing::Engine.root.join('app', 'views', 'dashing', 'widgets')

initializer 'require dashing jobs' do
Dir[Rails.root.join(Dashing.config.jobs_path, '**', '*.rb')].each { |file| require file }
Expand Down

0 comments on commit 92aa017

Please sign in to comment.