Skip to content

Commit

Permalink
automatic import from ryanb/railscasts-episodes
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanb committed Jan 17, 2012
0 parents commit 819ffbb
Show file tree
Hide file tree
Showing 127 changed files with 1,649 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
RailsCasts Episode #316: Private Pub

http://railscasts.com/episodes/316-private-pub

Requires Ruby 1.9.2 or higher.

Commands used in episode

bundle
rails g private_pub:install
rackup private_pub.ru -s thin -E production
15 changes: 15 additions & 0 deletions chatter-after/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile ~/.gitignore_global

# Ignore bundler config
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3

# Ignore all logfiles and tempfiles.
/log/*.log
/tmp
16 changes: 16 additions & 0 deletions chatter-after/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
source 'http://rubygems.org'

gem 'rails', '3.1.3'
gem 'sqlite3'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.1.5'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

gem 'private_pub'
141 changes: 141 additions & 0 deletions chatter-after/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
GEM
remote: http://rubygems.org/
specs:
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)
addressable (2.2.6)
arel (2.2.1)
builder (3.0.0)
coffee-rails (3.1.1)
coffee-script (>= 2.2.0)
railties (~> 3.1.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.2.0)
cookiejar (0.3.0)
daemons (1.1.5)
em-hiredis (0.1.0)
hiredis (~> 0.3.0)
em-http-request (0.3.0)
addressable (>= 2.0.0)
escape_utils
eventmachine (>= 0.12.9)
erubis (2.7.0)
escape_utils (0.2.4)
eventmachine (0.12.10)
execjs (1.2.13)
multi_json (~> 1.0)
faye (0.7.1)
cookiejar (>= 0.3.0)
em-hiredis (>= 0.0.1)
em-http-request (~> 0.3)
eventmachine (~> 0.12.0)
json (>= 1.0)
rack (>= 1.0)
thin (~> 1.2)
hike (1.2.1)
hiredis (0.3.2)
i18n (0.6.0)
jquery-rails (1.0.19)
railties (~> 3.0)
thor (~> 0.14)
json (1.6.5)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.17.2)
multi_json (1.0.4)
polyglot (0.3.3)
private_pub (1.0.0)
faye
rack (1.3.6)
rack-cache (1.1)
rack (>= 0.4)
rack-mount (0.8.3)
rack (>= 1.0.0)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
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)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
sass (3.1.12)
sass-rails (3.1.5)
actionpack (~> 3.1.0)
railties (~> 3.1.0)
sass (~> 3.1.10)
tilt (~> 1.3.2)
sprockets (2.0.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.5)
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)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.31)
uglifier (1.2.2)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)

PLATFORMS
ruby

DEPENDENCIES
coffee-rails (~> 3.1.1)
jquery-rails
private_pub
rails (= 3.1.3)
sass-rails (~> 3.1.5)
sqlite3
uglifier (>= 1.0.3)
9 changes: 9 additions & 0 deletions chatter-after/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
= RailsCasts Example Application

Run these commands to try it out.

bundle
rake db:setup
rails s

Requires Ruby 1.9.2 or later to run.
7 changes: 7 additions & 0 deletions chatter-after/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)

Chatter::Application.load_tasks
Binary file added chatter-after/app/assets/images/rails.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions chatter-after/app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// 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 private_pub
//= require_tree .
5 changes: 5 additions & 0 deletions chatter-after/app/assets/javascripts/messages.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
PrivatePub.subscribe "/messages/new", (data, channel) ->
alert data.message.content
87 changes: 87 additions & 0 deletions chatter-after/app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* 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 .
*/

body {
background-color: #4B7399;
font-family: Verdana, Helvetica, Arial;
font-size: 14px;
}

a img {
border: none;
}

a {
color: #0000FF;
}

.clear {
clear: both;
height: 0;
overflow: hidden;
}

#container {
width: 75%;
margin: 0 auto;
background-color: #FFF;
padding: 20px 40px;
border: solid 1px black;
margin-top: 20px;
}

#flash_notice, #flash_error, #flash_alert {
padding: 5px 8px;
margin: 10px 0;
}

#flash_notice {
background-color: #CFC;
border: solid 1px #6C6;
}

#flash_error, #flash_alert {
background-color: #FCC;
border: solid 1px #C66;
}

.field_with_errors {
display: inline;
}

.error_messages {
width: 400px;
border: 2px solid #CF0000;
padding: 0px;
padding-bottom: 12px;
margin-bottom: 20px;
background-color: #f0f0f0;
font-size: 12px;
}

.error_messages h2 {
text-align: left;
font-weight: bold;
padding: 5px 10px;
font-size: 12px;
margin: 0;
background-color: #c00;
color: #fff;
}

.error_messages p {
margin: 8px 10px;
}

.error_messages ul {
margin-bottom: 0;
}

form .field, form .actions {
margin: 12px 0;
}
24 changes: 24 additions & 0 deletions chatter-after/app/assets/stylesheets/messages.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
ul#chat {
list-style: none;
padding: 0;
width: 300px;
height: 150px;
border: solid 1px #777;
margin: 5px 0;
overflow: auto;
li {
margin: 2px 5px;
padding: 0;
.created_at {
float: right;
color: #777;
font-size: 11px;
padding-left: 4px;
padding-top: 2px;
}
}
}

input#message_content {
width: 240px;
}
3 changes: 3 additions & 0 deletions chatter-after/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class ApplicationController < ActionController::Base
protect_from_forgery
end
10 changes: 10 additions & 0 deletions chatter-after/app/controllers/messages_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class MessagesController < ApplicationController
def index
@messages = Message.all
end

def create
@message = Message.create!(params[:message])
PrivatePub.publish_to("/messages/new", message: @message)
end
end
2 changes: 2 additions & 0 deletions chatter-after/app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ApplicationHelper
end
2 changes: 2 additions & 0 deletions chatter-after/app/helpers/messages_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module MessagesHelper
end
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions chatter-after/app/models/message.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Message < ActiveRecord::Base
end
17 changes: 17 additions & 0 deletions chatter-after/app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<title>Chatter</title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tag %>
</head>
<body>
<div id="container">
<% flash.each do |name, msg| %>
<%= content_tag :div, msg, :id => "flash_#{name}" %>
<% end %>
<%= yield %>
</div>
</body>
</html>
4 changes: 4 additions & 0 deletions chatter-after/app/views/messages/_message.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<li>
<span class="created_at"><%= message.created_at.strftime("%H:%M") %></span>
<%= message.content %>
</li>
4 changes: 4 additions & 0 deletions chatter-after/app/views/messages/create.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<% publish_to "/messages/new" do %>
$("#chat").append("<%= j render(@message) %>");
<% end %>
$("#new_message")[0].reset();
Loading

0 comments on commit 819ffbb

Please sign in to comment.