nomo 0.0.45 → 0.0.46
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/nomo/version.rb +1 -1
- data/vendor/assets/javascripts/nomo.js.coffee.erb +46 -26
- metadata +6 -6
data/lib/nomo/version.rb
CHANGED
@@ -5,37 +5,55 @@ $ ->
|
|
5
5
|
|
6
6
|
nomoKey = null
|
7
7
|
nomoLastModified = null
|
8
|
-
connection =
|
8
|
+
connection = null
|
9
|
+
connectionOpen = false
|
9
10
|
|
10
|
-
|
11
|
-
|
11
|
+
connect = ->
|
12
|
+
connection = new WebSocket('ws://<%= Nomo.server ? Nomo.server : request.host %>', 'nomo')
|
12
13
|
|
13
|
-
|
14
|
+
##
|
15
|
+
# WebSocket Connection
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
msgToServer = JSON.stringify({ key: nomoKey, lastModified: nomoLastModified })
|
17
|
+
connection.onopen = ->
|
18
|
+
connectionOpen = true
|
18
19
|
|
19
|
-
|
20
|
-
|
20
|
+
# If there's already a nomoKey there could be updates we haven't received
|
21
|
+
if nomoKey
|
22
|
+
msgToServer = JSON.stringify({ key: nomoKey, lastModified: nomoLastModified })
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
-
console.log('(nomo) connected')
|
25
|
-
$.ajax
|
26
|
-
type: 'HEAD',
|
27
|
-
dataType: 'html',
|
28
|
-
url: document.location.pathname
|
24
|
+
console.log('(nomo) connected -- msg to server: ' + msgToServer)
|
25
|
+
connection.send(msgToServer)
|
29
26
|
|
30
|
-
|
31
|
-
|
27
|
+
# Else send a HEAD request so we can fetch the nomoKey
|
28
|
+
else
|
29
|
+
console.log('(nomo) connected')
|
30
|
+
$.ajax
|
31
|
+
type: 'HEAD',
|
32
|
+
dataType: 'html',
|
33
|
+
url: document.location.pathname
|
34
|
+
|
35
|
+
##
|
36
|
+
# WebSocket Message
|
37
|
+
|
38
|
+
connection.onmessage = (msg) ->
|
39
|
+
msg = JSON.parse(msg.data)
|
32
40
|
|
33
|
-
|
34
|
-
|
41
|
+
if msg.event == 'update'
|
42
|
+
console.log('(nomo) nomo:update triggered')
|
43
|
+
$(document).trigger('nomo:update', [nomoKey, nomoLastModified])
|
35
44
|
|
36
|
-
|
37
|
-
|
38
|
-
|
45
|
+
##
|
46
|
+
# On connection close
|
47
|
+
|
48
|
+
connection.onclose = ->
|
49
|
+
connectionOpen = false
|
50
|
+
console.log '(nomo) connection closed, retrying in 5 seconds...'
|
51
|
+
|
52
|
+
setTimeout ->
|
53
|
+
connect() unless connectionOpen
|
54
|
+
, 5000
|
55
|
+
|
56
|
+
connect()
|
39
57
|
|
40
58
|
##
|
41
59
|
# ajaxComplete
|
@@ -47,7 +65,9 @@ $ ->
|
|
47
65
|
if nomoKeyHeader && (nomoKey != nomoKeyHeader)
|
48
66
|
nomoKey = nomoKeyHeader
|
49
67
|
nomoLastModified = nomoLastModifiedHeader
|
50
|
-
msgToServer = JSON.stringify({ key: nomoKey })
|
51
68
|
|
52
|
-
|
53
|
-
|
69
|
+
if connectionOpen
|
70
|
+
msgToServer = JSON.stringify({ key: nomoKey })
|
71
|
+
|
72
|
+
console.log('(nomo) page changed -- msg to server: ' + msgToServer)
|
73
|
+
connection.send(msgToServer)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nomo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.46
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis
|
16
|
-
requirement: &
|
16
|
+
requirement: &70339260059220 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70339260059220
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: redis-namespace
|
27
|
-
requirement: &
|
27
|
+
requirement: &70339260058800 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70339260058800
|
36
36
|
description: 304 Not Modified Headers made easy.
|
37
37
|
email:
|
38
38
|
- sausman@stackd.com
|