jschat 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -236,6 +236,10 @@ helpers do
236
236
  end
237
237
  end
238
238
 
239
+ def delete_twitter_user
240
+ JsChat::Storage.driver.delete_user({ 'twitter_name' => session[:twitter_name] })
241
+ end
242
+
239
243
  def load_twitter_user
240
244
  JsChat::Storage.driver.find_user({ 'twitter_name' => session[:twitter_name] }) || {}
241
245
  end
@@ -243,7 +247,7 @@ helpers do
243
247
  def load_twitter_user_and_set_bridge_id
244
248
  user = load_twitter_user
245
249
  if user['jschat_id'] and user['jschat_id'].size > 0
246
- response.set_cookie 'jschat_id', user['jschat_id']
250
+ session[:jschat_id] = user['jschat_id']
247
251
  end
248
252
  end
249
253
 
@@ -363,7 +367,7 @@ end
363
367
  get '/quit' do
364
368
  load_bridge
365
369
  @bridge.send_quit nickname
366
- load_bridge
370
+ delete_twitter_user if twitter_user?
367
371
  clear_cookies
368
372
  redirect '/'
369
373
  end
@@ -403,8 +407,8 @@ get '/twitter_auth' do
403
407
 
404
408
  # TODO: Make this cope if someone has the same name
405
409
  room = '#jschat'
406
- save_nickname @twitter.info['screen_name']
407
410
  user = load_twitter_user
411
+ save_nickname user['name']
408
412
  session[:jschat_id] = user['jschat_id'] if user['jschat_id'] and !user['jschat_id'].empty?
409
413
  save_twitter_user('twitter_name' => @twitter.info['screen_name'], 'jschat_id' => session[:jschat_id])
410
414
  user = load_twitter_user
@@ -415,6 +419,7 @@ get '/twitter_auth' do
415
419
  room = user['rooms'].first
416
420
  end
417
421
  else
422
+ # Reconnect
418
423
  session[:jschat_id] = nil
419
424
  load_and_connect
420
425
  save_twitter_user('jschat_id' => session[:jschat_id])
data/lib/jschat/server.rb CHANGED
@@ -372,7 +372,7 @@ module JsChat
372
372
  Array.new(8, '').collect { chars[rand(chars.size)] }.join
373
373
  end
374
374
 
375
- def register_stateless_cient
375
+ def register_stateless_client
376
376
  @stateless_cookie = new_cookie
377
377
  user = User.new(self)
378
378
  @@stateless_cookies << { :cookie => @stateless_cookie, :user => user }
@@ -510,7 +510,7 @@ module JsChat
510
510
  if input.has_key? 'protocol'
511
511
  if input['protocol'] == 'stateless'
512
512
  @stateless = true
513
- response << send_response(register_stateless_cient)
513
+ response << send_response(register_stateless_client)
514
514
  end
515
515
  elsif input.has_key? 'identify'
516
516
  input['ip'] ||= get_remote_ip
@@ -24,7 +24,7 @@ module JsChat::Storage
24
24
  end
25
25
 
26
26
  def self.lastlog(number, room)
27
- @db['events'].find({ :room => room }, { :limit => number, :sort => ['time', Mongo::DESCENDING] }).to_a
27
+ @db['events'].find({ :room => room }, { :limit => number, :sort => ['time', Mongo::DESCENDING] }).to_a.reverse
28
28
  end
29
29
 
30
30
  # TODO: use twitter oauth for the key
@@ -36,11 +36,8 @@ module JsChat::Storage
36
36
  @db['users'].save user
37
37
  end
38
38
 
39
- def self.set_rooms(name, rooms)
40
- user = find_user({ 'name' => name })
41
- user ||= { 'name' => name }
42
- user['rooms'] = rooms
43
- save_user user
39
+ def self.delete_user(user)
40
+ @db['users'].remove user
44
41
  end
45
42
 
46
43
  def self.available?
@@ -20,7 +20,7 @@ module JsChat::Storage
20
20
  def self.save_user(user)
