remove advertisement code

This commit is contained in:
r888888888 2017-02-21 13:33:20 -08:00
parent f4d9f76646
commit 6c9d5e4f9a
24 changed files with 1 additions and 704 deletions

View File

@ -1,12 +0,0 @@
class AdvertisementHitsController < ApplicationController
def create
advertisement = Advertisement.find(params[:advertisement_id])
advertisement.hits.create(:ip_addr => request.remote_ip)
redirect_to advertisement.referral_url
end
protected
def set_title
@page_title = Danbooru.config.app_name + "/advertisements"
end
end

View File

@ -1,58 +0,0 @@
class AdvertisementsController < ApplicationController
before_filter :advertiser_only
def new
@advertisement = Advertisement.new(
:ad_type => "vertical",
:status => "active"
)
end
def edit
@advertisement = Advertisement.find(params[:id])
end
def index
@advertisements = Advertisement.order("id desc")
@start_date = 1.month.ago.to_date
@end_date = Date.today
end
def show
@advertisement = Advertisement.find(params[:id])
end
def create
@advertisement = Advertisement.new(params[:advertisement])
if @advertisement.save
redirect_to advertisement_path(@advertisement), :notice => "Advertisement created"
else
flash[:notice] = "There were errors"
render :action => "new"
end
end
def update
@advertisement = Advertisement.find(params[:id])
if @advertisement.update_attributes(params[:advertisement])
redirect_to advertisement_path(@advertisement), :notice => "Advertisement updated"
else
flash[:notice] = "There were errors"
render :action => "edit"
end
end
def destroy
@advertisement = Advertisement.find(params[:id])
@advertisement.destroy
redirect_to advertisements_path, :notice => "Advertisement destroyed"
end
private
def advertiser_only
if !Danbooru.config.is_user_advertiser?(CurrentUser.user)
raise User::PrivilegeError
return false
end
end
end

View File

@ -1,35 +0,0 @@
module AdvertisementsHelper
def render_advertisement(ad_type)
if Danbooru.config.can_see_ads?(CurrentUser.user)
@advertisement = Advertisement.find(:first, :conditions => ["ad_type = ? AND status = 'active'", ad_type], :order => "random()")
if @advertisement
content_tag(
"div",
link_to(
image_tag(
@advertisement.image_url,
:alt => "Advertisement",
:width => @advertisement.width,
:height => @advertisement.height
),
advertisement_hits_path(:advertisement_id => @advertisement.id),
:method => :post
),
:style => "margin-bottom: 1em;"
)
end
else
""
end
end
def render_rss_advertisement(short_or_long, safe)
if Danbooru.config.can_see_ads?(CurrentUser.user)
if safe
render "advertisements/jlist_rss_ads_explicit_#{short_or_long}"
else
render "advertisements/jlist_rss_ads_safe_#{short_or_long}"
end
end
end
end

View File

@ -1,91 +0,0 @@
class Advertisement < ActiveRecord::Base
validates_inclusion_of :ad_type, :in => %w(horizontal vertical)
has_many :hits, :class_name => "AdvertisementHit"
after_create :copy_to_servers
after_destroy :delete_from_servers
attr_accessible :ad_type, :width, :height, :referral_url, :status, :file_name, :is_work_safe, :hit_count
def copy_to_servers
RemoteFileManager.new(image_path).distribute
end
def delete_from_servers
RemoteFileManager.new(image_path).delete
end
def hit!(ip_addr)
hits.create(:ip_addr => ip_addr)
end
def hit_sum(start_date, end_date)
hits.where(["created_at BETWEEN ? AND ?", start_date, end_date]).count
end
def unique_identifier
@unique_identifier ||= ("%.0f" % (Time.now.to_f * 1_000))
end
def image_url
"/images/advertisements/ads-#{date_prefix}/#{file_name}"
end
def date_prefix
created_at.try(:strftime, "%Y%m%d")
end
def image_path
"#{Danbooru.config.advertisement_path}/ads-#{date_prefix}/#{file_name}"
end
def file
nil
end
def file=(f)
if f.size > 0
self.file_name = unique_identifier + File.extname(f.original_filename)
FileUtils.mkdir_p(File.dirname(image_path))
if f.local_path
FileUtils.cp(f.local_path, image_path)
else
File.open(image_path, 'wb') {|nf| nf.write(f.read)}
end
File.chmod(0644, image_path)
File.open(image_path, "rb") do |file|
image_size = ImageSpec.new(file)
self.width = image_size.width
self.height = image_size.height
end
if width > height
self.ad_type = "horizontal"
else
self.ad_type = "vertical"
end
end
end
def preview_width
if width > 100 || height > 100
if width < height
ratio = 100.0 / height
return (width * ratio).to_i
else
return 100
end
end
end
def preview_height
if width > 100 || height > 100
if height < width
ratio = 100.0 / width
return (height * ratio).to_i
else
return 100
end
end
end
end

View File

@ -1,6 +0,0 @@
class AdvertisementHit < ActiveRecord::Base
belongs_to :advertisement
scope :between, lambda {|start_date, end_date| where("created_at BETWEEN ? AND ?", start_date, end_date)}
attr_accessible :ip_addr
end

View File

@ -1,6 +0,0 @@
<%= simple_form_for @advertisement, :html => {:multipart => true} do |f| %>
<%= f.input :file, :as => :file %>
<%= f.input :referral_url, :as => :string %>
<%= f.input :status, :collection => %w(active inactive) %>
<%= f.button :submit, "Submit" %>
<% end %>

View File

