diff --git a/openlibrary/plugins/upstream/utils.py b/openlibrary/plugins/upstream/utils.py index 5185e873cbc..1d227ab2964 100644 --- a/openlibrary/plugins/upstream/utils.py +++ b/openlibrary/plugins/upstream/utils.py @@ -1434,33 +1434,6 @@ def jsdef_get(obj, key, default=None): return obj.get(key, default) -@public -def get_donation_include() -> str: - ia_host = get_ia_host(allow_dev=True) - # The following allows archive.org staff to test banners without - # needing to reload openlibrary services - if ia_host != "archive.org": - script_src = f"https://{ia_host}/includes/donate.js" - else: - script_src = "/cdn/archive.org/donate.js" - - if 'ymd' in (web_input := web.input()): - # Should be eg 20220101 (YYYYMMDD) - if len(web_input.ymd) == 8 and web_input.ymd.isdigit(): - script_src += '?' + urllib.parse.urlencode({'ymd': web_input.ymd}) - else: - raise ValueError('?ymd should be 8 digits (eg 20220101)') - - html = ( - """ -
- - """ - % script_src - ) - return html - - @public def get_ia_host(allow_dev: bool = False) -> str: if allow_dev: diff --git a/openlibrary/templates/site/alert.html b/openlibrary/templates/site/alert.html index 103c78dd249..781cc22f8f8 100644 --- a/openlibrary/templates/site/alert.html +++ b/openlibrary/templates/site/alert.html @@ -1,5 +1,5 @@ -$if False and not is_bot(): - $:get_donation_include() +$if not is_bot(): + $:render_template('site/donation_banner') $ lang = get_lang() or 'en' $ supported_languages = get_supported_languages() diff --git a/openlibrary/templates/site/donate.html b/openlibrary/templates/site/donate.html deleted file mode 100644 index 7bc7b424819..00000000000 --- a/openlibrary/templates/site/donate.html +++ /dev/null @@ -1,3 +0,0 @@ - -$if not is_bot(): - $:get_donation_include() diff --git a/openlibrary/templates/site/donation_banner.html b/openlibrary/templates/site/donation_banner.html new file mode 100644 index 00000000000..fa15162fd4b --- /dev/null +++ b/openlibrary/templates/site/donation_banner.html @@ -0,0 +1,13 @@ +$ ia_host = get_ia_host(allow_dev=True) + +$# The following allows archive.org staff to test banners without +$# needing to reload openlibrary services +$# Note donate.js also reads the ?ymd=YYYYMMDD parameter and the +$# `variant` parameter. +$if ia_host != "archive.org": + $ script_src = "https://%s/includes/donate.js" % ia_host +$else: + $ script_src = "/cdn/archive.org/donate.js" + +
+