Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit ccbc2025a310e9aea53e8f3b4b0ae0ae44217f50 @johnsome johnsome committed Jun 30, 2011
Showing with 1,053 additions and 0 deletions.
  1. +5 −0 .gitignore
  2. +30 −0 Gemfile
  3. +125 −0 Gemfile.lock
  4. BIN HTML5_Websockets_with_Rails_and_Pusher.pdf
  5. BIN HTML5_Websockets_with_Rails_and_Pusher.ppt
  6. +18 −0 README.md
  7. +7 −0 Rakefile
  8. BIN app/assets/images/rails.png
  9. +10 −0 app/assets/javascripts/application.js
  10. +3 −0 app/assets/javascripts/products.js.coffee
  11. +7 −0 app/assets/stylesheets/application.css
  12. +7 −0 app/assets/stylesheets/products.css.scss
  13. +56 −0 app/assets/stylesheets/scaffolds.css.scss
  14. +3 −0 app/controllers/application_controller.rb
  15. +87 −0 app/controllers/products_controller.rb
  16. +2 −0 app/helpers/application_helper.rb
  17. +2 −0 app/helpers/products_helper.rb
  18. 0 app/mailers/.gitkeep
  19. 0 app/models/.gitkeep
  20. +2 −0 app/models/product.rb
  21. +14 −0 app/views/layouts/application.html.erb
  22. +29 −0 app/views/products/_form.html.erb
  23. +6 −0 app/views/products/edit.html.erb
  24. +65 −0 app/views/products/index.html.erb
  25. +5 −0 app/views/products/new.html.erb
  26. +20 −0 app/views/products/show.html.erb
  27. +4 −0 config.ru
  28. +42 −0 config/application.rb
  29. +6 −0 config/boot.rb
  30. +25 −0 config/database.yml
  31. +5 −0 config/environment.rb
  32. +27 −0 config/environments/development.rb
  33. +54 −0 config/environments/production.rb
  34. +39 −0 config/environments/test.rb
  35. +7 −0 config/initializers/backtrace_silencers.rb
  36. +10 −0 config/initializers/inflections.rb
  37. +5 −0 config/initializers/mime_types.rb
  38. +5 −0 config/initializers/pusher.rb
  39. +7 −0 config/initializers/secret_token.rb
  40. +8 −0 config/initializers/session_store.rb
  41. +12 −0 config/initializers/wrap_parameters.rb
  42. +5 −0 config/locales/en.yml
  43. +61 −0 config/routes.rb
  44. +11 −0 db/migrate/20110630045447_create_products.rb
  45. +23 −0 db/schema.rb
  46. +7 −0 db/seeds.rb
  47. +2 −0 doc/README_FOR_APP
  48. 0 lib/tasks/.gitkeep
  49. +26 −0 public/404.html
  50. +26 −0 public/422.html
  51. +26 −0 public/500.html
  52. 0 public/favicon.ico
  53. +5 −0 public/robots.txt
  54. +6 −0 script/rails
  55. 0 test/fixtures/.gitkeep
  56. +11 −0 test/fixtures/products.yml
  57. 0 test/functional/.gitkeep
  58. +49 −0 test/functional/products_controller_test.rb
  59. 0 test/integration/.gitkeep
  60. +12 −0 test/performance/browsing_test.rb
  61. +13 −0 test/test_helper.rb
  62. 0 test/unit/.gitkeep
  63. +4 −0 test/unit/helpers/products_helper_test.rb
  64. +7 −0 test/unit/product_test.rb
  65. 0 vendor/assets/stylesheets/.gitkeep
  66. 0 vendor/plugins/.gitkeep
@@ -0,0 +1,5 @@
+.bundle
+db/*.sqlite3
+log/*.log
+tmp/
+.sass-cache/
30 Gemfile
@@ -0,0 +1,30 @@
+source 'http://rubygems.org'
+
+gem 'rails', '3.1.0.rc4'
+gem 'pusher'
+
+# Bundle edge Rails instead:
+# gem 'rails', :git => 'git://github.com/rails/rails.git'
+
+gem 'sqlite3'
+
+# Asset template engines
+gem 'sass-rails', "~> 3.1.0.rc"
+gem 'coffee-script'
+gem 'uglifier'
+
+gem 'jquery-rails'
+
+# Use unicorn as the web server
+# gem 'unicorn'
+
+# Deploy with Capistrano
+# gem 'capistrano'
+
+# To use debugger
+# gem 'ruby-debug19', :require => 'ruby-debug'
+
+group :test do
+ # Pretty printed test output
+ gem 'turn', :require => false
+end
@@ -0,0 +1,125 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionmailer (3.1.0.rc4)
+ actionpack (= 3.1.0.rc4)
+ mail (~> 2.3.0)
+ actionpack (3.1.0.rc4)
+ activemodel (= 3.1.0.rc4)
+ activesupport (= 3.1.0.rc4)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6)
+ rack (~> 1.3.0)
+ rack-cache (~> 1.0.1)
+ rack-mount (~> 0.8.1)
+ rack-test (~> 0.6.0)
+ sprockets (~> 2.0.0.beta.10)
+ tzinfo (~> 0.3.27)
+ activemodel (3.1.0.rc4)
+ activesupport (= 3.1.0.rc4)
+ bcrypt-ruby (~> 2.1.4)
+ builder (~> 3.0.0)
+ i18n (~> 0.6)
+ activerecord (3.1.0.rc4)
+ activemodel (= 3.1.0.rc4)
+ activesupport (= 3.1.0.rc4)
+ arel (~> 2.1.1)
+ tzinfo (~> 0.3.27)
+ activeresource (3.1.0.rc4)
+ activemodel (= 3.1.0.rc4)
+ activesupport (= 3.1.0.rc4)
+ activesupport (3.1.0.rc4)
+ multi_json (~> 1.0)
+ ansi (1.2.5)
+ arel (2.1.3)
+ bcrypt-ruby (2.1.4)
+ builder (3.0.0)
+ coffee-script (2.2.0)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.1.1)
+ crack (0.1.8)
+ erubis (2.7.0)
+ execjs (1.2.0)
+ multi_json (~> 1.0)
+ hike (1.1.0)
+ i18n (0.6.0)
+ jquery-rails (1.0.12)
+ railties (~> 3.0)
+ thor (~> 0.14)
+ mail (2.3.0)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.16)
+ multi_json (1.0.3)
+ polyglot (0.3.1)
+ pusher (0.8.1)
+ crack (~> 0.1.0)
+ multi_json (~> 1.0)
+ ruby-hmac (~> 0.4.0)
+ signature (~> 0.1.2)
+ rack (1.3.0)
+ rack-cache (1.0.2)
+ rack (>= 0.4)
+ rack-mount (0.8.1)
+ rack (>= 1.0.0)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.0)
+ rack (>= 1.0)
+ rails (3.1.0.rc4)
+ actionmailer (= 3.1.0.rc4)
+ actionpack (= 3.1.0.rc4)
+ activerecord (= 3.1.0.rc4)
+ activeresource (= 3.1.0.rc4)
+ activesupport (= 3.1.0.rc4)
+ bundler (~> 1.0)
+ railties (= 3.1.0.rc4)
+ railties (3.1.0.rc4)
+ actionpack (= 3.1.0.rc4)
+ activesupport (= 3.1.0.rc4)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2)
+ rdoc (3.8)
+ ruby-hmac (0.4.0)
+ sass (3.1.3)
+ sass-rails (3.1.0.rc.3)
+ actionpack (~> 3.1.0.rc1)
+ railties (~> 3.1.0.rc1)
+ sass (>= 3.1.3)
+ sprockets (>= 2.0.0.beta.9)
+ signature (0.1.2)
+ ruby-hmac
+ sprockets (2.0.0.beta.10)
+ hike (~> 1.0)
+ rack (~> 1.0)
+ tilt (!= 1.3.0, ~> 1.1)
+ sqlite3 (1.3.3)
+ thor (0.14.6)
+ tilt (1.3.2)
+ treetop (1.4.9)
+ polyglot (>= 0.3.1)
+ turn (0.8.2)
+ ansi (>= 1.2.2)
+ tzinfo (0.3.29)
+ uglifier (1.0.0)
+ execjs (>= 0.3.0)
+ multi_json (>= 1.0.2)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ coffee-script
+ jquery-rails
+ pusher
+ rails (= 3.1.0.rc4)
+ sass-rails (~> 3.1.0.rc)
+ sqlite3
+ turn
+ uglifier
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,18 @@
+# HTML5 Websockets with Pusher and Rails (3.1RC)
+
+This is a rails (3.1RC) app built live by Mark Johnson (@logicspin) during the
+June 29th 2011 Aloha.rb meetup, to demonstrate HTML5 Websockets and Pusher.
+
+## Presentation slides
+
+* HTML5_Websockets_with_Rails_and_Pusher.pdf
+* HTML5_Websockets_with_Rails_and_Pusher.ppt
+
+## Getting Started
+
+1. setup ruby 1.9.2: see https://gist.github.com/1054688
+2. Create a Pusher account: http://pusher.com/
+3. update initializers/pusher.rb with your pusher account info
+4. in the pusher admin - view the debug console to see events are firing
+5. test with 2 browsers open - changes in one will update index of other etc.
+
@@ -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__)
+
+ProductsPusher::Application.load_tasks
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -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_tree .
+//= require jquery-ui
@@ -0,0 +1,3 @@
+# 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/
@@ -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 .
+*/
@@ -0,0 +1,7 @@
+// Place all the styles related to the products controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
+
+body.products {
+ // Place scoped styles here
+}
@@ -0,0 +1,56 @@
+body {
+ background-color: #fff;
+ color: #333;
+ font-family: verdana, arial, helvetica, sans-serif;
+ font-size: 13px;
+ line-height: 18px; }
+
+p, ol, ul, td {
+ font-family: verdana, arial, helvetica, sans-serif;
+ font-size: 13px;
+ line-height: 18px; }
+
+pre {
+ background-color: #eee;
+ padding: 10px;
+ font-size: 11px; }
+
+a {
+ color: #000;
+ &:visited {
+ color: #666; }
+ &:hover {
+ color: #fff;
+ background-color: #000; } }
+
+div {
+ &.field, &.actions {
+ margin-bottom: 10px; } }
+
+#notice {
+ color: green; }
+
+.field_with_errors {
+ padding: 2px;
+ background-color: red;
+ display: table; }
+
+#error_explanation {
+ width: 450px;
+ border: 2px solid red;
+ padding: 7px;
+ padding-bottom: 0;
+ margin-bottom: 20px;
+ background-color: #f0f0f0;
+ h2 {
+ text-align: left;
+ font-weight: bold;
+ padding: 5px 5px 5px 15px;
+ font-size: 12px;
+ margin: -7px;
+ margin-bottom: 0px;
+ background-color: #c00;
+ color: #fff; }
+ ul li {
+ font-size: 12px;
+ list-style: square; } }
@@ -0,0 +1,3 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery
+end
@@ -0,0 +1,87 @@
+class ProductsController < ApplicationController
+ # GET /products
+ # GET /products.json
+ def index
+ @products = Product.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @products }
+ end
+ end
+
+ # GET /products/1
+ # GET /products/1.json
+ def show
+ @product = Product.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @product }
+ end
+ end
+
+ # GET /products/new
+ # GET /products/new.json
+ def new
+ @product = Product.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @product }
+ end
+ end
+
+ # GET /products/1/edit
+ def edit
+ @product = Product.find(params[:id])
+ end
+
+ # POST /products
+ # POST /products.json
+ def create
+ @product = Product.new(params[:product])
+
+ respond_to do |format|
+ if @product.save
+ Pusher['products'].trigger('product-create', @product.attributes)
+
+ format.html { redirect_to @product, notice: 'Product was successfully created.' }
+ format.json { render json: @product, status: :created, location: @product }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @product.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /products/1
+ # PUT /products/1.json
+ def update
+ @product = Product.find(params[:id])
+
+ respond_to do |format|
+ if @product.update_attributes(params[:product])
+ Pusher['products'].trigger('product-update', @product.attributes)
+ format.html { redirect_to @product, notice: 'Product was successfully updated.' }
+ format.json { head :ok }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @product.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /products/1
+ # DELETE /products/1.json
+ def destroy
+ @product = Product.find(params[:id])
+ @product.destroy
+ Pusher['products'].trigger('product-destroy', @product.attributes)
+
+ respond_to do |format|
+ format.html { redirect_to products_url }
+ format.json { head :ok }
+ end
+ end
+end
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
@@ -0,0 +1,2 @@
+module ProductsHelper
+end
No changes.
No changes.
@@ -0,0 +1,2 @@
+class Product < ActiveRecord::Base
+end
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>ProductsPusher</title>
+ <%= stylesheet_link_tag "application" %>
+ <%= javascript_include_tag "application" %>
+ <%= csrf_meta_tags %>
+</head>
+<body>
+
+<%= yield %>
+
+</body>
+</html>
Oops, something went wrong.

0 comments on commit ccbc202

Please sign in to comment.