reeltalk 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+ --backtrace
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in reeltalk.gemspec
4
+ gemspec
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Tony Arcieri
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ reeltalk
2
+ ========
3
+ [![Build Status](https://secure.travis-ci.org/tarcieri/reeltalk.png?branch=master)](http://travis-ci.org/tarcieri/reeltalk)
4
+
5
+ An underdocumented web chat system
6
+
7
+ Contributing to reeltalk
8
+ ------------------------
9
+
10
+ * Fork this repository on github
11
+ * Make your changes and send me a pull request
12
+ * If I like them I'll merge them
13
+ * If I've accepted a patch, feel free to ask for commit access
14
+
15
+ License
16
+ -------
17
+
18
+ Copyright (c) 2012 Tony Arcieri. Distributed under the MIT License. See
19
+ LICENSE.txt for further details.
@@ -0,0 +1,4 @@
1
+ require "bundler/gem_tasks"
2
+ Dir["tasks/**/*.task"].each { |task| load task }
3
+
4
+ task :default => :spec
@@ -0,0 +1,5 @@
1
+ require "reeltalk/version"
2
+
3
+ module Reeltalk
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module Reeltalk
2
+ VERSION = "0.0.0"
3
+ end
Binary file
@@ -0,0 +1,36 @@
1
+ <html>
2
+ <head>
3
+ <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script>
4
+ <script src='http://jquery-json.googlecode.com/files/jquery.json-2.2.min.js'></script>
5
+ <script src='http://datejs.googlecode.com/svn/trunk/build/date.js'></script>
6
+ <script src='/javascripts/chat.js'></script>
7
+ <link rel="stylesheet" type="text/css" media="screen" href="/stylesheets/style.css" />
8
+ </head>
9
+ <body>
10
+ <img src="/images/logo.png" alt="Variety" />
11
+ <div id="error" class="bordered" style="display: none;">
12
+ This browser has no native WebSocket support.<br/>
13
+ Use a WebKit nightly or Google Chrome.
14
+ </div>
15
+ <div id="ask" class="bordered" style="display: none;">
16
+ Name: <input type="text" id="name" /> <a href="#"><span class="join">Join!</span></a>
17
+ </div>
18
+ <div id="channel" class="bordered" style="display: none;">
19
+ <div id="msgs">
20
+ <ul>
21
+ <li class="message" style="display: none">
22
+ <span class="user"></span><span class="message"></span>
23
+ <span class="time"></span>
24
+ </li>
25
+ <li class="control" style="display: none">
26
+ <span class="user"></span>&nbsp;<span class="message"></span>
27
+ <span class="time"></span>
28
+ </li>
29
+ </ul>
30
+ </div>
31
+ <div id="input">
32
+ <form><input type="text" id="message" /></form>
33
+ </div>
34
+ </div>
35
+ </body>
36
+ </html>
@@ -0,0 +1,77 @@
1
+ $(document).ready(function(){
2
+ if (typeof(WebSocket) != 'undefined' || typeof(MozWebSocket)) {
3
+ $('#ask').show();
4
+ } else {
5
+ $('#error').show();
6
+ }
7
+
8
+ // join on enter
9
+ $('#ask input').keydown(function(event) {
10
+ if (event.keyCode == 13) {
11
+ $('#ask a').click();
12
+ }
13
+ })
14
+
15
+ // join on click
16
+ $('#ask a').click(function() {
17
+ join($('#ask input').val());
18
+ $('#ask').hide();
19
+ $('#channel').show();
20
+ $('input#message').focus();
21
+ });
22
+
23
+ function join(name) {
24
+ var host = window.location.host.split(':')[0];
25
+
26
+ var SocketKlass = "MozWebSocket" in window ? MozWebSocket : WebSocket;
27
+ var ws = new SocketKlass('ws://' + window.location.host + '/websocket');
28
+
29
+ var container = $('div#msgs');
30
+ ws.onmessage = function(evt) {
31
+ var obj = $.evalJSON(evt.data);
32
+ if (typeof obj != 'object') return;
33
+
34
+ var action = obj['action'];
35
+ var struct = container.find('li.' + action + ':first');
36
+ if (struct.length < 1) {
37
+ console.log("Could not handle: " + evt.data);
38
+ return;
39
+ }
40
+
41
+ var msg = struct.clone();
42
+ msg.find('.time').text((new Date()).toString("HH:mm:ss"));
43
+
44
+ if (action == 'message') {
45
+ var matches;
46
+ if (matches = obj['message'].match(/^\s*[\/\\]me\s(.*)/)) {
47
+ msg.find('.user').text(obj['user'] + ' ' + matches[1]);
48
+ msg.find('.user').css('font-weight', 'bold');
49
+ } else {
50
+ msg.find('.user').text(obj['user']);
51
+ msg.find('.message').text(': ' + obj['message']);
52
+ }
53
+ } else if (action == 'control') {
54
+ msg.find('.user').text(obj['user']);
55
+ msg.find('.message').text(obj['message']);
56
+ msg.addClass('control');
57
+ }
58
+
59
+ if (obj['user'] == name) msg.find('.user').addClass('self');
60
+ container.find('ul').append(msg.show());
61
+ container.scrollTop(container.find('ul').innerHeight());
62
+ }
63
+
64
+ $('#channel form').submit(function(event) {
65
+ event.preventDefault();
66
+ var input = $(this).find(':input');
67
+ var msg = input.val();
68
+ ws.send($.toJSON({ action: 'message', message: msg }));
69
+ input.val('');
70
+ });
71
+
72
+ // send name when joining
73
+ ws.onopen = function() {
74
+ ws.send($.toJSON({ action: 'join', user: name }));
75
+ }
76
+ }
77
+ });
@@ -0,0 +1,7 @@
1
+ h1 {
2
+ color: #009630;
3
+ font-size: 5em;
4
+ font-style: italic;
5
+ font-weight: bold;
6
+ font-family: "Garamond Bold Italic", Times, serif;
7
+ }
@@ -0,0 +1,83 @@
1
+ * {
2
+ font-family: "Garamond Bold Italic", Times, serif;
3
+ }
4
+ a {
5
+ color: #000;
6
+ text-decoration: none;
7
+ }
8
+ a:hover {
9
+ text-decoration: underline;
10
+ }
11
+ div.bordered {
12
+ margin: 0 auto;
13
+ margin-top: 100px;
14
+ width: 600px;
15
+ padding: 20px;
16
+ text-align: center;
17
+ border: 10px solid #ddd;
18
+ -webkit-border-radius: 20px;
19
+ }
20
+ #error {
21
+ background-color: #BA0000;
22
+ color: #fff;
23
+ font-weight: bold;
24
+ }
25
+ #ask {
26
+ font-size: 20pt;
27
+ }
28
+ #ask input {
29
+ font-size: 20pt;
30
+ padding: 10px;
31
+ margin: 0 10px;
32
+ }
33
+ #ask span.join {
34
+ padding: 10px;
35
+ background-color: #ddd;
36
+ -webkit-border-radius: 10px;
37
+ }
38
+ #channel {
39
+ margin-top: 100px;
40
+ height: 480px;
41
+ position: relative;
42
+ }
43
+ div#msgs {
44
+ overflow-y: scroll;
45
+ height: 400px;
46
+ }
47
+ div#msgs ul {
48
+ list-style: none;
49
+ padding: 0;
50
+ margin: 0;
51
+ text-align: left;
52
+ }
53
+ div#msgs li {
54
+ line-height: 20px;
55
+ }
56
+ div#msgs li span.user {
57
+ color: #ff9900;
58
+ }
59
+ div#msgs li span.user.self {
60
+ color: #aa2211;
61
+ }
62
+ div#msgs li span.time {
63
+ float: right;
64
+ margin-right: 5px;
65
+ color: #aaa;
66
+ font-size: 12px;
67
+ }
68
+ div#msgs li.control {
69
+ text-align: center;
70
+ }
71
+ div#msgs li.control span.message {
72
+ color: #aaa;
73
+ }
74
+ div#input {
75
+ text-align: left;
76
+ margin-top: 20px;
77
+ }
78
+ div#input #message {
79
+ width: 600px;
80
+ border: 5px solid #bbb;
81
+ -webkit-border-radius: 3px;
82
+ font-size: 30pt;
83
+ }
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'reeltalk/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "reeltalk"
8
+ gem.version = Reeltalk::VERSION
9
+ gem.authors = ["Tony Arcieri"]
10
+ gem.email = ["tony.arcieri@gmail.com"]
11
+ gem.description = "Web chat system using Celluloid+Reel+Websockets"
12
+ gem.summary = "Reel is a realtime websockets-based chat system built using Celluloid and the Reel web server"
13
+ gem.homepage = "https://github.com/tarcieri/reeltalk"
14
+
15
+ gem.add_runtime_dependency 'reel'
16
+ gem.add_development_dependency 'rspec'
17
+
18
+ gem.files = `git ls-files`.split($/)
19
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
20
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
21
+ gem.require_paths = ["lib"]
22
+ end
@@ -0,0 +1,4 @@
1
+ $:.unshift File.expand_path('../../lib', __FILE__)
2
+
3
+ require 'rspec'
4
+ require 'reeltalk'
@@ -0,0 +1,7 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new
4
+
5
+ RSpec::Core::RakeTask.new(:rcov) do |task|
6
+ task.rcov = true
7
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: reeltalk
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.0
6
+ platform: ruby
7
+ authors:
8
+ - Tony Arcieri
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-26 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: reel
16
+ version_requirements: &2056 !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ! '>='
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ none: false
22
+ requirement: *2056
23
+ prerelease: false
24
+ type: :runtime
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ version_requirements: &2074 !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ! '>='
30
+ - !ruby/object:Gem::Version
31
+ version: '0'
32
+ none: false
33
+ requirement: *2074
34
+ prerelease: false
35
+ type: :development
36
+ description: Web chat system using Celluloid+Reel+Websockets
37
+ email:
38
+ - tony.arcieri@gmail.com
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - .gitignore
44
+ - .rspec
45
+ - Gemfile
46
+ - LICENSE.txt
47
+ - README.md
48
+ - Rakefile
49
+ - lib/reeltalk.rb
50
+ - lib/reeltalk/version.rb
51
+ - public/images/logo.png
52
+ - public/index.html
53
+ - public/javascripts/chat.js
54
+ - public/style.css
55
+ - public/stylesheets/style.css
56
+ - reeltalk.gemspec
57
+ - spec/spec_helper.rb
58
+ - tasks/rspec.task
59
+ homepage: https://github.com/tarcieri/reeltalk
60
+ licenses: []
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ none: false
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ none: false
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 1.8.15
80
+ signing_key:
81
+ specification_version: 3
82
+ summary: Reel is a realtime websockets-based chat system built using Celluloid and the Reel web server
83
+ test_files:
84
+ - spec/spec_helper.rb
85
+ has_rdoc:
86
+ ...