21
21
  end
22
22
 
23
- def self.set_rooms(name, rooms)
23
+ def self.delete_user(user)
24
24
  end
25
25
  end
26
26
  end
metadata CHANGED
@@ -1,12 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jschat
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 2
8
- - 6
9
- version: 0.2.6
4
+ version: 0.2.7
10
5
  platform: ruby
11
6
  authors:
12
7
  - Alex R. Young
@@ -19,74 +14,54 @@ default_executable: bin/jschat-server
19
14
  dependencies:
20
15
  - !ruby/object:Gem::Dependency
21
16
  name: sinatra
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
24
20
  requirements:
25
21
  - - ">="
26
22
  - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
- - 9
30
- - 4
31
23
  version: 0.9.4
32
- type: :runtime
33
- version_requirements: *id001
24
+ version:
34
25
  - !ruby/object:Gem::Dependency
35
26
  name: json
36
- prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
38
30
  requirements:
39
31
  - - ">="
40
32
  - !ruby/object:Gem::Version
41
- segments:
42
- - 1
43
- - 1
44
- - 9
45
33
  version: 1.1.9
46
- type: :runtime
47
- version_requirements: *id002
34
+ version:
48
35
  - !ruby/object:Gem::Dependency
49
36
  name: sprockets
50
- prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
52
40
  requirements:
53
41
  - - ">="
54
42
  - !ruby/object:Gem::Version
55
- segments:
56
- - 1
57
- - 0
58
- - 2
59
43
  version: 1.0.2
60
- type: :runtime
61
- version_requirements: *id003
44
+ version:
62
45
  - !ruby/object:Gem::Dependency
63
46
  name: eventmachine
64
- prerelease: false
65
- requirement: &id004 !ruby/object:Gem::Requirement
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
66
50
  requirements:
67
51
  - - ">="
68
52
  - !ruby/object:Gem::Version
69
- segments:
70
- - 0
71
- - 12
72
- - 8
73
53
  version: 0.12.8
74
- type: :runtime
75
- version_requirements: *id004
54
+ version:
76
55
  - !ruby/object:Gem::Dependency
77
56
  name: ncurses
78
- prerelease: false
79
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ type: :runtime
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
80
60
  requirements:
81
61
  - - ">="
82
62
  - !ruby/object:Gem::Version
83
- segments:
84
- - 0
85
- - 9
86
- - 1
87
63
  version: 0.9.1
88
- type: :runtime
89
- version_requirements: *id005
64
+ version:
90
65
  description: JsChat is a JSON-based web and console chat app.
91
66
  email: alex@alexyoung.org
92
67
  executables:
@@ -101,14 +76,21 @@ files:
101
76
  - bin/jschat-client
102
77
  - bin/jschat-server
103
78
  - bin/jschat-web
79
+ - lib/jschat
104
80
  - lib/jschat/client.rb
105
81
  - lib/jschat/errors.rb
106
82
  - lib/jschat/flood_protection.rb
83
+ - lib/jschat/http
84
+ - lib/jschat/http/config
107
85
  - lib/jschat/http/config/sprockets.yml
108
86
  - lib/jschat/http/config.ru
87
+ - lib/jschat/http/helpers
109
88
  - lib/jschat/http/helpers/url_for.rb
110
89
  - lib/jschat/http/jschat.rb
90
+ - lib/jschat/http/public
111
91
  - lib/jschat/http/public/favicon.ico
92
+ - lib/jschat/http/public/images
93
+ - lib/jschat/http/public/images/emoticons
112
94
  - lib/jschat/http/public/images/emoticons/angry.gif
113
95
  - lib/jschat/http/public/images/emoticons/arr.gif
114
96
  - lib/jschat/http/public/images/emoticons/blink.gif
@@ -161,25 +143,37 @@ files:
161
143
  - lib/jschat/http/public/images/emoticons/yucky.gif
162
144
  - lib/jschat/http/public/images/jschat.gif
