Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,14 +1,2 @@
PUSHER_APP_ID=12345

PUSHER_KEY=abc
PUSHER_SECRET=123

PUSHER_CLIENT_PORT=80
PUSHER_CLIENT_PORT_SSL=443
PUSHER_CLIENT_HOST=ws.pusherapp.com

PUSHER_API_HOST=api.pusherapp.com
PUSHER_API_PORT=80

ADMIN_USERNAME=admin
ADMIN_PASSWORD=secret
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source 'https://rails-assets.org'
ruby '2.1.2'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.6'
gem 'rails', '4.2.3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
Expand All @@ -17,8 +17,6 @@ gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

Expand All @@ -39,7 +37,9 @@ gem 'spring', group: :development

gem "autoprefixer-rails"
gem 'rails-assets-angular', "1.3.0.rc.4"
gem 'pusher'
gem 'actioncable', github: "rails/actioncable"
gem 'puma'
gem "active_model_serializers"

group :production, :staging do
gem 'pg'
Expand Down
161 changes: 106 additions & 55 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,34 +1,58 @@
GIT
remote: git://github.com/rails/actioncable.git
revision: c7dc339b1dbdb1982d82536d87b6e654e7b7108d
specs:
actioncable (0.1.0)
actionpack (>= 4.2.0)
activesupport (>= 4.2.0)
celluloid (~> 0.16.0)
em-hiredis (~> 0.3.0)
faye-websocket (~> 0.9.2)
redis (~> 3.0)
websocket-driver (= 0.5.4)

GEM
remote: https://rubygems.org/
remote: https://rails-assets.org/
specs:
actionmailer (4.1.6)
actionpack (= 4.1.6)
actionview (= 4.1.6)
actionmailer (4.2.3)
actionpack (= 4.2.3)
actionview (= 4.2.3)
activejob (= 4.2.3)
mail (~> 2.5, >= 2.5.4)
actionpack (4.1.6)
actionview (= 4.1.6)
activesupport (= 4.1.6)
rack (~> 1.5.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.3)
actionview (= 4.2.3)
activesupport (= 4.2.3)
rack (~> 1.6)
rack-test (~> 0.6.2)
actionview (4.1.6)
activesupport (= 4.1.6)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.3)
activesupport (= 4.2.3)
builder (~> 3.1)
erubis (~> 2.7.0)
activemodel (4.1.6)
activesupport (= 4.1.6)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
active_model_serializers (0.9.3)
activemodel (>= 3.2)
activejob (4.2.3)
activesupport (= 4.2.3)
globalid (>= 0.3.0)
activemodel (4.2.3)
activesupport (= 4.2.3)
builder (~> 3.1)
activerecord (4.1.6)
activemodel (= 4.1.6)
activesupport (= 4.1.6)
arel (~> 5.0.0)
activesupport (4.1.6)
i18n (~> 0.6, >= 0.6.9)
activerecord (4.2.3)
activemodel (= 4.2.3)
activesupport (= 4.2.3)
arel (~> 6.0)
activesupport (4.2.3)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (5.0.1.20140414130214)
arel (6.0.0)
autoprefixer-rails (2.2.0.20140727)
execjs
better_errors (1.0.1)
Expand All @@ -37,6 +61,8 @@ GEM
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.2.2)
celluloid (0.16.0)
timers (~> 4.0.0)
coderay (1.1.0)
coffee-rails (4.0.1)
coffee-script (>= 2.2.0)
Expand All @@ -51,56 +77,76 @@ GEM
dotenv-deployment (0.0.2)
dotenv-rails (0.11.1)
dotenv (= 0.11.1)
em-hiredis (0.3.0)
eventmachine (~> 1.0)
hiredis (~> 0.5.0)
erubis (2.7.0)
eventmachine (1.0.7)
execjs (2.2.1)
faye-websocket (0.9.2)
eventmachine (>= 0.12.0)
websocket-driver (>= 0.5.1)
globalid (0.3.5)
activesupport (>= 4.1.0)
hike (1.2.3)
httpclient (2.4.0)
i18n (0.6.11)
jbuilder (2.1.3)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
hiredis (0.5.2)
hitimes (1.2.2)
i18n (0.7.0)
jquery-rails (3.1.2)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.8.1)
mail (2.6.1)
json (1.8.3)
loofah (2.0.2)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
mime-types (2.3)
minitest (5.4.2)
multi_json (1.10.1)
mime-types (2.6.1)
mini_portile (0.6.2)
minitest (5.7.0)
multi_json (1.11.2)
mysql2 (0.3.16)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
pg (0.17.0)
pusher (0.14.1)
httpclient (~> 2.3)
multi_json (~> 1.0)
signature (~> 0.1.6)
rack (1.5.2)
rack-test (0.6.2)
puma (2.11.3)
rack (>= 1.1, < 2.0)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.1.6)
actionmailer (= 4.1.6)
actionpack (= 4.1.6)
actionview (= 4.1.6)
activemodel (= 4.1.6)
activerecord (= 4.1.6)
activesupport (= 4.1.6)
rails (4.2.3)
actionmailer (= 4.2.3)
actionpack (= 4.2.3)
actionview (= 4.2.3)
activejob (= 4.2.3)
activemodel (= 4.2.3)
activerecord (= 4.2.3)
activesupport (= 4.2.3)
bundler (>= 1.3.0, < 2.0)
railties (= 4.1.6)
sprockets-rails (~> 2.0)
railties (= 4.2.3)
sprockets-rails
rails-assets-angular (1.3.0.rc.4)
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.6)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.2)
loofah (~> 2.0)
rails_12factor (0.0.2)
rails_serve_static_assets
rails_stdout_logging
rails_serve_static_assets (0.0.2)
rails_stdout_logging (0.0.3)
railties (4.1.6)
actionpack (= 4.1.6)
activesupport (= 4.1.6)
railties (4.2.3)
actionpack (= 4.2.3)
activesupport (= 4.2.3)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.3.2)
rake (10.4.2)
rdoc (4.1.2)
json (~> 1.4)
redis (3.2.1)
sass (3.2.19)
sass-rails (4.0.3)
railties (>= 4.0.0, < 5.0)
Expand All @@ -110,43 +156,48 @@ GEM
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
signature (0.1.7)
spring (1.1.3)
sprockets (2.11.0)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.1.4)
sprockets-rails (2.3.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
sprockets (>= 2.8, < 4.0)
thor (0.19.1)
thread_safe (0.3.4)
thread_safe (0.3.5)
tilt (1.4.1)
timers (4.0.1)
hitimes
turbolinks (2.4.0)
coffee-rails
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (2.5.3)
execjs (>= 0.3.0)
json (>= 1.8.0)
websocket-driver (0.5.4)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)

