Skip to content

Commit

Permalink
Remove legacy example, add option to link remote script sources
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Sep 4, 2024
1 parent 1a1e8a9 commit 0c23950
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<%def name="stylesheets()">
<% css = script_attributes.get("css") %>
%if css is not None:
<% css = css if h.is_url(css) else f"{static_url}{css}" %>
<link rel="stylesheet" href="${css}">
%endif
</%def>
Expand All @@ -29,6 +30,7 @@
## Add script tag
<% script_src = script_attributes.get("src") %>
<% script_src = script_src if h.is_url(script_src) else f"{static_url}{script_src}" %>
<% script_type = script_attributes.get("type") or "module" %>
<script type="${script_type}" src="${script_src}"></script>
</%def>
45 changes: 0 additions & 45 deletions config/plugins/visualizations/example/config/example.xml

This file was deleted.

24 changes: 0 additions & 24 deletions config/plugins/visualizations/example/package.json

This file was deleted.

54 changes: 0 additions & 54 deletions config/plugins/visualizations/example/src/script.js

This file was deleted.

Binary file not shown.
3 changes: 3 additions & 0 deletions lib/galaxy/app_unittest_utils/galaxy_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,5 +439,8 @@ def dumps(*kwargs):
def js(*js_files):
pass

def is_url(*kwargs):
return True

def url_for(*kwargs):
return "/"
12 changes: 12 additions & 0 deletions lib/galaxy/web/framework/helpers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
GalaxyWebTransaction in galaxy/webapps/base/webapp.py
"""

import re
from datetime import (
datetime,
timedelta,
Expand Down Expand Up @@ -105,6 +106,17 @@ def is_true(val):
return val is True or val in ["True", "true", "T", "t"]


def is_url(val):
"""
Regular expression to match common URL protocols
"""
if val is not None:
url_pattern = re.compile(r"^(https?:\/\/|ftp:\/\/)")
return bool(url_pattern.match(val))
else:
return False


def to_js_bool(val):
"""
Prints javascript boolean for passed value.
Expand Down

0 comments on commit 0c23950

Please sign in to comment.