163
145
  - lib/jschat/http/public/images/shadow.png
146
+ - lib/jschat/http/public/javascripts
147
+ - lib/jschat/http/public/javascripts/app
148
+ - lib/jschat/http/public/javascripts/app/controllers
164
149
  - lib/jschat/http/public/javascripts/app/controllers/chat_controller.js
165
150
  - lib/jschat/http/public/javascripts/app/controllers/signon_controller.js
151
+ - lib/jschat/http/public/javascripts/app/helpers
166
152
  - lib/jschat/http/public/javascripts/app/helpers/emote_helper.js
167
153
  - lib/jschat/http/public/javascripts/app/helpers/form_helpers.js
168
154
  - lib/jschat/http/public/javascripts/app/helpers/link_helper.js
169
155
  - lib/jschat/http/public/javascripts/app/helpers/page_helper.js
170
156
  - lib/jschat/http/public/javascripts/app/helpers/text_helper.js
157
+ - lib/jschat/http/public/javascripts/app/lib
171
158
  - lib/jschat/http/public/javascripts/app/lib/split.js
159
+ - lib/jschat/http/public/javascripts/app/models
172
160
  - lib/jschat/http/public/javascripts/app/models/cookie.js
161
+ - lib/jschat/http/public/javascripts/app/protocol
173
162
  - lib/jschat/http/public/javascripts/app/protocol/change.js
174
163
  - lib/jschat/http/public/javascripts/app/protocol/chat_request.js
175
164
  - lib/jschat/http/public/javascripts/app/protocol/display.js
165
+ - lib/jschat/http/public/javascripts/app/ui
176
166
  - lib/jschat/http/public/javascripts/app/ui/commands.js
177
167
  - lib/jschat/http/public/javascripts/app/ui/tab_completion.js
178
168
  - lib/jschat/http/public/javascripts/init.js
169
+ - lib/jschat/http/public/stylesheets
179
170
  - lib/jschat/http/public/stylesheets/iphone.css
180
171
  - lib/jschat/http/public/stylesheets/screen.css
172
+ - lib/jschat/http/script
181
173
  - lib/jschat/http/script/sprockets.rb
174
+ - lib/jschat/http/tmp
182
175
  - lib/jschat/http/tmp/restart.txt
176
+ - lib/jschat/http/views
183
177
  - lib/jschat/http/views/form.erb
184
178
  - lib/jschat/http/views/index.erb
185
179
  - lib/jschat/http/views/iphone.erb
@@ -189,6 +183,7 @@ files:
189
183
  - lib/jschat/init.rb
190
184
  - lib/jschat/server.rb
191
185
  - lib/jschat/server_options.rb
186
+ - lib/jschat/storage
192
187
  - lib/jschat/storage/init.rb
193
188
  - lib/jschat/storage/mongo.rb
194
189
  - lib/jschat/storage/null.rb
@@ -199,8 +194,6 @@ files:
199
194
  - MIT-LICENSE
200
195
  has_rdoc: false
201
196
  homepage: http://github.com/alexyoung/jschat
202
- licenses: []
203
-
204
197
  post_install_message:
205
198
  rdoc_options: []
206
199
 
@@ -210,22 +203,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
210
203
  requirements:
211
204
  - - ">="
212
205
  - !ruby/object:Gem::Version
213
- segments:
214
- - 0
215
206
  version: "0"
207
+ version:
216
208
  required_rubygems_version: !ruby/object:Gem::Requirement
217
209
  requirements:
218
210
  - - ">="
219
211
  - !ruby/object:Gem::Version
220
- segments:
221
- - 0
222
212
  version: "0"
213
+ version:
223
214
  requirements: []
224
215
 
225
216
  rubyforge_project:
226
- rubygems_version: 1.3.6
217
+ rubygems_version: 1.3.1
227
218
  signing_key:
228
- specification_version: 3
219
+ specification_version: 2
229
220
  summary: JsChat features a chat server, client and web app.
230
221
  test_files: []
231
222