├── .gitignore
├── .travis.yml
├── Gemfile
├── Gemfile.lock
├── MIT-LICENSE
├── README.md
├── Rakefile
├── ad_man-0.0.13.gem
├── ad_man.gemspec
├── app
├── assets
│ ├── images
│ │ └── ad_man
│ │ │ └── .gitkeep
│ ├── javascripts
│ │ └── ad_man
│ │ │ ├── advertisements.js
│ │ │ ├── application.js
│ │ │ └── keywords.js
│ └── stylesheets
│ │ ├── ad_man
│ │ ├── advertisements.css
│ │ ├── application.css
│ │ └── keywords.css
│ │ └── scaffold.css
├── controllers
│ └── ad_man
│ │ ├── advertisements_controller.rb
│ │ ├── application_controller.rb
│ │ └── keywords_controller.rb
├── helpers
│ └── ad_man
│ │ ├── advertisements_helper.rb
│ │ ├── application_helper.rb
│ │ └── keywords_helper.rb
├── models
│ └── ad_man
│ │ ├── advertisement.rb
│ │ └── keyword.rb
└── views
│ ├── ad_man
│ ├── advertisements
│ │ ├── _form.html.erb
│ │ ├── edit.html.erb
│ │ ├── get_ad.js.erb
│ │ ├── index.html.erb
│ │ ├── new.html.erb
│ │ └── show.html.erb
│ └── keywords
│ │ ├── _form.html.erb
│ │ ├── edit.html.erb
│ │ ├── index.html.erb
│ │ ├── new.html.erb
│ │ └── show.html.erb
│ └── layouts
│ └── ad_man
│ └── application.html.erb
├── config
└── routes.rb
├── db
└── migrate
│ ├── 20120808085322_create_ad_man_advertisements.rb
│ └── 20120808091446_create_ad_man_keywords.rb
├── doc
├── AdMan.html
├── AdMan
│ ├── Advertisement.html
│ ├── AdvertisementTest.html
│ ├── AdvertisementsController.html
│ ├── AdvertisementsControllerTest.html
│ ├── AdvertisementsHelper.html
│ ├── AdvertisementsHelperTest.html
│ ├── ApplicationController.html
│ ├── ApplicationHelper.html
│ ├── Engine.html
│ ├── InstallGenerator.html
│ ├── Keyword.html
│ ├── KeywordTest.html
│ ├── KeywordsController.html
│ ├── KeywordsControllerTest.html
│ ├── KeywordsHelper.html
│ └── KeywordsHelperTest.html
├── AdManTest.html
├── ApplicationController.html
├── ApplicationHelper.html
├── CreateAdManAdvertisements.html
├── CreateAdManKeywords.html
├── Dummy.html
├── Dummy
│ └── Application.html
├── Gemfile.html
├── MIT-LICENSE.html
├── NavigationTest.html
├── Object.html
├── Rakefile.html
├── created.rid
├── images
│ ├── add.png
│ ├── brick.png
│ ├── brick_link.png
│ ├── bug.png
│ ├── bullet_black.png
│ ├── bullet_toggle_minus.png
│ ├── bullet_toggle_plus.png
│ ├── date.png
│ ├── delete.png
│ ├── find.png
│ ├── loadingAnimation.gif
│ ├── macFFBgHack.png
│ ├── package.png
│ ├── page_green.png
│ ├── page_white_text.png
│ ├── page_white_width.png
│ ├── plugin.png
│ ├── ruby.png
│ ├── tag_blue.png
│ ├── tag_green.png
│ ├── transparent.png
│ ├── wrench.png
│ ├── wrench_orange.png
│ └── zoom.png
├── index.html
├── js
│ ├── darkfish.js
│ ├── jquery.js
│ ├── navigation.js
│ ├── search.js
│ ├── search_index.js
│ └── searcher.js
├── rdoc.css
├── table_of_contents.html
└── test
│ └── dummy
│ ├── README_rdoc.html
│ └── Rakefile.html
├── lib
├── ad_man.rb
├── ad_man
│ ├── engine.rb
│ └── version.rb
├── generators
│ └── ad_man
│ │ ├── install_generator.rb
│ │ └── templates
│ │ ├── advertisements_controller.rb
│ │ └── keywords_controller.rb
└── tasks
│ └── ad_man_tasks.rake
├── script
└── rails
└── test
├── ad_man_test.rb
├── dummy
├── README.rdoc
├── Rakefile
├── app
│ ├── assets
│ │ ├── javascripts
│ │ │ └── application.js
│ │ └── stylesheets
│ │ │ └── application.css
│ ├── controllers
│ │ ├── ad_man
│ │ │ ├── advertisements_controller.rb
│ │ │ └── keywords_controller.rb
│ │ └── application_controller.rb
│ ├── helpers
│ │ └── application_helper.rb
│ ├── mailers
│ │ └── .gitkeep
│ ├── models
│ │ └── .gitkeep
│ └── views
│ │ └── layouts
│ │ └── application.html.erb
├── config.ru
├── config
│ ├── application.rb
│ ├── boot.rb
│ ├── database.yml
│ ├── environment.rb
│ ├── environments
│ │ ├── development.rb
│ │ ├── production.rb
│ │ └── test.rb
│ ├── initializers
│ │ ├── ad_man.rb
│ │ ├── backtrace_silencers.rb
│ │ ├── inflections.rb
│ │ ├── mime_types.rb
│ │ ├── secret_token.rb
│ │ ├── session_store.rb
│ │ └── wrap_parameters.rb
│ ├── locales
│ │ └── en.yml
│ └── routes.rb
├── db
│ └── schema.rb
├── lib
│ └── assets
│ │ └── .gitkeep
├── log
│ └── .gitkeep
├── public
│ ├── 404.html
│ ├── 422.html
│ ├── 500.html
│ ├── favicon.ico
│ └── system
│ │ └── ad_man
│ │ └── advertisements
│ │ └── ad_banners
│ │ └── 000
│ │ └── 000
│ │ ├── 001
│ │ ├── banner
│ │ │ └── 1-NR-728x90-cool-b.gif
│ │ ├── leaderboard
│ │ │ └── 1-NR-728x90-cool-b.gif
│ │ ├── original
│ │ │ ├── 1-NR-728x90-cool-b.gif
│ │ │ ├── FabTable_01.jpg
│ │ │ └── test.jpeg
│ │ └── small
│ │ │ └── FabTable_01.jpg
│ │ ├── 002
│ │ ├── banner
│ │ │ └── 61f8516ab0e6471b99443e17bf7533d5.jpeg
│ │ ├── leaderboard
│ │ │ └── 61f8516ab0e6471b99443e17bf7533d5.jpeg
│ │ ├── original
│ │ │ ├── 61f8516ab0e6471b99443e17bf7533d5.jpeg
│ │ │ ├── 728x90_2MM.jpg
│ │ │ └── d893babe671c41118c1fece177e0a21a.jpeg
│ │ └── small
│ │ │ ├── 728x90_2MM.jpg
│ │ │ └── d893babe671c41118c1fece177e0a21a.jpeg
│ │ ├── 014
│ │ ├── banner
│ │ │ └── 1-NR-728x90-cool-b.gif
│ │ ├── leaderboard
│ │ │ └── 1-NR-728x90-cool-b.gif
│ │ └── original
│ │ │ └── 1-NR-728x90-cool-b.gif
│ │ ├── 015
│ │ ├── banner
│ │ │ └── 9241eb4107b24c588c0ca0042534c03e.png
│ │ ├── leaderboard
│ │ │ └── 9241eb4107b24c588c0ca0042534c03e.png
│ │ └── original
│ │ │ └── 9241eb4107b24c588c0ca0042534c03e.png
│ │ └── 016
│ │ ├── banner
│ │ └── d893babe671c41118c1fece177e0a21a.jpeg
│ │ ├── leaderboard
│ │ └── d893babe671c41118c1fece177e0a21a.jpeg
│ │ └── original
│ │ └── d893babe671c41118c1fece177e0a21a.jpeg
└── script
│ └── rails
├── fixtures
├── ad_man
│ ├── advertisements.yml
│ └── keywords.yml
├── mrec.jpg
├── test.jpeg
└── top_daintiness.jpeg
├── functional
└── ad_man
│ ├── advertisements_controller_test.rb
│ └── keywords_controller_test.rb
├── integration
└── navigation_test.rb
├── test_helper.rb
└── unit
├── ad_man
├── advertisement_test.rb
└── keyword_test.rb
└── helpers
└── ad_man
├── advertisements_helper_test.rb
└── keywords_helper_test.rb
/.gitignore:
--------------------------------------------------------------------------------
1 | .bundle/
2 | log/*.log
3 | pkg/
4 | test/dummy/db/*.sqlite3
5 | test/dummy/log/*.log
6 | test/dummy/tmp/
7 | test/dummy/public/system/ad_man
8 | test/dummy/.sass-cache
9 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: ruby
2 | rvm:
3 | - 1.9.3
4 | env:
5 | - DB=sqlite
6 | script:
7 | - RAILS_ENV=test bundle exec rake --trace db:migrate
8 | - bundle exec rake
9 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source "http://rubygems.org"
2 |
3 | # Declare your gem's dependencies in ad_man.gemspec.
4 | # Bundler will treat runtime dependencies like base dependencies, and
5 | # development dependencies will be added by default to the :development group.
6 | gemspec
7 |
8 | # Paperclip, for image attachements
9 | gem 'paperclip'
10 |
11 | # jquery-rails is used by the dummy application
12 | gem "jquery-rails"
13 | gem "therubyracer"
14 | gem "uglifier"
15 |
16 |
17 | # Declare any dependencies that are still in development here instead of in
18 | # your gemspec. These might include edge Rails or gems from your path or
19 | # Git. Remember to move these dependencies to your gemspec before releasing
20 | # your gem to rubygems.org.
21 |
22 | # To use debugger
23 | # gem 'debugger'
24 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | PATH
2 | remote: .
3 | specs:
4 | ad_man (0.0.13)
5 | paperclip (~> 3.1)
6 | rails (~> 3.2)
7 |
8 | GEM
9 | remote: http://rubygems.org/
10 | specs:
11 | actionmailer (3.2.7)
12 | actionpack (= 3.2.7)
13 | mail (~> 2.4.4)
14 | actionpack (3.2.7)
15 | activemodel (= 3.2.7)
16 | activesupport (= 3.2.7)
17 | builder (~> 3.0.0)
18 | erubis (~> 2.7.0)
19 | journey (~> 1.0.4)
20 | rack (~> 1.4.0)
21 | rack-cache (~> 1.2)
22 | rack-test (~> 0.6.1)
23 | sprockets (~> 2.1.3)
24 | activemodel (3.2.7)
25 | activesupport (= 3.2.7)
26 | builder (~> 3.0.0)
27 | activerecord (3.2.7)
28 | activemodel (= 3.2.7)
29 | activesupport (= 3.2.7)
30 | arel (~> 3.0.2)
31 | tzinfo (~> 0.3.29)
32 | activeresource (3.2.7)
33 | activemodel (= 3.2.7)
34 | activesupport (= 3.2.7)
35 | activesupport (3.2.7)
36 | i18n (~> 0.6)
37 | multi_json (~> 1.0)
38 | arel (3.0.2)
39 | builder (3.0.0)
40 | cocaine (0.2.1)
41 | erubis (2.7.0)
42 | hike (1.2.1)
43 | i18n (0.6.0)
44 | journey (1.0.4)
45 | jquery-rails (2.0.2)
46 | railties (>= 3.2.0, < 5.0)
47 | thor (~> 0.14)
48 | json (1.7.4)
49 | mail (2.4.4)
50 | i18n (>= 0.4.0)
51 | mime-types (~> 1.16)
52 | treetop (~> 1.4.8)
53 | mime-types (1.19)
54 | multi_json (1.3.6)
55 | paperclip (3.1.2)
56 | activemodel (>= 3.0.0)
57 | activerecord (>= 3.0.0)
58 | activesupport (>= 3.0.0)
59 | cocaine (>= 0.0.2)
60 | mime-types
61 | polyglot (0.3.3)
62 | rack (1.4.1)
63 | rack-cache (1.2)
64 | rack (>= 0.4)
65 | rack-ssl (1.3.2)
66 | rack
67 | rack-test (0.6.1)
68 | rack (>= 1.0)
69 | rails (3.2.7)
70 | actionmailer (= 3.2.7)
71 | actionpack (= 3.2.7)
72 | activerecord (= 3.2.7)
73 | activeresource (= 3.2.7)
74 | activesupport (= 3.2.7)
75 | bundler (~> 1.0)
76 | railties (= 3.2.7)
77 | railties (3.2.7)
78 | actionpack (= 3.2.7)
79 | activesupport (= 3.2.7)
80 | rack-ssl (~> 1.3.2)
81 | rake (>= 0.8.7)
82 | rdoc (~> 3.4)
83 | thor (>= 0.14.6, < 2.0)
84 | rake (0.9.2.2)
85 | rdoc (3.12)
86 | json (~> 1.4)
87 | sprockets (2.1.3)
88 | hike (~> 1.2)
89 | rack (~> 1.0)
90 | tilt (~> 1.1, != 1.3.0)
91 | sqlite3 (1.3.6)
92 | thor (0.15.4)
93 | tilt (1.3.3)
94 | treetop (1.4.10)
95 | polyglot
96 | polyglot (>= 0.3.1)
97 | tzinfo (0.3.33)
98 |
99 | PLATFORMS
100 | ruby
101 |
102 | DEPENDENCIES
103 | ad_man!
104 | jquery-rails
105 | paperclip
106 | sqlite3
107 |
--------------------------------------------------------------------------------
/MIT-LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2012 Kudelabs
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Ad_man
2 | ======
3 |
4 | [](http://travis-ci.org/matenia/ad_man)
5 | [](https://codeclimate.com/github/matenia/ad_man)
6 |
7 | 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.
8 |
9 | Currently supports two image sizes for advertising: Leaderboard 728 x 90 and Banner 468 x 60.
10 | TODO: Will implement 9 different sizes as mentioned by google's adwords requirements.
11 |
12 | Requires Paperclip 3.1, and requires ImageMagick be running on the server.
13 |
14 | ## Getting started
15 |
16 | Ad_man works with Rails 3.2 onwards. You can add it to your Gemfile with:
17 |
18 | ```ruby
19 | gem 'ad_man'
20 | ```
21 |
22 | After you install Ad_man and add it to your Gemfile, you need to run the generator:
23 |
24 | ```console
25 | rails generate ad_man:install
26 | ```
27 |
28 | This will install the migrations and a few controller files, then just rake the database:
29 | ```console
30 | rake db:migrate
31 | ```
32 |
33 | See where Ad_man is located by running:
34 | ```console
35 | rake routes
36 | ```
37 |
38 | 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.
39 |
40 | Make sure to change references to the application using the main_app helper:
41 | ```erb
42 | <%= link_to "Home", main_app.root_path %>
43 | <%= link_to "Advertising", main_app.ad_man_path %>
44 | ```
45 |
46 | ## Changing default values
47 |
48 | 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.
49 |
50 | ```ruby
51 | # AdMan Default Values
52 | AdMan.leaderboard_size = "728x90"
53 | AdMan.banner_size = "468x60"
54 | AdMan.mobile_leaderboard_size = "320X50"
55 | AdMan.square_size = "250X250"
56 | AdMan.small_square_size = "200X200"
57 | AdMan.large_rectangle_size = "336X280"
58 | AdMan.inline_rectangle_size = "300X250"
59 | AdMan.skyscraper_size = "120X600"
60 | AdMan.wide_skyscraper_size = "160X600"
61 |
62 | AdMan.max_image_size = 50 # 50Kb maximum image size
63 |
64 | # These are configurable dimensions (currently leaderboard default)
65 | AdMan.image_dimensions_width = 728
66 | AdMan.image_dimensions_height = 90
67 |
68 | # Configurable content type for advertising
69 | AdMan.content_type = ["image/jpg", "image/bmp", "image/png", "image/gif", "image/jpeg"]
70 |
71 | # Configurable max advertising for keyword
72 | AdMan.max_count = 6
73 | ```
74 |
75 | ## Putting an advertisement in the view
76 |
77 | To put your advertisement in the view just add:
78 | ```erb
79 | <%= link_to_ad %>
80 | ```
81 | Currently there are three parameters that can control which ads get shown on your page. :keyword, :size, and :display_on_all_pages.
82 | ```erb
83 | <%= link_to_ad :keyword => "Your Keyword", :size => "leaderboard", :display_on_all_pages => false %>
84 | ```
85 |
86 | ## Ad_man and Javascript
87 | Ad_man supports inserting an advertisement using jQuery. It also uses jQuery in the backend when creating new ads. To use this functionality, include this line in the view:
88 | ```erb
89 | <%= javascript_include_tag "ad_man/advertisements.js" %>
90 | ```
91 |
92 | You can pass a `
` id element, the keyword name, and size to show an advertisement using the showAd(); function. Currently supported sizes are: `leaderboard` and `banner`.
93 | ```erb
94 |
97 | ```
98 | Then make sure you have a `
` element with the `div_id` you gave to the showAd function.
99 | ```erb
100 |
101 | ```
102 |
103 | ## Authors
104 | Written by [David Strand](http://www.github.com/wspyder) and [Tyler Hu](http://www.github.com/tylerhu)
105 |
106 | ## Contributors
107 | [Matenia Rossides](http://www.github.com/matenia)
108 |
109 | ## Copyright & Licensing
110 | This project is maintained by an intern team of developers and is freely available for commercial use under the terms of the MIT License.
111 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env rake
2 | begin
3 | require 'bundler/setup'
4 | rescue LoadError
5 | puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6 | end
7 | begin
8 | require 'rdoc/task'
9 | rescue LoadError
10 | require 'rdoc/rdoc'
11 | require 'rake/rdoctask'
12 | RDoc::Task = Rake::RDocTask
13 | end
14 |
15 | RDoc::Task.new(:rdoc) do |rdoc|
16 | rdoc.rdoc_dir = 'rdoc'
17 | rdoc.title = 'AdMan'
18 | rdoc.options << '--line-numbers'
19 | rdoc.rdoc_files.include('README.rdoc')
20 | rdoc.rdoc_files.include('lib/**/*.rb')
21 | end
22 |
23 | APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
24 | load 'rails/tasks/engine.rake'
25 |
26 |
27 |
28 | Bundler::GemHelper.install_tasks
29 |
30 | require 'rake/testtask'
31 |
32 | Rake::TestTask.new(:test) do |t|
33 | t.libs << 'lib'
34 | t.libs << 'test'
35 | t.pattern = 'test/**/*_test.rb'
36 | t.verbose = false
37 | end
38 |
39 |
40 | task :default => :test
41 |
--------------------------------------------------------------------------------
/ad_man-0.0.13.gem:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/ad_man-0.0.13.gem
--------------------------------------------------------------------------------
/ad_man.gemspec:
--------------------------------------------------------------------------------
1 | $:.push File.expand_path("../lib", __FILE__)
2 |
3 | # Maintain your gem's version:
4 | require "ad_man/version"
5 |
6 | # Describe your gem and declare its dependencies:
7 | Gem::Specification.new do |s|
8 | s.name = "ad_man"
9 | s.version = AdMan::VERSION.dup
10 | s.authors = ['David Strand', 'Tyler Hu']
11 | s.email = ["connect@kudelabs.com"]
12 | s.homepage = "http://github.com/kudelabs/ad_man"
13 | s.summary = "An advertising manager mountable engine"
14 | s.description = "An advertising manager mountable engine"
15 |
16 | s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md"]
17 | s.test_files = Dir["test/**/*"]
18 |
19 | s.add_dependency "rails", "~> 3.2"
20 | # s.add_dependency "jquery-rails"
21 | s.add_dependency "paperclip", "~> 3.1"
22 | s.add_development_dependency "sqlite3"
23 | end
24 |
--------------------------------------------------------------------------------
/app/assets/images/ad_man/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/app/assets/images/ad_man/.gitkeep
--------------------------------------------------------------------------------
/app/assets/javascripts/ad_man/advertisements.js:
--------------------------------------------------------------------------------
1 | // Place all the behaviors and hooks related to the matching controller here.
2 | // All this logic will automatically be available in application.js.
3 | var MAX_FILE_SIZE = 5242880; // 5MB
4 | var ACCEPT_FILE_TYPE = /image\/(jpg|jpeg|png|gif|bmp)/i;
5 |
6 | function handleFileSelect(evt) {
7 | var files = evt.target.files; // FileList object
8 | var form = jQuery(evt.target).closest('form');
9 |
10 | // Loop through the FileList and render image files as thumbnails.
11 | for (var i = 0, f; f = files[i]; i++) {
12 | // Only process image files.
13 | if (!f.type.match(ACCEPT_FILE_TYPE)) {
14 | showFormError('File is not an image', form);
15 | continue;
16 | }
17 |
18 | if (parseInt(f.size) > MAX_FILE_SIZE) {
19 | showFormError('File size exceeds 5MB.', form);
20 | continue;
21 | }
22 |
23 | var reader = new FileReader();
24 | // Closure to capture the file information.
25 | reader.onload = (function(theFile) {
26 | return function(e) {
27 | // Render thumbnail.
28 | var img = [''].join('');
30 | form.find('.preview').html(img);
31 | form.find('.preview').show();
32 | };
33 | })(f);
34 |
35 | // Read in the image file as a data URL.
36 | reader.readAsDataURL(f);
37 | }
38 | }
39 |
40 | function showFormError(msg, form) {
41 | var errorDiv = document.createElement('div');
42 | errorDiv.className = 'errors';
43 | errorDiv.innerHTML = msg;
44 | form.find('div.errors').remove();
45 | form.prepend(errorDiv);
46 | }
47 | AdMan = {
48 | //function showAd(div, key, size) {
49 | showAd: function(div, key, size) {
50 | jQuery.ajax({
51 | url: "/ad_man/advertisements/get_ad/" + div + "/" + key + "/" + size,
52 | dataType: "script",
53 | success: function(data){}
54 | });
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/app/assets/javascripts/ad_man/application.js:
--------------------------------------------------------------------------------
1 | // This is a manifest file that'll be compiled into application.js, which will include all the files
2 | // listed below.
3 | //
4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5 | // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6 | //
7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8 | // the compiled file.
9 | //
10 | // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11 | // GO AFTER THE REQUIRES BELOW.
12 | //
13 | //= require jquery
14 | //= require jquery_ujs
15 | //= require_tree .
16 |
--------------------------------------------------------------------------------
/app/assets/javascripts/ad_man/keywords.js:
--------------------------------------------------------------------------------
1 | // Place all the behaviors and hooks related to the matching controller here.
2 | // All this logic will automatically be available in application.js.
3 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/ad_man/advertisements.css:
--------------------------------------------------------------------------------
1 | /*
2 | Place all the styles related to the matching controller here.
3 | They will automatically be included in application.css.
4 | */
5 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/ad_man/application.css:
--------------------------------------------------------------------------------
1 | /*
2 | * This is a manifest file that'll be compiled into application.css, which will include all the files
3 | * listed below.
4 | *
5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6 | * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7 | *
8 | * You're free to add application-wide styles to this file and they'll appear at the top of the
9 | * compiled file, but it's generally better to create a new file per style scope.
10 | *
11 | *= require_self
12 | *= require_tree .
13 | */
14 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/ad_man/keywords.css:
--------------------------------------------------------------------------------
1 | /*
2 | Place all the styles related to the matching controller here.
3 | They will automatically be included in application.css.
4 | */
5 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/scaffold.css:
--------------------------------------------------------------------------------
1 | body { background-color: #fff; color: #333; }
2 |
3 | body, p, ol, ul, td {
4 | font-family: verdana, arial, helvetica, sans-serif;
5 | font-size: 13px;
6 | line-height: 18px;
7 | }
8 |
9 | pre {
10 | background-color: #eee;
11 | padding: 10px;
12 | font-size: 11px;
13 | }
14 |
15 | a { color: #000; }
16 | a:visited { color: #666; }
17 | a:hover { color: #fff; background-color:#000; }
18 |
19 | div.field, div.actions {
20 | margin-bottom: 10px;
21 | }
22 |
23 | #notice {
24 | color: green;
25 | }
26 |
27 | .field_with_errors {
28 | padding: 2px;
29 | background-color: red;
30 | display: table;
31 | }
32 |
33 | #error_explanation {
34 | width: 450px;
35 | border: 2px solid red;
36 | padding: 7px;
37 | padding-bottom: 0;
38 | margin-bottom: 20px;
39 | background-color: #f0f0f0;
40 | }
41 |
42 | #error_explanation h2 {
43 | text-align: left;
44 | font-weight: bold;
45 | padding: 5px 5px 5px 15px;
46 | font-size: 12px;
47 | margin: -7px;
48 | margin-bottom: 0px;
49 | background-color: #c00;
50 | color: #fff;
51 | }
52 |
53 | #error_explanation ul li {
54 | font-size: 12px;
55 | list-style: square;
56 | }
57 |
--------------------------------------------------------------------------------
/app/controllers/ad_man/advertisements_controller.rb:
--------------------------------------------------------------------------------
1 | class AdMan::AdvertisementsController < ApplicationController
2 | # GET /advertisements
3 | # GET /advertisements.json
4 | include AdMan::ApplicationHelper
5 |
6 | def index
7 | @advertisements = AdMan::Advertisement.all
8 |
9 | # depends on the "will_paginate" gem
10 | #@advertisements = AdMan::Advertisement.paginate :page => params[:page], :order => 'created_at desc',
11 | # :per_page => 5
12 | @keywords = AdMan::Keyword.all
13 |
14 | respond_to do |format|
15 | format.html # index.html.erb
16 | format.json { render json: @advertisements }
17 | end
18 | end
19 |
20 | # GET /advertisements/1
21 | # GET /advertisements/1.json
22 | def show
23 | @advertisement = AdMan::Advertisement.find(params[:id])
24 |
25 | respond_to do |format|
26 | format.html # show.html.erb
27 | format.json { render json: @advertisement }
28 | end
29 | end
30 |
31 | # GET /advertisements/new
32 | # GET /advertisements/new.json
33 | def new
34 | @advertisement = AdMan::Advertisement.new
35 |
36 | respond_to do |format|
37 | format.html # new.html.erb
38 | format.json { render json: @advertisement }
39 | end
40 | end
41 |
42 | # GET /advertisements/1/edit
43 | def edit
44 | @advertisement = AdMan::Advertisement.find(params[:id])
45 | end
46 |
47 | # POST /advertisements
48 | # POST /advertisements.json
49 | def create
50 | @advertisement = AdMan::Advertisement.new(params[:advertisement])
51 | #@advertisement.keyword_id = params[:keyword_id]
52 | #@advertisement.priority = params[:priority]
53 | respond_to do |format|
54 | if @advertisement.save
55 | format.html { redirect_to @advertisement, notice: 'Advertisement was successfully created.' }
56 | format.json { render json: @advertisement, status: :created, location: @advertisement }
57 | else
58 | format.html { render action: "new" }
59 | format.json { render json: @advertisement.errors, status: :unprocessable_entity }
60 | end
61 | end
62 | end
63 |
64 | # PUT /advertisements/1
65 | # PUT /advertisements/1.json
66 | def update
67 | @advertisement = AdMan::Advertisement.find(params[:id])
68 | #@advertisement.keyword_id = params[:keyword_id]
69 | #@advertisement.priority = params[:priority]
70 |
71 | respond_to do |format|
72 | if @advertisement.update_attributes(params[:advertisement])
73 | format.html { redirect_to @advertisement, notice: 'Advertisement was successfully updated.' }
74 | format.json { head :no_content }
75 | else
76 | format.html { render action: "edit" }
77 | format.json { render json: @advertisement.errors, status: :unprocessable_entity }
78 | end
79 | end
80 | end
81 |
82 | # DELETE /advertisements/1
83 | # DELETE /advertisements/1.json
84 | def destroy
85 | @advertisement = AdMan::Advertisement.find(params[:id])
86 | @advertisement.destroy
87 |
88 | respond_to do |format|
89 | format.html { redirect_to advertisements_url }
90 | format.json { head :no_content }
91 | end
92 | end
93 |
94 | # Click Through
95 | def click_through
96 | @advertisement = AdMan::Advertisement.find(params[:id])
97 | @advertisement.click_count += 1
98 | @advertisement.save
99 | redirect_to @advertisement.destination_url
100 | end
101 |
102 | def get_ad()
103 | keyword = params[:key]
104 | @div = params[:div]
105 | @size = params[:size]
106 | @ad = js_link_to_ad(keyword)
107 | end
108 |
109 | end
110 |
--------------------------------------------------------------------------------
/app/controllers/ad_man/application_controller.rb:
--------------------------------------------------------------------------------
1 | module AdMan
2 | class ApplicationController < ActionController::Base
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/app/controllers/ad_man/keywords_controller.rb:
--------------------------------------------------------------------------------
1 | class AdMan::KeywordsController < ApplicationController
2 | respond_to :html, :json
3 |
4 | def index
5 | @keywords = AdMan::Keyword.all
6 | respond_with @keywords
7 | end
8 |
9 | def show
10 | @keyword = AdMan::Keyword.find(params[:id])
11 | @advertisements = AdMan::Advertisement.find_all_by_keyword_id(params[:id])
12 | @keywords = AdMan::Keyword.all
13 | end
14 |
15 | def new
16 | @keyword = AdMan::Keyword.new
17 | respond_with(@keyword)
18 | end
19 |
20 | def edit
21 | @keyword = AdMan::Keyword.find(params[:id])
22 | end
23 |
24 | def create
25 | @keyword = AdMan::Keyword.new(params[:keyword])
26 | respond_to do |format|
27 | if @keyword.save
28 | format.html { redirect_to advertisements_path, notice: "Keyword successfully created."}
29 | format.json { render json: @keyword, status: :created, location: @keyword }
30 | else
31 | format.html { render action: "new"}
32 | format.json { render json: @keyword.errors, status: :unprocessable_entity }
33 | end
34 | end
35 | end
36 |
37 | def update
38 | @keyword = AdMan::Keyword.find(params[:id])
39 | respond_to do |format|
40 | if @keyword.update_attributes(params[:keyword])
41 | format.html { redirect_to advertisements_path, notice: "Keyword successfully updated."}
42 | format.json { head :no_content }
43 | else
44 | format.html { render action: "edit"}
45 | format.json { render json: @keyword.errors, status: :unprocessable_entity }
46 | end
47 | end
48 | end
49 |
50 | def destroy
51 | @keyword = AdMan::Keyword.find(params[:id])
52 | @keyword.destroy
53 | respond_to do |format|
54 | format.html { redirect_to advertisements_path }
55 | format.json { head :no_content }
56 | end
57 | end
58 |
59 | end
60 |
--------------------------------------------------------------------------------
/app/helpers/ad_man/advertisements_helper.rb:
--------------------------------------------------------------------------------
1 | module AdMan
2 | module AdvertisementsHelper
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/app/helpers/ad_man/application_helper.rb:
--------------------------------------------------------------------------------
1 | module AdMan
2 | module ApplicationHelper
3 | def link_to_ad(opts = {})
4 | opts.slice!(:size,:keyword)
5 | keyword = opts[:keyword]
6 | size = opts[:size] || "leaderboard"
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
11 | end
12 |
13 | def js_link_to_ad(keyword)
14 | ad_select(keyword)
15 | end
16 |
17 | protected
18 |
19 | #grab the keyword form request url
20 | def get_keyword_from_url
21 | if request.env["REQUEST_PATH"]
22 | req_url = request.env["REQUEST_PATH"].split("/")
23 | keyword_names = Keyword.all.map(&:name)
24 | keyword = req_url & keyword_names
25 | end
26 | end
27 |
28 | def ad_select(keyword=nil)
29 | keyword ||= get_keyword_from_url
30 | ad = if keyword.present? && Keyword.find_by_name(keyword)
31 | keyword_id = Keyword.find_by_name(keyword).id
32 | Advertisement.render_random_ad(keyword_id)
33 | #grab size? leaderboard or banner
34 | elsif keyword.blank? || keyword == 'all'
35 | 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
45 | end
46 |
--------------------------------------------------------------------------------
/app/helpers/ad_man/keywords_helper.rb:
--------------------------------------------------------------------------------
1 | module AdMan
2 | module KeywordsHelper
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/app/models/ad_man/advertisement.rb:
--------------------------------------------------------------------------------
1 | module AdMan
2 | class Advertisement < ActiveRecord::Base
3 | attr_accessible :destination_url, :title, :ad_banner, :display_count,
4 | :priority, :start_date, :end_date, :click_count, :keyword_id
5 | validates_with AttachmentPresenceValidator, :attributes => :ad_banner
6 | belongs_to :keyword
7 | has_attached_file :ad_banner, :styles => {
8 | :leaderboard => AdMan.leaderboard_size,
9 | :banner => AdMan.banner_size,
10 | :mobile_leaderboard => AdMan.mobile_leaderboard_size,
11 | :square => AdMan.square_size,
12 | :small_square => AdMan.small_square_size,
13 | :large_rectangle => AdMan.large_rectangle_size,
14 | :inline_rectangle => AdMan.inline_rectangle_size,
15 | :skyscraper => AdMan.skyscraper_size,
16 | :wide_skyscraper => AdMan.wide_skyscraper_size
17 | }
18 | validates_attachment :ad_banner, :presence => true,
19 | :content_type => {
20 | :content_type => AdMan.content_type
21 | },
22 | :size => { :in => 0..(AdMan.max_image_size).kilobytes }
23 | validates_presence_of :destination_url, :title, :keyword_id, :priority
24 | validates_uniqueness_of :title
25 | validate :image_dimensions, :on => :create
26 | after_initialize :init_priority
27 |
28 | def self.render_random_ad(keyword_id = nil)
29 | ads = fetch_ads(keyword_id)
30 | if ads.present?
31 | total_times = 1.0
32 | total_priority = 0.0
33 | ads.each { |advertisement|
34 | total_times += advertisement.display_count
35 | total_priority += advertisement.priority
36 | }
37 | ad = ads[rand(ads.size)]
38 | while((ad.display_count / total_times) > (ad.priority / total_priority))
39 | ad = ads[rand(ads.size)]
40 | end
41 | ad
42 | end
43 | end
44 |
45 | private
46 |
47 | def self.fetch_ads(keyword_id=nil)
48 | if keyword_id.blank?
49 | where("start_date <= ? AND end_date >= ?", Date.today, Date.today)
50 | else
51 | where("keyword_id = ? AND start_date <= ? AND end_date >= ? ", keyword_id, Date.today, Date.today)
52 | end
53 | end
54 |
55 | def image_dimensions
56 | temp_file = ad_banner.queued_for_write[:leaderboard] #get the file
57 | dimensions = Paperclip::Geometry.from_file(temp_file)
58 | max_width = AdMan.image_dimensions_width
59 | max_height = AdMan.image_dimensions_height
60 | if (dimensions.width > max_width) || (dimensions.height > max_height)
61 | errors.add("banner_dimmensions",
62 | "must be image size: #{max_width}X#{max_height}.")
63 | end
64 | end
65 |
66 | def init_priority
67 | self.priority ||= 1
68 | end
69 | end
70 | end
71 |
72 |
73 |
--------------------------------------------------------------------------------
/app/models/ad_man/keyword.rb:
--------------------------------------------------------------------------------
1 | module AdMan
2 | class Keyword < ActiveRecord::Base
3 | attr_accessible :name
4 | has_many :advertisements, :dependent => :destroy
5 | validates :name, :presence => true, :uniqueness => true
6 | MAX_COUNT = (AdMan.max_count)?(AdMan.max_count):5
7 |
8 | def to_s
9 | name
10 | end
11 |
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
19 |
20 | def self.unavailable
21 | Keyword.all.select { |keyword| keyword.advertisements.count >= MAX_COUNT}
22 | end
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/app/views/ad_man/advertisements/_form.html.erb:
--------------------------------------------------------------------------------
1 | <%= form_for(@advertisement) do |f| %>
2 | <% if @advertisement.errors.any? %>
3 |
4 |
<%= pluralize(@advertisement.errors.count, "error") %> prohibited this advertisement from being saved:
5 |
6 |
7 | <% @advertisement.errors.full_messages.each do |msg| %>
8 |
# Declare your gem’s dependencies in ad_man.gemspec. # Bundler will treat
133 | runtime dependencies like base dependencies, and # development dependencies
134 | will be added by default to the :development group. gemspec
135 |
136 |
# Paperclip, for image attachements gem ‘paperclip’
137 |
138 |
# jquery-rails is used by the dummy application gem “jquery-rails”
139 |
140 |
# Declare any dependencies that are still in development here instead of in
141 | # your gemspec. These might include edge Rails or gems from your path or #
142 | Git. Remember to move these dependencies to your gemspec before releasing #
143 | your gem to rubygems.org.
#!/usr/bin/env rake # Add your own tasks in files placed in lib/tasks
131 | ending in .rake, # for example lib/tasks/capistrano.rake, and they will
132 | automatically be available to Rake.
139 |
140 |
141 |
142 |
147 |
148 |
--------------------------------------------------------------------------------
/lib/ad_man.rb:
--------------------------------------------------------------------------------
1 | require "ad_man/engine"
2 |
3 | module AdMan
4 | # advert size names
5 | mattr_accessor :leaderboard_size,
6 | :banner_size,
7 | :mobile_leaderboard_size,
8 | :square_size,
9 | :small_square_size,
10 | :large_rectangle_size,
11 | :inline_rectangle_size,
12 | :skyscraper_size,
13 | :wide_skyscraper_size
14 |
15 | mattr_accessor :image_dimensions_width, :image_dimensions_height
16 | mattr_accessor :max_image_size
17 | mattr_accessor :content_type
18 | mattr_accessor :max_count
19 |
20 | # initialize default sizes
21 | self.leaderboard_size = "728X90"
22 | self.banner_size = '468X60'
23 | self.mobile_leaderboard_size = '320X50'
24 | self.square_size = '250X250'
25 | self.small_square_size = '200X200'
26 | self.large_rectangle_size = '336X280'
27 | self.inline_rectangle_size = '300X250'
28 | self.skyscraper_size = '120X600'
29 | self.wide_skyscraper_size = '160X600'
30 |
31 | # other attributes
32 | self.max_image_size = 50
33 | self.content_type = ["image/jpg","image/bmp","image/png", "image/gif", "image/jpeg"]
34 | self.image_dimensions_height = 90
35 | self.image_dimensions_width = 728
36 | end
37 |
--------------------------------------------------------------------------------
/lib/ad_man/engine.rb:
--------------------------------------------------------------------------------
1 | require 'paperclip'
2 |
3 | module AdMan
4 | class Engine < ::Rails::Engine
5 | isolate_namespace AdMan
6 |
7 | #expose helper methods to the consumer application
8 | initializer 'ad_man.action_controller' do |app|
9 | ActiveSupport.on_load :action_controller do
10 | helper AdMan::ApplicationHelper
11 | end
12 | end
13 |
14 | initializer 'ad_man.assets.precompile' do |app|
15 | app.config.assets.precompile += %w(ad_man/advertisements.js)
16 | end
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/lib/ad_man/version.rb:
--------------------------------------------------------------------------------
1 | module AdMan
2 | VERSION = "0.0.13"
3 | end
4 |
--------------------------------------------------------------------------------
/lib/generators/ad_man/install_generator.rb:
--------------------------------------------------------------------------------
1 | module AdMan
2 | class InstallGenerator < Rails::Generators::Base
3 | source_root File.expand_path('../templates', __FILE__)
4 | def create_extended_controller_file
5 | template "advertisements_controller.rb","app/controllers/ad_man/advertisements_controller.rb"
6 | template "keywords_controller.rb","app/controllers/ad_man/keywords_controller.rb"
7 | end
8 |
9 | def add_routes
10 | route("mount AdMan::Engine => '/ad_man'")
11 | end
12 |
13 | def install_migrations
14 | rake "ad_man:install:migrations"
15 | end
16 | end
17 | end
18 |
19 |
--------------------------------------------------------------------------------
/lib/generators/ad_man/templates/advertisements_controller.rb:
--------------------------------------------------------------------------------
1 | require File.join(AdMan::Engine.config.root,'app','controllers','ad_man','advertisements_controller')
2 | AdMan::AdvertisementsController.class_eval do
3 | # overrides go here
4 | end
5 |
--------------------------------------------------------------------------------
/lib/generators/ad_man/templates/keywords_controller.rb:
--------------------------------------------------------------------------------
1 | require File.join(AdMan::Engine.config.root,'app','controllers','ad_man','keywords_controller')
2 | AdMan::KeywordsController.class_eval do
3 | # overrides go here
4 | end
5 |
--------------------------------------------------------------------------------
/lib/tasks/ad_man_tasks.rake:
--------------------------------------------------------------------------------
1 | # desc "Explaining what the task does"
2 | # task :ad_man do
3 | # # Task goes here
4 | # end
5 |
--------------------------------------------------------------------------------
/script/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3 |
4 | ENGINE_ROOT = File.expand_path('../..', __FILE__)
5 | ENGINE_PATH = File.expand_path('../../lib/ad_man/engine', __FILE__)
6 |
7 | require 'rails/all'
8 | require 'rails/engine/commands'
9 |
--------------------------------------------------------------------------------
/test/ad_man_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class AdManTest < ActiveSupport::TestCase
4 | test "truth" do
5 | assert_kind_of Module, AdMan
6 | end
7 |
8 | test "default configs" do
9 | assert_equal "728X90", AdMan.leaderboard_size.upcase
10 | assert_equal "468X60", AdMan.banner_size.upcase
11 | assert_equal "320X50", AdMan.mobile_leaderboard_size.upcase
12 | assert_equal "250X250", AdMan.square_size.upcase
13 | assert_equal "200X200", AdMan.small_square_size.upcase
14 | assert_equal "336X280", AdMan.large_rectangle_size.upcase
15 | assert_equal "300X250", AdMan.inline_rectangle_size.upcase
16 | assert_equal "120X600", AdMan.skyscraper_size.upcase
17 | assert_equal "160X600", AdMan.wide_skyscraper_size.upcase
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/test/dummy/Rakefile:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env rake
2 | # Add your own tasks in files placed in lib/tasks ending in .rake,
3 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4 |
5 | require File.expand_path('../config/application', __FILE__)
6 |
7 | Dummy::Application.load_tasks
8 |
--------------------------------------------------------------------------------
/test/dummy/app/assets/javascripts/application.js:
--------------------------------------------------------------------------------
1 | // This is a manifest file that'll be compiled into application.js, which will include all the files
2 | // listed below.
3 | //
4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5 | // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6 | //
7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8 | // the compiled file.
9 | //
10 | // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11 | // GO AFTER THE REQUIRES BELOW.
12 | //
13 | //= require jquery
14 | //= require jquery_ujs
15 | //= require_tree .
16 |
--------------------------------------------------------------------------------
/test/dummy/app/assets/stylesheets/application.css:
--------------------------------------------------------------------------------
1 | /*
2 | * This is a manifest file that'll be compiled into application.css, which will include all the files
3 | * listed below.
4 | *
5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6 | * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7 | *
8 | * You're free to add application-wide styles to this file and they'll appear at the top of the
9 | * compiled file, but it's generally better to create a new file per style scope.
10 | *
11 | *= require_self
12 | *= require_tree .
13 | */
--------------------------------------------------------------------------------
/test/dummy/app/controllers/ad_man/advertisements_controller.rb:
--------------------------------------------------------------------------------
1 | require File.join(AdMan::Engine.config.root,'app','controllers','ad_man','advertisements_controller')
2 | AdMan::AdvertisementsController.class_eval do
3 | # overrides go here
4 | end
5 |
--------------------------------------------------------------------------------
/test/dummy/app/controllers/ad_man/keywords_controller.rb:
--------------------------------------------------------------------------------
1 | require File.join(AdMan::Engine.config.root,'app','controllers','ad_man','keywords_controller')
2 | AdMan::KeywordsController.class_eval do
3 | # overrides go here
4 | end
5 |
--------------------------------------------------------------------------------
/test/dummy/app/controllers/application_controller.rb:
--------------------------------------------------------------------------------
1 | class ApplicationController < ActionController::Base
2 | protect_from_forgery
3 | end
4 |
--------------------------------------------------------------------------------
/test/dummy/app/helpers/application_helper.rb:
--------------------------------------------------------------------------------
1 | module ApplicationHelper
2 | end
3 |
--------------------------------------------------------------------------------
/test/dummy/app/mailers/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/app/mailers/.gitkeep
--------------------------------------------------------------------------------
/test/dummy/app/models/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/app/models/.gitkeep
--------------------------------------------------------------------------------
/test/dummy/app/views/layouts/application.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Dummy
5 | <%= stylesheet_link_tag "application", :media => "all" %>
6 | <%= javascript_include_tag "application" %>
7 | <%= javascript_include_tag "ad_man/advertisements.js" %>
8 |
9 |
16 |
17 | <%= csrf_meta_tags %>
18 |
19 |
20 |
21 | <%= link_to_ad %>
22 |
23 |
24 | <%= yield %>
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/test/dummy/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require ::File.expand_path('../config/environment', __FILE__)
4 | run Dummy::Application
5 |
--------------------------------------------------------------------------------
/test/dummy/config/application.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path('../boot', __FILE__)
2 |
3 | require 'rails/all'
4 |
5 | Bundler.require
6 | require "ad_man"
7 |
8 | module Dummy
9 | class Application < Rails::Application
10 | # Settings in config/environments/* take precedence over those specified here.
11 | # Application configuration should go into files in config/initializers
12 | # -- all .rb files in that directory are automatically loaded.
13 |
14 | # Custom directories with classes and modules you want to be autoloadable.
15 | # config.autoload_paths += %W(#{config.root}/extras)
16 |
17 | # Only load the plugins named here, in the order given (default is alphabetical).
18 | # :all can be used as a placeholder for all plugins not explicitly named.
19 | # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
20 |
21 | # Activate observers that should always be running.
22 | # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
23 |
24 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
25 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
26 | # config.time_zone = 'Central Time (US & Canada)'
27 |
28 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
29 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
30 | # config.i18n.default_locale = :de
31 |
32 | # Configure the default encoding used in templates for Ruby 1.9.
33 | config.encoding = "utf-8"
34 |
35 | # Configure sensitive parameters which will be filtered from the log file.
36 | config.filter_parameters += [:password]
37 |
38 | # Enable escaping HTML in JSON.
39 | config.active_support.escape_html_entities_in_json = true
40 |
41 | # Use SQL instead of Active Record's schema dumper when creating the database.
42 | # This is necessary if your schema can't be completely dumped by the schema dumper,
43 | # like if you have constraints or database-specific column types
44 | # config.active_record.schema_format = :sql
45 |
46 | # Enforce whitelist mode for mass assignment.
47 | # This will create an empty whitelist of attributes available for mass-assignment for all models
48 | # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
49 | # parameters by using an attr_accessible or attr_protected declaration.
50 | config.active_record.whitelist_attributes = true
51 |
52 | # Enable the asset pipeline
53 | config.assets.enabled = true
54 |
55 | # Version of your assets, change this if you want to expire all your assets
56 | config.assets.version = '1.0'
57 | end
58 | end
59 |
60 |
--------------------------------------------------------------------------------
/test/dummy/config/boot.rb:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 | gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3 |
4 | if File.exist?(gemfile)
5 | ENV['BUNDLE_GEMFILE'] = gemfile
6 | require 'bundler'
7 | Bundler.setup
8 | end
9 |
10 | $:.unshift File.expand_path('../../../../lib', __FILE__)
--------------------------------------------------------------------------------
/test/dummy/config/database.yml:
--------------------------------------------------------------------------------
1 | # SQLite version 3.x
2 | # gem install sqlite3
3 | #
4 | # Ensure the SQLite 3 gem is defined in your Gemfile
5 | # gem 'sqlite3'
6 | development:
7 | adapter: sqlite3
8 | database: db/development.sqlite3
9 | pool: 5
10 | timeout: 5000
11 |
12 | # Warning: The database defined as "test" will be erased and
13 | # re-generated from your development database when you run "rake".
14 | # Do not set this db to the same as development or production.
15 | test:
16 | adapter: sqlite3
17 | database: db/test.sqlite3
18 | pool: 5
19 | timeout: 5000
20 |
21 | production:
22 | adapter: sqlite3
23 | database: db/production.sqlite3
24 | pool: 5
25 | timeout: 5000
26 |
--------------------------------------------------------------------------------
/test/dummy/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the rails application
2 | require File.expand_path('../application', __FILE__)
3 |
4 | # Initialize the rails application
5 | Dummy::Application.initialize!
6 |
--------------------------------------------------------------------------------
/test/dummy/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | Dummy::Application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb
3 |
4 | # In the development environment your application's code is reloaded on
5 | # every request. This slows down response time but is perfect for development
6 | # since you don't have to restart the web server when you make code changes.
7 | config.cache_classes = false
8 |
9 | # Log error messages when you accidentally call methods on nil.
10 | config.whiny_nils = true
11 |
12 | # Show full error reports and disable caching
13 | config.consider_all_requests_local = true
14 | config.action_controller.perform_caching = false
15 |
16 | # Don't care if the mailer can't send
17 | config.action_mailer.raise_delivery_errors = false
18 |
19 | # Print deprecation notices to the Rails logger
20 | config.active_support.deprecation = :log
21 |
22 | # Only use best-standards-support built into browsers
23 | config.action_dispatch.best_standards_support = :builtin
24 |
25 | # Raise exception on mass assignment protection for Active Record models
26 | config.active_record.mass_assignment_sanitizer = :strict
27 |
28 | # Log the query plan for queries taking more than this (works
29 | # with SQLite, MySQL, and PostgreSQL)
30 | config.active_record.auto_explain_threshold_in_seconds = 0.5
31 |
32 | # Do not compress assets
33 | config.assets.compress = false
34 |
35 | # Expands the lines which load the assets
36 | config.assets.debug = true
37 | end
38 |
--------------------------------------------------------------------------------
/test/dummy/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | Dummy::Application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb
3 |
4 | # Code is not reloaded between requests
5 | config.cache_classes = true
6 |
7 | # Full error reports are disabled and caching is turned on
8 | config.consider_all_requests_local = false
9 | config.action_controller.perform_caching = true
10 |
11 | # Disable Rails's static asset server (Apache or nginx will already do this)
12 | config.serve_static_assets = false
13 |
14 | # Compress JavaScripts and CSS
15 | config.assets.compress = true
16 |
17 | # Don't fallback to assets pipeline if a precompiled asset is missed
18 | config.assets.compile = false
19 |
20 | # Generate digests for assets URLs
21 | config.assets.digest = true
22 |
23 | # Defaults to nil and saved in location specified by config.assets.prefix
24 | # config.assets.manifest = YOUR_PATH
25 |
26 | # Specifies the header that your server uses for sending files
27 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
28 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
29 |
30 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31 | # config.force_ssl = true
32 |
33 | # See everything in the log (default is :info)
34 | # config.log_level = :debug
35 |
36 | # Prepend all log lines with the following tags
37 | # config.log_tags = [ :subdomain, :uuid ]
38 |
39 | # Use a different logger for distributed setups
40 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
41 |
42 | # Use a different cache store in production
43 | # config.cache_store = :mem_cache_store
44 |
45 | # Enable serving of images, stylesheets, and JavaScripts from an asset server
46 | # config.action_controller.asset_host = "http://assets.example.com"
47 |
48 | # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
49 | # config.assets.precompile += %w( search.js )
50 |
51 | # Disable delivery errors, bad email addresses will be ignored
52 | # config.action_mailer.raise_delivery_errors = false
53 |
54 | # Enable threaded mode
55 | # config.threadsafe!
56 |
57 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
58 | # the I18n.default_locale when a translation can not be found)
59 | config.i18n.fallbacks = true
60 |
61 | # Send deprecation notices to registered listeners
62 | config.active_support.deprecation = :notify
63 |
64 | # Log the query plan for queries taking more than this (works
65 | # with SQLite, MySQL, and PostgreSQL)
66 | # config.active_record.auto_explain_threshold_in_seconds = 0.5
67 | end
68 |
--------------------------------------------------------------------------------
/test/dummy/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | Dummy::Application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb
3 |
4 | # The test environment is used exclusively to run your application's
5 | # test suite. You never need to work with it otherwise. Remember that
6 | # your test database is "scratch space" for the test suite and is wiped
7 | # and recreated between test runs. Don't rely on the data there!
8 | config.cache_classes = true
9 |
10 | # Configure static asset server for tests with Cache-Control for performance
11 | config.serve_static_assets = true
12 | config.static_cache_control = "public, max-age=3600"
13 |
14 | # Log error messages when you accidentally call methods on nil
15 | config.whiny_nils = true
16 |
17 | # Show full error reports and disable caching
18 | config.consider_all_requests_local = true
19 | config.action_controller.perform_caching = false
20 |
21 | # Raise exceptions instead of rendering exception templates
22 | config.action_dispatch.show_exceptions = false
23 |
24 | # Disable request forgery protection in test environment
25 | config.action_controller.allow_forgery_protection = false
26 |
27 | # Tell Action Mailer not to deliver emails to the real world.
28 | # The :test delivery method accumulates sent emails in the
29 | # ActionMailer::Base.deliveries array.
30 | config.action_mailer.delivery_method = :test
31 |
32 | # Raise exception on mass assignment protection for Active Record models
33 | config.active_record.mass_assignment_sanitizer = :strict
34 |
35 | # Print deprecation notices to the stderr
36 | config.active_support.deprecation = :stderr
37 | end
38 |
--------------------------------------------------------------------------------
/test/dummy/config/initializers/ad_man.rb:
--------------------------------------------------------------------------------
1 | AdMan.leaderboard_size = "728x90"
2 | AdMan.banner_size = "468x60"
3 | AdMan.max_image_size = 50 # 50Kb maximum image size
4 |
5 | # TODO: Implement these other advertisement sizes
6 | # AdMan.mobile_leaderboard_size = "320x50"
7 | # AdMan.square_size = "250x250"
8 | # AdMan.small_square_size = "200x200"
9 | # AdMan.large_rectangle_size = "336x280"
10 | # AdMan.inline_rectangle_size = "300x250"
11 | # AdMan.skyscraper_size = "120x600"
12 | # AdMan.wide_skyscraper_size = "160x600"
13 |
14 | # These are configurable dimensions (currently leaderboard default)
15 | AdMan.image_dimensions_width = 728
16 | AdMan.image_dimensions_height = 90
17 |
18 | # Configurable content type for advertising
19 | AdMan.content_type = ["image/jpg", "image/bmp", "image/png", "image/gif", "image/jpeg"]
20 |
21 | # Configurable max advertising for keyword
22 | AdMan.max_count = 6
--------------------------------------------------------------------------------
/test/dummy/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
8 |
--------------------------------------------------------------------------------
/test/dummy/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format
4 | # (all these examples are active by default):
5 | # ActiveSupport::Inflector.inflections do |inflect|
6 | # inflect.plural /^(ox)$/i, '\1en'
7 | # inflect.singular /^(ox)en/i, '\1'
8 | # inflect.irregular 'person', 'people'
9 | # inflect.uncountable %w( fish sheep )
10 | # end
11 | #
12 | # These inflection rules are supported but not enabled by default:
13 | # ActiveSupport::Inflector.inflections do |inflect|
14 | # inflect.acronym 'RESTful'
15 | # end
16 |
--------------------------------------------------------------------------------
/test/dummy/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 | # Mime::Type.register_alias "text/html", :iphone
6 |
--------------------------------------------------------------------------------
/test/dummy/config/initializers/secret_token.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Your secret key for verifying the integrity of signed cookies.
4 | # If you change this key, all old signed cookies will become invalid!
5 | # Make sure the secret is at least 30 characters and all random,
6 | # no regular words or you'll be exposed to dictionary attacks.
7 | Dummy::Application.config.secret_token = 'dfadabd69a3c1d3100552c0380f309c796e70b8c7f37ebdba8cae430c5fb4e0f788ba29baf00bb88c52a31ddb8f16e6faeecb29ae1f0e5b2c7263f618fcdbe48'
8 |
--------------------------------------------------------------------------------
/test/dummy/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
4 |
5 | # Use the database for sessions instead of the cookie-based default,
6 | # which shouldn't be used to store highly confidential information
7 | # (create the session table with "rails generate session_migration")
8 | # Dummy::Application.config.session_store :active_record_store
9 |
--------------------------------------------------------------------------------
/test/dummy/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 | #
3 | # This file contains settings for ActionController::ParamsWrapper which
4 | # is enabled by default.
5 |
6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7 | ActiveSupport.on_load(:action_controller) do
8 | wrap_parameters format: [:json]
9 | end
10 |
11 | # Disable root element in JSON by default.
12 | ActiveSupport.on_load(:active_record) do
13 | self.include_root_in_json = false
14 | end
15 |
--------------------------------------------------------------------------------
/test/dummy/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Sample localization file for English. Add more files in this directory for other locales.
2 | # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3 |
4 | en:
5 | hello: "Hello world"
6 |
--------------------------------------------------------------------------------
/test/dummy/config/routes.rb:
--------------------------------------------------------------------------------
1 | Rails.application.routes.draw do
2 |
3 | mount AdMan::Engine => "/ad_man"
4 |
5 |
6 | end
7 |
--------------------------------------------------------------------------------
/test/dummy/db/schema.rb:
--------------------------------------------------------------------------------
1 | # encoding: UTF-8
2 | # This file is auto-generated from the current state of the database. Instead
3 | # of editing this file, please use the migrations feature of Active Record to
4 | # incrementally modify your database, and then regenerate this schema definition.
5 | #
6 | # Note that this schema.rb definition is the authoritative source for your
7 | # database schema. If you need to create the application database on another
8 | # system, you should be using db:schema:load, not running all the migrations
9 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10 | # you'll amass, the slower it'll run and the greater likelihood for issues).
11 | #
12 | # It's strongly recommended to check this file into your version control system.
13 |
14 | ActiveRecord::Schema.define(:version => 20120817083910) do
15 |
16 | create_table "ad_man_advertisements", :force => true do |t|
17 | t.string "title"
18 | t.string "destination_url"
19 | t.string "ad_banner_file_name"
20 | t.string "ad_banner_content_type"
21 | t.integer "ad_banner_file_size"
22 | t.datetime "ad_banner_updated_at"
23 | t.integer "display_count", :default => 0, :null => false
24 | t.integer "priority", :default => 1, :null => false
25 | t.date "start_date"
26 | t.date "end_date"
27 | t.integer "keyword_id"
28 | t.integer "click_count", :default => 0, :null => false
29 | t.datetime "created_at", :null => false
30 | t.datetime "updated_at", :null => false
31 | end
32 |
33 | create_table "ad_man_keywords", :force => true do |t|
34 | t.string "name"
35 | t.datetime "created_at", :null => false
36 | t.datetime "updated_at", :null => false
37 | end
38 |
39 | end
40 |
--------------------------------------------------------------------------------
/test/dummy/lib/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/lib/assets/.gitkeep
--------------------------------------------------------------------------------
/test/dummy/log/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/log/.gitkeep
--------------------------------------------------------------------------------
/test/dummy/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The page you were looking for doesn't exist (404)
5 |
17 |
18 |
19 |
20 |
21 |
22 |
The page you were looking for doesn't exist.
23 |
You may have mistyped the address or the page may have moved.