Skip to content

Commit

Permalink
Move donation banner to separate html file
Browse files Browse the repository at this point in the history
  • Loading branch information
cdrini committed Nov 20, 2024
1 parent 07cd6b8 commit 07615c0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 23 deletions.
19 changes: 0 additions & 19 deletions openlibrary/plugins/upstream/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1434,25 +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
# Note donate.js also reads the ?ymd=YYYYMMDD parameter and the
# `variant` parameter.
if ia_host != "archive.org":
script_src = f"https://{ia_host}/includes/donate.js"
else:
script_src = "/cdn/archive.org/donate.js"

html = f"""
<div id="donato"></div>
<script src="{websafe(script_src)}" data-platform="ol"></script>
"""
return html


@public
def get_ia_host(allow_dev: bool = False) -> str:
if allow_dev:
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/templates/site/alert.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$if not is_bot():
$:get_donation_include()
$:render_template('site/donation_banner')

$ lang = get_lang() or 'en'
$ supported_languages = get_supported_languages()
Expand Down
3 changes: 0 additions & 3 deletions openlibrary/templates/site/donate.html

This file was deleted.

13 changes: 13 additions & 0 deletions openlibrary/templates/site/donation_banner.html
Original file line number Diff line number Diff line change
@@ -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"

<div id="donato"></div>
<script src="$script_src" data-platform="ol"></script>

0 comments on commit 07615c0

Please sign in to comment.