advert_selector 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +132 -0
  3. data/Rakefile +40 -0
  4. data/app/assets/javascripts/advert_selector/application.js +15 -0
  5. data/app/assets/stylesheets/advert_selector/application.css +29 -0
  6. data/app/controllers/advert_selector/application_controller.rb +26 -0
  7. data/app/controllers/advert_selector/banners_controller.rb +122 -0
  8. data/app/controllers/advert_selector/main_controller.rb +13 -0
  9. data/app/controllers/advert_selector/placements_controller.rb +89 -0
  10. data/app/helpers/advert_selector/application_helper.rb +155 -0
  11. data/app/models/advert_selector/banner.rb +107 -0
  12. data/app/models/advert_selector/helper_item.rb +21 -0
  13. data/app/models/advert_selector/placement.rb +58 -0
  14. data/app/views/advert_selector/banners/_form.html.erb +42 -0
  15. data/app/views/advert_selector/banners/edit.html.erb +29 -0
  16. data/app/views/advert_selector/banners/index.html.erb +38 -0
  17. data/app/views/advert_selector/banners/new.html.erb +5 -0
  18. data/app/views/advert_selector/banners/show.html.erb +50 -0
  19. data/app/views/advert_selector/helper_items/_form.html.erb +37 -0
  20. data/app/views/advert_selector/helper_items/edit.html.erb +6 -0
  21. data/app/views/advert_selector/helper_items/index.html.erb +31 -0
  22. data/app/views/advert_selector/helper_items/new.html.erb +5 -0
  23. data/app/views/advert_selector/helper_items/show.html.erb +30 -0
  24. data/app/views/advert_selector/main/index.html.erb +20 -0
  25. data/app/views/advert_selector/placements/_form.html.erb +40 -0
  26. data/app/views/advert_selector/placements/edit.html.erb +6 -0
  27. data/app/views/advert_selector/placements/index.html.erb +25 -0
  28. data/app/views/advert_selector/placements/new.html.erb +5 -0
  29. data/app/views/advert_selector/placements/show.html.erb +20 -0
  30. data/app/views/layouts/advert_selector/application.html.erb +89 -0
  31. data/config/routes.rb +17 -0
  32. data/db/migrate/20120924165938_create_advert_selector_placements.rb +11 -0
  33. data/db/migrate/20120925122858_create_advert_selector_banners.rb +23 -0
  34. data/db/migrate/20120926132649_create_advert_selector_helper_items.rb +18 -0
  35. data/lib/advert_selector.rb +26 -0
  36. data/lib/advert_selector/engine.rb +18 -0
  37. data/lib/advert_selector/errors_cache.rb +21 -0
  38. data/lib/advert_selector/version.rb +3 -0
  39. data/lib/tasks/advert_selector_tasks.rake +4 -0
  40. data/test/advert_selector_test.rb +7 -0
  41. data/test/dummy/README.rdoc +261 -0
  42. data/test/dummy/Rakefile +7 -0
  43. data/test/dummy/app/assets/javascripts/application.js +15 -0
  44. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  45. data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
  46. data/test/dummy/app/controllers/application_controller.rb +4 -0
  47. data/test/dummy/app/controllers/examples_controller.rb +4 -0
  48. data/test/dummy/app/helpers/advert_selector_helper.rb +23 -0
  49. data/test/dummy/app/helpers/application_helper.rb +2 -0
  50. data/test/dummy/app/views/examples/index.html.erb +34 -0
  51. data/test/dummy/app/views/layouts/application.html.erb +20 -0
  52. data/test/dummy/config.ru +4 -0
  53. data/test/dummy/config/application.rb +59 -0
  54. data/test/dummy/config/boot.rb +10 -0
  55. data/test/dummy/config/database.yml +25 -0
  56. data/test/dummy/config/environment.rb +5 -0
  57. data/test/dummy/config/environments/development.rb +37 -0
  58. data/test/dummy/config/environments/production.rb +67 -0
  59. data/test/dummy/config/environments/test.rb +37 -0
  60. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  61. data/test/dummy/config/initializers/inflections.rb +15 -0
  62. data/test/dummy/config/initializers/mime_types.rb +5 -0
  63. data/test/dummy/config/initializers/secret_token.rb +7 -0
  64. data/test/dummy/config/initializers/session_store.rb +8 -0
  65. data/test/dummy/config/initializers/silence_assets.rb +20 -0
  66. data/test/dummy/config/initializers/simple_form.rb +178 -0
  67. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  68. data/test/dummy/config/locales/en.yml +5 -0
  69. data/test/dummy/config/locales/simple_form.en.yml +26 -0
  70. data/test/dummy/config/routes.rb +8 -0
  71. data/test/dummy/db/development.sqlite3 +0 -0
  72. data/test/dummy/db/migrate/20120928114159_create_advert_selector_placements.advert_selector.rb +12 -0
  73. data/test/dummy/db/migrate/20120928114160_create_advert_selector_banners.advert_selector.rb +24 -0
  74. data/test/dummy/db/migrate/20120928114161_create_advert_selector_helper_items.advert_selector.rb +19 -0
  75. data/test/dummy/db/schema.rb +53 -0
  76. data/test/dummy/db/test.sqlite3 +0 -0
  77. data/test/dummy/lib/templates/erb/scaffold/_form.html.erb +13 -0
  78. data/test/dummy/log/development.log +11516 -0
  79. data/test/dummy/log/test.log +66467 -0
  80. data/test/dummy/public/404.html +26 -0
  81. data/test/dummy/public/422.html +26 -0
  82. data/test/dummy/public/500.html +25 -0
  83. data/test/dummy/public/favicon.ico +0 -0
  84. data/test/dummy/script/rails +6 -0
  85. data/test/dummy/test/unit/helpers/examples_helper_test.rb +4 -0
  86. data/test/dummy/tmp/cache/88F/B60/AdvertSelectorBanner_2 +0 -0
  87. data/test/dummy/tmp/cache/943/570/advert_selector_errors +0 -0
  88. data/test/dummy/tmp/cache/A2C/760/AdvertSelectorBanner_207249520 +0 -0
  89. data/test/dummy/tmp/cache/A3E/CF0/AdvertSelectorBanner_394627963 +0 -0
  90. data/test/dummy/tmp/cache/A3F/BF0/AdvertSelectorBanner_814558298 +0 -0
  91. data/test/dummy/tmp/cache/A40/C00/AdvertSelectorBanner_814558299 +0 -0
  92. data/test/dummy/tmp/cache/assets/C57/D40/sprockets%2F4f1a95218761045e0b23975e889644aa +0 -0
  93. data/test/dummy/tmp/cache/assets/C5F/E80/sprockets%2F01c5361554f26407988a43647d88c5fe +0 -0
  94. data/test/dummy/tmp/cache/assets/C75/2E0/sprockets%2F23135a6eb5317973d290438c359a3c0a +0 -0
  95. data/test/dummy/tmp/cache/assets/C77/A40/sprockets%2F3b3d6c1426796a7024c7d3f42c283026 +0 -0
  96. data/test/dummy/tmp/cache/assets/C86/C20/sprockets%2Ffe1477ea429411b3b581466c928b6860 +0 -0
  97. data/test/dummy/tmp/cache/assets/C8C/B80/sprockets%2F371bf96e99717688ed7313a0c53f4212 +0 -0
  98. data/test/dummy/tmp/cache/assets/CBA/C70/sprockets%2F26288ca60ed05d24b8189328e4df9373 +0 -0
  99. data/test/dummy/tmp/cache/assets/CD1/A90/sprockets%2F433a791e2f93c0d8391aaa62203943ca +0 -0
  100. data/test/dummy/tmp/cache/assets/CD3/DE0/sprockets%2F0406286714c3c0abfcb4573336f7e33c +0 -0
  101. data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  102. data/test/dummy/tmp/cache/assets/CD9/E80/sprockets%2F9052578aacc61253aa3854fa03b4895d +0 -0
  103. data/test/dummy/tmp/cache/assets/CEB/040/sprockets%2F644677c3bb57b6ed6b675229cfe54305 +0 -0
  104. data/test/dummy/tmp/cache/assets/CF0/1D0/sprockets%2F6fc757c2c8329244ca95d6909865bbc2 +0 -0
  105. data/test/dummy/tmp/cache/assets/CF2/EF0/sprockets%2F30ffd128655c9f04e88fba233248e997 +0 -0
  106. data/test/dummy/tmp/cache/assets/CF7/B60/sprockets%2F2c2a2af94201088a2a815ba90b8d344c +0 -0
  107. data/test/dummy/tmp/cache/assets/D05/4D0/sprockets%2F2d14560f81284bfb61fc0e187a803f1d +0 -0
  108. data/test/dummy/tmp/cache/assets/D0E/380/sprockets%2Ff27b6f5008c5a7324a7d8a382f21e7f2 +0 -0
  109. data/test/dummy/tmp/cache/assets/D19/820/sprockets%2Fccd0e907b49615494cc88c43a4781a9c +0 -0
  110. data/test/dummy/tmp/cache/assets/D28/910/sprockets%2F79b8a6fa551206c9996cfe98b80492cb +0 -0
  111. data/test/dummy/tmp/cache/assets/D2D/C20/sprockets%2Ff7d7fd5892b198e1588dd7d90a29a717 +0 -0
  112. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  113. data/test/dummy/tmp/cache/assets/D36/570/sprockets%2Fadfccb7c2436e006496eae16d6901523 +0 -0
  114. data/test/dummy/tmp/cache/assets/D40/110/sprockets%2Fbc5fcd75a352287c59787234ccbb11a8 +0 -0
  115. data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  116. data/test/dummy/tmp/cache/assets/D50/030/sprockets%2F90296cd1ff74af449206b4fbd57cc995 +0 -0
  117. data/test/dummy/tmp/cache/assets/D50/BD0/sprockets%2F9c4832ce629b45b57ed8a55fbc717a86 +0 -0
  118. data/test/dummy/tmp/cache/assets/D55/240/sprockets%2F4b378a9f8c71e387569adfd712a26ce9 +0 -0
  119. data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  120. data/test/dummy/tmp/cache/assets/D68/0A0/sprockets%2F17a08f579f5d1585bbd0c6ce2bac4351 +0 -0
  121. data/test/dummy/tmp/cache/assets/D68/220/sprockets%2F701db0b265a7c593768caebb904de9a1 +0 -0
  122. data/test/dummy/tmp/cache/assets/D6A/EF0/sprockets%2F2eb65cc490ad96cc38604918b0caeb90 +0 -0
  123. data/test/dummy/tmp/cache/assets/D6F/040/sprockets%2Fbd56a4cbc86673dbf2242fb85571bf61 +0 -0
  124. data/test/dummy/tmp/cache/assets/D70/540/sprockets%2Ffb1dbed4c6b15bc994454964bd455a43 +0 -0
  125. data/test/dummy/tmp/cache/assets/D83/400/sprockets%2Fc5adb5e35a83a7e10361f02afa42d4c1 +0 -0
  126. data/test/dummy/tmp/cache/assets/D88/7F0/sprockets%2Fe3b83e01d5f51e442ec9c11b40cca81a +0 -0
  127. data/test/dummy/tmp/cache/assets/DA3/080/sprockets%2Ffb77a66783db0b5812e3fdbabe4608f6 +0 -0
  128. data/test/dummy/tmp/cache/assets/DCE/810/sprockets%2F6eeb2d90a03c9de3ce8f5f30acf58118 +0 -0
  129. data/test/dummy/tmp/cache/assets/DCE/D50/sprockets%2F2232ec55b4deca5e8120ced9bd79ef54 +0 -0
  130. data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  131. data/test/dummy/tmp/cache/assets/DF1/360/sprockets%2F23acf8b0d41e15db4d6ac2729f3eed1d +0 -0
  132. data/test/dummy/tmp/cache/assets/DF5/B00/sprockets%2Ff93edea94ff32d205acd8cdc4532b12b +0 -0
  133. data/test/dummy/tmp/cache/assets/DFB/9A0/sprockets%2Fb9a29f57d1ebf045452ed6cbd62eae1d +0 -0
  134. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  135. data/test/dummy/tmp/cache/assets/E53/3C0/sprockets%2Fcd0f7cae0b53d5ff22db8bf547d6a1bc +0 -0
  136. data/test/fixtures/advert_selector/banners.yml +38 -0
  137. data/test/fixtures/advert_selector/helper_items.yml +28 -0
  138. data/test/fixtures/advert_selector/placements.yml +17 -0
  139. data/test/functional/advert_selector/banners_controller_test.rb +64 -0
  140. data/test/functional/advert_selector/main_controller_test.rb +30 -0
  141. data/test/functional/advert_selector/placements_controller_test.rb +58 -0
  142. data/test/functional/examples_controller_test.rb +13 -0
  143. data/test/integration/banner_shows_test.rb +154 -0
  144. data/test/integration/navigation_test.rb +10 -0
  145. data/test/test_helper.rb +43 -0
  146. data/test/unit/advert_selector/banner_test.rb +160 -0
  147. data/test/unit/advert_selector/helper_item_test.rb +9 -0
  148. data/test/unit/advert_selector/placement_test.rb +50 -0
  149. data/test/unit/helpers/advert_selector/banners_helper_test.rb +6 -0
  150. data/test/unit/helpers/advert_selector/placements_helper_test.rb +6 -0
  151. metadata +425 -0
