ad_man 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/controllers/ad_man/advertisements_controller.rb +1 -1
- data/app/helpers/ad_man/application_helper.rb +0 -1
- data/app/models/ad_man/advertisement.rb +12 -8
- data/app/models/ad_man/keyword.rb +2 -1
- data/app/views/ad_man/advertisements/_form.html.erb +4 -2
- data/app/views/ad_man/keywords/show.html.erb +2 -2
- data/db/migrate/20120808095742_add_priority_to_ad_man_advertisements.rb +1 -1
- data/lib/ad_man/version.rb +1 -1
- data/lib/generators/ad_man/install_generator.rb +20 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +594 -0
- data/test/dummy/log/test.log +1312 -0
- data/test/dummy/tmp/pids/server.pid +1 -0
- data/test/fixtures/ad_man/advertisements.yml +9 -6
- data/test/fixtures/ad_man/keywords.yml +3 -2
- data/test/fixtures/test.jpeg +0 -0
- data/test/fixtures/top_daintiness.jpeg +0 -0
- data/test/functional/ad_man/advertisements_controller_test.rb +3 -0
- data/test/test_helper.rb +4 -0
- data/test/unit/ad_man/advertisement_test.rb +38 -3
- data/test/unit/ad_man/keyword_test.rb +5 -3
- metadata +19 -20
- data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/014/banner/1-NR-728x90-cool-b.gif +0 -0
- data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/014/leaderboard/1-NR-728x90-cool-b.gif +0 -0
- data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/014/original/1-NR-728x90-cool-b.gif +0 -0
- data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/015/banner/9241eb4107b24c588c0ca0042534c03e.png +0 -0
- data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/015/leaderboard/9241eb4107b24c588c0ca0042534c03e.png +0 -0
- data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/015/original/9241eb4107b24c588c0ca0042534c03e.png +0 -0
- /data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/{016/banner/d893babe671c41118c1fece177e0a21a.jpeg → 001/banner/test.jpeg} +0 -0
- /data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/{016/leaderboard/d893babe671c41118c1fece177e0a21a.jpeg → 001/leaderboard/test.jpeg} +0 -0
- /data/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/{016/original/d893babe671c41118c1fece177e0a21a.jpeg → 001/original/test.jpeg} +0 -0
@@ -47,7 +47,7 @@ class AdMan::AdvertisementsController < ApplicationController
|
|
47
47
|
def create
|
48
48
|
@advertisement = AdMan::Advertisement.new(params[:advertisement])
|
49
49
|
@advertisement.keyword_id = params[:keyword_id]
|
50
|
-
|
50
|
+
# @advertisement.priority = params[:priority]
|
51
51
|
respond_to do |format|
|
52
52
|
if @advertisement.save
|
53
53
|
format.html { redirect_to @advertisement, notice: 'Advertisement was successfully created.' }
|
@@ -8,14 +8,19 @@ module AdMan
|
|
8
8
|
validates_attachment :ad_banner, :presence => true,
|
9
9
|
:content_type => { :content_type => (AdMan.content_type)?(AdMan.content_type):
|
10
10
|
["image/jpg","image/bmp","image/png", "image/gif", "image/jpeg"] },
|
11
|
-
:size => { :in => 0..AdMan.max_image_size.kilobytes }
|
11
|
+
:size => { :in => 0..((AdMan.max_image_size)?(AdMan.max_image_size):50).kilobytes }
|
12
12
|
validates_presence_of :destination_url, :title, :keyword_id, :priority
|
13
13
|
validates_uniqueness_of :title
|
14
14
|
validate :image_dimensions, :on => :create
|
15
|
+
after_initialize :init_priority
|
15
16
|
|
16
|
-
def Advertisement.render_random_ad(keyword_id)
|
17
|
+
def Advertisement.render_random_ad(keyword_id = nil)
|
17
18
|
# ads = Advertisement.find_all_by_keyword_id(keyword_id)
|
18
|
-
|
19
|
+
if keyword_id.nil?
|
20
|
+
ads = Advertisement.where("start_date <= ? AND end_date >= ?", Date.today, Date.today)
|
21
|
+
else
|
22
|
+
ads = Advertisement.where("keyword_id = ? AND start_date <= ? AND end_date >= ? ", keyword_id, Date.today, Date.today)
|
23
|
+
end
|
19
24
|
if !ads.blank?
|
20
25
|
total_times = 1.0
|
21
26
|
total_priority = 0.0
|
@@ -30,11 +35,6 @@ module AdMan
|
|
30
35
|
ad
|
31
36
|
end
|
32
37
|
end
|
33
|
-
|
34
|
-
def Advertisement.render_random_ad
|
35
|
-
ads = Advertisement.all
|
36
|
-
ad = ads[rand(ads.size)]
|
37
|
-
end
|
38
38
|
|
39
39
|
private
|
40
40
|
def image_dimensions
|
@@ -47,6 +47,10 @@ module AdMan
|
|
47
47
|
"must be image size: #{max_width}X#{max_height}.")
|
48
48
|
end
|
49
49
|
end
|
50
|
+
|
51
|
+
def init_priority
|
52
|
+
self.priority ||= 1
|
53
|
+
end
|
50
54
|
|
51
55
|
end
|
52
56
|
end
|
@@ -2,7 +2,8 @@ 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
|
+
MAX_COUNT = (AdMan.max_count)?(AdMan.max_count):5
|
6
7
|
|
7
8
|
def to_s
|
8
9
|
name
|
@@ -31,10 +31,12 @@
|
|
31
31
|
<p><b><%= AdMan::Keyword.unavailable.collect { |keyword| keyword.name } %></b> keyword has allready been used 5 times.</p>
|
32
32
|
<% end %>
|
33
33
|
</div><br />
|
34
|
+
<!--
|
34
35
|
<div class="field">
|
35
|
-
|
36
|
-
|
36
|
+
<#%= f.label :priority %>
|
37
|
+
<#%= select_tag :priority, options_for_select(1..10) %>
|
37
38
|
</div><br />
|
39
|
+
-->
|
38
40
|
<div class="field">
|
39
41
|
<%= f.label :start_date %><br />
|
40
42
|
<%= date_select("advertisement", "start_date") %>
|
@@ -32,8 +32,8 @@
|
|
32
32
|
<br/>
|
33
33
|
|
34
34
|
<div style="display:inline-block;">
|
35
|
-
<%= link_to 'Edit Keyword',
|
35
|
+
<%= link_to 'Edit Keyword', edit_keyword_path(@keyword), :method => :get %>
|
36
36
|
<%= link_to "Destroy", @keyword, :method => :delete,
|
37
37
|
:confirm => "Deleting Keyword, this cannot be undone. WARNING: This will delete all advertisements connected with this keyword. Please confirm.", :style => "color:#b94a48"%>
|
38
38
|
<%= link_to 'Back', advertisements_path, :method => :get %>
|
39
|
-
</div>
|
39
|
+
</div>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class AddPriorityToAdManAdvertisements < ActiveRecord::Migration
|
2
2
|
def change
|
3
|
-
add_column :ad_man_advertisements, :priority, :integer
|
3
|
+
add_column :ad_man_advertisements, :priority, :integer, :null => false, :default => 1
|
4
4
|
AdMan::Advertisement.update_all ["priority = ? ", 1]
|
5
5
|
end
|
6
6
|
end
|
data/lib/ad_man/version.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
module AdMan
|
2
|
+
class InstallGenerator < Rails::Generators::Base
|
3
|
+
def create_extended_controller_file
|
4
|
+
create_file "app/controllers/ad_man/advertisements_controller.rb",
|
5
|
+
%Q[require AdMan::Engine.config.root + 'app' + 'controllers' + 'ad_man' + 'advertisements_controller'
|
6
|
+
AdMan::AdvertisementsController.class_eval do
|
7
|
+
end]
|
8
|
+
|
9
|
+
create_file "app/controllers/ad_man/keywords_controller.rb",
|
10
|
+
%Q[require AdMan::Engine.config.root + 'app' + 'controllers' + 'ad_man' + 'keywords_controller'
|
11
|
+
AdMan::KeywordsController.class_eval do
|
12
|
+
end]
|
13
|
+
end
|
14
|
+
|
15
|
+
def add_routes
|
16
|
+
route("mount AdMan::Engine, :at => '/ad_man'")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
Binary file
|
Binary file
|