ad_man 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +1 -1
- data/README.md +5 -9
- data/app/assets/javascripts/ad_man/advertisements.js +9 -7
- data/app/controllers/ad_man/advertisements_controller.rb +3 -1
- data/app/controllers/ad_man/keywords_controller.rb +3 -3
- data/app/helpers/ad_man/application_helper.rb +31 -26
- data/app/models/ad_man/keyword.rb +15 -14
- data/app/views/ad_man/advertisements/get_ad.js.erb +4 -2
- data/config/routes.rb +7 -5
- data/lib/ad_man/version.rb +1 -1
- data/lib/generators/ad_man/install_generator.rb +1 -1
- data/test/dummy/app/controllers/ad_man/advertisements_controller.rb +4 -0
- data/test/dummy/app/controllers/ad_man/keywords_controller.rb +4 -0
- data/test/dummy/app/views/layouts/application.html.erb +15 -0
- data/test/dummy/db/migrate/20120817083909_create_ad_man_advertisements.ad_man.rb +17 -0
- data/test/dummy/db/migrate/20120817083910_create_ad_man_keywords.ad_man.rb +9 -0
- data/test/dummy/db/schema.rb +1 -5
- data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/banner/1-NR-728x90-cool-b.gif +0 -0
- data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/leaderboard/1-NR-728x90-cool-b.gif +0 -0
- data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/original/1-NR-728x90-cool-b.gif +0 -0
- data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/banner/61f8516ab0e6471b99443e17bf7533d5.jpeg +0 -0
- data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/leaderboard/61f8516ab0e6471b99443e17bf7533d5.jpeg +0 -0
- data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/original/61f8516ab0e6471b99443e17bf7533d5.jpeg +0 -0
- metadata +22 -8
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +0 -789
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -78,16 +78,15 @@ Ad_man supports inserting an advertisement using jQuery. It also uses jQuery in
|
|
78
78
|
<%= javascript_include_tag "ad_man/advertisements.js" %>
|
79
79
|
```
|
80
80
|
|
81
|
-
You can pass the keyword name
|
81
|
+
You can pass a `<DIV>` id element, the keyword name, and size to show an advertisement using the showAd(); function. Currently supported sizes are: `leaderboard` and `banner`.
|
82
82
|
```erb
|
83
83
|
<script>
|
84
|
-
|
85
|
-
showAd('<%= @keyword %>'); // inserts a value from ruby in erb
|
84
|
+
AdMan.showAd('div_id', 'keyword', 'size');
|
86
85
|
</script>
|
87
86
|
```
|
88
|
-
Then
|
87
|
+
Then make sure you have a `<DIV>` element with the `div_id` you gave to the showAd function.
|
89
88
|
```erb
|
90
|
-
<div id="
|
89
|
+
<div id="banner_ad"></div>
|
91
90
|
```
|
92
91
|
|
93
92
|
## Authors
|
@@ -97,7 +96,4 @@ Written by [David Strand](http://www.github.com/wspyder) and [Tyler Hu](http://w
|
|
97
96
|
[Matenia Rossides](http://www.github.com/matenia)
|
98
97
|
|
99
98
|
## Copyright & Licensing
|
100
|
-
|
101
|
-
Copyright (c) 2012 [Kudelabs](http://kudelabs.com)
|
102
|
-
|
103
|
-
Released under MIT License.
|
99
|
+
This project is maintained by an intern team of developers and is freely available for commercial use under the terms of the MIT License.
|
@@ -44,11 +44,13 @@ function showFormError(msg, form) {
|
|
44
44
|
form.find('div.errors').remove();
|
45
45
|
form.prepend(errorDiv);
|
46
46
|
}
|
47
|
-
|
48
|
-
function showAd(key) {
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
47
|
+
AdMan = {
|
48
|
+
//function showAd(div, key, size) {
|
49
|
+
showAd: function(div, key, size) {
|
50
|
+
$.ajax({
|
51
|
+
url: "/ad_man/advertisements/get_ad/" + div + "/" + key + "/" + size,
|
52
|
+
dataType: "script",
|
53
|
+
success: function(data){}
|
54
|
+
});
|
55
|
+
}
|
54
56
|
}
|
@@ -13,9 +13,9 @@ class AdMan::KeywordsController < ApplicationController
|
|
13
13
|
# GET /keywords/1
|
14
14
|
# GET /keywords/1.json
|
15
15
|
def show
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
@keyword = AdMan::Keyword.find(params[:id])
|
17
|
+
@advertisements = AdMan::Advertisement.find_all_by_keyword_id(params[:id])
|
18
|
+
@keywords = AdMan::Keyword.all
|
19
19
|
end
|
20
20
|
|
21
21
|
# GET /keywords/new
|
@@ -1,40 +1,45 @@
|
|
1
1
|
module AdMan
|
2
2
|
module ApplicationHelper
|
3
3
|
def link_to_ad(keyword = nil, size = "leaderboard")
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
# def link_to_ad(hash = {:keyword => nil, :size => "leaderboard"})
|
5
|
+
# keyword = hash[:keyword]
|
6
|
+
# size = hash[:size]
|
7
|
+
ad = ad_select(keyword)
|
8
|
+
if ad
|
9
|
+
link_to image_tag(ad.ad_banner.url(size)), ad_man.click_through_advertisements_path(ad.id), :target => '_blank', :method => :post
|
10
|
+
end
|
7
11
|
end
|
8
12
|
|
9
13
|
def js_link_to_ad(keyword)
|
10
|
-
ad_select(keyword
|
14
|
+
ad_select(keyword)
|
11
15
|
end
|
12
16
|
|
13
17
|
protected
|
14
18
|
#grab the keyword form request url
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
19
|
+
def get_keyword_from_url
|
20
|
+
if request.env["REQUEST_PATH"]
|
21
|
+
req_url = request.env["REQUEST_PATH"].split("/")
|
22
|
+
keyword_names = Keyword.all.map{ |keyword| keyword.name }
|
23
|
+
keyword = req_url & keyword_names
|
21
24
|
end
|
25
|
+
end
|
22
26
|
|
23
27
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
28
|
+
def ad_select(keyword)
|
29
|
+
keyword ||= get_keyword_from_url
|
30
|
+
if keyword && !keyword.blank? && Keyword.find_by_name(keyword)
|
31
|
+
keyword_id = Keyword.find_by_name(keyword).id
|
32
|
+
ad = Advertisement.render_random_ad(keyword_id)
|
33
|
+
#grab size? leaderboard or banner
|
34
|
+
elsif keyword.nil? || keyword.blank?
|
35
|
+
ad = Advertisement.render_random_ad
|
36
|
+
end
|
37
|
+
if ad
|
38
|
+
ad.display_count += 1
|
39
|
+
ad.save
|
40
|
+
ad
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
40
45
|
end
|
@@ -1,23 +1,24 @@
|
|
1
1
|
module AdMan
|
2
2
|
class Keyword < ActiveRecord::Base
|
3
3
|
attr_accessible :name
|
4
|
-
|
4
|
+
has_many :advertisements, :dependent => :destroy
|
5
5
|
validates :name, :presence => true, :uniqueness => true
|
6
|
-
|
6
|
+
MAX_COUNT = (AdMan.max_count)?(AdMan.max_count):5
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
def to_s
|
9
|
+
name
|
10
|
+
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
def number_of_ads
|
13
|
+
self.advertisements.count
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.available
|
17
|
+
Keyword.all.select { |keyword| keyword.advertisements.count < MAX_COUNT}
|
18
|
+
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
def self.unavailable
|
21
|
+
Keyword.all.select { |keyword| keyword.advertisements.count >= MAX_COUNT}
|
22
|
+
end
|
22
23
|
end
|
23
24
|
end
|
@@ -1,2 +1,4 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
<% if @ad %>
|
2
|
+
$(<%= @div %>).html('<%= link_to image_tag(@ad.ad_banner.url(@size)),
|
3
|
+
ad_man.click_through_advertisements_path(@ad.id), :target => "_blank", :method => :post %>');
|
4
|
+
<% end %>
|
data/config/routes.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
AdMan::Engine.routes.draw do
|
2
2
|
resources :keywords
|
3
|
-
resources :advertisements
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
resources :advertisements do
|
4
|
+
collection do
|
5
|
+
match 'click_through/:id' => "advertisements#click_through", :as => :click_through
|
6
|
+
match 'get_ad/:div/:key/:size' => 'advertisements#get_ad', :as => :get_ad
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
8
10
|
root :to => "advertisements#index"
|
9
11
|
|
10
12
|
end
|
data/lib/ad_man/version.rb
CHANGED
@@ -5,11 +5,26 @@
|
|
5
5
|
<%= stylesheet_link_tag "application", :media => "all" %>
|
6
6
|
<%= javascript_include_tag "application" %>
|
7
7
|
<%= javascript_include_tag "ad_man/advertisements.js" %>
|
8
|
+
|
9
|
+
<script>
|
10
|
+
// showAd(keyword)
|
11
|
+
<% if AdMan::Keyword.first %>
|
12
|
+
AdMan.showAd('<%= AdMan::Keyword.first.name %>', 'banner', 'advertisement1'); //
|
13
|
+
AdMan.showAd('<%= AdMan::Keyword.last.name %>', 'leaderboard', 'advertisement2');
|
14
|
+
<% end %>
|
15
|
+
</script>
|
16
|
+
|
8
17
|
<%= csrf_meta_tags %>
|
9
18
|
</head>
|
10
19
|
<body>
|
11
20
|
|
21
|
+
<%= link_to_ad %>
|
22
|
+
<hr/>
|
23
|
+
|
12
24
|
<%= yield %>
|
13
25
|
|
26
|
+
|
27
|
+
<div id="advertisement1"></div>
|
28
|
+
<div id="advertisement2"></div>
|
14
29
|
</body>
|
15
30
|
</html>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# This migration comes from ad_man (originally 20120808085322)
|
2
|
+
class CreateAdManAdvertisements < ActiveRecord::Migration
|
3
|
+
def change
|
4
|
+
create_table :ad_man_advertisements do |t|
|
5
|
+
t.string :title
|
6
|
+
t.string :destination_url
|
7
|
+
t.has_attached_file :ad_banner
|
8
|
+
t.integer :display_count, :null => false, :default => 0
|
9
|
+
t.integer :priority, :null => false, :default => 1
|
10
|
+
t.date :start_date
|
11
|
+
t.date :end_date
|
12
|
+
t.integer :keyword_id
|
13
|
+
t.integer :click_count, :null => false, :default => 0
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/test/dummy/db/schema.rb
CHANGED
@@ -11,10 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended to check this file into your version control system.
|
13
13
|
|
14
|
-
|
15
|
-
ActiveRecord::Schema.define(:version => 0) do
|
16
|
-
=======
|
17
|
-
ActiveRecord::Schema.define(:version => 20120812095547) do
|
14
|
+
ActiveRecord::Schema.define(:version => 20120817083910) do
|
18
15
|
|
19
16
|
create_table "ad_man_advertisements", :force => true do |t|
|
20
17
|
t.string "title"
|
@@ -38,6 +35,5 @@ ActiveRecord::Schema.define(:version => 20120812095547) do
|
|
38
35
|
t.datetime "created_at", :null => false
|
39
36
|
t.datetime "updated_at", :null => false
|
40
37
|
end
|
41
|
-
>>>>>>> ebccd78bf25a122cf7949094b969681a8bd1a867
|
42
38
|
|
43
39
|
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ad_man
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-08-
|
13
|
+
date: 2012-08-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -110,6 +110,8 @@ files:
|
|
110
110
|
- test/ad_man_test.rb
|
111
111
|
- test/dummy/app/assets/javascripts/application.js
|
112
112
|
- test/dummy/app/assets/stylesheets/application.css
|
113
|
+
- test/dummy/app/controllers/ad_man/advertisements_controller.rb
|
114
|
+
- test/dummy/app/controllers/ad_man/keywords_controller.rb
|
113
115
|
- test/dummy/app/controllers/application_controller.rb
|
114
116
|
- test/dummy/app/helpers/application_helper.rb
|
115
117
|
- test/dummy/app/views/layouts/application.html.erb
|
@@ -130,17 +132,22 @@ files:
|
|
130
132
|
- test/dummy/config/locales/en.yml
|
131
133
|
- test/dummy/config/routes.rb
|
132
134
|
- test/dummy/config.ru
|
133
|
-
- test/dummy/db/
|
135
|
+
- test/dummy/db/migrate/20120817083909_create_ad_man_advertisements.ad_man.rb
|
136
|
+
- test/dummy/db/migrate/20120817083910_create_ad_man_keywords.ad_man.rb
|
134
137
|
- test/dummy/db/schema.rb
|
135
|
-
- test/dummy/db/test.sqlite3
|
136
|
-
- test/dummy/log/development.log
|
137
138
|
- test/dummy/public/404.html
|
138
139
|
- test/dummy/public/422.html
|
139
140
|
- test/dummy/public/500.html
|
140
141
|
- test/dummy/public/favicon.ico
|
142
|
+
- test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/banner/1-NR-728x90-cool-b.gif
|
143
|
+
- test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/leaderboard/1-NR-728x90-cool-b.gif
|
144
|
+
- test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/original/1-NR-728x90-cool-b.gif
|
141
145
|
- test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/original/FabTable_01.jpg
|
142
146
|
- test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/original/test.jpeg
|
143
147
|
- test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/small/FabTable_01.jpg
|
148
|
+
- test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/banner/61f8516ab0e6471b99443e17bf7533d5.jpeg
|
149
|
+
- test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/leaderboard/61f8516ab0e6471b99443e17bf7533d5.jpeg
|
150
|
+
- test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/original/61f8516ab0e6471b99443e17bf7533d5.jpeg
|
144
151
|
- test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/original/728x90_2MM.jpg
|
145
152
|
- test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/original/d893babe671c41118c1fece177e0a21a.jpeg
|
146
153
|
- test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/small/728x90_2MM.jpg
|
@@ -197,6 +204,8 @@ test_files:
|
|
197
204
|
- test/ad_man_test.rb
|
198
205
|
- test/dummy/app/assets/javascripts/application.js
|
199
206
|
- test/dummy/app/assets/stylesheets/application.css
|
207
|
+
- test/dummy/app/controllers/ad_man/advertisements_controller.rb
|
208
|
+
- test/dummy/app/controllers/ad_man/keywords_controller.rb
|
200
209
|
- test/dummy/app/controllers/application_controller.rb
|
201
210
|
- test/dummy/app/helpers/application_helper.rb
|
202
211
|
- test/dummy/app/views/layouts/application.html.erb
|
@@ -217,17 +226,22 @@ test_files:
|
|
217
226
|
- test/dummy/config/locales/en.yml
|
218
227
|
- test/dummy/config/routes.rb
|
219
228
|
- test/dummy/config.ru
|
220
|
-
- test/dummy/db/
|
229
|
+
- test/dummy/db/migrate/20120817083909_create_ad_man_advertisements.ad_man.rb
|
230
|
+
- test/dummy/db/migrate/20120817083910_create_ad_man_keywords.ad_man.rb
|
221
231
|
- test/dummy/db/schema.rb
|
222
|
-
- test/dummy/db/test.sqlite3
|
223
|
-
- test/dummy/log/development.log
|
224
232
|
- test/dummy/public/404.html
|
225
233
|
- test/dummy/public/422.html
|
226
234
|
- test/dummy/public/500.html
|
227
235
|
- test/dummy/public/favicon.ico
|
236
|
+
- test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/banner/1-NR-728x90-cool-b.gif
|
237
|
+
- test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/leaderboard/1-NR-728x90-cool-b.gif
|
238
|
+
- test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/original/1-NR-728x90-cool-b.gif
|
228
239
|
- test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/original/FabTable_01.jpg
|
229
240
|
- test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/original/test.jpeg
|
230
241
|
- test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/small/FabTable_01.jpg
|
242
|
+
- test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/banner/61f8516ab0e6471b99443e17bf7533d5.jpeg
|
243
|
+
- test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/leaderboard/61f8516ab0e6471b99443e17bf7533d5.jpeg
|
244
|
+
- test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/original/61f8516ab0e6471b99443e17bf7533d5.jpeg
|
231
245
|
- test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/original/728x90_2MM.jpg
|
232
246
|
- test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/original/d893babe671c41118c1fece177e0a21a.jpeg
|
233
247
|
- test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/small/728x90_2MM.jpg
|
Binary file
|
data/test/dummy/db/test.sqlite3
DELETED
File without changes
|