@ -1,70 +0,0 @@
<div id="jlist-rss-ads-for-show">
<!-- Start J-List Product Feed -->
<iframe id="jlf1316043514" src="http://anime.jlist.com/feed.php?affid=2253&size=b&length=10&site=jlist&url=http://feeds.jlist.com/TOPPROD/S2/feed2.xml&title=Top+Photobooks+%28all%29" width="108" height="1416" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="1" scrolling="no"></iframe>
<script type="text/javascript">
var $jlFeeds1316043514 = new Array();
$jlFeeds1316043514[0] = "http://feeds.jbox.com/TOPPROD/BENTO/BENTO/feed2.xml&title=Top+Bento+Products";
$jlFeeds1316043514[1] = "http://feeds.jbox.com/TOPPROD/BENTO/BNBX/feed2.xml&title=Top+Bento+Boxes";
$jlFeeds1316043514[2] = "http://feeds.jbox.com/COSPLAY/COST/feed2.xml&order=random&title=Cosplay+Items+%28All%29";
$jlFeeds1316043514[3] = "http://feeds.jbox.com/TOPPROD/COSPLAY/COST/feed2.xml&title=Top+Cosplay+Items+%28All%29";
$jlFeeds1316043514[4] = "http://feeds.jbox.com/MAGAZINES/MAG2/feed2.xml&order=random&title=Anime+%26+Manga+Magazines";
$jlFeeds1316043514[5] = "http://feeds.jbox.com/TOPPROD/MAGAZINES/MAG2/feed2.xml&title=Top+Anime+%26+Manga+Magazines";
$jlFeeds1316043514[6] = "http://feeds.jbox.com/MANGA/MNBA/feed2.xml&order=random&title=Manga+%26+Artbooks";
$jlFeeds1316043514[7] = "http://feeds.jbox.com/TOPPROD/MANGA/MNBA/feed2.xml&title=Top+Manga+%26+Artbooks";
$jlFeeds1316043514[8] = "http://feeds.jbox.com/TOPPROD/MN/feed2.xml&title=Top+Manga+from+Japan";
$jlFeeds1316043514[9] = "http://feeds.jbox.com/TOPPROD/ANIME/RES1/feed2.xml&title=Top+Magazine+Subscriptions";
$jlFeeds1316043514[10] = "http://feeds.jbox.com/CALENDARS/CLAL/feed2.xml&order=random&title=Calendars+%28all%29";
$jlFeeds1316043514[11] = "http://feeds.jbox.com/TOPPROD/CALENDARS/CLAL/feed2.xml&title=Top+Calendars+%28all%29";
$jlFeeds1316043514[12] = "http://feeds.jbox.com/CALENDARS/CAL5/feed2.xml&order=random&title=Calendars+%28anime%29";
$jlFeeds1316043514[13] = "http://feeds.jbox.com/TOPPROD/CALENDARS/CAL5/feed2.xml&title=Top+Calendars+%28anime%29";
$jlFeeds1316043514[14] = "http://feeds.jbox.com/TOPPROD/ANIME/ANSR/feed2.xml&title=Top+Hello+Kitty+%26+Sanrio";
$jlFeeds1316043514[15] = "http://feeds.jbox.com/ANIME/ANST/feed2.xml&order=random&title=Totoro+%26+Ghibli";
$jlFeeds1316043514[16] = "http://feeds.jbox.com/TOPPROD/ANIME/ANST/feed2.xml&title=Top+Totoro+%26+Ghibli";
$jlFeeds1316043514[17] = "http://feeds.jbox.com/SHRT/TSHR/feed2.xml&order=random&title=Japanese+T-Shirts";
$jlFeeds1316043514[18] = "http://feeds.jbox.com/TOPPROD/SHRT/TSHR/feed2.xml&title=Top+Japanese+T-Shirts";
$jlFeeds1316043514[19] = "http://feeds.jbox.com/TOPPROD/CTTR/TRTR/feed2.xml&title=Top+Traditional+Items+%28all%29";
$jlFeeds1316043514[20] = "http://feeds.jbox.com/COMPUTER/CMMO/feed2.xml&order=random&title=iPod+%26+Computer";
$jlFeeds1316043514[21] = "http://feeds.jbox.com/TOPPROD/COMPUTER/CMMO/feed2.xml&title=Top+iPod+%26+Computer";
$jlFeeds1316043514[22] = "http://feeds.jbox.com/SNACKS/SNGE/feed2.xml&order=random&title=Snacks+%28all%29";
$jlFeeds1316043514[23] = "http://feeds.jbox.com/TOPPROD/SNACKS/SNGE/feed2.xml&title=Top+Snacks+%28all%29";
$jlFeeds1316043514[24] = "http://feeds.jbox.com/TOPPROD/SNACKS/SKAN/feed2.xml&title=Top+Anime+Snacks";
$jlFeeds1316043514[25] = "http://feeds.jlist.com/TOPPROD/S2/feed2.xml&title=Top+Photobooks+%28all%29";
$jlFeeds1316043514[26] = "http://feeds.jlist.com/TOPPROD/CD/feed2.xml&title=Top+Hentai+Games+%28all%29";
$jlFeeds1316043514[27] = "http://feeds.jlist.com/HENTAI/GADL/feed2.xml&order=random&title=H-Games+by+Download";
$jlFeeds1316043514[28] = "http://feeds.jlist.com/TOPPROD/HENTAI/GADL/feed2.xml&title=Top+H-Games+by+Download";
$jlFeeds1316043514[29] = "http://feeds.jlist.com/MAGAZINES/MAG2/feed2.xml&order=random&title=Anime%2C+Hentai+%26+2D+Magazines";
$jlFeeds1316043514[30] = "http://feeds.jlist.com/TOPPROD/MAGAZINES/MAG2/feed2.xml&title=Top+Anime%2C+Hentai+%26+2D+Magazines";
$jlFeeds1316043514[31] = "http://feeds.jlist.com/MANGA/MNBA/feed2.xml&order=random&title=Manga+%26+Artbooks";
$jlFeeds1316043514[32] = "http://feeds.jlist.com/TOPPROD/MANGA/MNBA/feed2.xml&title=Top+Manga+%26+Artbooks";
$jlFeeds1316043514[33] = "http://feeds.jlist.com/TOPPROD/ANIME/RES1/feed2.xml&title=Top+Magazine+Subscriptions";
$jlFeeds1316043514[34] = "http://feeds.jlist.com/TOPPROD/MN/feed2.xml&title=Top+Hentai+Manga+in+Japanese";
$jlFeeds1316043514[35] = "http://feeds.jlist.com/TOPPROD/DV/feed2.xml&title=Top+DVDs+%26+More";
$jlFeeds1316043514[36] = "http://feeds.jlist.com/DVD/DVLS/feed2.xml&order=random&title=DVDs+%28Lesbian%29";
$jlFeeds1316043514[37] = "http://feeds.jlist.com/DVD/DVBL/feed2.xml&order=random&title=Blu-Ray";
$jlFeeds1316043514[38] = "http://feeds.jlist.com/TOPPROD/DVD/DVBL/feed2.xml&title=Top+Blu-Ray";
$jlFeeds1316043514[39] = "http://feeds.jlist.com/ADULTTOYS/ADTY/feed2.xml&order=random&title=Adult+Toys+%26+More";
$jlFeeds1316043514[40] = "http://feeds.jlist.com/TOPPROD/ADULTTOYS/ADTY/feed2.xml&title=Top+Adult+Toys+%26+More";
$jlFeeds1316043514[41] = "http://feeds.jlist.com/ADULTTOYS/ADHT/feed2.xml&order=random&title=TENGA+%26+More";
$jlFeeds1316043514[42] = "http://feeds.jlist.com/TOPPROD/ADULTTOYS/ADHT/feed2.xml&title=Top+TENGA+%26+More";
$jlFeeds1316043514[43] = "http://feeds.jlist.com/ANIME/ANHF/feed2.xml&order=random&title=Sexy+Anime+Figures";
$jlFeeds1316043514[44] = "http://feeds.jlist.com/TOPPROD/ANIME/ANHF/feed2.xml&title=Top+Sexy+Anime+Figures";
$jlFeeds1316043514[45] = "http://feeds.jlist.com/WISHLIST/feed2.xml&order=random&title=Customer+Wishlist+Additions";
$jlFeeds1316043514[46] = "http://feeds.jlist.com/UPDATES/feed2.xml&order=random&title=All+new+Products";
$jlFeeds1316043514[47] = "http://feeds.jlist.com/TOPPROD/feed2.xml&title=Top+selling+products";
$jlFeeds1316043514[48] = "http://feeds.jlist.com/SEARCH/touhou/feed2.xml&order=random&title=Touhou";
$jlFeeds1316043514[49] = "http://feeds.jlist.com/SEARCH/%2Btouhou/feed2.xml&order=random&title=We+Love+Touhou";
$jlFeeds1316043514[50] = "http://feeds.jlist.com/SEARCH/%2Bmadoka_%2Bmagika/feed2.xml&order=random&title=We+Love+Madoka+Magika";
$jlFeeds1316043514[51] = "http://feeds.jlist.com/SEARCH/%2Bqueen%27s_%2Bblade/feed2.xml&order=random&title=Queen%27s+Blade";
$jlFeeds1316043514[52] = "http://feeds.jlist.com/SEARCH/%2Bfutanari/feed2.xml&order=random&title=Futanari+Products";
$jlFeeds1316043514[53] = "http://feeds.jlist.com/SEARCH/doujinshi/feed2.xml&order=random&title=Doujinshi+%26+More";
$jlFeeds1316043514[54] = "http://feeds.jlist.com/SEARCH/%2Bimportgames/feed2.xml&order=random&title=Import+Eroge+%26+Doujin+Soft";
$jlFeeds1316043514[55] = "http://feeds.jlist.com/SEARCH/samurai_ninja/feed2.xml&order=random&title=Ninja+Products";
$jlFeeds1316043514[56] = "http://feeds.jlist.com/SEARCH/%2Bparody_%2Bonahole/feed2.xml&order=random&title=Stress+Toys+for+Otakus";
$jlFeeds1316043514[57] = "http://feeds.jlist.com/SEARCH/shimapan_panties/feed2.xml&order=random&title=Striped+Panty+Fetish";
$jlFeeds1316043514[58] = "http://feeds.jlist.com/SEARCH/zenra/feed2.xml&order=random&title=Zenra+DVDs+%26+More";
document.getElementById('jlf1316043514').src = 'http://anime.jlist.com/feed.php?affid=2253&size=b&length=10&site=jlist&url=' + $jlFeeds1316043514[Math.floor(Math.random()*$jlFeeds1316043514.length)];
</script>
<!-- End J-List Product Feed -->
</div>

View File

@ -1,70 +0,0 @@
<div id="jlist-rss-ads-for-show">
<!-- Start J-List Product Feed -->
<iframe id="jlf1316043772" src="http://moe.jlist.com/feed.php?affid=2253&size=b&length=7&site=jlist&url=http://feeds.jbox.com/TOPPROD/COSPLAY/COST/feed2.xml&title=Top+Cosplay+Items+%28All%29" width="108" height="1014" style="margin-top: 100px;" frameborder="1" scrolling="no"></iframe>
<script type="text/javascript">
var $jlFeeds1316043772 = new Array();
$jlFeeds1316043772[0] = "http://feeds.jbox.com/TOPPROD/BENTO/BENTO/feed2.xml&title=Top+Bento+Products";
$jlFeeds1316043772[1] = "http://feeds.jbox.com/TOPPROD/BENTO/BNBX/feed2.xml&title=Top+Bento+Boxes";
$jlFeeds1316043772[2] = "http://feeds.jbox.com/COSPLAY/COST/feed2.xml&order=random&title=Cosplay+Items+%28All%29";
$jlFeeds1316043772[3] = "http://feeds.jbox.com/TOPPROD/COSPLAY/COST/feed2.xml&title=Top+Cosplay+Items+%28All%29";
$jlFeeds1316043772[4] = "http://feeds.jbox.com/MAGAZINES/MAG2/feed2.xml&order=random&title=Anime+%26+Manga+Magazines";
$jlFeeds1316043772[5] = "http://feeds.jbox.com/TOPPROD/MAGAZINES/MAG2/feed2.xml&title=Top+Anime+%26+Manga+Magazines";
$jlFeeds1316043772[6] = "http://feeds.jbox.com/MANGA/MNBA/feed2.xml&order=random&title=Manga+%26+Artbooks";
$jlFeeds1316043772[7] = "http://feeds.jbox.com/TOPPROD/MANGA/MNBA/feed2.xml&title=Top+Manga+%26+Artbooks";
$jlFeeds1316043772[8] = "http://feeds.jbox.com/TOPPROD/MN/feed2.xml&title=Top+Manga+from+Japan";
$jlFeeds1316043772[9] = "http://feeds.jbox.com/TOPPROD/ANIME/RES1/feed2.xml&title=Top+Magazine+Subscriptions";
$jlFeeds1316043772[10] = "http://feeds.jbox.com/CALENDARS/CLAL/feed2.xml&order=random&title=Calendars+%28all%29";
$jlFeeds1316043772[11] = "http://feeds.jbox.com/TOPPROD/CALENDARS/CLAL/feed2.xml&title=Top+Calendars+%28all%29";
$jlFeeds1316043772[12] = "http://feeds.jbox.com/CALENDARS/CAL5/feed2.xml&order=random&title=Calendars+%28anime%29";
$jlFeeds1316043772[13] = "http://feeds.jbox.com/TOPPROD/CALENDARS/CAL5/feed2.xml&title=Top+Calendars+%28anime%29";
$jlFeeds1316043772[14] = "http://feeds.jbox.com/TOPPROD/ANIME/ANSR/feed2.xml&title=Top+Hello+Kitty+%26+Sanrio";
$jlFeeds1316043772[15] = "http://feeds.jbox.com/ANIME/ANST/feed2.xml&order=random&title=Totoro+%26+Ghibli";
$jlFeeds1316043772[16] = "http://feeds.jbox.com/TOPPROD/ANIME/ANST/feed2.xml&title=Top+Totoro+%26+Ghibli";
$jlFeeds1316043772[17] = "http://feeds.jbox.com/SHRT/TSHR/feed2.xml&order=random&title=Japanese+T-Shirts";
$jlFeeds1316043772[18] = "http://feeds.jbox.com/TOPPROD/SHRT/TSHR/feed2.xml&title=Top+Japanese+T-Shirts";
$jlFeeds1316043772[19] = "http://feeds.jbox.com/TOPPROD/CTTR/TRTR/feed2.xml&title=Top+Traditional+Items+%28all%29";
$jlFeeds1316043772[20] = "http://feeds.jbox.com/COMPUTER/CMMO/feed2.xml&order=random&title=iPod+%26+Computer";
$jlFeeds1316043772[21] = "http://feeds.jbox.com/TOPPROD/COMPUTER/CMMO/feed2.xml&title=Top+iPod+%26+Computer";
$jlFeeds1316043772[22] = "http://feeds.jbox.com/SNACKS/SNGE/feed2.xml&order=random&title=Snacks+%28all%29";
$jlFeeds1316043772[23] = "http://feeds.jbox.com/TOPPROD/SNACKS/SNGE/feed2.xml&title=Top+Snacks+%28all%29";
$jlFeeds1316043772[24] = "http://feeds.jbox.com/TOPPROD/SNACKS/SKAN/feed2.xml&title=Top+Anime+Snacks";
$jlFeeds1316043772[25] = "http://feeds.jlist.com/TOPPROD/S2/feed2.xml&title=Top+Photobooks+%28all%29";
$jlFeeds1316043772[26] = "http://feeds.jlist.com/TOPPROD/CD/feed2.xml&title=Top+Hentai+Games+%28all%29";
$jlFeeds1316043772[27] = "http://feeds.jlist.com/HENTAI/GADL/feed2.xml&order=random&title=H-Games+by+Download";
$jlFeeds1316043772[28] = "http://feeds.jlist.com/TOPPROD/HENTAI/GADL/feed2.xml&title=Top+H-Games+by+Download";
$jlFeeds1316043772[29] = "http://feeds.jlist.com/MAGAZINES/MAG2/feed2.xml&order=random&title=Anime%2C+Hentai+%26+2D+Magazines";
$jlFeeds1316043772[30] = "http://feeds.jlist.com/TOPPROD/MAGAZINES/MAG2/feed2.xml&title=Top+Anime%2C+Hentai+%26+2D+Magazines";
$jlFeeds1316043772[31] = "http://feeds.jlist.com/MANGA/MNBA/feed2.xml&order=random&title=Manga+%26+Artbooks";
$jlFeeds1316043772[32] = "http://feeds.jlist.com/TOPPROD/MANGA/MNBA/feed2.xml&title=Top+Manga+%26+Artbooks";
$jlFeeds1316043772[33] = "http://feeds.jlist.com/TOPPROD/ANIME/RES1/feed2.xml&title=Top+Magazine+Subscriptions";
$jlFeeds1316043772[34] = "http://feeds.jlist.com/TOPPROD/MN/feed2.xml&title=Top+Hentai+Manga+in+Japanese";
$jlFeeds1316043772[35] = "http://feeds.jlist.com/TOPPROD/DV/feed2.xml&title=Top+DVDs+%26+More";
$jlFeeds1316043772[36] = "http://feeds.jlist.com/DVD/DVLS/feed2.xml&order=random&title=DVDs+%28Lesbian%29";
$jlFeeds1316043772[37] = "http://feeds.jlist.com/DVD/DVBL/feed2.xml&order=random&title=Blu-Ray";
$jlFeeds1316043772[38] = "http://feeds.jlist.com/TOPPROD/DVD/DVBL/feed2.xml&title=Top+Blu-Ray";
$jlFeeds1316043772[39] = "http://feeds.jlist.com/ADULTTOYS/ADTY/feed2.xml&order=random&title=Adult+Toys+%26+More";
$jlFeeds1316043772[40] = "http://feeds.jlist.com/TOPPROD/ADULTTOYS/ADTY/feed2.xml&title=Top+Adult+Toys+%26+More";
$jlFeeds1316043772[41] = "http://feeds.jlist.com/ADULTTOYS/ADHT/feed2.xml&order=random&title=TENGA+%26+More";
$jlFeeds1316043772[42] = "http://feeds.jlist.com/TOPPROD/ADULTTOYS/ADHT/feed2.xml&title=Top+TENGA+%26+More";
$jlFeeds1316043772[43] = "http://feeds.jlist.com/ANIME/ANHF/feed2.xml&order=random&title=Sexy+Anime+Figures";
$jlFeeds1316043772[44] = "http://feeds.jlist.com/TOPPROD/ANIME/ANHF/feed2.xml&title=Top+Sexy+Anime+Figures";
$jlFeeds1316043772[45] = "http://feeds.jlist.com/WISHLIST/feed2.xml&order=random&title=Customer+Wishlist+Additions";
$jlFeeds1316043772[46] = "http://feeds.jlist.com/UPDATES/feed2.xml&order=random&title=All+new+Products";
$jlFeeds1316043772[47] = "http://feeds.jlist.com/TOPPROD/feed2.xml&title=Top+selling+products";
$jlFeeds1316043772[48] = "http://feeds.jlist.com/SEARCH/touhou/feed2.xml&order=random&title=Touhou";
$jlFeeds1316043772[49] = "http://feeds.jlist.com/SEARCH/%2Btouhou/feed2.xml&order=random&title=We+Love+Touhou";
$jlFeeds1316043772[50] = "http://feeds.jlist.com/SEARCH/%2Bmadoka_%2Bmagika/feed2.xml&order=random&title=We+Love+Madoka+Magika";
$jlFeeds1316043772[51] = "http://feeds.jlist.com/SEARCH/%2Bqueen%27s_%2Bblade/feed2.xml&order=random&title=Queen%27s+Blade";
$jlFeeds1316043772[52] = "http://feeds.jlist.com/SEARCH/%2Bfutanari/feed2.xml&order=random&title=Futanari+Products";
$jlFeeds1316043772[53] = "http://feeds.jlist.com/SEARCH/doujinshi/feed2.xml&order=random&title=Doujinshi+%26+More";
$jlFeeds1316043772[54] = "http://feeds.jlist.com/SEARCH/%2Bimportgames/feed2.xml&order=random&title=Import+Eroge+%26+Doujin+Soft";
$jlFeeds1316043772[55] = "http://feeds.jlist.com/SEARCH/samurai_ninja/feed2.xml&order=random&title=Ninja+Products";
$jlFeeds1316043772[56] = "http://feeds.jlist.com/SEARCH/%2Bparody_%2Bonahole/feed2.xml&order=random&title=Stress+Toys+for+Otakus";
$jlFeeds1316043772[57] = "http://feeds.jlist.com/SEARCH/shimapan_panties/feed2.xml&order=random&title=Striped+Panty+Fetish";
$jlFeeds1316043772[58] = "http://feeds.jlist.com/SEARCH/zenra/feed2.xml&order=random&title=Zenra+DVDs+%26+More";
document.getElementById('jlf1316043772').src = 'http://moe.jlist.com/feed.php?affid=2253&size=b&length=7&site=jlist&url=' + $jlFeeds1316043772[Math.floor(Math.random()*$jlFeeds1316043772.length)];
</script>
<!-- End J-List Product Feed -->
</div>

View File

@ -1,63 +0,0 @@
<div id="jlist-rss-ads-for-show">
<!-- Start J-List Product Feed -->
<iframe id="jlf1316043926" src="http://pocky.jlist.com/feed.php?affid=2253&size=f&length=10&site=jbox&url=http://feeds.jbox.com/TOPPROD/feed2.xml&title=Top+selling+products" width="108" height="1616" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="1" scrolling="no"></iframe>
<script type="text/javascript">
var $jlFeeds1316043926 = new Array();
$jlFeeds1316043926[0] = "http://feeds.jbox.com/TOPPROD/BENTO/BENTO/feed2.xml&title=Top+Bento+Products";
$jlFeeds1316043926[1] = "http://feeds.jbox.com/BENTO/BNBX/feed2.xml&order=random&title=Bento+Boxes";
$jlFeeds1316043926[2] = "http://feeds.jbox.com/TOPPROD/BENTO/BNBX/feed2.xml&title=Top+Bento+Boxes";
$jlFeeds1316043926[3] = "http://feeds.jbox.com/COSPLAY/COST/feed2.xml&order=random&title=Cosplay+Items+%28All%29";
$jlFeeds1316043926[4] = "http://feeds.jbox.com/MAGAZINES/MGFS/feed2.xml&order=random&title=Fashion+Magazines+%26+More";
$jlFeeds1316043926[5] = "http://feeds.jbox.com/MAGAZINES/MAG2/feed2.xml&order=random&title=Anime+%26+Manga+Magazines";
$jlFeeds1316043926[6] = "http://feeds.jbox.com/TOPPROD/MAGAZINES/MAG2/feed2.xml&title=Top+Anime+%26+Manga+Magazines";
$jlFeeds1316043926[7] = "http://feeds.jbox.com/MANGA/MNBA/feed2.xml&order=random&title=Manga+%26+Artbooks";
$jlFeeds1316043926[8] = "http://feeds.jbox.com/TOPPROD/MANGA/MNBA/feed2.xml&title=Top+Manga+%26+Artbooks";
$jlFeeds1316043926[9] = "http://feeds.jbox.com/CALENDARS/CLAL/feed2.xml&order=random&title=Calendars+%28all%29";
$jlFeeds1316043926[10] = "http://feeds.jbox.com/TOPPROD/CALENDARS/CLAL/feed2.xml&title=Top+Calendars+%28all%29";
$jlFeeds1316043926[11] = "http://feeds.jbox.com/CALENDARS/CAL5/feed2.xml&order=random&title=Calendars+%28anime%29";
$jlFeeds1316043926[12] = "http://feeds.jbox.com/TOPPROD/CALENDARS/CAL5/feed2.xml&title=Top+Calendars+%28anime%29";
$jlFeeds1316043926[13] = "http://feeds.jbox.com/ANIME/ANAL/feed2.xml&order=random&title=Anime%2C+Toys+%26+More";
$jlFeeds1316043926[14] = "http://feeds.jbox.com/ANIME/ANHF/feed2.xml&order=random&title=Anime+Figures+%26+More";
$jlFeeds1316043926[15] = "http://feeds.jbox.com/TOPPROD/ANIME/ANHF/feed2.xml&title=Top+Anime+Figures+%26+More";
$jlFeeds1316043926[16] = "http://feeds.jbox.com/ANIME/ANSR/feed2.xml&order=random&title=Hello+Kitty+%26+Sanrio";
$jlFeeds1316043926[17] = "http://feeds.jbox.com/TOPPROD/ANIME/ANSR/feed2.xml&title=Top+Hello+Kitty+%26+Sanrio";
$jlFeeds1316043926[18] = "http://feeds.jbox.com/ANIME/ANST/feed2.xml&order=random&title=Totoro+%26+Ghibli";
$jlFeeds1316043926[19] = "http://feeds.jbox.com/TOPPROD/ANIME/ANST/feed2.xml&title=Top+Totoro+%26+Ghibli";
$jlFeeds1316043926[20] = "http://feeds.jbox.com/ANIME/ANPL/feed2.xml&order=random&title=Plush+Toys+from+Japan";
$jlFeeds1316043926[21] = "http://feeds.jbox.com/TOPPROD/ANIME/ANDM/feed2.xml&title=Top+Domo-kun";
$jlFeeds1316043926[22] = "http://feeds.jbox.com/TOPPROD/ANIME/TRSW/feed2.xml&title=Top+Star+Wars+%26+Star+Trek";
$jlFeeds1316043926[23] = "http://feeds.jbox.com/SHRT/TSHR/feed2.xml&order=random&title=Japanese+T-Shirts";
$jlFeeds1316043926[24] = "http://feeds.jbox.com/TOPPROD/SHRT/TSHR/feed2.xml&title=Top+Japanese+T-Shirts";
$jlFeeds1316043926[25] = "http://feeds.jbox.com/TOPPROD/SHRT/TSGR/feed2.xml&title=Top+T-Shirts+%28for+girls%29";
$jlFeeds1316043926[26] = "http://feeds.jbox.com/CTTR/TRTR/feed2.xml&order=random&title=Traditional+Items+%28all%29";
$jlFeeds1316043926[27] = "http://feeds.jbox.com/TOPPROD/CTTR/TRTR/feed2.xml&title=Top+Traditional+Items+%28all%29";
$jlFeeds1316043926[28] = "http://feeds.jbox.com/TOPPROD/s3/feed2.xml&title=Top+Japanese+Study+Items+%28all%29";
$jlFeeds1316043926[29] = "http://feeds.jbox.com/TOPPROD/STUDYAIDS/WANO/feed2.xml&title=Top+Japanese+Pens+%26+Notebooks";
$jlFeeds1316043926[30] = "http://feeds.jbox.com/COMPUTER/CMMO/feed2.xml&order=random&title=iPod+%26+Computer";
$jlFeeds1316043926[31] = "http://feeds.jbox.com/SNACKS/SNGE/feed2.xml&order=random&title=Snacks+%28all%29";
$jlFeeds1316043926[32] = "http://feeds.jbox.com/TOPPROD/SNACKS/SNGE/feed2.xml&title=Top+Snacks+%28all%29";
$jlFeeds1316043926[33] = "http://feeds.jbox.com/TOPPROD/SNACKS/SNGM/feed2.xml&title=Top+Japanese+gum";
$jlFeeds1316043926[34] = "http://feeds.jbox.com/SNACKS/SKAN/feed2.xml&order=random&title=Anime+Snacks";
$jlFeeds1316043926[35] = "http://feeds.jlist.com/HENTAI/GADL/feed2.xml&order=random&title=H-Games+by+Download";
$jlFeeds1316043926[36] = "http://feeds.jlist.com/TOPPROD/HENTAI/GADL/feed2.xml&title=Top+H-Games+by+Download";
$jlFeeds1316043926[37] = "http://feeds.jlist.com/MAGAZINES/MAG2/feed2.xml&order=random&title=Anime%2C+Hentai+%26+2D+Magazines";
$jlFeeds1316043926[38] = "http://feeds.jlist.com/TOPPROD/MAGAZINES/MAG2/feed2.xml&title=Top+Anime%2C+Hentai+%26+2D+Magazines";
$jlFeeds1316043926[39] = "http://feeds.jlist.com/ANIME/ANHF/feed2.xml&order=random&title=Sexy+Anime+Figures";
$jlFeeds1316043926[40] = "http://feeds.jbox.com/WISHLIST/feed2.xml&order=random&title=Customer+Wishlist+Additions";
$jlFeeds1316043926[41] = "http://feeds.jbox.com/UPDATES/feed2.xml&order=random&title=All+new+Products";
$jlFeeds1316043926[42] = "http://feeds.jbox.com/TOPPROD/feed2.xml&title=Top+selling+products";
$jlFeeds1316043926[43] = "http://feeds.jbox.com/SEARCH/touhou/feed2.xml&order=random&title=Touhou";
$jlFeeds1316043926[44] = "http://feeds.jbox.com/SEARCH/%2Btouhou/feed2.xml&order=random&title=We+Love+Touhou";
$jlFeeds1316043926[45] = "http://feeds.jbox.com/SEARCH/%2Bqueen%27s_%2Bblade/feed2.xml&order=random&title=Queen%27s+Blade";
$jlFeeds1316043926[46] = "http://feeds.jbox.com/SEARCH/importgames/feed2.xml&order=random&title=Import+Games+%26+More";
$jlFeeds1316043926[47] = "http://feeds.jbox.com/SEARCH/%2Bhigh_%2Bschool_%2Bdead/feed2.xml&order=random&title=High+School+of+the+Dead";
$jlFeeds1316043926[48] = "http://feeds.jbox.com/SEARCH/samurai_ninja/feed2.xml&order=random&title=Ninja+Products";
$jlFeeds1316043926[49] = "http://feeds.jbox.com/SEARCH/%2Bonepiece/feed2.xml&order=random&title=One+Piece+Products";
$jlFeeds1316043926[50] = "http://feeds.jbox.com/SEARCH/k-on_keion/feed2.xml&order=random&title=We+Love+K-On%21";
$jlFeeds1316043926[51] = "http://feeds.jbox.com/SEARCH/%2Bmadoka_%2Bmagika/feed2.xml&order=random&title=We+Love+Madoka%21";
document.getElementById('jlf1316043926').src = 'http://pocky.jlist.com/feed.php?affid=2253&size=f&length=10&site=jbox&url=' + $jlFeeds1316043926[Math.floor(Math.random()*$jlFeeds1316043926.length)];
</script>
<!-- End J-List Product Feed -->
</div>

