rack-push-notification 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +40 -1
- data/README.md +22 -5
- data/lib/rack/push-notification.rb +30 -108
- data/lib/rack/push-notification/admin.rb +129 -0
- data/lib/rack/push-notification/assets/images/wallpaper-clown-fish.jpg +0 -0
- data/lib/rack/push-notification/assets/javascripts/application.coffee +28 -0
- data/lib/rack/push-notification/assets/javascripts/collections/devices.coffee +28 -0
- data/lib/rack/push-notification/assets/javascripts/models/device.coffee +2 -0
- data/lib/rack/push-notification/assets/javascripts/routers/root.coffee +30 -0
- data/lib/rack/push-notification/assets/javascripts/rpn.coffee +14 -0
- data/lib/rack/push-notification/assets/javascripts/templates/_devices.jst.eco +23 -0
- data/lib/rack/push-notification/assets/javascripts/templates/_preview.jst.eco +24 -0
- data/lib/rack/push-notification/assets/javascripts/templates/compose.jst.eco +46 -0
- data/lib/rack/push-notification/assets/javascripts/templates/devices.jst.eco +12 -0
- data/lib/rack/push-notification/assets/javascripts/templates/pagination.jst.eco +12 -0
- data/lib/rack/push-notification/assets/javascripts/vendor/backbone.js +1431 -0
- data/lib/rack/push-notification/assets/javascripts/vendor/backbone.paginator.js +833 -0
- data/lib/rack/push-notification/assets/javascripts/vendor/codemirror.javascript.js +411 -0
- data/lib/rack/push-notification/assets/javascripts/vendor/codemirror.js +3047 -0
- data/lib/rack/push-notification/assets/javascripts/vendor/date.js +104 -0
- data/lib/rack/push-notification/assets/javascripts/vendor/jquery.js +9404 -0
- data/lib/rack/push-notification/assets/javascripts/vendor/underscore.js +1059 -0
- data/lib/rack/push-notification/assets/javascripts/views/compose.coffee +119 -0
- data/lib/rack/push-notification/assets/javascripts/views/devices.coffee +23 -0
- data/lib/rack/push-notification/assets/javascripts/views/pagination.coffee +29 -0
- data/lib/rack/push-notification/assets/stylesheets/_codemirror.sass +219 -0
- data/lib/rack/push-notification/assets/stylesheets/_preview.sass +148 -0
- data/lib/rack/push-notification/assets/stylesheets/screen.sass +110 -0
- data/lib/rack/push-notification/assets/views/index.haml +26 -0
- data/lib/rack/push-notification/device.rb +33 -0
- data/lib/rack/push-notification/migrations/001_base_schema.rb +26 -0
- data/lib/rack/push-notification/migrations/002_add_full_text_search.rb +23 -0
- data/rack-push-notification.gemspec +9 -1
- metadata +164 -8
- data/lib/rack/push-notification/version.rb +0 -5
@@ -0,0 +1,110 @@
|
|
1
|
+
@import "compass"
|
2
|
+
|
3
|
+
$btnPrimaryBackground: #f00
|
4
|
+
@import "bootstrap"
|
5
|
+
|
6
|
+
|
7
|
+
@mixin helvetica-font-stack
|
8
|
+
font-family: "Helvetica Neue", Helvetica, Arial, Geneva, sans-serif
|
9
|
+
|
10
|
+
@mixin meslo-font-stack
|
11
|
+
font-family: "Meslo", Menlo, Monaco, monospace
|
12
|
+
|
13
|
+
@import "./codemirror"
|
14
|
+
@import "./preview"
|
15
|
+
|
16
|
+
html body
|
17
|
+
font-family: "Helvetica Neue", "Helvetica", sans-serif
|
18
|
+
-webkit-text-stroke: 1px transparent
|
19
|
+
-webkit-background-clip: padding-box
|
20
|
+
|
21
|
+
& > header
|
22
|
+
@extend .navbar
|
23
|
+
@extend .navbar-static-top
|
24
|
+
|
25
|
+
nav
|
26
|
+
@extend .navbar-inner
|
27
|
+
|
28
|
+
ul
|
29
|
+
@extend .nav
|
30
|
+
|
31
|
+
[role="main"]
|
32
|
+
& > header
|
33
|
+
@extend .page-header
|
34
|
+
|
35
|
+
h1
|
36
|
+
|
37
|
+
aside
|
38
|
+
float: right
|
39
|
+
|
40
|
+
section
|
41
|
+
@extend .row
|
42
|
+
|
43
|
+
& > .alert
|
44
|
+
width: 95%
|
45
|
+
margin-top: 1em
|
46
|
+
|
47
|
+
.alert
|
48
|
+
clear: both
|
49
|
+
|
50
|
+
form#compose
|
51
|
+
+clearfix
|
52
|
+
|
53
|
+
fieldset
|
54
|
+
@extend .span7
|
55
|
+
float: left
|
56
|
+
|
57
|
+
ol
|
58
|
+
list-style: none
|
59
|
+
padding: 0
|
60
|
+
margin: 0
|
61
|
+
|
62
|
+
li
|
63
|
+
@extend .control-group
|
64
|
+
|
65
|
+
input[type="radio"], label
|
66
|
+
display: inline-block
|
67
|
+
|
68
|
+
input[type="radio"]
|
69
|
+
margin-right: 0.5em
|
70
|
+
margin-top: -5px
|
71
|
+
|
72
|
+
label
|
73
|
+
@extend .control-label
|
74
|
+
|
75
|
+
textarea
|
76
|
+
display: block
|
77
|
+
margin-left: 1.5em
|
78
|
+
width: 530px
|
79
|
+
font-size: 0.9em
|
80
|
+
|
81
|
+
hr
|
82
|
+
clear: both
|
83
|
+
width: 100%
|
84
|
+
margin-top: 5em
|
85
|
+
|
86
|
+
button
|
87
|
+
@extend .btn
|
88
|
+
@extend .btn-large
|
89
|
+
float: right
|
90
|
+
|
91
|
+
table
|
92
|
+
@extend .table
|
93
|
+
@extend .table-bordered
|
94
|
+
@extend .table-hover
|
95
|
+
|
96
|
+
caption
|
97
|
+
span
|
98
|
+
float: left
|
99
|
+
display: block
|
100
|
+
position: relative
|
101
|
+
top: -20px
|
102
|
+
|
103
|
+
form.filter
|
104
|
+
@extend .form-search
|
105
|
+
float: right
|
106
|
+
margin-bottom: 0
|
107
|
+
|
108
|
+
input[type="text"]
|
109
|
+
@extend .input-medium
|
110
|
+
@extend .search-query
|
@@ -0,0 +1,26 @@
|
|
1
|
+
!!! 5
|
2
|
+
%html{lang: "en"}
|
3
|
+
%head
|
4
|
+
%meta{charset: "utf-8"}
|
5
|
+
%meta{:'http-equiv' => "X-UA-Compatible", content: "IE=edge,chrome=1"}
|
6
|
+
%title Rack::PushNotification Admin Console
|
7
|
+
%link{rel: "shortcut icon", href: "/favicon.ico", type: "image/x-icon"}
|
8
|
+
%link{rel: "license", href: "http://opensource.org/licenses/MIT", :title => "MIT License"}
|
9
|
+
%link{rel: "description", href: "Push Notifications"}
|
10
|
+
%link{rel: "stylesheet", href: "/stylesheets/screen.css", type: 'text/css', media: "screen", charset: "utf-8"}
|
11
|
+
|
12
|
+
%body
|
13
|
+
%header
|
14
|
+
%nav
|
15
|
+
.container
|
16
|
+
%a.brand{href: "/"} Rack::PushNotification
|
17
|
+
|
18
|
+
%ul
|
19
|
+
%li.devices
|
20
|
+
%a{href: "/"} Devices
|
21
|
+
%li.compose
|
22
|
+
%a{href: "/compose"} Compose
|
23
|
+
|
24
|
+
.container{role: "main"}
|
25
|
+
|
26
|
+
%script{type: "text/javascript", src: "/javascripts/application.js" }
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Sequel.connect(ENV['DATABASE_URL'] || "postgres://localhost:5432/rack_push_notification")
|
2
|
+
|
3
|
+
module Rack
|
4
|
+
class PushNotification::Device < Sequel::Model
|
5
|
+
self.dataset = :devices
|
6
|
+
|
7
|
+
Sequel::Migrator.run(self.db, ::File.join(::File.dirname(__FILE__), "migrations"))
|
8
|
+
|
9
|
+
self.strict_param_setting = false
|
10
|
+
self.raise_on_save_failure = false
|
11
|
+
|
12
|
+
plugin :json_serializer, naked: true, except: :id
|
13
|
+
plugin :validation_helpers
|
14
|
+
plugin :timestamps, force: true
|
15
|
+
plugin :schema
|
16
|
+
|
17
|
+
def before_validation
|
18
|
+
normalize_token!
|
19
|
+
end
|
20
|
+
|
21
|
+
def validate
|
22
|
+
validates_presence :token
|
23
|
+
validates_unique :token
|
24
|
+
validates_format /[[:xdigit:]]{40}/, :token
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def normalize_token!
|
30
|
+
self.token = self.token.strip.gsub(/[<\s>]/, '')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
up do
|
3
|
+
create_table :devices do
|
4
|
+
primary_key :id
|
5
|
+
|
6
|
+
column :token, :varchar, empty: false, unique: true
|
7
|
+
column :alias, :varchar
|
8
|
+
column :badge, :int4, null: false, default: 0
|
9
|
+
column :locale, :varchar
|
10
|
+
column :language, :varchar
|
11
|
+
column :timezone, :varchar, empty: false, default: 'UTC'
|
12
|
+
column :ip_address, :inet
|
13
|
+
column :lat, :float8
|
14
|
+
column :lng, :float8
|
15
|
+
column :tags, :'text[]'
|
16
|
+
|
17
|
+
index :token
|
18
|
+
index :alias
|
19
|
+
index [:lat, :lng]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
down do
|
24
|
+
drop_table :devices
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
up do
|
3
|
+
add_column :devices, :tsv, 'TSVector'
|
4
|
+
|
5
|
+
run %{
|
6
|
+
CREATE INDEX tsv_GIN ON devices \
|
7
|
+
USING GIN(tsv);
|
8
|
+
}
|
9
|
+
|
10
|
+
run %{
|
11
|
+
CREATE TRIGGER TS_tsv \
|
12
|
+
BEFORE INSERT OR UPDATE ON devices \
|
13
|
+
FOR EACH ROW EXECUTE PROCEDURE \
|
14
|
+
tsvector_update_trigger(tsv, 'pg_catalog.english', token, alias, locale, timezone);
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
down do
|
19
|
+
drop_column :devices, :tsv
|
20
|
+
drop_index :devices, :tsv_GIN
|
21
|
+
drop_trigger :devices, :TS_tsv
|
22
|
+
end
|
23
|
+
end
|
@@ -16,9 +16,17 @@ Gem::Specification.new do |s|
|
|
16
16
|
|
17
17
|
s.add_dependency "rack", "~> 1.4"
|
18
18
|
s.add_dependency "rack-contrib", "~> 1.1.0"
|
19
|
+
s.add_dependency "sequel", "~> 3.37.0"
|
19
20
|
s.add_dependency "sinatra", "~> 1.3.2"
|
20
21
|
s.add_dependency "sinatra-param", "~> 0.1.1"
|
21
|
-
s.add_dependency "
|
22
|
+
s.add_dependency "coffee-script", "~> 2.2.0"
|
23
|
+
s.add_dependency "eco", "~> 1.0.0"
|
24
|
+
s.add_dependency "haml", "~> 3.1.7"
|
25
|
+
s.add_dependency "sass", "~> 3.2.3"
|
26
|
+
s.add_dependency "bootstrap-sass", "~> 2.1.1"
|
27
|
+
s.add_dependency "sprockets", "~> 2.8.1"
|
28
|
+
s.add_dependency "sprockets-sass", "~> 0.9.1"
|
29
|
+
s.add_dependency "houston", "~> 0.1.1"
|
22
30
|
|
23
31
|
s.files = Dir["./**/*"].reject { |file| file =~ /\.\/(bin|example|log|pkg|script|spec|test|vendor)/ }
|
24
32
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-push-notification
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -75,6 +75,22 @@ dependencies:
|
|
75
75
|
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: 1.1.0
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: sequel
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 3.37.0
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 3.37.0
|
78
94
|
- !ruby/object:Gem::Dependency
|
79
95
|
name: sinatra
|
80
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,13 +124,13 @@ dependencies:
|
|
108
124
|
- !ruby/object:Gem::Version
|
109
125
|
version: 0.1.1
|
110
126
|
- !ruby/object:Gem::Dependency
|
111
|
-
name:
|
127
|
+
name: coffee-script
|
112
128
|
requirement: !ruby/object:Gem::Requirement
|
113
129
|
none: false
|
114
130
|
requirements:
|
115
131
|
- - ~>
|
116
132
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
133
|
+
version: 2.2.0
|
118
134
|
type: :runtime
|
119
135
|
prerelease: false
|
120
136
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -122,7 +138,119 @@ dependencies:
|
|
122
138
|
requirements:
|
123
139
|
- - ~>
|
124
140
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
141
|
+
version: 2.2.0
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: eco
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ~>
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: 1.0.0
|
150
|
+
type: :runtime
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ~>
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: 1.0.0
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: haml
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ~>
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: 3.1.7
|
166
|
+
type: :runtime
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ~>
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 3.1.7
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: sass
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ~>
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: 3.2.3
|
182
|
+
type: :runtime
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ~>
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: 3.2.3
|
190
|
+
- !ruby/object:Gem::Dependency
|
191
|
+
name: bootstrap-sass
|
192
|
+
requirement: !ruby/object:Gem::Requirement
|
193
|
+
none: false
|
194
|
+
requirements:
|
195
|
+
- - ~>
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: 2.1.1
|
198
|
+
type: :runtime
|
199
|
+
prerelease: false
|
200
|
+
version_requirements: !ruby/object:Gem::Requirement
|
201
|
+
none: false
|
202
|
+
requirements:
|
203
|
+
- - ~>
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
version: 2.1.1
|
206
|
+
- !ruby/object:Gem::Dependency
|
207
|
+
name: sprockets
|
208
|
+
requirement: !ruby/object:Gem::Requirement
|
209
|
+
none: false
|
210
|
+
requirements:
|
211
|
+
- - ~>
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: 2.8.1
|
214
|
+
type: :runtime
|
215
|
+
prerelease: false
|
216
|
+
version_requirements: !ruby/object:Gem::Requirement
|
217
|
+
none: false
|
218
|
+
requirements:
|
219
|
+
- - ~>
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: 2.8.1
|
222
|
+
- !ruby/object:Gem::Dependency
|
223
|
+
name: sprockets-sass
|
224
|
+
requirement: !ruby/object:Gem::Requirement
|
225
|
+
none: false
|
226
|
+
requirements:
|
227
|
+
- - ~>
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: 0.9.1
|
230
|
+
type: :runtime
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
none: false
|
234
|
+
requirements:
|
235
|
+
- - ~>
|
236
|
+
- !ruby/object:Gem::Version
|
237
|
+
version: 0.9.1
|
238
|
+
- !ruby/object:Gem::Dependency
|
239
|
+
name: houston
|
240
|
+
requirement: !ruby/object:Gem::Requirement
|
241
|
+
none: false
|
242
|
+
requirements:
|
243
|
+
- - ~>
|
244
|
+
- !ruby/object:Gem::Version
|
245
|
+
version: 0.1.1
|
246
|
+
type: :runtime
|
247
|
+
prerelease: false
|
248
|
+
version_requirements: !ruby/object:Gem::Requirement
|
249
|
+
none: false
|
250
|
+
requirements:
|
251
|
+
- - ~>
|
252
|
+
- !ruby/object:Gem::Version
|
253
|
+
version: 0.1.1
|
126
254
|
description: Generate a REST API for registering and querying push notification device
|
127
255
|
tokens.
|
128
256
|
email: m@mattt.me
|
@@ -132,7 +260,35 @@ extra_rdoc_files: []
|
|
132
260
|
files:
|
133
261
|
- ./Gemfile
|
134
262
|
- ./Gemfile.lock
|
135
|
-
- ./lib/rack/push-notification/
|
263
|
+
- ./lib/rack/push-notification/admin.rb
|
264
|
+
- ./lib/rack/push-notification/assets/images/wallpaper-clown-fish.jpg
|
265
|
+
- ./lib/rack/push-notification/assets/javascripts/application.coffee
|
266
|
+
- ./lib/rack/push-notification/assets/javascripts/collections/devices.coffee
|
267
|
+
- ./lib/rack/push-notification/assets/javascripts/models/device.coffee
|
268
|
+
- ./lib/rack/push-notification/assets/javascripts/routers/root.coffee
|
269
|
+
- ./lib/rack/push-notification/assets/javascripts/rpn.coffee
|
270
|
+
- ./lib/rack/push-notification/assets/javascripts/templates/_devices.jst.eco
|
271
|
+
- ./lib/rack/push-notification/assets/javascripts/templates/_preview.jst.eco
|
272
|
+
- ./lib/rack/push-notification/assets/javascripts/templates/compose.jst.eco
|
273
|
+
- ./lib/rack/push-notification/assets/javascripts/templates/devices.jst.eco
|
274
|
+
- ./lib/rack/push-notification/assets/javascripts/templates/pagination.jst.eco
|
275
|
+
- ./lib/rack/push-notification/assets/javascripts/vendor/backbone.js
|
276
|
+
- ./lib/rack/push-notification/assets/javascripts/vendor/backbone.paginator.js
|
277
|
+
- ./lib/rack/push-notification/assets/javascripts/vendor/codemirror.javascript.js
|
278
|
+
- ./lib/rack/push-notification/assets/javascripts/vendor/codemirror.js
|
279
|
+
- ./lib/rack/push-notification/assets/javascripts/vendor/date.js
|
280
|
+
- ./lib/rack/push-notification/assets/javascripts/vendor/jquery.js
|
281
|
+
- ./lib/rack/push-notification/assets/javascripts/vendor/underscore.js
|
282
|
+
- ./lib/rack/push-notification/assets/javascripts/views/compose.coffee
|
283
|
+
- ./lib/rack/push-notification/assets/javascripts/views/devices.coffee
|
284
|
+
- ./lib/rack/push-notification/assets/javascripts/views/pagination.coffee
|
285
|
+
- ./lib/rack/push-notification/assets/stylesheets/_codemirror.sass
|
286
|
+
- ./lib/rack/push-notification/assets/stylesheets/_preview.sass
|
287
|
+
- ./lib/rack/push-notification/assets/stylesheets/screen.sass
|
288
|
+
- ./lib/rack/push-notification/assets/views/index.haml
|
289
|
+
- ./lib/rack/push-notification/device.rb
|
290
|
+
- ./lib/rack/push-notification/migrations/001_base_schema.rb
|
291
|
+
- ./lib/rack/push-notification/migrations/002_add_full_text_search.rb
|
136
292
|
- ./lib/rack/push-notification.rb
|
137
293
|
- ./LICENSE
|
138
294
|
- ./rack-push-notification.gemspec
|
@@ -152,7 +308,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
152
308
|
version: '0'
|
153
309
|
segments:
|
154
310
|
- 0
|
155
|
-
hash:
|
311
|
+
hash: -2802516591035753533
|
156
312
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
313
|
none: false
|
158
314
|
requirements:
|
@@ -161,7 +317,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
317
|
version: '0'
|
162
318
|
segments:
|
163
319
|
- 0
|
164
|
-
hash:
|
320
|
+
hash: -2802516591035753533
|
165
321
|
requirements: []
|
166
322
|
rubyforge_project:
|
167
323
|
rubygems_version: 1.8.24
|