Skip to content

Commit

Permalink
Updating to work under Rails 3.1.3
Browse files Browse the repository at this point in the history
 - Switching to use SQLite for simplicity
  • Loading branch information
Michael Khait committed Dec 2, 2011
1 parent bb931e5 commit 8701287
Show file tree
Hide file tree
Showing 35 changed files with 192 additions and 9,385 deletions.
8 changes: 6 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
source 'http://rubygems.org'

gem 'rails', '3.0.2'
gem 'rails'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'mysql2'
# gem 'mysql2'
gem 'sqlite3'

# Use jQuery-Rails
gem 'jquery-rails'

# Use unicorn as the web server
# gem 'unicorn'
Expand Down
149 changes: 84 additions & 65 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,84 +1,103 @@
GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
actionmailer (3.0.2)
actionpack (= 3.0.2)
mail (~> 2.2.9)
actionpack (3.0.2)
activemodel (= 3.0.2)
activesupport (= 3.0.2)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4.1)
rack (~> 1.2.1)
rack-mount (~> 0.6.13)
rack-test (~> 0.5.6)
tzinfo (~> 0.3.23)
activemodel (3.0.2)
activesupport (= 3.0.2)
builder (~> 2.1.2)
i18n (~> 0.4.1)
activerecord (3.0.2)
activemodel (= 3.0.2)
activesupport (= 3.0.2)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
activeresource (3.0.2)
activemodel (= 3.0.2)
activesupport (= 3.0.2)
activesupport (3.0.2)
arel (2.0.2)
builder (2.1.2)
actionmailer (3.1.3)
actionpack (= 3.1.3)
mail (~> 2.3.0)
actionpack (3.1.3)
activemodel (= 3.1.3)
activesupport (= 3.1.3)
builder (~> 3.0.0)
erubis (~> 2.7.0)
i18n (~> 0.6)
rack (~> 1.3.5)
rack-cache (~> 1.1)
rack-mount (~> 0.8.2)
rack-test (~> 0.6.1)
sprockets (~> 2.0.3)
activemodel (3.1.3)
activesupport (= 3.1.3)
builder (~> 3.0.0)
i18n (~> 0.6)
activerecord (3.1.3)
activemodel (= 3.1.3)
activesupport (= 3.1.3)
arel (~> 2.2.1)
tzinfo (~> 0.3.29)
activeresource (3.1.3)
activemodel (= 3.1.3)
activesupport (= 3.1.3)
activesupport (3.1.3)
multi_json (~> 1.0)
arel (2.2.1)
builder (3.0.0)
crack (0.1.8)
erubis (2.6.6)
abstract (>= 1.0.0)
i18n (0.4.2)
json (1.4.6)
mail (2.2.9.1)
activesupport (>= 2.3.6)
i18n (>= 0.4.1)
erubis (2.7.0)
hike (1.2.1)
i18n (0.6.0)
jquery-rails (1.0.17)
railties (~> 3.0)
thor (~> 0.14)
json (1.6.2)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
mysql2 (0.2.6)
polyglot (0.3.1)
pusher (0.6.0)
crack
json
ruby-hmac
signature
rack (1.2.1)
rack-mount (0.6.13)
mime-types (1.17.2)
multi_json (1.0.4)
polyglot (0.3.3)
pusher (0.8.4)
crack (~> 0.1.0)
multi_json (~> 1.0)
ruby-hmac (~> 0.4.0)
signature (~> 0.1.2)
rack (1.3.5)
rack-cache (1.1)
rack (>= 0.4)
rack-mount (0.8.3)
rack (>= 1.0.0)
rack-test (0.5.6)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.0.2)
actionmailer (= 3.0.2)
actionpack (= 3.0.2)
activerecord (= 3.0.2)
activeresource (= 3.0.2)
activesupport (= 3.0.2)
bundler (~> 1.0.0)
railties (= 3.0.2)
railties (3.0.2)
actionpack (= 3.0.2)
activesupport (= 3.0.2)
rails (3.1.3)
actionmailer (= 3.1.3)
actionpack (= 3.1.3)
activerecord (= 3.1.3)
activeresource (= 3.1.3)
activesupport (= 3.1.3)
bundler (~> 1.0)
railties (= 3.1.3)
railties (3.1.3)
actionpack (= 3.1.3)
activesupport (= 3.1.3)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rdoc (3.11)
json (~> 1.4)
ruby-hmac (0.4.0)
signature (0.1.2)
ruby-hmac
thor (0.14.4)
treetop (1.4.8)
sprockets (2.0.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.4)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.23)
tzinfo (0.3.31)

PLATFORMS
ruby

DEPENDENCIES
mysql2
jquery-rails
pusher
rails (= 3.0.2)
rails
sqlite3
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Add some Pusher credentials in `config/initializers/pusher.rb`

Start the server

$ script/rails server
$ rails s

Visit <http://localhost:3000/> in two browsers and start chatting.

Expand All @@ -20,4 +20,4 @@ Visit <http://localhost:3000/> in two browsers and start chatting.
If something isn't working it's most likely the Pusher credentials:

* Take a look at the Rails log for any Pusher errors
* Enable javascript debugging on line 20 of `public/javascripts/chat.js`
* Enable javascript debugging on line 20 of `app/assets/javascripts/chat.js`
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
9 changes: 9 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require jquery
//= require jquery_ujs
//= require_tree .
2 changes: 0 additions & 2 deletions public/javascripts/base.js → app/assets/javascripts/base.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
$(function() {

re_tiptip();

});

