h2g_ajaxchat 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/h2g_ajaxchat.rb +20 -15
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7db5c15f7f4833080876a74afc5aa0a5076e8a08e5401c2d40a5a2b3c5082d89
|
4
|
+
data.tar.gz: 57f9b086460821188a16c3f028abc3528683afcb4efb23be2e460e1b7c84a442
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d8252c053581cc82b74299d5fb022ef064a08e1533824725b8af01fd44980bf487731b4653b30f0ed48b817a4ed4452601858af482784251f3115fc70307014
|
7
|
+
data.tar.gz: 340a2b64327b71919d839c9a860343ad55a93fa51f774090d991eec0ef4835c026beb8485f31e12cb6b00e4cf6cce58c3fdc50de0fbb8a2191aca196c8ce9d3d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/h2g_ajaxchat.rb
CHANGED
@@ -24,12 +24,15 @@ require 'simple-config'
|
|
24
24
|
|
25
25
|
class AjaxChatPlugin
|
26
26
|
|
27
|
-
|
27
|
+
# ac = ajaxchat object
|
28
|
+
#
|
29
|
+
def initialize(ac, settings={}, debug: false)
|
30
|
+
@ac, @settings, @debug = ac, settings, debug
|
28
31
|
end
|
29
32
|
|
30
|
-
# Customises the ajax chat html etc;
|
33
|
+
# Customises the ajax chat html etc;
|
31
34
|
#
|
32
|
-
def apply(
|
35
|
+
def apply()
|
33
36
|
end
|
34
37
|
|
35
38
|
# messages from the plugin to be added to the chat timeline
|
@@ -40,7 +43,7 @@ class AjaxChatPlugin
|
|
40
43
|
|
41
44
|
# messages from the chat timeline
|
42
45
|
#
|
43
|
-
def on_newmessage(
|
46
|
+
def on_newmessage(time, userid, username, msg)
|
44
47
|
end
|
45
48
|
end
|
46
49
|
|
@@ -130,7 +133,6 @@ class ChatCore
|
|
130
133
|
|
131
134
|
end
|
132
135
|
|
133
|
-
protected
|
134
136
|
|
135
137
|
def append_message(t=Time.now, id=@session[:session_id].to_s,
|
136
138
|
u=@session[:username], msg)
|
@@ -144,16 +146,17 @@ end
|
|
144
146
|
|
145
147
|
class DummyRws
|
146
148
|
|
147
|
-
attr_accessor :req
|
149
|
+
attr_accessor :req, :ac
|
150
|
+
attr_reader :rsc
|
148
151
|
|
149
|
-
def initialize(
|
152
|
+
def initialize(ac=nil, rsc: nil)
|
150
153
|
|
151
|
-
@
|
154
|
+
@ac, @rsc = ac, rsc
|
152
155
|
|
153
156
|
end
|
154
157
|
|
155
158
|
def redirect(s)
|
156
|
-
@
|
159
|
+
@ac.method(s.to_sym).call
|
157
160
|
end
|
158
161
|
end
|
159
162
|
|
@@ -385,8 +388,8 @@ class AjaxChat
|
|
385
388
|
next if settings[:disabled]
|
386
389
|
pluginklass_name = 'AjaxChatPlugin' + name.to_s
|
387
390
|
|
388
|
-
#Kernel.const_get(pluginklass_name).new(settings)
|
389
|
-
eval("#{pluginklass_name}.new(#{settings})")
|
391
|
+
#Kernel.const_get(pluginklass_name).new(self, settings, debug: false)
|
392
|
+
eval("#{pluginklass_name}.new(self, #{settings}, debug: false)")
|
390
393
|
|
391
394
|
end.compact
|
392
395
|
|
@@ -412,7 +415,7 @@ class AjaxChat
|
|
412
415
|
logout_post: @logout_post
|
413
416
|
}
|
414
417
|
|
415
|
-
@plugins.each {|plugin| plugin.apply
|
418
|
+
@plugins.each {|plugin| plugin.apply if plugin.respond_to? :apply }
|
416
419
|
|
417
420
|
end
|
418
421
|
|
@@ -421,7 +424,7 @@ class AjaxChat
|
|
421
424
|
id, users = @rws.req.session[:session_id].to_s, @chat.users
|
422
425
|
|
423
426
|
chat = @chat
|
424
|
-
|
427
|
+
|
425
428
|
# check for new messages to be added via the plugins
|
426
429
|
@plugins.each do |plugin|
|
427
430
|
|
@@ -429,12 +432,14 @@ class AjaxChat
|
|
429
432
|
plugin.messages.each {|x| chat.append_message *x }
|
430
433
|
|
431
434
|
end
|
435
|
+
|
436
|
+
plugins = @plugins
|
432
437
|
|
433
438
|
@chat.chatter(@rws.req, newmsg) do |t, uid, username, msg|
|
434
439
|
|
435
|
-
|
440
|
+
plugins.each do |x|
|
436
441
|
|
437
|
-
|
442
|
+
x.on_newmessage(t, uid, username, msg) if x.respond_to? :on_newmessage
|
438
443
|
|
439
444
|
end
|
440
445
|
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|