PLATFORMS
ruby

DEPENDENCIES
actioncable!
active_model_serializers
autoprefixer-rails
better_errors
binding_of_caller
coffee-rails (~> 4.0.0)
dotenv-rails
jbuilder (~> 2.0)
jquery-rails
mysql2
pg
pusher
rails (= 4.1.6)
puma
rails (= 4.2.3)
rails-assets-angular (= 1.3.0.rc.4)
rails_12factor
sass-rails (~> 4.0.3)
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ $ rake db:migrate
$ cp .env.example .env
```

Modify the `.env` file to match with your [Pusher](http://pusher.com) application credentials or setup [Slanger](https://github.com/stevegraham/slanger) (perhaps with [docker-slanger](https://github.com/adambutler/docker-slanger))


## Contributing

Contributions are welcome, please follow [GitHub Flow](https://guides.github.com/introduction/flow/index.html)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
angular
.module("Poll")
.controller "ResultController", ["$scope", "$interval", "Pusher", ($scope, $interval, Pusher) ->
.controller "ResultController", ["$scope", "$interval", ($scope, $interval) ->

$scope.ctx = $('canvas')[0].getContext("2d")

Expand All @@ -11,38 +11,44 @@ angular
animationSteps: 45
}

$scope.render = (data) ->
$scope.$apply ->
if $scope.chartData.length != data.length
colors = color.randomColors(data.length)
$scope.chartData = $.extend true, data, colors
else
$scope.chartData = $.extend true, $scope.chartData, data

total = 0
for datum, index in data
total += datum.value

if $scope.chart?
for datum, index in data
$scope.chart.segments[index].value = datum.value
$scope.chart.update()
else if total > 0
$scope.chart = new Chart($scope.ctx).Doughnut($scope.chartData, $scope.chartOptions)

$scope.updateChart = ->
$.ajax
url: "/#{$scope.question}/results.json"
success: (data) ->
$scope.$apply ->
if $scope.chartData.length != data.length
colors = color.randomColors(data.length)
$scope.chartData = $.extend true, data, colors
else
$scope.chartData = $.extend true, $scope.chartData, data

total = 0
for datum, index in data
total += datum.value

console.log "Total = #{total}"

if $scope.chart?
console.log 'a'
for datum, index in data
$scope.chart.segments[index].value = datum.value
$scope.chart.update()
else if total > 0
console.log 'b'
$scope.chart = new Chart($scope.ctx).Doughnut($scope.chartData, $scope.chartOptions)
$scope.render(data)


$scope.setQuestion = (question) ->
$scope.question = question
$scope.updateChart()
channel = Pusher.subscribe(question)
channel.bind "vote", ->
$scope.updateChart()

App.votes = App.cable.subscriptions.create "VotesChannel",
connected: ->
setTimeout =>
@perform 'follow', question_id: $("[data-question-secret]").data("question-secret")
, 500

received: (data) ->
$scope.render(data)


]
18 changes: 0 additions & 18 deletions app/assets/javascripts/angular/factories/Pusher.coffee.erb

This file was deleted.

Loading