Commit 4abac2ca authored by Simon Welsh's avatar Simon Welsh

Switch out STW sponsorship for google ads

parent fffd7ec5
<?hh
$withAd = true;
require 'xhp/init.php';
require 'tags/calendar.php';
......
......@@ -9,7 +9,7 @@ class :logs:document extends :x:element {
return <x:doctype>
<html>
{$this->getAttribute('head')}
<body>
<body class="ads adsbygoogle ad">
{$this->getAttribute('body')}
<logs:foot />
</body>
......
<?hh
class :logs:sponsor extends :x:element {
attribute
bool withAd = false,
bool foot = false;
protected function render() {
return <p>
Logging kindly sponsored by <a href="http://stripethenet.com/">Stripe The Net: Hosting and Deployment, made simple</a>.
</p>;
if ($this->:withAd) {
if ($this->:foot) {
$ad = <p>
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-2032949232018859"
data-ad-slot="3717064928"></ins>
</p>;
} else {
$ad = <p>
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-2032949232018859"
data-ad-slot="3856665720"></ins>
</p>;
}
$ad->appendChild(<script>(adsbygoogle = window.adsbygoogle || []).push({'{}'});</script>);
} else {
$ad = <x:frag />;
}
return <x:frag>
<p>
Logging sponsored by you? <a href="mailto:sponsor@logged.nz?subject=SilverStripe Log Sponsorship">Get in touch</a>!
</p>
{$ad};
</x:frag>;
}
}
......@@ -8,6 +8,10 @@ $dates = build_dates();
$body = <x:frag />;
if ($withAd) {
$body->appendChild(<script src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" async={true} />);
}
if(isset($_GET['date']) && preg_match('#^20[0-9]{2}-[01][0-9]-[0-3][0-9]$#', $_GET['date'])) {
$time = strtotime($_GET['date']);
$year = date('Y', $time);
......@@ -19,11 +23,11 @@ if(isset($_GET['date']) && preg_match('#^20[0-9]{2}-[01][0-9]-[0-3][0-9]$#', $_G
$body->appendChild(<logs:info>
<h2>IRC log for {date('j F Y', $time)}</h2>
</logs:info>);
$body->appendChild(<logs:sponsor />);
$body->appendChild(<logs:sponsor withAd={$withAd} />);
$body->appendChild(<logs:timezone />);
$body->appendChild(<logs:logs stamp={$time} />);
$body->appendChild(<logs:sponsor />);
$body->appendChild(<logs:sponsor withAd={$withAd} foot={true} />);
} else {
header('Location: index.php');
exit;
......@@ -41,7 +45,7 @@ if(isset($_GET['date']) && preg_match('#^20[0-9]{2}-[01][0-9]-[0-3][0-9]$#', $_G
} else {
$body->appendChild(<logs:info />);
}
$body->appendChild(<logs:sponsor />);
$body->appendChild(<logs:sponsor withAd={$withAd} />);
$body->appendChild(<logs:timezone />);
$thisMonth = mktime(0, 0, 0, date('n'), 1, date('Y'));
......@@ -49,7 +53,7 @@ if(isset($_GET['date']) && preg_match('#^20[0-9]{2}-[01][0-9]-[0-3][0-9]$#', $_G
foreach($dates as $year => $months) {
$body->appendChild(<logs:year year={$year} months={$months} />);
}
$body->appendChild(<logs:sponsor />);
$body->appendChild(<logs:sponsor withAd={$withAd} foot={true} />);
}
echo <logs:document head={$head} body={$body} />;
......@@ -22,6 +22,10 @@ $id = 0;
$body = <x:frag />;
if ($withAd) {
$body->appendChild(<script src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" async={true} />);
}
$header = <h2>Search results for "{$term}"</h2>;
if($order) {
......@@ -32,7 +36,7 @@ if($order) {
$body->appendChild(<logs:info>
{$header}
</logs:info>);
$body->appendChild(<logs:sponsor />);
$body->appendChild(<logs:sponsor withAd={$withAd} />);
$body->appendChild(<logs:timezone />);
if(empty($results)) {
......@@ -45,6 +49,6 @@ if(empty($results)) {
$body->appendChild(<logs:logs logs={$results} format="d/m/Y H:i:s" class="results" />);
}
$body->appendChild(<logs:sponsor />);
$body->appendChild(<logs:sponsor withAd={$withAd} foot={true} />);
echo <logs:document head={$head} body={$body} />;
......@@ -10,9 +10,14 @@ $body = <x:frag>
<logs:info>
<h2>Swear stats</h2>
</logs:info>
<logs:sponsor />
<logs:sponsor withAd={$withAd} />
</x:frag>;
if ($withAd) {
$body->appendChild(<script src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" async={true} />);
}
$stats = get_stats();
$d = <div class="swear" id="top"><h3>Top speakers</h3></div>;
......@@ -51,6 +56,6 @@ foreach($stats[1] as $name => $values) {
}
$body->appendChild(<div class="clear"></div>);
$body->appendChild(<logs:sponsor />);
$body->appendChild(<logs:sponsor withAd={$withAd} foot={true} />);
echo <logs:document head={$head} body={$body} />;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment