more changes to advertisements
added two new ad spots, bottom of post#index and post#show. spots can be selectively activated in the booru config. by default, only original spots are active.
This commit is contained in:
parent
11d4f3772e
commit
e2533565bc
@ -9,16 +9,13 @@ class AdvertisementsHelper extends Rails\ActionView\Helper
|
|||||||
if ($ad->html) {
|
if ($ad->html) {
|
||||||
return $ad->html;
|
return $ad->html;
|
||||||
} else {
|
} else {
|
||||||
return $this->contentTag("div",
|
return $this->linkTo(
|
||||||
$this->linkTo(
|
|
||||||
$this->imageTag(
|
$this->imageTag(
|
||||||
$ad->image_url,
|
$ad->image_url,
|
||||||
['alt' => "Advertisement", 'width' => $ad->width, 'height' => $ad->height]
|
['alt' => "Advertisement", 'width' => $ad->width, 'height' => $ad->height]
|
||||||
),
|
),
|
||||||
$this->redirectAdvertisementPath($ad),
|
$this->redirectAdvertisementPath($ad),
|
||||||
['target' => '_blank']
|
['target' => '_blank']
|
||||||
),
|
|
||||||
['style' => "margin-bottom: 1em;"]
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
<?php
|
<div style="margin-bottom: 1em;">
|
||||||
echo $this->print_advertisement("horizontal");
|
<?= $this->print_advertisement("horizontal") ?>
|
||||||
|
</div>
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
<?php
|
<div style="margin-bottom: 1em;">
|
||||||
echo $this->print_advertisement("vertical");
|
<?= $this->print_advertisement("vertical") ?>
|
||||||
|
</div>
|
||||||
|
@ -73,7 +73,7 @@
|
|||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<?php if (CONFIG()->can_see_ads(current_user())) : ?>
|
<?php if (CONFIG()->can_show_ad('post#index-sidebar', current_user())) : ?>
|
||||||
<?= $this->partial('vertical') ?>
|
<?= $this->partial('vertical') ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
@ -83,8 +83,8 @@
|
|||||||
<?= $this->t('.ambiguous') ?><?php array_map(function($x){echo linkTo(h($x), 'wiki#show', array('title' => $x));}, $ambiguous_tags) ?>
|
<?= $this->t('.ambiguous') ?><?php array_map(function($x){echo linkTo(h($x), 'wiki#show', array('title' => $x));}, $ambiguous_tags) ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?php if (CONFIG()->can_see_ads(current_user())) : ?>
|
<?php if (CONFIG()->can_show_ad('post#index-top', current_user())) : ?>
|
||||||
<?= CONFIG()->ad_code_index_bottom ?>
|
<?= $this->partial('horizontal') ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<div id="quick-edit" style="display: none;" class="top-corner-float">
|
<div id="quick-edit" style="display: none;" class="top-corner-float">
|
||||||
@ -99,6 +99,9 @@
|
|||||||
<?= $this->partial("hover") ?>
|
<?= $this->partial("hover") ?>
|
||||||
<?= $this->partial('posts', array('posts' => $this->posts)) ?>
|
<?= $this->partial('posts', array('posts' => $this->posts)) ?>
|
||||||
|
|
||||||
|
<?php if (CONFIG()->can_show_ad('post#index-bottom', current_user())) : ?>
|
||||||
|
<?= $this->partial('horizontal') ?>
|
||||||
|
<?php endif ?>
|
||||||
<div id="paginator">
|
<div id="paginator">
|
||||||
<?= $this->willPaginate($this->posts) ?>
|
<?= $this->willPaginate($this->posts) ?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -20,18 +20,23 @@
|
|||||||
<?= $this->partial('post/show_partials/options_panel') ?>
|
<?= $this->partial('post/show_partials/options_panel') ?>
|
||||||
<?= $this->partial('post/show_partials/related_posts_panel') ?>
|
<?= $this->partial('post/show_partials/related_posts_panel') ?>
|
||||||
<br />
|
<br />
|
||||||
<?php if (CONFIG()->can_see_ads(current_user())) : ?>
|
<?php if (CONFIG()->can_show_ad('post#show-sidebar', current_user())) : ?>
|
||||||
<?= $this->partial('vertical') ?>
|
<?= $this->partial('vertical') ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="content" id="right-col">
|
<div class="content" id="right-col">
|
||||||
<?php if (CONFIG()->can_see_ads(current_user())) : ?>
|
<?php if (CONFIG()->can_show_ad('post#show-top', current_user())) : ?>
|
||||||
<?= $this->partial('horizontal') ?>
|
<?= $this->partial('horizontal') ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<?= $this->partial('post/show_partials/image') ?>
|
<?= $this->partial('post/show_partials/image') ?>
|
||||||
<?= $this->partial('post/show_partials/image_footer', ['post_id' => $this->post->id]) ?>
|
<?= $this->partial('post/show_partials/image_footer', ['post_id' => $this->post->id]) ?>
|
||||||
<?= $this->partial('post/show_partials/edit') ?>
|
<?= $this->partial('post/show_partials/edit') ?>
|
||||||
<?= $this->partial('post/show_partials/comments') ?>
|
<?= $this->partial('post/show_partials/comments') ?>
|
||||||
|
|
||||||
|
<?php if (CONFIG()->can_show_ad('post#show-bottom', current_user())) : ?>
|
||||||
|
<?= $this->partial('horizontal') ?>
|
||||||
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?= $this->contentFor('post_cookie_javascripts', function() { ?>
|
<?= $this->contentFor('post_cookie_javascripts', function() { ?>
|
||||||
|
@ -435,6 +435,21 @@ abstract class DefaultConfig
|
|||||||
'similarity' => 90
|
'similarity' => 90
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Active advertisements spots.
|
||||||
|
* Remove one of them from the list and the ads in that
|
||||||
|
* page/place won't show.
|
||||||
|
* The ones commented are new, extra spots.
|
||||||
|
*/
|
||||||
|
public $active_ad_spots = [
|
||||||
|
'post#index-sidebar',
|
||||||
|
'post#show-sidebar',
|
||||||
|
'post#show-top',
|
||||||
|
'post#index-top',
|
||||||
|
// 'post#index-bottom',
|
||||||
|
// 'post#show-bottom'
|
||||||
|
];
|
||||||
|
|
||||||
# Timeout for Danbooru::http_get_streaming() (used by batch upload, similar images, etc.).
|
# Timeout for Danbooru::http_get_streaming() (used by batch upload, similar images, etc.).
|
||||||
# If this limit is reached, the file that's being downloaded will be invalid.
|
# If this limit is reached, the file that's being downloaded will be invalid.
|
||||||
# Set to 0 to wait indefinitely.
|
# Set to 0 to wait indefinitely.
|
||||||
@ -452,6 +467,18 @@ abstract class DefaultConfig
|
|||||||
return $this->enable_asynchronous_tasks && in_array($name, $this->active_job_tasks);
|
return $this->enable_asynchronous_tasks && in_array($name, $this->active_job_tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does a couple of checks:
|
||||||
|
* - If $user can see ads.
|
||||||
|
* - If $spot is active.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function can_show_ad($spot, $user)
|
||||||
|
{
|
||||||
|
return in_array($spot, $this->active_ad_spots) && $this->can_see_ads($user);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses image filename into tags.
|
* Parses image filename into tags.
|
||||||
* Must return an array with tags or an empty value.
|
* Must return an array with tags or an empty value.
|
||||||
|
Reference in New Issue
Block a user