View File

@ -1,63 +0,0 @@
<div id="jlist-rss-ads-for-show">
<!-- Start J-List Product Feed -->
<iframe id="jlf1316043893" src="http://anime.jlist.com/feed.php?affid=2253&size=f&length=7&site=jbox&url=http://feeds.jlist.com/ANIME/ANHF/feed2.xml&order=random&title=Sexy+Anime+Figures" width="108" height="1154" style="margin-top: 100px" frameborder="1" scrolling="no"></iframe>
<script type="text/javascript">
var $jlFeeds1316043893 = new Array();
$jlFeeds1316043893[0] = "http://feeds.jbox.com/TOPPROD/BENTO/BENTO/feed2.xml&title=Top+Bento+Products";
$jlFeeds1316043893[1] = "http://feeds.jbox.com/BENTO/BNBX/feed2.xml&order=random&title=Bento+Boxes";
$jlFeeds1316043893[2] = "http://feeds.jbox.com/TOPPROD/BENTO/BNBX/feed2.xml&title=Top+Bento+Boxes";
$jlFeeds1316043893[3] = "http://feeds.jbox.com/COSPLAY/COST/feed2.xml&order=random&title=Cosplay+Items+%28All%29";
$jlFeeds1316043893[4] = "http://feeds.jbox.com/MAGAZINES/MGFS/feed2.xml&order=random&title=Fashion+Magazines+%26+More";
$jlFeeds1316043893[5] = "http://feeds.jbox.com/MAGAZINES/MAG2/feed2.xml&order=random&title=Anime+%26+Manga+Magazines";
$jlFeeds1316043893[6] = "http://feeds.jbox.com/TOPPROD/MAGAZINES/MAG2/feed2.xml&title=Top+Anime+%26+Manga+Magazines";
$jlFeeds1316043893[7] = "http://feeds.jbox.com/MANGA/MNBA/feed2.xml&order=random&title=Manga+%26+Artbooks";
$jlFeeds1316043893[8] = "http://feeds.jbox.com/TOPPROD/MANGA/MNBA/feed2.xml&title=Top+Manga+%26+Artbooks";
$jlFeeds1316043893[9] = "http://feeds.jbox.com/CALENDARS/CLAL/feed2.xml&order=random&title=Calendars+%28all%29";
$jlFeeds1316043893[10] = "http://feeds.jbox.com/TOPPROD/CALENDARS/CLAL/feed2.xml&title=Top+Calendars+%28all%29";
$jlFeeds1316043893[11] = "http://feeds.jbox.com/CALENDARS/CAL5/feed2.xml&order=random&title=Calendars+%28anime%29";
$jlFeeds1316043893[12] = "http://feeds.jbox.com/TOPPROD/CALENDARS/CAL5/feed2.xml&title=Top+Calendars+%28anime%29";
$jlFeeds1316043893[13] = "http://feeds.jbox.com/ANIME/ANAL/feed2.xml&order=random&title=Anime%2C+Toys+%26+More";
$jlFeeds1316043893[14] = "http://feeds.jbox.com/ANIME/ANHF/feed2.xml&order=random&title=Anime+Figures+%26+More";
$jlFeeds1316043893[15] = "http://feeds.jbox.com/TOPPROD/ANIME/ANHF/feed2.xml&title=Top+Anime+Figures+%26+More";
$jlFeeds1316043893[16] = "http://feeds.jbox.com/ANIME/ANSR/feed2.xml&order=random&title=Hello+Kitty+%26+Sanrio";
$jlFeeds1316043893[17] = "http://feeds.jbox.com/TOPPROD/ANIME/ANSR/feed2.xml&title=Top+Hello+Kitty+%26+Sanrio";
$jlFeeds1316043893[18] = "http://feeds.jbox.com/ANIME/ANST/feed2.xml&order=random&title=Totoro+%26+Ghibli";
$jlFeeds1316043893[19] = "http://feeds.jbox.com/TOPPROD/ANIME/ANST/feed2.xml&title=Top+Totoro+%26+Ghibli";
$jlFeeds1316043893[20] = "http://feeds.jbox.com/ANIME/ANPL/feed2.xml&order=random&title=Plush+Toys+from+Japan";
$jlFeeds1316043893[21] = "http://feeds.jbox.com/TOPPROD/ANIME/ANDM/feed2.xml&title=Top+Domo-kun";
$jlFeeds1316043893[22] = "http://feeds.jbox.com/TOPPROD/ANIME/TRSW/feed2.xml&title=Top+Star+Wars+%26+Star+Trek";
$jlFeeds1316043893[23] = "http://feeds.jbox.com/SHRT/TSHR/feed2.xml&order=random&title=Japanese+T-Shirts";
$jlFeeds1316043893[24] = "http://feeds.jbox.com/TOPPROD/SHRT/TSHR/feed2.xml&title=Top+Japanese+T-Shirts";
$jlFeeds1316043893[25] = "http://feeds.jbox.com/TOPPROD/SHRT/TSGR/feed2.xml&title=Top+T-Shirts+%28for+girls%29";
$jlFeeds1316043893[26] = "http://feeds.jbox.com/CTTR/TRTR/feed2.xml&order=random&title=Traditional+Items+%28all%29";
$jlFeeds1316043893[27] = "http://feeds.jbox.com/TOPPROD/CTTR/TRTR/feed2.xml&title=Top+Traditional+Items+%28all%29";
$jlFeeds1316043893[28] = "http://feeds.jbox.com/TOPPROD/s3/feed2.xml&title=Top+Japanese+Study+Items+%28all%29";
$jlFeeds1316043893[29] = "http://feeds.jbox.com/TOPPROD/STUDYAIDS/WANO/feed2.xml&title=Top+Japanese+Pens+%26+Notebooks";
$jlFeeds1316043893[30] = "http://feeds.jbox.com/COMPUTER/CMMO/feed2.xml&order=random&title=iPod+%26+Computer";
$jlFeeds1316043893[31] = "http://feeds.jbox.com/SNACKS/SNGE/feed2.xml&order=random&title=Snacks+%28all%29";
$jlFeeds1316043893[32] = "http://feeds.jbox.com/TOPPROD/SNACKS/SNGE/feed2.xml&title=Top+Snacks+%28all%29";
$jlFeeds1316043893[33] = "http://feeds.jbox.com/TOPPROD/SNACKS/SNGM/feed2.xml&title=Top+Japanese+gum";
$jlFeeds1316043893[34] = "http://feeds.jbox.com/SNACKS/SKAN/feed2.xml&order=random&title=Anime+Snacks";
$jlFeeds1316043893[35] = "http://feeds.jlist.com/HENTAI/GADL/feed2.xml&order=random&title=H-Games+by+Download";
$jlFeeds1316043893[36] = "http://feeds.jlist.com/TOPPROD/HENTAI/GADL/feed2.xml&title=Top+H-Games+by+Download";
$jlFeeds1316043893[37] = "http://feeds.jlist.com/MAGAZINES/MAG2/feed2.xml&order=random&title=Anime%2C+Hentai+%26+2D+Magazines";
$jlFeeds1316043893[38] = "http://feeds.jlist.com/TOPPROD/MAGAZINES/MAG2/feed2.xml&title=Top+Anime%2C+Hentai+%26+2D+Magazines";
$jlFeeds1316043893[39] = "http://feeds.jlist.com/ANIME/ANHF/feed2.xml&order=random&title=Sexy+Anime+Figures";
$jlFeeds1316043893[40] = "http://feeds.jbox.com/WISHLIST/feed2.xml&order=random&title=Customer+Wishlist+Additions";
$jlFeeds1316043893[41] = "http://feeds.jbox.com/UPDATES/feed2.xml&order=random&title=All+new+Products";
$jlFeeds1316043893[42] = "http://feeds.jbox.com/TOPPROD/feed2.xml&title=Top+selling+products";
$jlFeeds1316043893[43] = "http://feeds.jbox.com/SEARCH/touhou/feed2.xml&order=random&title=Touhou";
$jlFeeds1316043893[44] = "http://feeds.jbox.com/SEARCH/%2Btouhou/feed2.xml&order=random&title=We+Love+Touhou";
$jlFeeds1316043893[45] = "http://feeds.jbox.com/SEARCH/%2Bqueen%27s_%2Bblade/feed2.xml&order=random&title=Queen%27s+Blade";
$jlFeeds1316043893[46] = "http://feeds.jbox.com/SEARCH/importgames/feed2.xml&order=random&title=Import+Games+%26+More";
$jlFeeds1316043893[47] = "http://feeds.jbox.com/SEARCH/%2Bhigh_%2Bschool_%2Bdead/feed2.xml&order=random&title=High+School+of+the+Dead";
$jlFeeds1316043893[48] = "http://feeds.jbox.com/SEARCH/samurai_ninja/feed2.xml&order=random&title=Ninja+Products";
$jlFeeds1316043893[49] = "http://feeds.jbox.com/SEARCH/%2Bonepiece/feed2.xml&order=random&title=One+Piece+Products";
$jlFeeds1316043893[50] = "http://feeds.jbox.com/SEARCH/k-on_keion/feed2.xml&order=random&title=We+Love+K-On%21";
$jlFeeds1316043893[51] = "http://feeds.jbox.com/SEARCH/%2Bmadoka_%2Bmagika/feed2.xml&order=random&title=We+Love+Madoka%21";
document.getElementById('jlf1316043893').src = 'http://anime.jlist.com/feed.php?affid=2253&size=f&length=7&site=jbox&url=' + $jlFeeds1316043893[Math.floor(Math.random()*$jlFeeds1316043893.length)];
</script>
<!-- End J-List Product Feed -->
</div>

