Skip to content

Commit dedebe7

Browse files
authored
Merge pull request #10053 from cdrini/reenable-donations
Re-enable donations banner
2 parents 1425c88 + 07615c0 commit dedebe7

File tree

4 files changed

+15
-32
lines changed

4 files changed

+15
-32
lines changed

openlibrary/plugins/upstream/utils.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,33 +1434,6 @@ def jsdef_get(obj, key, default=None):
14341434
return obj.get(key, default)
14351435

14361436

1437-
@public
1438-
def get_donation_include() -> str:
1439-
ia_host = get_ia_host(allow_dev=True)
1440-
# The following allows archive.org staff to test banners without
1441-
# needing to reload openlibrary services
1442-
if ia_host != "archive.org":
1443-
script_src = f"https://{ia_host}/includes/donate.js"
1444-
else:
1445-
script_src = "/cdn/archive.org/donate.js"
1446-
1447-
if 'ymd' in (web_input := web.input()):
1448-
# Should be eg 20220101 (YYYYMMDD)
1449-
if len(web_input.ymd) == 8 and web_input.ymd.isdigit():
1450-
script_src += '?' + urllib.parse.urlencode({'ymd': web_input.ymd})
1451-
else:
1452-
raise ValueError('?ymd should be 8 digits (eg 20220101)')
1453-
1454-
html = (
1455-
"""
1456-
<div id="donato"></div>
1457-
<script src="%s" data-platform="ol"></script>
1458-
"""
1459-
% script_src
1460-
)
1461-
return html
1462-
1463-
14641437
@public
14651438
def get_ia_host(allow_dev: bool = False) -> str:
14661439
if allow_dev:

openlibrary/templates/site/alert.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
$if False and not is_bot():
2-
$:get_donation_include()
1+
$if not is_bot():
2+
$:render_template('site/donation_banner')
33

44
$ lang = get_lang() or 'en'
55
$ supported_languages = get_supported_languages()

openlibrary/templates/site/donate.html

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
$ ia_host = get_ia_host(allow_dev=True)
2+
3+
$# The following allows archive.org staff to test banners without
4+
$# needing to reload openlibrary services
5+
$# Note donate.js also reads the ?ymd=YYYYMMDD parameter and the
6+
$# `variant` parameter.
7+
$if ia_host != "archive.org":
8+
$ script_src = "https://%s/includes/donate.js" % ia_host
9+
$else:
10+
$ script_src = "/cdn/archive.org/donate.js"
11+
12+
<div id="donato"></div>
13+
<script src="$script_src" data-platform="ol"></script>

0 commit comments

Comments
 (0)