camping-abingo 1.0.3 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/doc/classes/ABingoCampingPlugin.html +16 -16
  2. data/doc/classes/ABingoCampingPlugin/Controllers.html +10 -10
  3. data/doc/classes/ABingoCampingPlugin/Filters.html +5 -5
  4. data/doc/classes/ABingoCampingPlugin/Helpers.html +65 -65
  5. data/doc/classes/ABingoCampingPlugin/Models.html +15 -15
  6. data/doc/classes/ABingoCampingPlugin/Models/Alternative.html +15 -15
  7. data/doc/classes/ABingoCampingPlugin/Models/Experiment.html +45 -45
  8. data/doc/classes/ABingoCampingPlugin/Views.html +15 -15
  9. data/doc/classes/ActiveSupport/Cache/MemoryStore.html +5 -5
  10. data/doc/classes/ActiveSupport/Cache/MemoryStore.src/M000001.html +18 -0
  11. data/doc/classes/CampingABingoTest.html +6 -6
  12. data/doc/classes/CampingABingoTest.src/M000002.html +24 -0
  13. data/doc/classes/CampingABingoTest/Controllers/Index.html +5 -5
  14. data/doc/classes/CampingABingoTest/Controllers/Index.src/M000009.html +18 -0
  15. data/doc/classes/CampingABingoTest/Controllers/Landing.html +5 -5
  16. data/doc/classes/CampingABingoTest/Controllers/Landing.src/M000011.html +18 -0
  17. data/doc/classes/CampingABingoTest/Controllers/SignIn.html +10 -10
  18. data/doc/classes/CampingABingoTest/Controllers/SignIn.src/M000015.html +18 -0
  19. data/doc/classes/CampingABingoTest/Controllers/SignIn.src/M000016.html +34 -0
  20. data/doc/classes/CampingABingoTest/Controllers/SignOut.html +5 -5
  21. data/doc/classes/CampingABingoTest/Controllers/SignOut.src/M000014.html +21 -0
  22. data/doc/classes/CampingABingoTest/Controllers/SignUp.html +10 -10
  23. data/doc/classes/CampingABingoTest/Controllers/SignUp.src/M000012.html +23 -0
  24. data/doc/classes/CampingABingoTest/Controllers/SignUp.src/M000013.html +33 -0
  25. data/doc/classes/CampingABingoTest/Controllers/Welcome.html +5 -5
  26. data/doc/classes/CampingABingoTest/Controllers/Welcome.src/M000010.html +18 -0
  27. data/doc/classes/CampingABingoTest/Helpers.html +1 -1
  28. data/doc/classes/CampingABingoTest/Models.html +1 -1
  29. data/doc/classes/CampingABingoTest/Models/CreateUserSchema.html +11 -11
  30. data/doc/classes/CampingABingoTest/Models/CreateUserSchema.src/M000017.html +26 -0
  31. data/doc/classes/CampingABingoTest/Models/CreateUserSchema.src/M000018.html +19 -0
  32. data/doc/classes/CampingABingoTest/Views.html +30 -30
  33. data/doc/classes/CampingABingoTest/Views.src/M000003.html +70 -0
  34. data/doc/classes/CampingABingoTest/Views.src/M000004.html +22 -0
  35. data/doc/classes/CampingABingoTest/Views.src/M000005.html +51 -0
  36. data/doc/classes/CampingABingoTest/Views.src/M000006.html +31 -0
  37. data/doc/classes/CampingABingoTest/Views.src/M000007.html +31 -0
  38. data/doc/classes/CampingABingoTest/Views.src/M000008.html +20 -0
  39. data/doc/created.rid +1 -1
  40. data/doc/files/examples/camping-abingo-test/camping-abingo-test_rb.html +1 -1
  41. data/doc/files/lib/camping-abingo_rb.html +3 -4
  42. data/doc/fr_class_index.html +0 -10
  43. data/doc/fr_file_index.html +0 -1
  44. data/doc/fr_method_index.html +18 -70
  45. data/examples/camping-abingo-test/camping-abingo-test-skeleton.rb +456 -0
  46. data/examples/camping-abingo-test/camping-abingo-test.rb +510 -0
  47. data/examples/camping-abingo-test/config.ru +26 -0
  48. data/examples/camping-abingo-test/config/database.yml +4 -0
  49. data/lib/camping-abingo.rb +1 -10
  50. metadata +50 -18