function re_tiptip() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ function send_message() {

}

function scrollToTheTop() {
$("#messages").scrollTop(20000000);
}

function replaceURLWithHTMLLinks(text) {
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
return text.replace(exp,"<a href='$1' target='_blank'>$1</a>");
Expand Down
16 changes: 8 additions & 8 deletions public/javascripts/chat.js → app/assets/javascripts/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ $(document).ready(function()

// Increment the number of people in the room when you successfully subscribe to the room
presenceChannel.bind('pusher:subscription_succeeded', function(member_list){
updateCount(member_list.length);
updateCount(member_list.count);
})

// When somebody joins, pop a note to tell the user
presenceChannel.bind('pusher:member_added', function(member) {
$('#messages').append('<li class="note"><strong>' + member.chat_user.nickname + '</strong> joined the chat.</li>');
$("#messages").attr("scrollTop",$("#messages").attr("scrollHeight") - $('#messages').height());
scrollToTheTop();
updateCount(1);
});

// When somebody leaves, pop a note to tell the user
presenceChannel.bind('pusher:member_removed', function(member) {
$('#messages').append('<li class="note"><strong>' + member.chat_user.nickname + '</strong> left the chat.</li>');
$("#messages").attr("scrollTop",$("#messages").attr("scrollHeight") - $('#messages').height());
scrollToTheTop();
updateCount(-1);
});

Expand All @@ -54,7 +54,7 @@ $(document).ready(function()
{
$('#messages').append('<li class="note"><strong>' + member.old_nickname + '</strong> updated their nickname to <strong>' + member.nickname + '</strong>.</li>');
}
$("#messages").attr("scrollTop",$("#messages").attr("scrollHeight") - $('#messages').height());
scrollToTheTop();
});

// Deal with incoming messages!
Expand Down Expand Up @@ -92,7 +92,7 @@ $(document).ready(function()

$('#messages').append('<li class="' + you + 'just_added_id_' + message.id + '" style="display:none;"><strong>' + message.user.nickname + '</strong> said:<br />' + replaceURLWithHTMLLinks(message.message) + '</li>');
$('#messages li.just_added_id_' + message.id).fadeIn();
$("#messages").attr("scrollTop",$("#messages").attr("scrollHeight") - $('#messages').height());
scrollToTheTop();
});

// Typing Messages
Expand All @@ -103,13 +103,13 @@ $(document).ready(function()
} else {
$('#messages #is_typing_' + notification.user.id).remove();
}
$("#messages").attr("scrollTop",$("#messages").attr("scrollHeight") - $('#messages').height());
scrollToTheTop();
});

// Now pusher is all setup lets let the user go wild!
$('#loading').fadeOut();
$('#message').attr("disabled","");
$("#messages").attr("scrollTop",$("#messages").attr("scrollHeight") - $('#messages').height());
$('#message').removeAttr("disabled");
scrollToTheTop();

// Enter key to send message
$('#message').keydown(function(e)
Expand Down
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. 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_self
*= require_tree .
*/
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ a:hover, a:visited:hover { border-bottom: 1px solid #3f8eda; }
a.button:hover, a.button:visited:hover { border-bottom: none; }

button, input[type=submit], input[type=button] {
background: url(/images/button_bg.png) no-repeat top left;
background: url(/assets/button_bg.png) no-repeat top left;
border: none;
height: 24px;
padding: 0 0 2px 0;
Expand Down Expand Up @@ -107,7 +107,7 @@ input[type=text]
}
#wrapper .header #beta-bookmark {
float: right;
background: url(/images/beta-bookmark.png) 0% 0% no-repeat transparent;
background: url(/assets/beta-bookmark.png) 0% 0% no-repeat transparent;
width: 53px;
height: 93px;
text-indent: -150px;
Expand All @@ -117,7 +117,7 @@ input[type=text]
#wrapper .header #loading {
width: 16px;
height: 16px;
background: url(/images/spinner.gif) no-repeat center center;
background: url(/assets/spinner.gif) no-repeat center center;
display: inline-block;
float: right;
margin: 0 10px 0 0;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion app/views/chat/view.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
user_id = "<%= @user.id %>";
</script>

<%= javascript_include_tag "http://js.pusherapp.com/1.7/pusher.min.js", "chat" %>
<%= javascript_include_tag "http://js.pusherapp.com/1.9/pusher.min.js" %>

<div id="wrapper">
<div class="header">
Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<html>
<head>
<title>Pusher Chat</title>
<%= stylesheet_link_tag "style", "tipTip" %>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<script type="text/javascript" charset="utf-8">
var PUSHER_KEY = '<%= Pusher.key %>'
</script>
<%= javascript_include_tag "http://code.jquery.com/jquery-1.4.4.min.js", "jquery.tipTip.minified", "base", "chat.functions" %>
</head>
<body>

Expand Down
18 changes: 12 additions & 6 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

require 'rails/all'

# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env) if defined?(Bundler)
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end

module PusherChat
class Application < Rails::Application
Expand Down Expand Up @@ -32,13 +35,16 @@ class Application < Rails::Application
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de

# JavaScript files you want as :defaults (application.js is always included).
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)

# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"

# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]

# Enable the asset pipeline
config.assets.enabled = true

# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
end
end
Loading

0 comments on commit 8701287

Please sign in to comment.