ad_man 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/README.md +87 -0
  2. data/app/controllers/ad_man/advertisements_controller.rb +1 -1
  3. data/app/helpers/ad_man/application_helper.rb +23 -22
  4. data/app/views/ad_man/advertisements/_form.html.erb +10 -5
  5. data/app/views/ad_man/keywords/new.html.erb +1 -1
  6. data/db/migrate/20120808085322_create_ad_man_advertisements.rb +7 -1
  7. data/db/migrate/20120808091446_create_ad_man_keywords.rb +0 -1
  8. data/lib/ad_man/version.rb +1 -1
  9. data/test/dummy/db/development.sqlite3 +0 -0
  10. data/test/dummy/db/schema.rb +2 -1
  11. data/test/dummy/log/development.log +15098 -30734
  12. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/003/original/tshirthangout-banner_728x90.gif +0 -0
  13. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/003/small/tshirthangout-banner_728x90.gif +0 -0
  14. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/004/original/ieeextreme_banner_728x90.gif +0 -0
  15. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/004/small/ieeextreme_banner_728x90.gif +0 -0
  16. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/005/original/banner_728x90.jpg +0 -0
  17. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/005/small/banner_728x90.jpg +0 -0
  18. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/006/small/728x90_2MM.jpg +0 -0
  19. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/007/original/banner_728x90_2.jpg +0 -0
  20. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/007/small/banner_728x90_2.jpg +0 -0
  21. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/008/banner/728x90_2MM.jpg +0 -0
  22. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/008/leaderboard/728x90_2MM.jpg +0 -0
  23. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/008/original/728x90_2MM.jpg +0 -0
  24. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/009/banner/banner_728x90_2.jpg +0 -0
  25. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/009/leaderboard/banner_728x90_2.jpg +0 -0
  26. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/009/original/banner_728x90_2.jpg +0 -0
  27. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/010/banner/hubpages_728-90-b.gif +0 -0
  28. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/010/leaderboard/hubpages_728-90-b.gif +0 -0
  29. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/010/original/hubpages_728-90-b.gif +0 -0
  30. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/011/banner/728_90banner2health.gif +0 -0
  31. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/011/leaderboard/728_90banner2health.gif +0 -0
  32. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/011/original/728_90banner2health.gif +0 -0
  33. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/012/banner/tshirthangout-banner_728x90.gif +0 -0
  34. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/012/leaderboard/tshirthangout-banner_728x90.gif +0 -0
  35. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/012/original/tshirthangout-banner_728x90.gif +0 -0
  36. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/013/banner/ieeextreme_banner_728x90.gif +0 -0
  37. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/013/leaderboard/ieeextreme_banner_728x90.gif +0 -0
  38. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/013/original/ieeextreme_banner_728x90.gif +0 -0
  39. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/014/banner/1-NR-728x90-cool-b.gif +0 -0
  40. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/014/banner/tshirthangout-banner_728x90.gif +0 -0
  41. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/014/leaderboard/1-NR-728x90-cool-b.gif +0 -0
  42. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/014/leaderboard/tshirthangout-banner_728x90.gif +0 -0
  43. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/014/original/1-NR-728x90-cool-b.gif +0 -0
  44. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/014/original/tshirthangout-banner_728x90.gif +0 -0
  45. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/015/banner/9241eb4107b24c588c0ca0042534c03e.png +0 -0
  46. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/015/leaderboard/9241eb4107b24c588c0ca0042534c03e.png +0 -0
  47. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/015/original/9241eb4107b24c588c0ca0042534c03e.png +0 -0
  48. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/016/banner/d893babe671c41118c1fece177e0a21a.jpeg +0 -0
  49. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/016/leaderboard/d893babe671c41118c1fece177e0a21a.jpeg +0 -0
  50. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/016/original/d893babe671c41118c1fece177e0a21a.jpeg +0 -0
  51. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/018/banner/tshirthangout-banner_728x90.gif +0 -0
  52. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/018/leaderboard/tshirthangout-banner_728x90.gif +0 -0
  53. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/018/original/tshirthangout-banner_728x90.gif +0 -0
  54. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/019/banner/ieeextreme_banner_728x90.gif +0 -0
  55. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/019/leaderboard/ieeextreme_banner_728x90.gif +0 -0
  56. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/019/original/ieeextreme_banner_728x90.gif +0 -0
  57. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/020/banner/banner_728x90.jpg +0 -0
  58. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/020/leaderboard/banner_728x90.jpg +0 -0
  59. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/020/original/banner_728x90.jpg +0 -0
  60. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/021/banner/728_90banner2health.gif +0 -0
  61. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/021/leaderboard/728_90banner2health.gif +0 -0
  62. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/021/original/728_90banner2health.gif +0 -0
  63. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/022/banner/ls_mimi_08_05_728_90.jpg +0 -0
  64. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/022/leaderboard/ls_mimi_08_05_728_90.jpg +0 -0
  65. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/022/original/ls_mimi_08_05_728_90.jpg +0 -0
  66. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/024/banner/hubpages_728-90-b.gif +0 -0
  67. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/024/leaderboard/hubpages_728-90-b.gif +0 -0
  68. data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/024/original/hubpages_728-90-b.gif +0 -0
  69. data/test/dummy/tmp/cache/assets/{CE4/9E0/sprockets%2F3f5956491fde7227a651e20e4d756b1a → C4B/270/sprockets%2Fe4e551930b178644219b4815cd20b726} +0 -0
  70. data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  71. data/test/dummy/tmp/cache/assets/{D3E/AF0/sprockets%2F317881d54abbd5721deee7d204e70e66 → CE6/0E0/sprockets%2F2ea8935a8e0017c0f2e7740e88b1d597} +0 -0
  72. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  73. data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  74. data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  75. data/test/dummy/tmp/cache/assets/{C02/0A0/sprockets%2F625bdc26802f8c498265353870490587 → D60/4E0/sprockets%2F1afdb2579da0da75df12b43c58333f04} +0 -0
  76. data/test/dummy/tmp/cache/assets/{D3A/220/sprockets%2Fce53c5b352a83645d36d96aff26020fb → D6D/A00/sprockets%2Ffda0ab5b1163661cd985617b079ff6bc} +0 -0
  77. data/test/dummy/tmp/cache/assets/{D31/910/sprockets%2Fc1c18d3d756fe2777d18b236a0aea400 → D93/C00/sprockets%2F62ce5a5ac0174b45e8ec26cfd0e372c3} +0 -0
  78. data/test/dummy/tmp/cache/assets/{DF7/090/sprockets%2Fb3b1a32b0f923d6741fd5dacdf9f59ab → DA6/7B0/sprockets%2Fb8f1adecef3b6c4780afb36783e75047} +0 -0
  79. data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  80. data/test/dummy/tmp/cache/assets/{DBA/3C0/sprockets%2F9ca84f8118d29c3fd7bfd2876f83dc7e → E00/6F0/sprockets%2F41b788fc4de0cdcfa86c81c25b1fd72e} +0 -0
  81. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  82. data/test/dummy/tmp/pids/server.pid +1 -1
  83. metadata +133 -29
  84. data/README.rdoc +0 -3
  85. data/db/migrate/20120808085909_add_attachment_ad_banner_to_advertisements.rb +0 -11
  86. data/db/migrate/20120808095330_add_display_count_to_ad_man_advertisements.rb +0 -5
  87. data/db/migrate/20120808095742_add_priority_to_ad_man_advertisements.rb +0 -6
  88. data/db/migrate/20120808100040_add_start_date_and_end_date_to_ad_man_advertisements.rb +0 -8
  89. data/db/migrate/20120808101547_add_keyword_id_to_ad_man_advertisements.rb +0 -5
  90. data/db/migrate/20120809065243_add_click_count_to_ad_man_advertisements.rb +0 -5
  91. data/test/dummy/db/test.sqlite3 +0 -0
  92. data/test/dummy/log/test.log +0 -1312
  93. /data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/{002 → 006}/original/728x90_2MM.jpg +0 -0