View File

@ -1,11 +0,0 @@
<% content_for(:secondary_links) do %>
<menu id="secondary-links">
<li><%= link_to "Listing", advertisements_path %></li>
<li><%= link_to "New", new_advertisement_path %></li>
<% if @advertisement && !@advertisement.new_record? %>
<li>|</li>
<li><%= link_to "Edit", edit_advertisement_path(@advertisement) %></li>
<li><%= link_to "Show", advertisement_path(@advertisement) %></li>
<% end %>
</menu>
<% end %>

View File

@ -1,14 +0,0 @@
<div id="c-advertisements">
<div id="a-edit">
<h1>Edit Advertisement</h1>
<%= image_tag(@advertisement.image_url) %>
<%= render "form" %>
</div>
</div>
<%= render "secondary_links" %>
<% content_for(:page_title) do %>
Edit Advertisement - <%= Danbooru.config.app_name %>
<% end %>

View File

@ -1,30 +0,0 @@
<div id="c-advertisements">
<div id="c-index">
<h1>Advertisements</h1>
<table width="100%" class="highlightable">
<thead>
<tr>
<th width="5%"></th>
<th width="5%" style="text-align: right;">Hits</th>
<th width="90%"></th>
</tr>
</thead>
<tbody>
<% @advertisements.each do |advertisement| %>
<tr>
<td><%= image_tag(advertisement.image_url, :width => advertisement.preview_width, :height => advertisement.preview_height) %></td>
<td style="text-align: right;"><%= advertisement.hits.between(@start_date, @end_date).count %></td>
<td><%= link_to "Edit", edit_advertisement_path(advertisement) %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<%= render "secondary_links" %>
<% content_for(:page_title) do %>
Advertisements - <%= Danbooru.config.app_name %>
<% end %>

