Skip to content

Commit

Permalink
release v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gottfrois committed Nov 1, 2013
1 parent b89206e commit e230d7a
Show file tree
Hide file tree
Showing 81 changed files with 348 additions and 161 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,11 @@
## 2.0.0

* Refactor assets management. Now they all live in `vendor` directory.
* Introduce a widget generator to build custom widget in a few seconds (`rails g dashing:widget my_widget`).
* Rename configuration attributes (you need to regenerate the initializer config file with `rails g dashing:install`)
* Simplify widget view path
* Bug fixes

## 1.0.3

* cherrypick https://github.com/Shopify/dashing/pull/253
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
dashing-rails (1.0.3)
dashing-rails (2.0.0)
coffee-script (~> 2.2)
connection_pool (~> 1.1)
jquery-rails (~> 3.0)
Expand Down
96 changes: 34 additions & 62 deletions README.md
Expand Up @@ -7,6 +7,8 @@
Dashing-rails is the Rails Engine version of [Dashing by Shopify](http://shopify.github.io/dashing/).
A huge thanks to Shopify for their great work with the Sinatra version.

**Warning**: To upgrade from `1.x.x` to `2.x.x` you need to run `rails g dashing:install`. Please read `CHANGELOG.md` for more details.

## Introduction

Dashing is a Rails engine that lets you build beautiful dashboards.
Expand All @@ -33,11 +35,11 @@ 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`:

gem 'puma'
gem 'puma'

3. Bundle install

Expand All @@ -47,17 +49,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 +72,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 +87,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,87 +133,56 @@ 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

The `reload` action provided by [Shopify Dashing](http://shopify.github.io/dashing/) is currently not available.

## Additional Resources

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

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

Be sure to look at the [list of third party widgets](https://github.com/Shopify/dashing/wiki/Additional-Widgets).

## Browser Compatibility
## Create a new Widget

Tested in Chrome, Safari 6+, and Firefox 15+.
In order to create or add a custom widget to dashing-rails, simply follow the following steps:

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

## Heroku
$ rails g dashing:widget my_widget

Setting Dashing-rails on Heroku is pretty simple:
2. Edit `app/views/dashing/widgets/my_widget.html`

1. Create a new app:
3. Edit `app/assets/javascripts/dashing/widgets/my_widget.coffee`

heroku apps:create example
2. Add [RedisToGo](https://devcenter.heroku.com/articles/redistogo) addon to heroku's app:
4. Edit `app/assets/stylesheets/dashing/widgets/my_widget.scss`

heroku addons:add redistogo
3. Add [PostgresSQL](https://devcenter.heroku.com/articles/heroku-postgresql) addon to heroku's app (this is up to you):
You can also install pre-package widget compatible with dashing-rails. Here is [a list of all Dashing-Rails compatible Widgets](https://github.com/gottfrois/dashing-rails/wiki).

heroku addons:add heroku-postgresql:dev
4. Add `puma` to your `Gemfile`:
*Note: the paths may be different depending on your dashing-rails configuration. Check your `config/initializers/dashing.rb` file.*

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

web: bundle exec puma -p $PORT -e $RACK_ENV -t 0:5
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.

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

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:
Tested in Chrome, Safari 6+, and Firefox 15+.

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.*
Does not work in Internet Explorer because it relies on [Server Sent Events](http://www.html5rocks.com/en/tutorials/eventsource/basics/).

## 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.
$ rake

## License

Expand Down
Empty file removed app/assets/images/dashing/.keep
Empty file.
13 changes: 1 addition & 12 deletions app/assets/javascripts/dashing/application.js
Expand Up @@ -10,18 +10,7 @@
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery.gridster
//= require jquery.knob
//= require jquery.leanModal.min
//= require jquery.timeago
//= require moment.min
//= require rickshaw-1.4.3.min
//= require batman
//= require batman.jquery
//= require d3-3.2.8.min
//= require es5-shim
//= require dashing
//= require_tree .
//= require dashing.gridster
//= require default_widgets
//= require widgets
6 changes: 1 addition & 5 deletions app/assets/stylesheets/dashing/application.css
Expand Up @@ -8,10 +8,6 @@
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require font-awesome
*= require jquery.gridster
*= require default_widgets
*= require widgets
*= require_self
*= require dashing
*= require_tree .
*/
6 changes: 3 additions & 3 deletions app/controllers/dashing/dashboards_controller.rb
Expand Up @@ -6,11 +6,11 @@ class DashboardsController < ApplicationController
rescue_from ActionView::MissingTemplate, with: :template_not_found

def index
render file: dashboard_path(Dashing.config.default_dashboard || Dashing.first_dashboard || ''), layout: Dashing.config.dashboard_layout
render file: dashboard_path(Dashing.config.default_dashboard || Dashing.first_dashboard || ''), layout: Dashing.config.dashboard_layout_path
end

def show
render file: dashboard_path(params[:name]), layout: Dashing.config.dashboard_layout
render file: dashboard_path(params[:name]), layout: Dashing.config.dashboard_layout_path
end

private
Expand All @@ -20,7 +20,7 @@ def check_dashboard_name
end

def dashboard_path(name)
Rails.root.join(Dashing.config.dashboards_path, name)
Rails.root.join(Dashing.config.dashboards_views_path, name)
end

def template_not_found
Expand Down
9 changes: 2 additions & 7 deletions app/controllers/dashing/widgets_controller.rb
Expand Up @@ -26,20 +26,15 @@ def check_widget_name
end

def withdet_path
"#{params[:name]}/#{params[:name]}"
params[:name]
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', 'default_widgets')
end

def main_app_view_path
Rails.root.join(Dashing.config.widgets_path)
Rails.root.join(Dashing.config.widgets_views_path)
end

def template_not_found
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
48 changes: 25 additions & 23 deletions dashing.gemspec
@@ -1,29 +1,31 @@
$:.push File.expand_path('../lib', __FILE__)

# Maintain your gem's version:
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'dashing/version'

# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = 'dashing-rails'
s.version = Dashing::VERSION
s.authors = ['Pierre-Louis Gottfrois']
s.email = ['pierrelouis.gottfrois@gmail.com']
s.homepage = 'https://github.com/gottfrois/dashing-rails'
s.summary = 'The exceptionally handsome dashboard framework for Rails.'
s.description = 'The exceptionally handsome dashboard framework for Rails.'
Gem::Specification.new do |spec|
spec.name = 'dashing-rails'
spec.version = Dashing::VERSION
spec.authors = ['Pierre-Louis Gottfrois']
spec.email = ['pierrelouis.gottfrois@gmail.com']
spec.description = 'The exceptionally handsome dashboard framework for Rails.'
spec.summary = 'The exceptionally handsome dashboard framework for Rails.'
spec.homepage = 'https://github.com/gottfrois/dashing-rails'
spec.license = 'MIT'

s.files = Dir['{app,config,db,lib}/**/*', 'MIT-LICENSE', 'Rakefile', 'README.md']
s.test_files = Dir['spec/**/*']
spec.files = `git ls-files`.split($/)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

s.add_dependency 'rails', '~> 4.0.0'
s.add_dependency 'jquery-rails', '~> 3.0'
s.add_dependency 'coffee-script', '~> 2.2'
s.add_dependency 'rufus-scheduler', '~> 3.0'
s.add_dependency 'redis', '~> 3.0'
s.add_dependency 'connection_pool', '~> 1.1'
spec.add_dependency 'rails', '~> 4.0.0'
spec.add_dependency 'jquery-rails', '~> 3.0'
spec.add_dependency 'coffee-script', '~> 2.2'
spec.add_dependency 'rufus-scheduler', '~> 3.0'
spec.add_dependency 'redis', '~> 3.0'
spec.add_dependency 'connection_pool', '~> 1.1'

s.add_development_dependency 'rspec-rails', '~> 2.14'
s.add_development_dependency 'pry-rails', '~> 0.3'
s.add_development_dependency 'better_errors', '~> 1.0'
spec.add_development_dependency 'rspec-rails', '~> 2.14'
spec.add_development_dependency 'pry-rails', '~> 0.3'
spec.add_development_dependency 'better_errors', '~> 1.0'
end
2 changes: 1 addition & 1 deletion lib/dashing.rb
Expand Up @@ -14,7 +14,7 @@ def configure
end

def first_dashboard
files = Dir[Rails.root.join(config.dashboards_path, '*')].collect { |f| File.basename(f, '.*') }
files = Dir[Rails.root.join(config.dashboards_views_path, '*')].collect { |f| File.basename(f, '.*') }
files.sort.first
end

Expand Down

2 comments on commit e230d7a

@apneadiving
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not even a line for the guy who told you to have a decent app structure!

@gottfrois
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9bcb73c :)

Please sign in to comment.