Skip to content

Commit b1e48ce

Browse files
committed
Handle External URLs, add https if needed
1 parent 8282c7f commit b1e48ce

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

idr_gallery/templates/idr_gallery/idr_study.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ <h2>{{ idr_id }}</h2>
4646
<p>PMC ID: <a href="{{ pmc_id.link }}">{{ pmc_id.name }}</a></p>
4747
{% endif %}
4848

49+
{% for url in external_urls %}
50+
<p>External URL: <a href="{{ url }}">{{ url }}</a></p>
51+
{% endfor %}
52+
4953
<hr>
5054

5155
{% for kvp in other_kvps %}

idr_gallery/utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,10 @@ def parse_kvp_with_link(key, kvps):
5050
"name": value.split("http", 1)[0].strip(),
5151
"link": "http" + value.split("http", 1)[1] if "http" in value else None
5252
}
53+
54+
55+
def prefix_http(url):
56+
"""Ensure the URL starts with http:// or https://."""
57+
if not url.startswith(("http://", "https://")):
58+
return "https://" + url
59+
return url

idr_gallery/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from .data.background_images import IDR_IMAGES, TISSUE_IMAGES, CELL_IMAGES
2121
from .data.tabs import TABS
2222
from .version import VERSION
23-
from .utils import get_image_info, BIA_URL, parse_kvp_with_link
23+
from .utils import get_image_info, BIA_URL, parse_kvp_with_link, prefix_http
2424

2525
try:
2626
from omero_mapr import mapr_settings

0 commit comments

Comments
 (0)