data/README.md ADDED
@@ -0,0 +1,87 @@
1
+ Ad_man
2
+ ======
3
+
4
+ Ad_man is an advertising manager mountable engine. It allows the user to upload and manage advertising banners, and provides an easy to use helper for inserting the banners on your website. Also counts the number of times an ad has shown, and the number of times an advertisement has been clicked on. The user must set a keyword for each ad.
5
+
6
+ Currently supports two image sizes for advertising: Leaderboard 728 x 90 and Banner 468 x 60.
7
+ TODO: Will implement 9 different sizes as mentioned by google's adwords requirements.
8
+
9
+ Requires Paperclip 3.1, and requires ImageMagick be running on the server.
10
+
11
+ ## Getting started
12
+
13
+ Ad_man works with Rails 3.2 onwards. You can add it to your Gemfile with:
14
+
15
+ ```ruby
16
+ gem 'ad_man'
17
+ ```
18
+
19
+ After you install Ad_man and add it to your Gemfile, you need to run the generator:
20
+
21
+ ```console
22
+ rails generate ad_man:install
23
+ ```
24
+
25
+ Install the migrations, and rake the database:
26
+ ```console
27
+ rake ad_man:install:migrations
28
+ rake db:migrate
29
+ ```
30
+
31
+ See where Ad_man is located by running:
32
+ ```console
33
+ rake routes
34
+ ```
35
+
36
+ In our case, we needed to move the line generated by the install in the routes file to our admin space. Then add any before_filters to the controllers that were generated.
37
+
38
+ Make sure to change references to the application using the main_app helper:
39
+ ```erb
40
+ <%= link_to "Home", main_app.root_path %>
41
+ <%= link_to "Advertising", main_app.ad_man_path %>
42
+ ```
43
+
44
+ One final change may be necessary in order to preview an image before saving, and that is to add this line to the admin view:
45
+ ```erb
46
+ <%= javascript_include_tag "ad_man/advertisements.js" %>
47
+ ```
48
+
49
+ ## Changing default values
50
+
51
+ If you need to change the default values set by ad_man, you will need to create an ad_man.rb initializer in your config/initializers folder.
52
+
53
+ ```ruby
54
+ # AdMan Default Values
55
+ AdMan.leaderboard_size = "728x90"
56
+ AdMan.banner_size = "468x60"
57
+ AdMan.max_image_size = 50 # 50Kb maximum image size
58
+
59
+ # These are configurable dimensions (currently leaderboard default)
60
+ AdMan.image_dimensions_width = 728
61
+ AdMan.image_dimensions_height = 90
62
+
63
+ # Configurable content type for advertising
64
+ AdMan.content_type = ["image/jpg", "image/bmp", "image/png", "image/gif", "image/jpeg"]
65
+
66
+ # Configurable max advertising for keyword
67
+ AdMan.max_count = 6
68
+ ```
69
+
70
+ ## Putting an advertisement in the view
71
+
72
+ To put your advertisement in the view just add:
73
+ ```erb
74
+ <%= link_to_ad %>
75
+ ```
76
+ Currently there are three parameters that can control which ads get shown on your page. :keyword, :size, and :display_on_all_pages.
77
+ ```erb
78
+ <%= link_to_ad :keyword => "Your Keyword", :size => "leaderboard", :display_on_all_pages => false %>
79
+ ```
80
+ ## Authors
81
+ Written by [David Strand](http://www.github.com/wspyder) and [Tyler Hu](http://www.github.com/tylerhu)
82
+
83
+ ## Copyright & Licensing
84
+
85
+ Copyright (c) 2012 [Kudelabs](http://kudelabs.com), [Kudelabs on Github](http://github.com/kudelabs)
86
+
87
+ Released under MIT License.
@@ -64,7 +64,7 @@ class AdMan::AdvertisementsController < ApplicationController
64
64
  def update
65
65
  @advertisement = AdMan::Advertisement.find(params[:id])
66
66
  @advertisement.keyword_id = params[:keyword_id]
67
- @advertisement.priority = params[:priority]
67
+ # @advertisement.priority = params[:priority]
68
68
 
69
69
  respond_to do |format|
70
70
  if @advertisement.update_attributes(params[:advertisement])
@@ -1,27 +1,28 @@
1
1
  module AdMan
2
2
  module ApplicationHelper
3
- def link_to_ad(keyword = nil, size = "leaderboard")
4
- keyword ||= get_keyword_from_url
5
- if keyword && !keyword.blank?
6
- keyword_id = Keyword.find_by_name(keyword).id
7
- ad = Advertisement.render_random_ad(keyword_id)
8
- #grab size? leaderboard or banner
9
- else
10
- ad = Advertisement.render_random_ad
11
- end
12
- if !ad.nil?
13
- ad.display_count += 1
14
- ad.save
15
- link_to image_tag(ad.ad_banner.url(size)), { :controller => 'advertisements', :action => 'click_through', :id => ad.id },
16
- :method => :post, :target => '_blank'
17
- end
18
- end
3
+ def link_to_ad(hash = {:keyword => nil, :size => "leaderboard", :display_on_all_pages => true})
4
+ keyword = hash[:keyword]
5
+ keyword ||= get_keyword_from_url
6
+ if !keyword.blank? && !Keyword.find_by_name(keyword).nil?
7
+ keyword_id = Keyword.find_by_name(keyword).id
8
+ ad = Advertisement.render_random_ad(keyword_id)
9
+ elsif keyword.blank? && hash[:display_on_all_pages]
10
+ ad = Advertisement.render_random_ad
11
+ end
12
+ if !ad.nil?
13
+ ad.display_count += 1
14
+ ad.save
15
+ size = hash[:size]
16
+ link_to image_tag(ad.ad_banner.url(size)), { :controller => 'advertisements', :action => 'click_through', :id => ad.id },
17
+ :method => :post, :target => '_blank'
18
+ end
19
+ end
19
20
 
20
21
  #grab the keyword form request url
21
- def get_keyword_from_url
22
- req_url = request.env["REQUEST_PATH"].split("/")
23
- keyword_names = Keyword.all.map{ |keyword| keyword.name }
24
- keyword = req_url & keyword_names
25
- end
26
- end
22
+ def get_keyword_from_url
23
+ req_url = request.env["REQUEST_PATH"].split("/")
24
+ keyword_names = Keyword.all.map{ |keyword| keyword.name }
25
+ keyword = req_url & keyword_names
26
+ end
27
+ end
27
28
  end
@@ -26,9 +26,16 @@
26
26
  </div><br />
27
27
  <div class="field">
28
28
  <%= f.label :keyword %>
29
- <%= select_tag :keyword_id, options_for_select(AdMan::Keyword.available.collect { |keyword| [keyword.name, keyword.id]})%>
29
+ <% if @advertisement.keyword.nil? %>
30
+ <!-- for new advertisement page -->
31
+ <%= select_tag :keyword_id, options_for_select(AdMan::Keyword.available.collect { |keyword| [keyword.name, keyword.id]})%>
32
+ <% else %>
33
+ <!-- for edit advertisement page -->
34
+ <%= select_tag :keyword_id, options_for_select(AdMan::Keyword.available.collect { |keyword| [keyword.name, keyword.id]} | [[@advertisement.keyword.name, @advertisement.keyword_id]],
35
+ :selected => @advertisement.keyword_id) %>
36
+ <% end %>
30
37
  <% if AdMan::Keyword.unavailable.count > 0%>
31
- <p><b><%= AdMan::Keyword.unavailable.collect { |keyword| keyword.name } %></b> keyword has allready been used 5 times.</p>
38
+ <p>Warning: <b><%= AdMan::Keyword.unavailable.collect { |keyword| keyword.name } %></b> keyword has already been used <%= AdMan::Keyword::MAX_COUNT %> times.</p>
32
39
  <% end %>
33
40
  </div><br />
34
41
  <!--
@@ -43,9 +50,7 @@
43
50
  </div><br />
44
51
  <div class="field">
45
52
  <%=f.label :end_date %><br />
46
- <!--
47
- <#% TODO : end date should be 30 days plus %> -->
48
- <%= date_select("advertisement", "end_date") %>
53
+ <%= date_select("advertisement", "end_date", :default => 1.month.from_now) %>
49
54
  </div><br />
50
55
 
51
56
 
@@ -2,4 +2,4 @@
2
2
 
3
3
  <%= render 'form' %>
4
4
 
5
- <%= link_to 'Back', keywords_path %>
5
+ <%= link_to 'Back', advertisements_path %>
@@ -3,7 +3,13 @@ class CreateAdManAdvertisements < ActiveRecord::Migration
3
3
  create_table :ad_man_advertisements do |t|
4
4
  t.string :title
5
5
  t.string :destination_url
6
-
6
+ t.has_attached_file :ad_banner
7
+ t.integer :display_count, :null => false, :default => 0
8
+ t.integer :priority, :null => false, :default => 1
9
+ t.date :start_date
10
+ t.date :end_date
11
+ t.integer :keyword_id
12
+ t.integer :click_count, :null => false, :default => 0
7
13
  t.timestamps
8
14
  end
9
15
  end
@@ -2,7 +2,6 @@ class CreateAdManKeywords < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :ad_man_keywords do |t|
4
4
  t.string :name
5
-
6
5
  t.timestamps
7
6
  end
8
7
  end
@@ -1,3 +1,3 @@
1
1
  module AdMan
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
Binary file
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended to check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(:version => 20120808101547) do
14
+ ActiveRecord::Schema.define(:version => 20120809065243) do
15
15
 
16
16
  create_table "ad_man_advertisements", :force => true do |t|
17
17
  t.string "title"
@@ -27,6 +27,7 @@ ActiveRecord::Schema.define(:version => 20120808101547) do
27
27
  t.date "start_date"
28
28
  t.date "end_date"
29
29
  t.integer "keyword_id"
30
+ t.integer "click_count", :default => 0, :null => false
30
31
  end
31
32
 
32
33
  create_table "ad_man_keywords", :force => true do |t|