View File

@ -1,13 +0,0 @@
<div id="c-advertisements">
<div id="a-new">
<h1>New Advertisement</h1>
<%= error_messages_for :advertisement %>
<%= render "form" %>
</div>
</div>
<%= render "secondary_links" %>
<% content_for(:page_title) do %>
New Advertisement - <%= Danbooru.config.app_name %>
<% end %>

View File

@ -1,17 +0,0 @@
<div id="c-advertisements">
<div id="a-show">
<h1>Advertisement</h1>
<%= image_tag(@advertisement.image_url, :width => @advertisement.preview_width, :height => @advertisement.preview_height) %>
<ul>
<li>Hits: <%= @advertisement.hits.between(@start_date, @end_date).count %></li>
</ul>
</div>
</div>
<%= render "secondary_links" %>
<% content_for(:page_title) do %>
Advertisement - <%= Danbooru.config.app_name %>
<% end %>

View File

@ -130,10 +130,6 @@
<li><%= link_to("Alias & Implication Import", new_admin_alias_and_implication_import_path) %></li>
<li><%= link_to("Admin Dashboard", admin_dashboard_path) %></li>
<% end %>
<% if Danbooru.config.is_user_advertiser?(CurrentUser.user) %>
<li><%= link_to("Advertisements", advertisements_path) %></li>
<% end %>
</ul>
</section>
</div>