@@ -0,0 +1,5 @@
1
+ <h1>New banner</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', banners_path %>
@@ -0,0 +1,50 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>Name:</b>
5
+ <%= @banner.name %>
6
+ </p>
7
+
8
+ <p>
9
+ <b>Start time:</b>
10
+ <%= @banner.start_time %>
11
+ </p>
12
+
13
+ <p>
14
+ <b>End time:</b>
15
+ <%= @banner.end_time %>
16
+ </p>
17
+
18
+ <p>
19
+ <b>Target view count:</b>
20
+ <%= @banner.target_view_count %>
21
+ </p>
22
+
23
+ <p>
24
+ <b>Frequency:</b>
25
+ <%= @banner.frequency %>
26
+ </p>
27
+
28
+ <p>
29
+ <b>Delay requests:</b>
30
+ <%= @banner.delay_requests %>
31
+ </p>
32
+
33
+ <p>
34
+ <b>Comment:</b>
35
+ <%= @banner.comment %>
36
+ </p>
37
+
38
+ <p>
39
+ <b>Confirmed:</b>
40
+ <%= @banner.confirmed %>
41
+ </p>
42
+
43
+ <p>
44
+ <b>Placement:</b>
45
+ <%= @banner.placement_id %>
46
+ </p>
47
+
48
+
49
+ <%= link_to 'Edit', edit_banner_path(@banner) %> |
50
+ <%= link_to 'Back', banners_path %>
@@ -0,0 +1,37 @@
1
+ <%= form_for(@helper_item) do |f| %>
2
+ <% if @helper_item.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@helper_item.errors.count, "error") %> prohibited this helper_item from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @helper_item.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :master_id %><br />
16
+ <%= f.number_field :master_id %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :master_type %><br />
20
+ <%= f.text_field :master_type %>
21
+ </div>
22
+ <div class="field">
23
+ <%= f.label :name %><br />
24
+ <%= f.text_field :name %>
25
+ </div>
26
+ <div class="field">
27
+ <%= f.label :content_for %><br />
28
+ <%= f.check_box :content_for %>
29
+ </div>
30
+ <div class="field">
31
+ <%= f.label :content %><br />
32
+ <%= f.text_area :content %>
33
+ </div>
34
+ <div class="actions">
35
+ <%= f.submit %>
36
+ </div>
37
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing helper_item</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @helper_item %> |
6
+ <%= link_to 'Back', helper_items_path %>
@@ -0,0 +1,31 @@
1
+ <h1>Listing helper_items</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Master</th>
6
+ <th>Master type</th>
7
+ <th>Name</th>
8
+ <th>Content for</th>
9
+ <th>Content</th>
10
+ <th></th>
11
+ <th></th>
12
+ <th></th>
13
+ </tr>
14
+
15
+ <% @helper_items.each do |helper_item| %>
16
+ <tr>
17
+ <td><%= helper_item.master_id %></td>
18
+ <td><%= helper_item.master_type %></td>
19
+ <td><%= helper_item.name %></td>
20
+ <td><%= helper_item.content_for %></td>
21
+ <td><%= helper_item.content %></td>
22
+ <td><%= link_to 'Show', helper_item %></td>
23
+ <td><%= link_to 'Edit', edit_helper_item_path(helper_item) %></td>
24
+ <td><%= link_to 'Destroy', helper_item, :method => :delete, :data => { :confirm => 'Are you sure?' } %></td>
25
+ </tr>
26
+ <% end %>
27
+ </table>
28
+
29
+ <br />
30
+
31
+ <%= link_to 'New Helper item', new_helper_item_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New helper_item</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', helper_items_path %>
@@ -0,0 +1,30 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>Master:</b>
5
+ <%= @helper_item.master_id %>
6
+ </p>
7
+
8
+ <p>
9
+ <b>Master type:</b>
10
+ <%= @helper_item.master_type %>
11
+ </p>
12
+
13
+ <p>
14
+ <b>Name:</b>
15
+ <%= @helper_item.name %>
16
+ </p>
17
+
18
+ <p>
19
+ <b>Content for:</b>
20
+ <%= @helper_item.content_for %>
21
+ </p>
22
+
23
+ <p>
24
+ <b>Content:</b>
25
+ <%= @helper_item.content %>
26
+ </p>
27
+
28
+
29
+ <%= link_to 'Edit', edit_helper_item_path(@helper_item) %> |
30
+ <%= link_to 'Back', helper_items_path %>
@@ -0,0 +1,20 @@
1
+ <h1>Advert Selector Main</h1>
2
+
3
+ <% unless AdvertSelector::ErrorsCache.errors.blank? %>
4
+ <div class="alert alert-error">
5
+ <h3>Latest errors - <%= link_to 'Clear errors log.', clear_errors_log_url %></h3>
6
+ <ul>
7
+ <% AdvertSelector::ErrorsCache.errors.each do |error| %>
8
+ <li><%= simple_format(h(error)) %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% else %>
13
+ <div class="alert alert-success">
14
+ No errors currently.
15
+ </div>
16
+
17
+ <% end %>
18
+
19
+
20
+ <p>Find me in app/views/advert_selector/main/index.html.erb</p>
@@ -0,0 +1,40 @@
1
+ <%= simple_form_for(@placement, :html => {:class => 'form-horizontal'}) do |f| %>
2
+
3
+ <%= f.error_notification %>
4
+
5
+ <div class="row">
6
+ <div class="span5">
7
+ <%= f.input :name %>
8
+
9
+ <%= f.input :only_once_per_session %>
10
+
11
+ <%= f.input :conflicting_placements_array, :input_html => {:rows => 5} %>
12
+
13
+ <div class="well" style="margin-left: 40px; font-size: 12px;">
14
+ <strong>Conflicting links:</strong>
15
+ <ul>
16
+ <% @placement.conflicting_placements.each do |name| %>
17
+ <li>
18
+ <% if place = AdvertSelector::Placement.by_name(name).first %>
19
+ <%= link_to place.name, place %>
20
+ <% else %>
21
+ <strong><%= name %> - NOT FOUND</strong>
22
+ <% end %>
23
+ </li>
24
+ <% end %>
25
+ </ul>
26
+ </div>
27
+
28
+ </div>
29
+
30
+ <div class="span4">
31
+ </div>
32
+
33
+ </div>
34
+
35
+ <div class="form-actions">
36
+ <%= f.button :submit %>
37
+ </div>
38
+
39
+ <% end %>
40
+
@@ -0,0 +1,6 @@
1
+ <h1>Editing placement</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @placement %> |
6
+ <%= link_to 'Back', placements_path %>
@@ -0,0 +1,25 @@
1
+ <h1>Listing placements</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Name</th>
6
+ <th>Conflicting placements array</th>
7
+ <th></th>
8
+ <th></th>
9
+ <th></th>
10
+ </tr>
11
+
12
+ <% @placements.each do |placement| %>
13
+ <tr>
14
+ <td><%= placement.name %></td>
15
+ <td><%= placement.conflicting_placements_array %></td>
16
+ <td><%= link_to 'Show', placement %></td>
17
+ <td><%= link_to 'Edit', edit_placement_path(placement) %></td>
18
+ <td><%= link_to 'Destroy', placement, :method => :delete, :data => { :confirm => 'Are you sure?' } %></td>
19
+ </tr>
20
+ <% end %>
21
+ </table>
22
+
23
+ <br />
24
+
25
+ <%= link_to 'New Placement', new_placement_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New placement</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', placements_path %>
@@ -0,0 +1,20 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>Name:</b>
5
+ <%= @placement.name %>
6
+ </p>
7
+
8
+ <p>
9
+ <b>Development code:</b>
10
+ <%= @placement.development_code %>
11
+ </p>
12
+
13
+ <p>
14
+ <b>Conflicting placements array:</b>
15
+ <%= @placement.conflicting_placements_array %>
16
+ </p>
17
+
18
+
19
+ <%= link_to 'Edit', edit_placement_path(@placement) %> |
20
+ <%= link_to 'Back', placements_path %>
@@ -0,0 +1,89 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>AdvertSelector</title>
5
+
6
+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
7
+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
8
+ <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/themes/redmond/jquery-ui.css" rel="stylesheet" type="text/css"/>
9
+
10
+
11
+ <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/css/bootstrap-combined.min.css" rel="stylesheet">
12
+ <script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/js/bootstrap.min.js"></script>
13
+
14
+ <%= stylesheet_link_tag "advert_selector/application", :media => "all" %>
15
+ <%= javascript_include_tag "advert_selector/application" %>
16
+ <%= csrf_meta_tags %>
17
+ </head>
18
+ <body>
19
+
20
+
21
+ <div class="navbar navbar-inverse navbar-fixed-top">
22
+ <div class="navbar-inner">
23
+ <div class="container-fluid">
24
+ <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
25
+ <span class="icon-bar"></span>
26
+ <span class="icon-bar"></span>
27
+ <span class="icon-bar"></span>
28
+ </a>
29
+ <a class="brand" href="/">Advert selector</a>
30
+ <div class="nav-collapse collapse">
31
+ <p class="navbar-text pull-right">
32
+ Logged in as <a href="#" class="navbar-link">Username</a>
33
+ </p>
34
+ <ul class="nav">
35
+ <% [['Placements', placements_url],
36
+ ['Banners', banners_url],
37
+ ['About this gem', 'https://github.com/holli/advert_selector']
38
+ ].each do |str, url| %>
39
+ <li><%= link_to str, url %></li>
40
+ <% end %>
41
+ </ul>
42
+ </div><!--/.nav-collapse -->
43
+ </div>
44
+ </div>
45
+ </div>
46
+
47
+
48
+ <div class="container-fluid">
49
+ <div class="row-fluid">
50
+ <div class="span3">
51
+ <div class="well sidebar-nav">
52
+ <ul class="nav nav-list">
53
+ <li class="nav-header"><%= link_to 'Banners', banners_url %></li>
54
+ <% AdvertSelector::Banner.order('priority desc').where('end_time is null or end_time > ?', 2.days.ago).limit(10).each do |banner| %>
55
+ <li><%= link_to "#{banner.name} -> #{banner.placement.name}", edit_banner_url(banner) %></li>
56
+ <% end %>
57
+
58
+ <li><%= link_to 'Show all', banners_url %></li>
59
+ <li><%= link_to 'Create New', new_banner_url %></li>
60
+
61
+ <li class="nav-header">
62
+ <%= link_to 'Placements', placements_url %>
63
+ </li>
64
+ <% AdvertSelector::Placement.all.each do |placement| %>
65
+ <li><%= link_to placement.name, edit_placement_url(placement) %></li>
66
+ <% end %>
67
+ <li><%= link_to 'Create New', new_placement_url %></li>
68
+ </ul>
69
+ </div><!--/.well -->
70
+ </div><!--/span-->
71
+
72
+ <% unless AdvertSelector::ErrorsCache.errors.blank? %>
73
+ <div class="alert alert-error span9">
74
+ <h3>Advertisement causes errors. <%= link_to 'See all', main_url %></h3>
75
+ <%= simple_format(AdvertSelector::ErrorsCache.errors.last) %>
76
+ </div>
77
+ <% end %>
78
+
79
+
80
+ <div class="span9">
81
+ <%= yield %>
82
+ </div>
83
+
84
+
85
+ </div>
86
+ </div>
87
+
88
+ </body>
89
+ </html>
@@ -0,0 +1,17 @@
1
+ AdvertSelector::Engine.routes.draw do
2
+
3
+
4
+ get "/" => "main#index", :as => :main
5
+ get "/clear_errors_log" => "main#clear_errors_log", :as => :clear_errors_log
6
+
7
+
8
+ resources :banners do
9
+ #resources :helper_items
10
+ put 'update_running_view_count', :on => :member
11
+ end
12
+
13
+ resources :placements
14
+
15
+
16
+ #match '/' => redirect {|params, request| '/advert_selector/placements' }
17
+ end
@@ -0,0 +1,11 @@
1
+ class CreateAdvertSelectorPlacements < ActiveRecord::Migration
2
+ def change
3
+ create_table :advert_selector_placements do |t|
4
+ t.string :name, :null => false
5
+ t.boolean :only_once_per_session
6
+ t.text :conflicting_placements_array
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ class CreateAdvertSelectorBanners < ActiveRecord::Migration
2
+ def change
3
+ create_table :advert_selector_banners do |t|
4
+ t.string :name, :null => false
5
+ t.datetime :start_time
6
+ t.datetime :end_time
7
+ t.integer :priority, :null => false, :default => 0
8
+ t.integer :target_view_count
9
+ t.integer :running_view_count, :null => false, :default => 0
10
+ t.integer :frequency
11
+ t.boolean :fast_mode, :null => false, :default => false
12
+ t.text :comment
13
+ t.boolean :confirmed, :null => false, :default => false
14
+ t.integer :placement_id, :null => false
15
+ #t.boolean :in_serve_cache, :null => false, :default => false
16
+
17
+ t.timestamps
18
+ end
19
+
20
+ #add_index(:advert_selector_banners, [:in_serve_cache, :priority])
21
+ add_index(:advert_selector_banners, [:end_time])
22
+ end
23
+ end