Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Pushing up notifications

  • Loading branch information...
commit 1ba2ca44dd4880456aad8b1ed7bf01e546272318 1 parent f75854f
@beleblanc authored
View
2  Gemfile
@@ -20,7 +20,9 @@ gem 'activeadmin-cancan'
gem 'meta_search', '>= 1.1.0.pre'
gem 'wicked'
gem 'prawn'
+gem 'private_pub'
gem 'country-select'
+gem 'thin'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
View
31 Gemfile.lock
@@ -44,6 +44,7 @@ GEM
activesupport (3.2.3)
i18n (~> 0.6)
multi_json (~> 1.0)
+ addressable (2.2.8)
arel (3.0.2)
bcrypt-ruby (3.0.1)
bourbon (2.1.0)
@@ -65,17 +66,37 @@ GEM
execjs
coffee-script-source (1.3.1)
commonjs (0.2.5)
+ cookiejar (0.3.0)
country-select (1.1.1)
+ daemons (1.1.8)
devise (2.0.4)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.0.3)
railties (~> 3.1)
warden (~> 1.1.1)
diff-lcs (1.1.3)
+ em-http-request (1.0.2)
+ addressable (>= 2.2.3)
+ cookiejar
+ em-socksify
+ eventmachine (>= 1.0.0.beta.4)
+ http_parser.rb (>= 0.5.3)
+ em-socksify (0.2.0)
+ eventmachine (>= 1.0.0.beta.4)
erubis (2.7.0)
+ eventmachine (1.0.0.rc.1)
execjs (1.3.0)
multi_json (~> 1.0)
fastercsv (1.5.5)
+ faye (0.8.2)
+ cookiejar (>= 0.3.0)
+ em-http-request (>= 0.3.0)
+ eventmachine (>= 0.12.0)
+ faye-websocket (>= 0.4.0)
+ rack (>= 1.0.0)
+ yajl-ruby (>= 1.0.0)
+ faye-websocket (0.4.5)
+ eventmachine (>= 0.12.0)
formtastic (2.1.1)
actionpack (~> 3.0)
haml (3.1.6)
@@ -87,6 +108,7 @@ GEM
has_scope (0.5.1)
highline (1.6.11)
hike (1.2.1)
+ http_parser.rb (0.5.3)
httparty (0.8.3)
multi_json (~> 1.0)
multi_xml
@@ -153,6 +175,8 @@ GEM
prawn (0.12.0)
pdf-reader (>= 0.9.0)
ttfunk (~> 1.0.2)
+ private_pub (1.0.1)
+ faye
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
@@ -204,6 +228,10 @@ GEM
tilt (~> 1.1, != 1.3.0)
therubyracer (0.10.0)
libv8 (~> 3.3.10)
+ thin (1.3.1)
+ daemons (>= 1.0.9)
+ eventmachine (>= 0.12.6)
+ rack (>= 1.0.0)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
@@ -227,6 +255,7 @@ GEM
wicked (0.1.6)
activesupport (>= 3.0.7)
rails (>= 3.0.7)
+ yajl-ruby (1.1.0)
PLATFORMS
ruby
@@ -247,11 +276,13 @@ DEPENDENCIES
mysql2
paperclip (~> 3.0.4)
prawn
+ private_pub
rails (= 3.2.3)
rolify
rspec
sass-rails (~> 3.2.3)
simple_form
+ thin
twitter-bootstrap-rails
uglifier (>= 1.0.3)
unicorn
View
1  app/assets/javascripts/application.js
@@ -17,6 +17,7 @@
//= require dataTables/jquery.dataTables
//= require jquery.ui.datepicker
//= require jquery.ui.autocomplete
+//= require private_pub
//= require_tree .
View
11 app/assets/stylesheets/application.css.scss
@@ -99,4 +99,15 @@
.text-left {
text-align: left !important;
+}
+
+//Messaging Stylong
+
+#messaging {
+ position: fixed;
+ bottom: 0;
+ right: 0;
+ width: 200px;
+ border: 3px solid #CCC;
+ border-radius: 20px;
}
View
2  app/controllers/wait_lists_controller.rb
@@ -43,7 +43,7 @@ def edit
# POST /waitlist.json
def create
@waitlist = WaitList.new(params[:wait_list])
-
+ PrivatePub.publish_to "/messages/super_admin", :chat_message => "Hello, world!"
respond_to do |format|
if @waitlist.save
format.html { redirect_to people_path, notice: 'Patient was successfully checked-in.' }
View
2  app/models/role.rb
@@ -1,5 +1,5 @@
class Role < ActiveRecord::Base
- attr_accessible :name
+ attr_accessible :name ,:resource_type
has_and_belongs_to_many :users, :join_table => :users_roles
belongs_to :resource, :polymorphic => true
View
0  app/views/layouts/_flash.html.haml
No changes.
View
16 app/views/layouts/_messaging.html.haml
@@ -0,0 +1,16 @@
+-if user_signed_in?
+ -current_user.roles.each do |role|
+ =subscribe_to "/messages/#{role.name}"
+ -if current_user.has_role?(:doctor)
+ =subscribe_to "/messages/#{current_user.username}"
+ -if current_user.has_role?(:doctor)
+ :javascript
+ PrivatePub.subscribe("/messages/#{current_user.username}", function(data, channel) {
+ $("#messaging").append('<div class="alert"><a class="close" data-dismiss= "alert">x</a>'+data.chat_message+'</div>');});
+
+ -current_user.roles.each do |role|
+ :javascript
+ PrivatePub.subscribe("/messages/#{role.name}", function(data, channel) {
+ $("#messaging").append('<div class="alert"><a class="close" data-dismiss= "alert">x</a>'+data.chat_message+'</div>');});
+
+ #messaging
View
3  app/views/layouts/application.html.haml
@@ -55,7 +55,7 @@
-
+
%footer
%p &copy; Company 2012
/
@@ -63,3 +63,4 @@
\==================================================
/ Placed at the end of the document so the pages load faster
= javascript_include_tag "application"
+ =render :partial => 'layouts/messaging'
View
10 config/private_pub.yml
@@ -0,0 +1,10 @@
+development:
+ server: "http://localhost:9292/faye"
+ secret_token: "secret"
+test:
+ server: "http://localhost:9292/faye"
+ secret_token: "secret"
+production:
+ server: "http://example.com/faye"
+ secret_token: "66315bd602a6bccf199d9ff0cadc79aa6c100d9e02c482b943721428a384c78a"
+ signature_expiration: 3600 # one hour
View
9 private_pub.ru
@@ -0,0 +1,9 @@
+# Run with: rackup private_pub.ru -s thin -E production
+require "bundler/setup"
+require "yaml"
+require "faye"
+require "private_pub"
+
+PrivatePub.load_config(File.expand_path("../config/private_pub.yml", __FILE__), ENV["RAILS_ENV"] || "development")
+run PrivatePub.faye_app
+Faye::WebSocket.load_adapter('thin')
Please sign in to comment.
Something went wrong with that request. Please try again.