View File

@ -107,11 +107,6 @@ module Danbooru
300
end
# Where the ad banners are stored in the file system
def advertisement_path
nil
end
# List of memcached servers
def memcached_servers
%w(127.0.0.1:11211)
@ -266,10 +261,6 @@ module Danbooru
!user.is_gold?
end
def is_user_advertiser?(user)
user.is_admin?
end
def can_user_see_post?(user, post)
if is_user_restricted?(user) && is_post_restricted?(post)
false

View File

@ -71,9 +71,6 @@ Rails.application.routes.draw do
end
end
resources :advertisements do
resources :hits, :controller => "advertisement_hits", :only => [:create]
end
resources :artists do
member do
put :revert

View File

@ -104,16 +104,7 @@ namespace :images do
upload.generate_resizes(post.file_path)
post.distribute_files
end
desc "Finds advertisement images that don't exist"
task :find_missing_ads => :environment do
Advertisement.where("status = 'active'").each do |ad|
if !File.exists?(ad.image_path)
puts ad.image_path
end
end
end
desc "Generate thumbnail-sized images of posts"
task :generate_preview => :environment do
Post.where("image_width > ?", Danbooru.config.small_image_width).find_each do |post|

View File

@ -1,5 +1,3 @@
truncate table advertisement_hits;
truncate table advertisements;
update artist_versions set updater_ip_addr = '127.0.0.1';
truncate table bans;
truncate table comment_votes;

View File

@ -1,10 +0,0 @@
FactoryGirl.define do
factory(:advertisement) do
referral_url "http://google.com"
ad_type "vertical"
status "active"
width 728
height 90
file_name "google.gif"
end
end

View File

@ -1,17 +0,0 @@
require 'test_helper'
class AdvertisementHitsControllerTest < ActionController::TestCase
context "An advertisement hits controller" do
setup do
@ad = FactoryGirl.create(:advertisement)
@advertiser = FactoryGirl.create(:admin_user)
end
should "create a new hit" do
assert_difference("AdvertisementHit.count", 1) do
post :create, {:advertisement_id => @ad.id}
end
assert_redirected_to(@ad.referral_url)
end
end
end

View File

@ -1,58 +0,0 @@
require 'test_helper'
class AdvertisementsControllerTest < ActionController::TestCase
context "An advertisement controller" do
setup do
@ad = FactoryGirl.create(:advertisement)
@advertiser = FactoryGirl.create(:admin_user)
end
should "get the new page" do
get :new, {}, {:user_id => @advertiser.id}
assert_response :success
end
should "get the edit page" do
get :edit, {:id => @ad.id}, {:user_id => @advertiser.id}
assert_response :success
end
should "get the index page" do
get :index, {}, {:user_id => @advertiser.id}
assert_response :success
end
should "get the show page" do
get :show, {:id => @ad.id}, {:user_id => @advertiser.id}
assert_response :success
end
should "create an ad" do
assert_difference("Advertisement.count", 1) do
post :create, {:advertisement => FactoryGirl.attributes_for(:advertisement)}, {:user_id => @advertiser.id}
end
ad = Advertisement.last
assert_redirected_to(advertisement_path(ad))
end
should "update an ad" do
post :update, {:id => @ad.id, :advertisement => {:width => 100}}, {:user_id => @advertiser.id}
ad = Advertisement.last
assert_equal(100, ad.width)
assert_redirected_to(advertisement_path(ad))
end
should "delete an ad" do
assert_difference("Advertisement.count", -1) do
post :destroy, {:id => @ad.id}, {:user_id => @advertiser.id}
end
assert_redirected_to(advertisements_path)
end
should "block non-advertisers" do
regular_user = FactoryGirl.create(:user)
get :index, {}, {:user_id => regular_user.id}
assert_response(403)
end
end
end

View File

@ -1,32 +0,0 @@
require 'test_helper'
require 'helpers/upload_test_helper'
class AdvertisementTest < ActiveSupport::TestCase
include UploadTestHelper
context "An advertisement" do
setup do
Danbooru.config.stubs(:advertisement_path).returns("/tmp")
@ad = FactoryGirl.create(:advertisement, :file => upload_jpeg("#{Rails.root}/test/files/test.jpg"))
end
teardown do
FileUtils.rm_f(Dir.glob("#{Rails.root}/public/images/advertisements/*.jpg"))
end
should "create new hit records" do
assert_difference("AdvertisementHit.count") do
@ad.hit!("0.0.0.0")
end
assert_equal("0.0.0.0", AdvertisementHit.first.ip_addr.to_s)
assert_equal(@ad.id, AdvertisementHit.first.advertisement_id)
assert_equal(1, @ad.hit_sum(1.day.ago, 1.day.from_now))
assert_equal(0, @ad.hit_sum(2.days.ago, 1.day.ago))
end
should "know its preview height and preview width" do
assert_equal(100, @ad.preview_width)
assert_equal(67, @ad.preview_height)
end
end
end