├── .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 | [![Build Status](https://secure.travis-ci.org/matenia/ad_man.png)](http://travis-ci.org/matenia/ad_man) 5 | [![Code Climate](https://codeclimate.com/badge.png)](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 |
  • <%= msg %>
  • 9 | <% end %> 10 |
11 |
12 | <% end %> 13 | 14 |
15 | <%= f.label :ad_banner, "Acceptable sizes: 728x90 or 468x60" %>
16 | <%= f.file_field :ad_banner %> 17 |
18 |

19 |
20 | <%= f.label :title %>
21 | <%= f.text_field :title %> 22 |

23 |
24 | <%= f.label :destination_url %>
25 | <%= f.url_field :destination_url %> 26 |

27 |
28 | <%= f.label :keyword %> 29 | <% if @advertisement.keyword %> 30 | 31 | <%= f.collection_select :keyword_id, AdMan::Keyword.available | [@advertisement.keyword], :id, :name, :include_blank => true %> 32 | <% else %> 33 | 34 | <%= f.collection_select :keyword_id, AdMan::Keyword.available, :id, :name, :include_blank => true %> 35 | <% end %> 36 | <% if AdMan::Keyword.unavailable.count > 0 %> 37 |

Warning: <%= AdMan::Keyword.unavailable.map(&:name) %> keyword has already been used <%= AdMan::Keyword::MAX_COUNT %> times.

38 | <% end %> 39 |
40 |
41 | 47 |
48 | <%= f.label :start_date %>
49 | <%= f.date_select :start_date %> 50 |

51 |
52 | <%= f.label :end_date %>
53 | <%= f.date_select :end_date, :default => 1.month.from_now %> 54 |

55 | 56 | 57 |
58 | <%= f.submit %> 59 |
60 | <% end %> 61 | 62 | 65 | -------------------------------------------------------------------------------- /app/views/ad_man/advertisements/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Editing advertisement

2 | 3 | <%= render 'form' %> 4 | 5 | <%= link_to 'Show', @advertisement %> | 6 | <%= link_to 'Back', advertisements_path %> 7 | -------------------------------------------------------------------------------- /app/views/ad_man/advertisements/get_ad.js.erb: -------------------------------------------------------------------------------- 1 | <% if @ad %> 2 | jQuery(<%= @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 %> 5 | -------------------------------------------------------------------------------- /app/views/ad_man/advertisements/index.html.erb: -------------------------------------------------------------------------------- 1 |

Advertisements

2 |
3 | <% if !@keywords.blank? %> 4 |
5 | <% if !@advertisements.blank? %> 6 | 7 | <% @advertisements.each do |advertisement| %> 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | <% end %> 16 |
<%= link_to advertisement.title, advertisement %><%= advertisement.destination_url%>
<%= link_to image_tag(advertisement.ad_banner.url(:banner)), advertisement %>
17 | <% else %> 18 |

You don't have any advertisements yet,
why don't you create one:

19 | <% end %> 20 | 21 | 24 | 25 |
26 | 27 |
28 |

Keywords

29 | <% if !@keywords.blank? %> 30 |

    31 | <% @keywords.each do |keyword| %> 32 |
  • <%= link_to keyword.name, keyword %>(<%= keyword.number_of_ads %>)
  • 33 | <% end %> 34 |

35 | <% else %> 36 | You don't have any keywords yet,
why don't you create one:

37 | <% end %> 38 |
39 | <%= button_to 'New Keyword', new_keyword_path, :method => :get %> 40 |
41 |
42 | 43 | <%= button_to 'New Advertisement', new_advertisement_path, :method => :get %> 44 | <% else %> 45 |

You don't have any keywords yet,
why don't you create one:

46 | 47 | <%= button_to 'New Keyword', new_keyword_path, :method => :get %> 48 | <% end %> -------------------------------------------------------------------------------- /app/views/ad_man/advertisements/new.html.erb: -------------------------------------------------------------------------------- 1 |

Upload a New Advertisement

2 | 3 | <%= render 'form' %> 4 | 5 | <%= link_to 'Back', advertisements_path %> 6 | -------------------------------------------------------------------------------- /app/views/ad_man/advertisements/show.html.erb: -------------------------------------------------------------------------------- 1 |

<%= notice %>

2 | 3 |

<%= @advertisement.title %>

4 | 5 |
6 |

7 | Leaderboard:   728x90
8 | <%= image_tag @advertisement.ad_banner.url(:leaderboard) %> 9 |

10 | Banner:   468x60
11 | <%= image_tag @advertisement.ad_banner.url(:banner) %>
12 |

13 |

14 | Keyword: 15 | <%= link_to @advertisement.keyword.name, @advertisement.keyword %> 16 |

17 |

18 | Page Views: 19 | <%= @advertisement.display_count %> 20 |

21 |

22 | Clicks: 23 | <%= @advertisement.click_count %> 24 |

25 |

26 | File Size: 27 | <%= number_to_human_size(@advertisement.ad_banner.size) %> 28 |

29 |

30 | Destination url: 31 | <%= link_to @advertisement.destination_url, @advertisement.destination_url %> 32 |

33 |
34 |
35 | <%= link_to 'Edit', edit_advertisement_path(@advertisement), :method => :get %> 36 | <%= link_to "Destroy", @advertisement, :method => :delete, 37 | :data => { :confirm => "Deleting Advertisement, this cannot be undone. Please confirm."}, :style => "color:#b94a48"%> 38 | <%= link_to 'Back', advertisements_path, :method => :get %> 39 |
40 | -------------------------------------------------------------------------------- /app/views/ad_man/keywords/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_for(@keyword) do |f| %> 2 | <% if @keyword.errors.any? %> 3 |
4 |

<%= pluralize(@keyword.errors.count, "error") %> prohibited this advertisement from being saved:

5 | 6 |
    7 | <% @keyword.errors.full_messages.each do |msg| %> 8 |
  • <%= msg %>
  • 9 | <% end %> 10 |
11 |
12 | <% end %> 13 | 14 |
15 | <%= f.label :name %>
16 | <%= f.text_field :name %> 17 |

18 | 19 |
20 | <%= f.submit %> 21 |
22 | <% end %> 23 | -------------------------------------------------------------------------------- /app/views/ad_man/keywords/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Editing keyword

2 | 3 | <%= render 'form' %> 4 | 5 | <%= link_to 'Show', @keyword %> | 6 | <%= link_to 'Back', keywords_path %> 7 | -------------------------------------------------------------------------------- /app/views/ad_man/keywords/index.html.erb: -------------------------------------------------------------------------------- 1 |

Current Keywords

2 |
3 | 4 | <% @keywords.each do |keyword| %> 5 | 6 | 7 | 8 | <% end %> 9 |
<%= link_to keyword.name, keyword %>
10 |
11 | <%= button_to 'New Keyword', new_keyword_path, :method => :get %> 12 |
13 |
14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/views/ad_man/keywords/new.html.erb: -------------------------------------------------------------------------------- 1 |

New keyword

2 | 3 | <%= render 'form' %> 4 | 5 | <%= link_to 'Back', advertisements_path %> 6 | -------------------------------------------------------------------------------- /app/views/ad_man/keywords/show.html.erb: -------------------------------------------------------------------------------- 1 |

<%= notice %>

2 | 3 |

Keyword: <%= @keyword %>

4 | 5 |
6 |
7 | 8 | <% @advertisements.each do |advertisement| %> 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | <% end %> 17 |
<%= link_to advertisement.title, advertisement %><%= advertisement.destination_url%>
<%= link_to image_tag(advertisement.ad_banner.url(:banner)), advertisement %>
18 |
19 | 20 |
21 | <%= link_to "All Advertisements", advertisements_path %>

22 | <%= button_to "New Advertisement", new_advertisement_path, :method => :get %> 23 |

Current Keywords

24 |

    25 | <% @keywords.each do |keyword| %> 26 |
  • <%= link_to keyword.name, keyword %>(<%= keyword.number_of_ads %>)
  • 27 | <% end %> 28 |

    29 |
30 |
31 |
32 |
33 | 34 |
35 | <%= link_to 'Edit Keyword', edit_keyword_path(@keyword), :method => :get %> 36 | <%= link_to "Destroy", @keyword, :method => :delete, 37 | :data => {:confirm => "Deleting Keyword, this cannot be undone. WARNING: This will delete all advertisements connected with this keyword. Please confirm."}, :style => "color:#b94a48"%> 38 | <%= link_to 'Back', advertisements_path, :method => :get %> 39 |
40 | -------------------------------------------------------------------------------- /app/views/layouts/ad_man/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AdMan 5 | <%= stylesheet_link_tag "ad_man/application", :media => "all" %> 6 | <%= javascript_include_tag "ad_man/application" %> 7 | <%= javascript_include_tag "ad_man/advertisements.js" %> 8 | <%= csrf_meta_tags %> 9 | 10 | 11 | 12 | <%= yield %> 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | AdMan::Engine.routes.draw do 2 | resources :keywords 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 | 10 | root :to => "advertisements#index" 11 | 12 | end 13 | -------------------------------------------------------------------------------- /db/migrate/20120808085322_create_ad_man_advertisements.rb: -------------------------------------------------------------------------------- 1 | class CreateAdManAdvertisements < ActiveRecord::Migration 2 | def change 3 | create_table :ad_man_advertisements do |t| 4 | t.string :title 5 | t.string :destination_url 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 13 | t.timestamps 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /db/migrate/20120808091446_create_ad_man_keywords.rb: -------------------------------------------------------------------------------- 1 | class CreateAdManKeywords < ActiveRecord::Migration 2 | def change 3 | create_table :ad_man_keywords do |t| 4 | t.string :name 5 | t.timestamps 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /doc/AdMan/AdvertisementTest.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | class AdMan::AdvertisementTest - RDoc Documentation 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 151 | 152 |
153 |

class AdMan::AdvertisementTest

154 | 155 |
156 | 157 |
158 | 159 | 160 | 161 | 162 |
163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 |
174 | 175 |
176 | 177 | 178 | 183 | 184 | -------------------------------------------------------------------------------- /doc/AdMan/AdvertisementsControllerTest.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | class AdMan::AdvertisementsControllerTest - RDoc Documentation 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 151 | 152 |
153 |

class AdMan::AdvertisementsControllerTest

154 | 155 |
156 | 157 |
158 | 159 | 160 | 161 | 162 |
163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 |
174 | 175 |
176 | 177 | 178 | 183 | 184 | -------------------------------------------------------------------------------- /doc/AdMan/AdvertisementsHelper.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | module AdMan::AdvertisementsHelper - RDoc Documentation 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 145 | 146 |
147 |

module AdMan::AdvertisementsHelper

148 | 149 |
150 | 151 |
152 | 153 | 154 | 155 | 156 |
157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 |
168 | 169 |
170 | 171 | 172 | 177 | 178 | -------------------------------------------------------------------------------- /doc/AdMan/AdvertisementsHelperTest.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | class AdMan::AdvertisementsHelperTest - RDoc Documentation 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 151 | 152 |
153 |

class AdMan::AdvertisementsHelperTest

154 | 155 |
156 | 157 |
158 | 159 | 160 | 161 | 162 |
163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 |
174 | 175 |
176 | 177 | 178 | 183 | 184 | -------------------------------------------------------------------------------- /doc/AdMan/ApplicationController.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | class AdMan::ApplicationController - RDoc Documentation 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 151 | 152 |
153 |

class AdMan::ApplicationController

154 | 155 |
156 | 157 |
158 | 159 | 160 | 161 | 162 |
163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 |
174 | 175 |
176 | 177 | 178 | 183 | 184 | -------------------------------------------------------------------------------- /doc/AdMan/Engine.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | class AdMan::Engine - RDoc Documentation 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 151 | 152 |
153 |

class AdMan::Engine

154 | 155 |
156 | 157 |
158 | 159 | 160 | 161 | 162 |
163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 |
174 | 175 |
176 | 177 | 178 | 183 | 184 | -------------------------------------------------------------------------------- /doc/AdMan/KeywordTest.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | class AdMan::KeywordTest - RDoc Documentation 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 151 | 152 |
153 |

class AdMan::KeywordTest

154 | 155 |
156 | 157 |
158 | 159 | 160 | 161 | 162 |
163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 |
174 | 175 |
176 | 177 | 178 | 183 | 184 | -------------------------------------------------------------------------------- /doc/AdMan/KeywordsControllerTest.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | class AdMan::KeywordsControllerTest - RDoc Documentation 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 151 | 152 |
153 |

class AdMan::KeywordsControllerTest

154 | 155 |
156 | 157 |
158 | 159 | 160 | 161 | 162 |
163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 |
174 | 175 |
176 | 177 | 178 | 183 | 184 | -------------------------------------------------------------------------------- /doc/AdMan/KeywordsHelper.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | module AdMan::KeywordsHelper - RDoc Documentation 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 145 | 146 |
147 |

module AdMan::KeywordsHelper

148 | 149 |
150 | 151 |
152 | 153 | 154 | 155 | 156 |
157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 |
168 | 169 |
170 | 171 | 172 | 177 | 178 | -------------------------------------------------------------------------------- /doc/AdMan/KeywordsHelperTest.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | class AdMan::KeywordsHelperTest - RDoc Documentation 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 151 | 152 |
153 |

class AdMan::KeywordsHelperTest

154 | 155 |
156 | 157 |
158 | 159 | 160 | 161 | 162 |
163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 |
174 | 175 |
176 | 177 | 178 | 183 | 184 | -------------------------------------------------------------------------------- /doc/AdManTest.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | class AdManTest - RDoc Documentation 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 151 | 152 |
153 |

class AdManTest

154 | 155 |
156 | 157 |
158 | 159 | 160 | 161 | 162 |
163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 |
174 | 175 |
176 | 177 | 178 | 183 | 184 | -------------------------------------------------------------------------------- /doc/ApplicationController.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | class ApplicationController - RDoc Documentation 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 151 | 152 |
153 |

class ApplicationController

154 | 155 |
156 | 157 |
158 | 159 | 160 | 161 | 162 |
163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 |
174 | 175 |
176 | 177 | 178 | 183 | 184 | -------------------------------------------------------------------------------- /doc/ApplicationHelper.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | module ApplicationHelper - RDoc Documentation 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 145 | 146 |
147 |

module ApplicationHelper

148 | 149 |
150 | 151 |
152 | 153 | 154 | 155 | 156 |
157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 |
168 | 169 |
170 | 171 | 172 | 177 | 178 | -------------------------------------------------------------------------------- /doc/Dummy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | module Dummy - RDoc Documentation 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 145 | 146 |
147 |

module Dummy

148 | 149 |
150 | 151 |
152 | 153 | 154 | 155 | 156 |
157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 |
168 | 169 |
170 | 171 | 172 | 177 | 178 | -------------------------------------------------------------------------------- /doc/Dummy/Application.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | class Dummy::Application - RDoc Documentation 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 151 | 152 |
153 |

class Dummy::Application

154 | 155 |
156 | 157 |
158 | 159 | 160 | 161 | 162 |
163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 |
174 | 175 |
176 | 177 | 178 | 183 | 184 | -------------------------------------------------------------------------------- /doc/Gemfile.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Gemfile - RDoc Documentation 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 127 | 128 |
129 | 130 |

source “rubygems.org

131 | 132 |

# 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.

144 | 145 |

# To use debugger # gem ‘debugger’

146 | 147 |
148 | 149 | 150 | 151 | 156 | 157 | -------------------------------------------------------------------------------- /doc/NavigationTest.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | class NavigationTest - RDoc Documentation 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 151 | 152 |
153 |

class NavigationTest

154 | 155 |
156 | 157 |
158 | 159 | 160 | 161 | 162 |
163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 |
174 | 175 |
176 | 177 | 178 | 183 | 184 | -------------------------------------------------------------------------------- /doc/created.rid: -------------------------------------------------------------------------------- 1 | Mon, 13 Aug 2012 18:14:26 +0800 2 | ./app/controllers/ad_man/advertisements_controller.rb Mon, 13 Aug 2012 12:24:10 +0800 3 | ./app/controllers/ad_man/application_controller.rb Wed, 08 Aug 2012 16:44:50 +0800 4 | ./app/controllers/ad_man/keywords_controller.rb Thu, 09 Aug 2012 14:38:57 +0800 5 | ./app/helpers/ad_man/advertisements_helper.rb Wed, 08 Aug 2012 16:53:22 +0800 6 | ./app/helpers/ad_man/application_helper.rb Mon, 13 Aug 2012 17:54:05 +0800 7 | ./app/helpers/ad_man/keywords_helper.rb Wed, 08 Aug 2012 17:34:42 +0800 8 | ./app/models/ad_man/advertisement.rb Fri, 10 Aug 2012 11:47:39 +0800 9 | ./app/models/ad_man/keyword.rb Fri, 10 Aug 2012 12:05:14 +0800 10 | ./config/routes.rb Thu, 09 Aug 2012 16:05:13 +0800 11 | ./db/migrate/20120808085322_create_ad_man_advertisements.rb Mon, 13 Aug 2012 11:05:27 +0800 12 | ./db/migrate/20120808091446_create_ad_man_keywords.rb Mon, 13 Aug 2012 11:05:27 +0800 13 | ./Gemfile Wed, 08 Aug 2012 16:55:47 +0800 14 | ./lib/ad_man/engine.rb Wed, 08 Aug 2012 17:49:10 +0800 15 | ./lib/ad_man/version.rb Mon, 13 Aug 2012 17:55:30 +0800 16 | ./lib/ad_man.rb Thu, 09 Aug 2012 14:56:19 +0800 17 | ./lib/generators/ad_man/install_generator.rb Fri, 10 Aug 2012 15:11:13 +0800 18 | ./MIT-LICENSE Wed, 08 Aug 2012 16:44:50 +0800 19 | ./Rakefile Wed, 08 Aug 2012 16:44:50 +0800 20 | ./script/rails Wed, 08 Aug 2012 16:44:50 +0800 21 | ./test/ad_man_test.rb Thu, 09 Aug 2012 13:20:04 +0800 22 | ./test/dummy/app/controllers/application_controller.rb Thu, 09 Aug 2012 13:20:04 +0800 23 | ./test/dummy/app/helpers/application_helper.rb Thu, 09 Aug 2012 13:20:04 +0800 24 | ./test/dummy/config/application.rb Thu, 09 Aug 2012 13:20:04 +0800 25 | ./test/dummy/config/boot.rb Thu, 09 Aug 2012 13:20:04 +0800 26 | ./test/dummy/config/environment.rb Thu, 09 Aug 2012 13:20:04 +0800 27 | ./test/dummy/config/environments/development.rb Thu, 09 Aug 2012 13:20:04 +0800 28 | ./test/dummy/config/environments/production.rb Thu, 09 Aug 2012 13:20:04 +0800 29 | ./test/dummy/config/environments/test.rb Thu, 09 Aug 2012 13:20:04 +0800 30 | ./test/dummy/config/initializers/ad_man.rb Thu, 09 Aug 2012 14:56:55 +0800 31 | ./test/dummy/config/initializers/backtrace_silencers.rb Thu, 09 Aug 2012 13:20:04 +0800 32 | ./test/dummy/config/initializers/inflections.rb Thu, 09 Aug 2012 13:20:04 +0800 33 | ./test/dummy/config/initializers/mime_types.rb Thu, 09 Aug 2012 13:20:04 +0800 34 | ./test/dummy/config/initializers/secret_token.rb Thu, 09 Aug 2012 13:20:04 +0800 35 | ./test/dummy/config/initializers/session_store.rb Thu, 09 Aug 2012 13:20:04 +0800 36 | ./test/dummy/config/initializers/wrap_parameters.rb Thu, 09 Aug 2012 13:20:04 +0800 37 | ./test/dummy/config/routes.rb Thu, 09 Aug 2012 15:53:34 +0800 38 | ./test/dummy/db/schema.rb Thu, 09 Aug 2012 15:28:09 +0800 39 | ./test/dummy/Rakefile Thu, 09 Aug 2012 13:20:04 +0800 40 | ./test/dummy/README.rdoc Thu, 09 Aug 2012 13:20:04 +0800 41 | ./test/dummy/script/rails Thu, 09 Aug 2012 13:20:04 +0800 42 | ./test/dummy/tmp/cache/assets/C02/0A0/sprockets%2F625bdc26802f8c498265353870490587 Wed, 08 Aug 2012 17:41:03 +0800 43 | ./test/dummy/tmp/cache/assets/CC8/220/sprockets%2F234102a39a522cfab9195fd0d7c12640 Mon, 13 Aug 2012 15:38:44 +0800 44 | ./test/dummy/tmp/cache/assets/CD6/A60/sprockets%2Fcca4c63026454615fd0a54b65b881d64 Mon, 13 Aug 2012 15:38:44 +0800 45 | ./test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 Thu, 09 Aug 2012 14:02:04 +0800 46 | ./test/dummy/tmp/cache/assets/CE4/9E0/sprockets%2F3f5956491fde7227a651e20e4d756b1a Wed, 08 Aug 2012 17:41:03 +0800 47 | ./test/dummy/tmp/cache/assets/D31/910/sprockets%2Fc1c18d3d756fe2777d18b236a0aea400 Wed, 08 Aug 2012 17:41:03 +0800 48 | ./test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 Thu, 09 Aug 2012 14:02:04 +0800 49 | ./test/dummy/tmp/cache/assets/D3A/220/sprockets%2Fce53c5b352a83645d36d96aff26020fb Wed, 08 Aug 2012 18:40:49 +0800 50 | ./test/dummy/tmp/cache/assets/D3E/AF0/sprockets%2F317881d54abbd5721deee7d204e70e66 Wed, 08 Aug 2012 18:40:49 +0800 51 | ./test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 Mon, 13 Aug 2012 15:38:44 +0800 52 | ./test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 Thu, 09 Aug 2012 14:02:04 +0800 53 | ./test/dummy/tmp/cache/assets/D79/2D0/sprockets%2F0d684f7bbe7d675f000dff8821d90ae8 Mon, 13 Aug 2012 15:38:44 +0800 54 | ./test/dummy/tmp/cache/assets/DBA/3C0/sprockets%2F9ca84f8118d29c3fd7bfd2876f83dc7e Wed, 08 Aug 2012 17:41:03 +0800 55 | ./test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 Wed, 08 Aug 2012 17:41:03 +0800 56 | ./test/dummy/tmp/cache/assets/DF7/090/sprockets%2Fb3b1a32b0f923d6741fd5dacdf9f59ab Wed, 08 Aug 2012 18:40:49 +0800 57 | ./test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af Mon, 13 Aug 2012 15:38:44 +0800 58 | ./test/dummy/tmp/cache/assets/E56/460/sprockets%2F5dde4d3dd93c8afa78eb0ba3fb55c20c Mon, 13 Aug 2012 15:38:44 +0800 59 | ./test/functional/ad_man/advertisements_controller_test.rb Fri, 10 Aug 2012 11:55:58 +0800 60 | ./test/functional/ad_man/keywords_controller_test.rb Thu, 09 Aug 2012 13:20:04 +0800 61 | ./test/integration/navigation_test.rb Thu, 09 Aug 2012 13:20:04 +0800 62 | ./test/test_helper.rb Fri, 10 Aug 2012 12:42:03 +0800 63 | ./test/unit/ad_man/advertisement_test.rb Fri, 10 Aug 2012 15:01:58 +0800 64 | ./test/unit/ad_man/keyword_test.rb Fri, 10 Aug 2012 12:11:30 +0800 65 | ./test/unit/helpers/ad_man/advertisements_helper_test.rb Thu, 09 Aug 2012 13:20:04 +0800 66 | ./test/unit/helpers/ad_man/keywords_helper_test.rb Thu, 09 Aug 2012 13:20:04 +0800 67 | -------------------------------------------------------------------------------- /doc/images/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/doc/images/add.png -------------------------------------------------------------------------------- /doc/images/brick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/doc/images/brick.png -------------------------------------------------------------------------------- /doc/images/brick_link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/doc/images/brick_link.png -------------------------------------------------------------------------------- /doc/images/bug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/doc/images/bug.png -------------------------------------------------------------------------------- /doc/images/bullet_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/doc/images/bullet_black.png -------------------------------------------------------------------------------- /doc/images/bullet_toggle_minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/doc/images/bullet_toggle_minus.png -------------------------------------------------------------------------------- /doc/images/bullet_toggle_plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/doc/images/bullet_toggle_plus.png -------------------------------------------------------------------------------- /doc/images/date.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/doc/images/date.png -------------------------------------------------------------------------------- /doc/images/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/doc/images/delete.png -------------------------------------------------------------------------------- /doc/images/find.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/doc/images/find.png -------------------------------------------------------------------------------- /doc/images/loadingAnimation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/doc/images/loadingAnimation.gif -------------------------------------------------------------------------------- /doc/images/macFFBgHack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/doc/images/macFFBgHack.png -------------------------------------------------------------------------------- /doc/images/package.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/doc/images/package.png -------------------------------------------------------------------------------- /doc/images/page_green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/doc/images/page_green.png -------------------------------------------------------------------------------- /doc/images/page_white_text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/doc/images/page_white_text.png -------------------------------------------------------------------------------- /doc/images/page_white_width.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/doc/images/page_white_width.png -------------------------------------------------------------------------------- /doc/images/plugin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/doc/images/plugin.png -------------------------------------------------------------------------------- /doc/images/ruby.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/doc/images/ruby.png -------------------------------------------------------------------------------- /doc/images/tag_blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/doc/images/tag_blue.png -------------------------------------------------------------------------------- /doc/images/tag_green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/doc/images/tag_green.png -------------------------------------------------------------------------------- /doc/images/transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/doc/images/transparent.png -------------------------------------------------------------------------------- /doc/images/wrench.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/doc/images/wrench.png -------------------------------------------------------------------------------- /doc/images/wrench_orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/doc/images/wrench_orange.png -------------------------------------------------------------------------------- /doc/images/zoom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/doc/images/zoom.png -------------------------------------------------------------------------------- /doc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | RDoc Documentation 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 127 | 128 |

This is the API documentation for RDoc Documentation. 129 | 130 | 131 |

136 | 137 | -------------------------------------------------------------------------------- /doc/js/darkfish.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * Darkfish Page Functions 4 | * $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $ 5 | * 6 | * Author: Michael Granger 7 | * 8 | */ 9 | 10 | /* Provide console simulation for firebug-less environments */ 11 | if (!("console" in window) || !("firebug" in console)) { 12 | var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", 13 | "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; 14 | 15 | window.console = {}; 16 | for (var i = 0; i < names.length; ++i) 17 | window.console[names[i]] = function() {}; 18 | }; 19 | 20 | 21 | /** 22 | * Unwrap the first element that matches the given @expr@ from the targets and return them. 23 | */ 24 | $.fn.unwrap = function( expr ) { 25 | return this.each( function() { 26 | $(this).parents( expr ).eq( 0 ).after( this ).remove(); 27 | }); 28 | }; 29 | 30 | 31 | function showSource( e ) { 32 | var target = e.target; 33 | var codeSections = $(target). 34 | parents('.method-detail'). 35 | find('.method-source-code'); 36 | 37 | $(target). 38 | parents('.method-detail'). 39 | find('.method-source-code'). 40 | slideToggle(); 41 | }; 42 | 43 | function hookSourceViews() { 44 | $('.method-heading').click( showSource ); 45 | }; 46 | 47 | function toggleDebuggingSection() { 48 | $('.debugging-section').slideToggle(); 49 | }; 50 | 51 | function hookDebuggingToggle() { 52 | $('#debugging-toggle img').click( toggleDebuggingSection ); 53 | }; 54 | 55 | function hookTableOfContentsToggle() { 56 | $('.indexpage li .toc-toggle').each( function() { 57 | $(this).click( function() { 58 | $(this).toggleClass('open'); 59 | }); 60 | 61 | var section = $(this).next(); 62 | 63 | $(this).click( function() { 64 | section.slideToggle(); 65 | }); 66 | }); 67 | } 68 | 69 | function hookSearch() { 70 | var input = $('#search-field').eq(0); 71 | var result = $('#search-results').eq(0); 72 | $(result).show(); 73 | 74 | var search_section = $('#search-section').get(0); 75 | $(search_section).show(); 76 | 77 | var search = new Search(search_data, input, result); 78 | 79 | search.renderItem = function(result) { 80 | var li = document.createElement('li'); 81 | var html = ''; 82 | 83 | // TODO add relative path to 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 127 | 128 |
129 | 130 |

#!/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.

133 | 134 |

require File.expand_path(‘../config/application’, __FILE__)

135 | 136 |

Dummy::Application.load_tasks

137 | 138 |
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.

24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /test/dummy/public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 17 | 18 | 19 | 20 | 21 |
22 |

The change you wanted was rejected.

23 |

Maybe you tried to change something you didn't have access to.

24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /test/dummy/public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 17 | 18 | 19 | 20 | 21 |
22 |

We're sorry, but something went wrong.

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /test/dummy/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/public/favicon.ico -------------------------------------------------------------------------------- /test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/banner/1-NR-728x90-cool-b.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/banner/1-NR-728x90-cool-b.gif -------------------------------------------------------------------------------- /test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/leaderboard/1-NR-728x90-cool-b.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/leaderboard/1-NR-728x90-cool-b.gif -------------------------------------------------------------------------------- /test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/original/1-NR-728x90-cool-b.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/original/1-NR-728x90-cool-b.gif -------------------------------------------------------------------------------- /test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/original/FabTable_01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/original/FabTable_01.jpg -------------------------------------------------------------------------------- /test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/original/test.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/original/test.jpeg -------------------------------------------------------------------------------- /test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/small/FabTable_01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/001/small/FabTable_01.jpg -------------------------------------------------------------------------------- /test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/banner/61f8516ab0e6471b99443e17bf7533d5.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/banner/61f8516ab0e6471b99443e17bf7533d5.jpeg -------------------------------------------------------------------------------- /test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/leaderboard/61f8516ab0e6471b99443e17bf7533d5.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/leaderboard/61f8516ab0e6471b99443e17bf7533d5.jpeg -------------------------------------------------------------------------------- /test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/original/61f8516ab0e6471b99443e17bf7533d5.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/original/61f8516ab0e6471b99443e17bf7533d5.jpeg -------------------------------------------------------------------------------- /test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/original/728x90_2MM.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/original/728x90_2MM.jpg -------------------------------------------------------------------------------- /test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/original/d893babe671c41118c1fece177e0a21a.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/original/d893babe671c41118c1fece177e0a21a.jpeg -------------------------------------------------------------------------------- /test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/small/728x90_2MM.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/small/728x90_2MM.jpg -------------------------------------------------------------------------------- /test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/small/d893babe671c41118c1fece177e0a21a.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/002/small/d893babe671c41118c1fece177e0a21a.jpeg -------------------------------------------------------------------------------- /test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/014/banner/1-NR-728x90-cool-b.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/014/banner/1-NR-728x90-cool-b.gif -------------------------------------------------------------------------------- /test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/014/leaderboard/1-NR-728x90-cool-b.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/014/leaderboard/1-NR-728x90-cool-b.gif -------------------------------------------------------------------------------- /test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/014/original/1-NR-728x90-cool-b.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/014/original/1-NR-728x90-cool-b.gif -------------------------------------------------------------------------------- /test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/015/banner/9241eb4107b24c588c0ca0042534c03e.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/015/banner/9241eb4107b24c588c0ca0042534c03e.png -------------------------------------------------------------------------------- /test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/015/leaderboard/9241eb4107b24c588c0ca0042534c03e.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/015/leaderboard/9241eb4107b24c588c0ca0042534c03e.png -------------------------------------------------------------------------------- /test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/015/original/9241eb4107b24c588c0ca0042534c03e.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/015/original/9241eb4107b24c588c0ca0042534c03e.png -------------------------------------------------------------------------------- /test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/016/banner/d893babe671c41118c1fece177e0a21a.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/016/banner/d893babe671c41118c1fece177e0a21a.jpeg -------------------------------------------------------------------------------- /test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/016/leaderboard/d893babe671c41118c1fece177e0a21a.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/016/leaderboard/d893babe671c41118c1fece177e0a21a.jpeg -------------------------------------------------------------------------------- /test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/016/original/d893babe671c41118c1fece177e0a21a.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/dummy/public/system/ad_man/advertisements/ad_banners/000/000/016/original/d893babe671c41118c1fece177e0a21a.jpeg -------------------------------------------------------------------------------- /test/dummy/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 | APP_PATH = File.expand_path('../../config/application', __FILE__) 5 | require File.expand_path('../../config/boot', __FILE__) 6 | require 'rails/commands' 7 | -------------------------------------------------------------------------------- /test/fixtures/ad_man/advertisements.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html 2 | 3 | rubyonrails: 4 | id: 1 5 | title: Ruby on Rails 6 | destination_url: http://www.rubyonrails.org 7 | keyword_id: 1 8 | 9 | google: 10 | id: 2 11 | title: Google 12 | destination_url: http://www.google.com -------------------------------------------------------------------------------- /test/fixtures/ad_man/keywords.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html 2 | 3 | test_keyword: 4 | id: 1 5 | name: test 6 | 7 | one: 8 | name: FirstKeyword 9 | 10 | two: 11 | name: MyString 12 | -------------------------------------------------------------------------------- /test/fixtures/mrec.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/fixtures/mrec.jpg -------------------------------------------------------------------------------- /test/fixtures/test.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/fixtures/test.jpeg -------------------------------------------------------------------------------- /test/fixtures/top_daintiness.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kudelabs/ad_man/9b9eaffd2b42ba67e4a61c4f619e5ee73b6cefd4/test/fixtures/top_daintiness.jpeg -------------------------------------------------------------------------------- /test/functional/ad_man/advertisements_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | module AdMan 4 | class AdvertisementsControllerTest < ActionController::TestCase 5 | 6 | setup do 7 | @advertisement = ad_man_advertisements(:rubyonrails) 8 | @routes = AdMan::Engine.routes 9 | end 10 | 11 | test "should get index" do 12 | get :index 13 | assert_response :success 14 | assert_not_nil assigns(:advertisements) 15 | assert_not_nil assigns(:keywords) 16 | end 17 | 18 | test "should get new" do 19 | get :new 20 | assert_response :success 21 | end 22 | 23 | test "should create advertisement" do 24 | assert_difference('Advertisement.count') do 25 | post :create, advertisement: { 26 | destination_url: "http://stackoverflow.com/", 27 | title: "UniqueTitle", 28 | ad_banner: fixture_file_upload("/test.jpeg","image/jpeg"), 29 | display_count: 0, 30 | click_count: 0, 31 | priority: 1 32 | }, keyword_id: 1 33 | end 34 | 35 | assert_redirected_to advertisement_path(assigns(:advertisement)) 36 | end 37 | 38 | test "should show advertisement" do 39 | get :show, id: @advertisement 40 | assert_response :success 41 | end 42 | 43 | test "should get edit" do 44 | get :edit, id: @advertisement 45 | assert_response :success 46 | end 47 | 48 | test "should update advertisement" do 49 | put :update, id: @advertisement, advertisement: { 50 | destination_url: "http://stackoverflow.com/", 51 | title: "UniqueTitle", 52 | ad_banner: fixture_file_upload("/test.jpeg","image/jpeg"), 53 | display_count: 0, 54 | click_count: 0, 55 | priority: 1 56 | }, keyword_id: 1 57 | assert_redirected_to advertisement_path(assigns(:advertisement)) 58 | end 59 | 60 | test "should destroy advertisement" do 61 | assert_difference('Advertisement.count', -1) do 62 | delete :destroy, id: @advertisement 63 | end 64 | 65 | assert_redirected_to advertisements_path 66 | end 67 | 68 | test "should redirect on click through" do 69 | get :click_through, id: @advertisement.id 70 | assert_redirected_to @advertisement.destination_url 71 | end 72 | end 73 | end 74 | -------------------------------------------------------------------------------- /test/functional/ad_man/keywords_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | module AdMan 4 | class KeywordsControllerTest < ActionController::TestCase 5 | setup do 6 | @keyword = ad_man_keywords(:one) 7 | @routes = AdMan::Engine.routes 8 | end 9 | 10 | test "should get index" do 11 | get :index 12 | assert_response :success 13 | assert_not_nil assigns(:keywords) 14 | end 15 | 16 | test "should get new" do 17 | get :new 18 | assert_response :success 19 | end 20 | 21 | test "should create keyword" do 22 | assert_difference('Keyword.count') do 23 | post :create, keyword: { name: 'RandomName' } 24 | end 25 | assert_redirected_to advertisements_path 26 | end 27 | 28 | test "should show keyword" do 29 | get :show, id: @keyword 30 | assert_response :success 31 | end 32 | 33 | test "should get edit" do 34 | get :edit, id: @keyword 35 | assert_response :success 36 | end 37 | 38 | test "should update keyword" do 39 | put :update, id: @keyword, keyword: { name: @keyword.name } 40 | assert_redirected_to advertisements_path 41 | end 42 | 43 | test "should destroy keyword" do 44 | assert_difference('Keyword.count', -1) do 45 | delete :destroy, id: @keyword 46 | end 47 | assert_redirected_to advertisements_path 48 | end 49 | end 50 | end 51 | -------------------------------------------------------------------------------- /test/integration/navigation_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class NavigationTest < ActionDispatch::IntegrationTest 4 | fixtures :all 5 | 6 | # test "the truth" do 7 | # assert true 8 | # end 9 | end 10 | 11 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | # Configure Rails Environment 3 | ENV["RAILS_ENV"] = "test" 4 | require File.expand_path("../dummy/config/environment.rb", __FILE__) 5 | require "rails/test_help" 6 | 7 | Rails.backtrace_cleaner.remove_silencers! 8 | 9 | # Load support files 10 | Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } 11 | 12 | if ActiveSupport::TestCase.method_defined?(:fixture_path=) 13 | ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__) 14 | end 15 | 16 | def sample_file(filename = "test.jpeg") 17 | File.new("#{AdMan::Engine.root}/test/fixtures/#{filename}") 18 | end 19 | 20 | class ActiveSupport::TestCase 21 | fixtures :all 22 | end 23 | 24 | -------------------------------------------------------------------------------- /test/unit/ad_man/advertisement_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | module AdMan 4 | class AdvertisementTest < ActiveSupport::TestCase 5 | 6 | test "should not save advertisement without keyword" do 7 | advertisement = Advertisement.new 8 | advertisement.ad_banner = sample_file 9 | assert !advertisement.keyword_id, "must have a keyword_id association" 10 | assert !advertisement.save, "should not save without keyword_id" 11 | end 12 | 13 | test "properly save without destination_url and title" do 14 | advertisement = Advertisement.new 15 | advertisement.ad_banner = sample_file 16 | keyword = Keyword.new 17 | keyword.name = "Test" 18 | keyword.save 19 | advertisement.keyword_id = keyword.id 20 | assert !advertisement.save, "should not save without destination_url and title" 21 | end 22 | 23 | test "properly save" do 24 | advertisement = Advertisement.new 25 | advertisement.ad_banner = sample_file 26 | keyword = Keyword.new 27 | keyword.name = "Test" 28 | assert_nothing_raised do 29 | keyword.save! 30 | end 31 | advertisement.keyword_id = keyword.id 32 | advertisement.title = "test" 33 | advertisement.destination_url = "test.com" 34 | assert advertisement.save, "is this valid information?" 35 | end 36 | 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /test/unit/ad_man/keyword_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | module AdMan 4 | class KeywordTest < ActiveSupport::TestCase 5 | test "should not save keyword without name" do 6 | keyword = AdMan::Keyword.new 7 | assert !keyword.save, "Saved the post without a keyword name" 8 | end 9 | end 10 | 11 | end 12 | -------------------------------------------------------------------------------- /test/unit/helpers/ad_man/advertisements_helper_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | module AdMan 4 | class AdvertisementsHelperTest < ActionView::TestCase 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /test/unit/helpers/ad_man/keywords_helper_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | module AdMan 4 | class KeywordsHelperTest < ActionView::TestCase 5 | end 6 | end 7 | --------------------------------------------------------------------------------