Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit 4fbb3bc

Browse files
committed
Bring back simple ask for $$ to support Runestone
1 parent 267dc40 commit 4fbb3bc

File tree

3 files changed

+52
-8
lines changed

3 files changed

+52
-8
lines changed

runestone/common/css/runestone-custom-sphinx-bootstrap.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,3 +1147,20 @@ margin-right: 3px;
11471147
border-radius: 1.25em;
11481148
}
11491149
/*End theme toggle*/
1150+
1151+
/* for ads */
1152+
.adcopy {
1153+
width: 60%;
1154+
background-color: #f2e0c3;
1155+
padding: 10px;
1156+
margin-left: auto;
1157+
margin-right: auto;
1158+
margin-top: 10px;
1159+
border: solid black 2px;
1160+
border-radius: 10px;
1161+
}
1162+
1163+
.adcopy .donateb {
1164+
1165+
margin-left: 30%;
1166+
}

runestone/common/js/bookfuncs.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,24 @@ function notifyRunestoneComponents() {
251251
$(document).trigger("runestone:pre-login-complete");
252252
}
253253

254+
function placeAdCopy() {
255+
if (typeof showAd !== "undefined" && showAd) {
256+
let adNum = Math.floor(Math.random() * 2) + 1;
257+
let adBlock = document.getElementById(`adcopy_${adNum}`);
258+
let rsElements = document.querySelectorAll(".runestone");
259+
if (rsElements.length > 0) {
260+
let randomIndex = Math.floor(Math.random() * rsElements.length);
261+
rsElements[randomIndex].after(adBlock)
262+
adBlock.style.display = "block";
263+
}
264+
}
265+
}
266+
254267
// initialize stuff
255268
$(function () {
256269
if (eBookConfig) {
257270
handlePageSetup();
271+
placeAdCopy();
258272
} else {
259273
if (typeof eBookConfig === "undefined") {
260274
console.log(

runestone/common/project_template/_templates/plugin_layouts/sphinx_bootstrap/layout.html

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -309,15 +309,28 @@
309309
<!-- Ad Serving for Runestone Campaign -->
310310
{% if dynamic_pages == 'True' %}
311311
{% raw %}
312-
{% if settings.num_banners > 0 and settings.show_rs_banner %}
313-
<div style="width: 100%;">
314-
<a href="/runestone/default/donate?banner={{banner_num}}">
315-
<img class="runestone-banner"
316-
src="/runestone/static/images/RunestoneBanner{{banner_num}}.png"
317-
alt="Please Support Runestone"
318-
style="display: block; width: 728px; margin-left: auto; margin-right: auto; margin-top: 10px;">
319-
</a>
312+
{% if show_rs_banner %}
313+
<script>
314+
var showAd = true;
315+
</script>
316+
<div id="adcopy_1" class="adcopy" style="display: none;">
317+
<h4>Before you keep reading...</h4>
318+
<p>Runestone Academy can only continue if we get support from individuals like you. As a student you are well aware of the high cost of textbooks. Our mission is to provide great books to you for free, but we ask that you consider a $10 donation, more if you can or less if $10 is a burden.
319+
</p>
320+
<div class="donateb">
321+
<a href="/runestone/default/donate?ad=1" role="button" class="btn btn-info">Support Runestone Academy Today</a></div>
322+
<div id="adcopy_2" class="adcopy" style="display: none;">
323+
<h4>Before you keep reading...</h4>
324+
<p>Making great stuff takes time and $$. If you appreciate the book you are reading now and want to keep quality materials free for other students please consider a donation to Runestone Academy. We ask that you consider a $10 donation, but if you can give more thats great, if $10 is too much for your budget we would be happy with whatever you can afford as a show of support.
325+
</p>
326+
<div class="donateb">
327+
<a href="/runestone/default/donate?ad=2" role="button" class="btn btn-info">Support Runestone Academy Today</a></div>
320328
</div>
329+
</div>
330+
{% else %}
331+
<script>
332+
var showAd = false;
333+
</script>
321334
{% endif %}
322335
{% endraw %}
323336
{% endif %}

0 commit comments

Comments
 (0)