Skip to content

Commit 6629b2d

Browse files
author
Rory Low
committed
initial commit
1 parent 6bea43b commit 6629b2d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1094
-0
lines changed

.gitignore

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
#
3+
# If you find yourself ignoring temporary files generated by your text editor
4+
# or operating system, you probably want to add a global ignore instead:
5+
# git config --global core.excludesfile '~/.gitignore_global'
6+
7+
# Ignore bundler config.
8+
/.bundle
9+
10+
# Ignore the default SQLite database.
11+
/db/*.sqlite3
12+
/db/*.sqlite3-journal
13+
14+
# Ignore all logfiles and tempfiles.
15+
/log/*.log
16+
/tmp

Gemfile

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
source 'https://rubygems.org'
2+
3+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
4+
gem 'rails', '4.0.0'
5+
6+
# Use sqlite3 as the database for Active Record
7+
gem 'sqlite3'
8+
9+
# Use SCSS for stylesheets
10+
gem 'sass-rails', '~> 4.0.0'
11+
12+
# Use Uglifier as compressor for JavaScript assets
13+
gem 'uglifier', '>= 1.3.0'
14+
15+
# Use CoffeeScript for .js.coffee assets and views
16+
gem 'coffee-rails', '~> 4.0.0'
17+
18+
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
19+
gem 'therubyracer', platforms: :ruby
20+
21+
# Use jquery as the JavaScript library
22+
gem 'jquery-rails'
23+
24+
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
25+
gem 'turbolinks'
26+
27+
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
28+
gem 'jbuilder', '~> 1.2'
29+
30+
group :doc do
31+
# bundle exec rake doc:rails generates the API under doc/api.
32+
gem 'sdoc', require: false
33+
end
34+
35+
# Use ActiveModel has_secure_password
36+
# gem 'bcrypt-ruby', '~> 3.0.0'
37+
38+
# Use unicorn as the app server
39+
# gem 'unicorn'
40+
41+
# Use Capistrano for deployment
42+
# gem 'capistrano', group: :development
43+
44+
# Use debugger
45+
# gem 'debugger', group: [:development, :test]
46+
gem 'twitter-bootstrap-rails'
47+
gem 'haml-rails'
48+
gem 'websocket-rails', github: 'moaa/websocket-rails'
49+

Gemfile.lock

+167
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
GIT
2+
remote: git://github.com/moaa/websocket-rails.git
3+
revision: a091e4cba97e4143f9fe4309b3b182c7a508d7c8
4+
specs:
5+
websocket-rails (0.4.9)
6+
em-synchrony
7+
faye-websocket
8+
hiredis
9+
rack
10+
rails
11+
redis
12+
thin
13+
14+
GEM
15+
remote: https://rubygems.org/
16+
specs:
17+
actionmailer (4.0.0)
18+
actionpack (= 4.0.0)
19+
mail (~> 2.5.3)
20+
actionpack (4.0.0)
21+
activesupport (= 4.0.0)
22+
builder (~> 3.1.0)
23+
erubis (~> 2.7.0)
24+
rack (~> 1.5.2)
25+
rack-test (~> 0.6.2)
26+
activemodel (4.0.0)
27+
activesupport (= 4.0.0)
28+
builder (~> 3.1.0)
29+
activerecord (4.0.0)
30+
activemodel (= 4.0.0)
31+
activerecord-deprecated_finders (~> 1.0.2)
32+
activesupport (= 4.0.0)
33+
arel (~> 4.0.0)
34+
activerecord-deprecated_finders (1.0.3)
35+
activesupport (4.0.0)
36+
i18n (~> 0.6, >= 0.6.4)
37+
minitest (~> 4.2)
38+
multi_json (~> 1.3)
39+
thread_safe (~> 0.1)
40+
tzinfo (~> 0.3.37)
41+
arel (4.0.0)
42+
atomic (1.1.13)
43+
builder (3.1.4)
44+
coffee-rails (4.0.0)
45+
coffee-script (>= 2.2.0)
46+
railties (>= 4.0.0.beta, < 5.0)
47+
coffee-script (2.2.0)
48+
coffee-script-source
49+
execjs
50+
coffee-script-source (1.6.3)
51+
daemons (1.1.9)
52+
em-synchrony (1.0.3)
53+
eventmachine (>= 1.0.0.beta.1)
54+
erubis (2.7.0)
55+
eventmachine (1.0.3)
56+
execjs (2.0.0)
57+
faye-websocket (0.6.3)
58+
eventmachine (>= 0.12.0)
59+
websocket-driver (>= 0.2.0)
60+
haml (4.0.3)
61+
tilt
62+
haml-rails (0.4)
63+
actionpack (>= 3.1, < 4.1)
64+
activesupport (>= 3.1, < 4.1)
65+
haml (>= 3.1, < 4.1)
66+
railties (>= 3.1, < 4.1)
67+
hike (1.2.3)
68+
hiredis (0.4.5)
69+
i18n (0.6.5)
70+
jbuilder (1.5.0)
71+
activesupport (>= 3.0.0)
72+
multi_json (>= 1.2.0)
73+
jquery-rails (3.0.4)
74+
railties (>= 3.0, < 5.0)
75+
thor (>= 0.14, < 2.0)
76+
json (1.8.0)
77+
libv8 (3.16.14.3)
78+
mail (2.5.4)
79+
mime-types (~> 1.16)
80+
treetop (~> 1.4.8)
81+
mime-types (1.24)
82+
minitest (4.7.5)
83+
multi_json (1.7.9)
84+
polyglot (0.3.3)
85+
rack (1.5.2)
86+
rack-test (0.6.2)
87+
rack (>= 1.0)
88+
rails (4.0.0)
89+
actionmailer (= 4.0.0)
90+
actionpack (= 4.0.0)
91+
activerecord (= 4.0.0)
92+
activesupport (= 4.0.0)
93+
bundler (>= 1.3.0, < 2.0)
94+
railties (= 4.0.0)
95+
sprockets-rails (~> 2.0.0)
96+
railties (4.0.0)
97+
actionpack (= 4.0.0)
98+
activesupport (= 4.0.0)
99+
rake (>= 0.8.7)
100+
thor (>= 0.18.1, < 2.0)
101+
rake (10.1.0)
102+
rdoc (3.12.2)
103+
json (~> 1.4)
104+
redis (3.0.4)
105+
ref (1.0.5)
106+
sass (3.2.10)
107+
sass-rails (4.0.0)
108+
railties (>= 4.0.0.beta, < 5.0)
109+
sass (>= 3.1.10)
110+
sprockets-rails (~> 2.0.0)
111+
sdoc (0.3.20)
112+
json (>= 1.1.3)
113+
rdoc (~> 3.10)
114+
sprockets (2.10.0)
115+
hike (~> 1.2)
116+
multi_json (~> 1.0)
117+
rack (~> 1.0)
118+
tilt (~> 1.1, != 1.3.0)
119+
sprockets-rails (2.0.0)
120+
actionpack (>= 3.0)
121+
activesupport (>= 3.0)
122+
sprockets (~> 2.8)
123+
sqlite3 (1.3.8)
124+
therubyracer (0.12.0)
125+
libv8 (~> 3.16.14.0)
126+
ref
127+
thin (1.5.1)
128+
daemons (>= 1.0.9)
129+
eventmachine (>= 0.12.6)
130+
rack (>= 1.0.0)
131+
thor (0.18.1)
132+
thread_safe (0.1.2)
133+
atomic
134+
tilt (1.4.1)
135+
treetop (1.4.15)
136+
polyglot
137+
polyglot (>= 0.3.1)
138+
turbolinks (1.3.0)
139+
coffee-rails
140+
twitter-bootstrap-rails (2.2.8)
141+
actionpack (>= 3.1)
142+
execjs
143+
rails (>= 3.1)
144+
railties (>= 3.1)
145+
tzinfo (0.3.37)
146+
uglifier (2.1.2)
147+
execjs (>= 0.3.0)
148+
multi_json (~> 1.0, >= 1.0.2)
149+
websocket-driver (0.2.3)
150+
151+
PLATFORMS
152+
ruby
153+
154+
DEPENDENCIES
155+
coffee-rails (~> 4.0.0)
156+
haml-rails
157+
jbuilder (~> 1.2)
158+
jquery-rails
159+
rails (= 4.0.0)
160+
sass-rails (~> 4.0.0)
161+
sdoc
162+
sqlite3
163+
therubyracer
164+
turbolinks
165+
twitter-bootstrap-rails
166+
uglifier (>= 1.3.0)
167+
websocket-rails!

README.rdoc

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
== README
2+
3+
This README would normally document whatever steps are necessary to get the
4+
application up and running.
5+
6+
Things you may want to cover:
7+
8+
* Ruby version
9+
10+
* System dependencies
11+
12+
* Configuration
13+
14+
* Database creation
15+
16+
* Database initialization
17+
18+
* How to run the test suite
19+
20+
* Services (job queues, cache servers, search engines, etc.)
21+
22+
* Deployment instructions
23+
24+
* ...
25+
26+
27+
Please feel free to use a different markup language if you do not plan to run
28+
<tt>rake doc:app</tt>.

Rakefile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Add your own tasks in files placed in lib/tasks ending in .rake,
2+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3+
4+
require File.expand_path('../config/application', __FILE__)
5+
6+
WebsocketRailsDemo::Application.load_tasks

app/assets/images/.keep

Whitespace-only changes.

app/assets/javascripts/application.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// This is a manifest file that'll be compiled into application.js, which will include all the files
2+
// listed below.
3+
//
4+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6+
//
7+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8+
// compiled file.
9+
//
10+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11+
// about supported directives.
12+
//
13+
//= require jquery
14+
//= require jquery_ujs
15+
//= require twitter/bootstrap
16+
//= require turbolinks
17+
//= require websocket_rails/main
18+
//= require bootstrap
19+
//= require chat_app
20+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
jQuery ->
2+
$("a[rel~=popover], .has-popover").popover()
3+
$("a[rel~=tooltip], .has-tooltip").tooltip()
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
$(document).ready ->
2+
ws = new WebSocketRails('localhost:3000/websocket')
3+
ws.on_open = ->
4+
console.log 'socket opened'
5+
ws.bind 'new_message', (data) ->
6+
console.log data
7+
$('#chat_history').append('<br /><span>'+data['user']+':</label>'+data['text'])
8+
9+
10+
$('#send_message').on 'click', ->
11+
ws.trigger 'incoming_message', {text: $('#new_message').val()}
12+
$('#new_message').val('')
13+
14+
$('#set_name').on 'click', ->
15+
ws.trigger 'set_name', {name: $('#screen_name').val()}

app/assets/javascripts/chat_app.js.js

+24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/assets/javascripts/home.js.coffee

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Place all the behaviors and hooks related to the matching controller here.
2+
# All this logic will automatically be available in application.js.
3+
# You can use CoffeeScript in this file: http://coffeescript.org/
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* This is a manifest file that'll be compiled into application.css, which will include all the files
3+
* listed below.
4+
*
5+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7+
*
8+
* You're free to add application-wide styles to this file and they'll appear at the top of the
9+
* compiled file, but it's generally better to create a new file per style scope.
10+
*
11+
*= require_self
12+
*= require_tree .
13+
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
=require twitter-bootstrap-static/bootstrap
3+
4+
Use Font Awesome icons (default)
5+
To use Glyphicons sprites instead of Font Awesome, replace with "require twitter-bootstrap-static/sprites"
6+
=require twitter-bootstrap-static/fontawesome
7+
*/

app/assets/stylesheets/home.css.scss

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Place all the styles related to the home controller here.
2+
// They will automatically be included in application.css.
3+
// You can use Sass (SCSS) here: http://sass-lang.com/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class ApplicationController < ActionController::Base
2+
# Prevent CSRF attacks by raising an exception.
3+
# For APIs, you may want to use :null_session instead.
4+
protect_from_forgery with: :exception
5+
end

app/controllers/chat_controller.rb

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class ChatController < WebsocketRails::BaseController
2+
3+
def user_connected
4+
5+
end
6+
7+
def incoming_message
8+
screen_name = connection_store[:screen_name]
9+
broadcast_message :new_message, {:user => screen_name, :text => message[:text]}
10+
end
11+
12+
def set_name
13+
connection_store[:screen_name] = message[:name]
14+
end
15+
end

app/controllers/concerns/.keep

Whitespace-only changes.

app/controllers/home_controller.rb

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class HomeController < ApplicationController
2+
def index
3+
end
4+
end

app/helpers/application_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module ApplicationHelper
2+
end

0 commit comments

Comments
 (0)