@@ -0,0 +1,510 @@
1
+ gem 'camping' , '>= 2.0'
2
+ gem 'filtering_camping' , '>= 1.0'
3
+ gem 'camping-abingo'
4
+
5
+ %w(rubygems active_record erb fileutils json markaby md5 redcloth
6
+ camping camping/session filtering_camping camping-abingo
7
+ ).each { |lib| require lib }
8
+
9
+ Camping.goes :CampingABingoTest
10
+
11
+ module ActiveSupport::Cache
12
+ class MemoryStore < Store
13
+ def data
14
+ @data
15
+ end
16
+ end
17
+ end # ActiveSupport::Cache
18
+
19
+ module CampingABingoTest
20
+ include Camping::Session
21
+ include CampingFilters
22
+
23
+ extend ABingoCampingPlugin
24
+ include ABingoCampingPlugin::Filters
25
+
26
+ app_logger = Logger.new(File.dirname(__FILE__) + '/camping-abingo-test.log')
27
+ app_logger.level = Logger::DEBUG
28
+ Camping::Models::Base.logger = app_logger
29
+ ABingoCampingPlugin.logger = app_logger
30
+
31
+ def CampingABingoTest.create
32
+ dbconfig = YAML.load(File.read('config/database.yml'))
33
+ Camping::Models::Base.establish_connection dbconfig['development']
34
+
35
+ ABingoCampingPlugin.create
36
+ Abingo.cache.logger = Camping::Models::Base.logger
37
+ Abingo.options[:abingo_administrator_user_id] = 1
38
+ CampingABingoTest::Models.create_schema :assume => (CampingABingoTest::Models::User.table_exists? ? 1.1 : 0.0)
39
+ end
40
+ end
41
+
42
+ module CampingABingoTest::Models
43
+ include ABingoCampingPlugin::Models
44
+
45
+ class User < Base;
46
+ end
47
+
48
+ class CreateUserSchema < V 1.1
49
+ def self.up
50
+ create_table :CampingABingoTest_users, :force => true do |t|
51
+ t.integer :id, :null => false
52
+ t.string :username
53
+ t.string :password
54
+ end
55
+
56
+ User.create :username => 'admin', :password => 'camping'
57
+
58
+ ABingoCampingPlugin::Models.up
59
+ end
60
+
61
+ def self.down
62
+ ABingoCampingPlugin::Models.down
63
+ drop_table :CampingABingoTest_users
64
+ end
65
+ end
66
+
67
+ end
68
+
69
+ module CampingABingoTest::Helpers
70
+ extend ABingoCampingPlugin::Helpers
71
+ include ABingoCampingPlugin::Helpers
72
+ end
73
+
74
+ module CampingABingoTest::Controllers
75
+ extend ABingoCampingPlugin::Controllers
76
+
77
+ class Index
78
+ def get
79
+ render :index
80
+ end
81
+ end
82
+
83
+ class Landing < R '/landing'
84
+ def get
85
+ render :landing
86
+ end
87
+ end
88
+
89
+ class SignIn < R '/signin'
90
+ def get
91
+ render :signin
92
+ end
93
+
94
+ def post
95
+ @user = User.find_by_username_and_password(input.username, input.password)
96
+
97
+ if @user
98
+ @state.user_id = @user.id
99
+
100
+ if @state.return_to.nil?
101
+ redirect R(Welcome)
102
+ else
103
+ return_to = @state.return_to
104
+ @state.return_to = nil
105
+ redirect(return_to)
106
+ end
107
+ else
108
+ @info = 'Wrong username or password.'
109
+ end
110
+
111
+ render :signin
112
+ end
113
+ end
114
+
115
+ class SignOut < R '/signout'
116
+ def get
117
+ @state.user_id = nil
118
+ @state.abingo_identity = Abingo.identity = rand(10 ** 10).to_i
119
+
120
+ render :index
121
+ end
122
+ end
123
+
124
+ class SignUp < R '/signup'
125
+ def get
126
+ if @input.special_promo
127
+ bingo! "special_promo"
128
+ end
129
+ bingo! "call_to_action"
130
+
131
+ render :signup
132
+ end
133
+
134
+ def post
135
+ @user = User.find_by_username(input.username)
136
+ if @user
137
+ @info = 'A user account already exist for this username.'
138
+ else
139
+ @user = User.new :username => input.username,
140
+ :password => input.password
141
+ @user.save
142
+ if @user
143
+ @state.user_id = @user.id
144
+ @state.abingo_identity = @user.id
145
+ redirect R(Welcome)
146
+ else
147
+ @info = @user.errors.full_messages unless @user.errors.empty?
148
+ end
149
+ end
150
+ render :signup
151
+ end
152
+ end
153
+
154
+ class Welcome < R '/welcome'
155
+ def get
156
+ render :welcome
157
+ end
158
+ end
159
+
160
+ include_abingo_controllers
161
+ end #Controllers
162
+
163
+ module CampingABingoTest::Views
164
+ extend ABingoCampingPlugin::Views
165
+
166
+ def layout
167
+ html do
168
+
169
+ head do
170
+ title "Ruby Camping ABingo Plugin Demo"
171
+
172
+ style :type => 'text/css' do
173
+ <<-STYLE
174
+
175
+ /* --- General Test App Styles --- */
176
+
177
+ body {
178
+ padding:0 0 0 0;
179
+ margin:5px;
180
+ font-family:'Lucida Grande','Lucida Sans Unicode',sans-serif;
181
+ font-size: 0.8em;
182
+ color:#303030;
183
+ background-color: #fbf9b5;
184
+ }
185
+
186
+ a {
187
+ color:#303030;
188
+ text-decoration:none;
189
+ border-bottom:1px dotted #505050;
190
+ }
191
+
192
+ a:hover {
193
+ color:#303030;
194
+ background: yellow;
195
+ text-decoration:none;
196
+ border-bottom:4px solid orange;
197
+ }
198
+
199
+ h1 {
200
+ font-size: 14px;
201
+ color: #cc3300;
202
+ }
203
+
204
+ table {
205
+ font-size:0.9em;
206
+ width: 1050px;
207
+ }
208
+
209
+ tr
210
+ {
211
+ background:lightgoldenRodYellow;
212
+ vertical-align:top;
213
+ }
214
+
215
+ th
216
+ {
217
+ font-size: 0.9em;
218
+ font-weight:bold;
219
+ background:lightBlue none repeat scroll 0 0;
220
+
221
+ text-align:left;
222
+ }
223
+
224
+ #header
225
+ {
226
+ width: 100%;
227
+ height: 30px;
228
+ border-bottom: 4px solid #ccc;
229
+ }
230
+
231
+ #header_title
232
+ {
233
+ float: left;
234
+ }
235
+
236
+ #top_nav
237
+ {
238
+ float: right;
239
+ }
240
+
241
+ #footer
242
+ {
243
+ width: 100%;
244
+ border-top: 4px solid #ccc;
245
+ }
246
+
247
+
248
+ #footer_notices
249
+ {
250
+ width: 100%;
251
+ border-top: 4px solid #ccc;
252
+ }
253
+
254
+ #home
255
+ {
256
+ background-color: #C9E3F5;
257
+ padding: 10px;
258
+ height: 300px;
259
+ }
260
+
261
+ #debug_panel
262
+ {
263
+ background-color: wheat;
264
+ padding: 10px;
265
+ }
266
+
267
+ .xyz
268
+ {
269
+ background-color: #D1F2A5;
270
+ padding: 10px;
271
+ height: 300px;
272
+ }
273
+
274
+ .xyz h1
275
+ {
276
+ color: #9D9F89;
277
+ }
278
+
279
+ #special_promo
280
+ {
281
+ margin: 20px;
282
+ }
283
+
284
+ #landing a:hover
285
+ {
286
+ background-color: #B2DE93;
287
+ border-bottom-color:green;
288
+ }
289
+
290
+ #marketing
291
+ {
292
+ width: 480px;
293
+ height: 100px;
294
+ margin: 20px;
295
+ }
296
+
297
+ #benefits
298
+ {
299
+ float: left;
300
+ width: 300px;
301
+ height: 100px;
302
+ font-size: 1.3em;
303
+ font-weight: bold;
304
+ color: green;
305
+ background-color: #B2DE93;
306
+ }
307
+
308
+ #actnow
309
+ {
310
+ float: right;
311
+ width: 180px;
312
+ height: 100px;
313
+ text-align: center;
314
+ background-color: #8BC59B;
315
+ }
316
+
317
+ #signup_btn
318
+ {
319
+ background-color:#91F1A0;
320
+ border:4px solid green;
321
+ font-size:1.5em;
322
+ font-weight:bold;
323
+ height:72px;
324
+ margin: 10px 20px 10px 22px;
325
+ width:130px;
326
+ }
327
+
328
+ #actnow a:hover #signup_btn
329
+ {
330
+ background-color: #69F17F;
331
+ color: #007300;
332
+ border: 4px solid #00AA00;
333
+ }
334
+
335
+ /* --- ABingo Dashboard Styles ---*/
336
+
337
+ #abingo_dashboard
338
+ {
339
+ background-color: white;
340
+ padding: 10px;
341
+ }
342
+
343
+ abingo_experiment_table
344
+ {
345
+ width: 100%;
346
+ }
347
+
348
+ .abingo_experiment_row
349
+ {
350
+ }
351
+
352
+ .abingo_alternative_row
353
+ {
354
+ color: red;
355
+ font-weight: bold;
356
+ }
357
+
358
+ .abingo_debug
359
+ {
360
+ display: block;
361
+ width: 100%;
362
+ }
363
+
364
+ .abingo_explain
365
+ {
366
+ color: #CCC;
367
+ font-style:italics;
368
+ }
369
+
370
+
371
+ STYLE
372
+ end
373
+ end #head
374
+
375
+ body do
376
+ div.header! do
377
+ div.header_title! "Ruby Camping ABingo Plugin Demo"
378
+ div.top_nav! do
379
+ a "Home", :href=>"/"
380
+ span " | "
381
+ if @state.nil? || @state.user_id.nil?
382
+ a "Sign-In", :href=>'/signin'
383
+ span " | "
384
+ a "Sign-Up", :href=>'/signup'
385
+ else
386
+ a "XYZ", :href=>"/welcome"
387
+ span " | "
388
+ a "Sign-Out", :href=>'/signout'
389
+ if @state.user_id == abingo_administrator_user_id
390
+ span " | "
391
+ a "ABingo Dashboard", :href=>"/abingo/dashboard"
392
+ end
393
+ end
394
+ end
395
+ end
396
+
397
+ self << yield
398
+
399
+ div.footer! do
400
+ div.debug_panel! do
401
+ h4 "Debugging Information:"
402
+ h5 "State:"
403
+ div "#{@state.inspect}"
404
+
405
+ h5 "Cache Data:"
406
+ if Abingo.cache && Abingo.cache.data
407
+ Abingo.cache.data.each do | k,v |
408
+ div.abingo_debug "#{k} => #{v.inspect}";
409
+ end
410
+ end
411
+ end
412
+
413
+ div.footer_notices! { "Copyright &copy; 2010 &nbsp; - #{ a('Patrick McKenzie', :href => 'http://www.bingocardcreator.com/abingo') } and #{ a('Philippe Monnet', :href => 'http://blog.monnet-usa.com/') } " }
414
+ end
415
+ end
416
+
417
+ end
418
+ end
419
+
420
+
421
+ def index
422
+ div.home! do
423
+ h1 'My CampingABingoTest App'
424
+
425
+ a "XYZ SAAS Application Landing page variations", :href=>"/landing"; br;
426
+ end
427
+ end
428
+
429
+ def landing
430
+ div.xyz do
431
+ h1 'XYZ SAAS Application'
432
+
433
+ if ab_test("special_promo")
434
+ div.special_promo! do
435
+ div "Special offer for today only"
436
+ a "Sign-Up Now and get a month free!", :href=>"/signup?special_promo=1"
437
+ end
438
+ else
439
+ div.abingo_explain "The special promo was not selected for this user"
440
+ end
441
+
442
+ div.marketing! do
443
+ div.benefits! do
444
+ ul do
445
+ li "Save XYZ time in half"
446
+ li "Reduce XYZ cost by 25%"
447
+ li "Improve quality"
448
+ end
449
+ end
450
+
451
+ div.actnow! do
452
+ signup_text = ab_test("call_to_action",
453
+ [ "Sign-Up Now!",
454
+ "Try It For Free Now!",
455
+ "Start Your Free Trial Now!",
456
+ ])
457
+
458
+ a :href=>"/signup" do
459
+ div.signup_btn! signup_text
460
+ end
461
+ end
462
+ end
463
+ end
464
+ end
465
+
466
+ def signin
467
+ div.xyz do
468
+ h1 'XYZ SAAS Application Sign-In'
469
+ div @info if @info
470
+
471
+ form :action => R(SignIn), :method => 'post' do
472
+ label 'Username', :for => 'username'; br
473
+ input :name => 'username', :type => 'text'; br
474
+
475
+ label 'Password', :for => 'password'; br
476
+ input :name => 'password', :type => 'text'; br
477
+
478
+ input :type => 'submit', :name => 'signin', :value => 'Sign-In'
479
+ end
480
+ end
481
+ end
482
+
483
+ def signup
484
+ div.xyz do
485
+ h1 'XYZ SAAS Application Sign-Up'
486
+ div @info if @info
487
+
488
+ form :action => R(SignUp), :method => 'post' do
489
+ label 'Username', :for => 'username'; br
490
+ input :name => 'username', :type => 'text'; br
491
+
492
+ label 'Password', :for => 'password'; br
493
+ input :name => 'password', :type => 'password'; br;br
494
+
495
+ input :type => 'submit', :name => 'signup', :value => 'Sign-Up'
496
+ end
497
+ end
498
+ end
499
+
500
+ def welcome
501
+ div.xyz do
502
+ h1 'Welcome'
503
+ end
504
+ end
505
+
506
+ include_abingo_views
507
+ end
508
+
509
+ CampingABingoTest.create
510
+