From 528898b3b3c56047c9bbeeace8196d9cdc7add2a Mon Sep 17 00:00:00 2001 From: guerler Date: Tue, 30 Jul 2024 14:13:55 +0300 Subject: [PATCH 01/14] Add vis parameters to script based visualizations --- .../common/templates/script_entry_point.mako | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/config/plugins/visualizations/common/templates/script_entry_point.mako b/config/plugins/visualizations/common/templates/script_entry_point.mako index dfdf4137666b..82d33bc868c0 100644 --- a/config/plugins/visualizations/common/templates/script_entry_point.mako +++ b/config/plugins/visualizations/common/templates/script_entry_point.mako @@ -3,8 +3,17 @@ ## No stylesheets <%def name="stylesheets()"> -## No javascript libraries + +## Create a container, attach data and import script file <%def name="late_javascripts()"> + <% container = script_attributes.get("container") or "app" %> + <% data_incoming = { + "visualization_id": visualization_id, + "visualization_name": visualization_name, + "visualization_plugin": visualization_plugin, + "visualization_config": config } + %> +
<% tag_attrs = ' '.join([ '{0}="{1}"'.format( key, attr ) for key, attr in script_attributes.items() ]) %> From 59b189d3cb6201665bd96d1c3c7cd50648633323 Mon Sep 17 00:00:00 2001 From: guerler Date: Thu, 1 Aug 2024 13:53:51 +0300 Subject: [PATCH 02/14] Limit allowed script tags, allow adding stylesheet for now --- .../common/templates/script_entry_point.mako | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/config/plugins/visualizations/common/templates/script_entry_point.mako b/config/plugins/visualizations/common/templates/script_entry_point.mako index 82d33bc868c0..8895ff868a10 100644 --- a/config/plugins/visualizations/common/templates/script_entry_point.mako +++ b/config/plugins/visualizations/common/templates/script_entry_point.mako @@ -1,19 +1,29 @@ # -*- coding: utf-8 -*- <%inherit file="visualization_base.mako"/> -## No stylesheets -<%def name="stylesheets()"> +## Add stylesheet +<%def name="stylesheets()"> + <% css = script_attributes.get("css") %> + %if css is not None: + + %endif + ## Create a container, attach data and import script file -<%def name="late_javascripts()"> - <% container = script_attributes.get("container") or "app" %> +<%def name="get_body()"> + ## Collect incoming data <% data_incoming = { "visualization_id": visualization_id, "visualization_name": visualization_name, "visualization_plugin": visualization_plugin, "visualization_config": config } %> + + ## Create a container with default identifier `app` + <% container = script_attributes.get("container") or "app" %>
- <% tag_attrs = ' '.join([ '{0}="{1}"'.format( key, attr ) for key, attr in script_attributes.items() ]) %> - + + ## Add script tag + <% src = script_attributes.get("src") %> + From f0d148cdc783a6717d04060304d6d8cccd2d8ef7 Mon Sep 17 00:00:00 2001 From: guerler Date: Sat, 3 Aug 2024 13:07:01 +0300 Subject: [PATCH 03/14] Allow changing the script type, add root to visualization config --- .../visualizations/common/templates/script_entry_point.mako | 6 ++++-- lib/galaxy/visualization/plugins/config_parser.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/config/plugins/visualizations/common/templates/script_entry_point.mako b/config/plugins/visualizations/common/templates/script_entry_point.mako index 8895ff868a10..2837c717ad2f 100644 --- a/config/plugins/visualizations/common/templates/script_entry_point.mako +++ b/config/plugins/visualizations/common/templates/script_entry_point.mako @@ -13,6 +13,7 @@ <%def name="get_body()"> ## Collect incoming data <% data_incoming = { + "root": h.url_for("/"), "visualization_id": visualization_id, "visualization_name": visualization_name, "visualization_plugin": visualization_plugin, @@ -24,6 +25,7 @@
## Add script tag - <% src = script_attributes.get("src") %> - + <% script_src = script_attributes.get("src") %> + <% script_type = script_attributes.get("type") or "module" %> + diff --git a/lib/galaxy/visualization/plugins/config_parser.py b/lib/galaxy/visualization/plugins/config_parser.py index 85b1ccc79be9..160f52acef2c 100644 --- a/lib/galaxy/visualization/plugins/config_parser.py +++ b/lib/galaxy/visualization/plugins/config_parser.py @@ -221,7 +221,7 @@ def parse(self, xml_tree): # when no tests are given, default to isinstance( object, model_class ) returned["tests"] = self.parse_tests(xml_tree.findall("test")) - # to_params (optional, 0 or more) - tells the registry to set certain params based on the model_clas, tests + # to_params (optional, 0 or more) - tells the registry to set certain params based on the model_class, tests returned["to_params"] = {} if to_params := self.parse_to_params(xml_tree.findall("to_param")): returned["to_params"] = to_params From 151ff346871c848e1ff9e29b70cbd123e9e3405d Mon Sep 17 00:00:00 2001 From: guerler Date: Tue, 6 Aug 2024 14:45:56 +0300 Subject: [PATCH 04/14] Escape title --- .../common/templates/script_entry_point.mako | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/config/plugins/visualizations/common/templates/script_entry_point.mako b/config/plugins/visualizations/common/templates/script_entry_point.mako index 2837c717ad2f..677be72b02b5 100644 --- a/config/plugins/visualizations/common/templates/script_entry_point.mako +++ b/config/plugins/visualizations/common/templates/script_entry_point.mako @@ -12,12 +12,15 @@ ## Create a container, attach data and import script file <%def name="get_body()"> ## Collect incoming data - <% data_incoming = { - "root": h.url_for("/"), - "visualization_id": visualization_id, - "visualization_name": visualization_name, - "visualization_plugin": visualization_plugin, - "visualization_config": config } + <% + from markupsafe import escape + data_incoming = { + "root": h.url_for("/"), + "visualization_id": visualization_id, + "visualization_name": visualization_name, + "visualization_plugin": visualization_plugin, + "visualization_title": escape(title), + "visualization_config": config } %> ## Create a container with default identifier `app` From 550ee0406ff27085c9718f2fd3632511e34b431f Mon Sep 17 00:00:00 2001 From: guerler Date: Tue, 6 Aug 2024 17:29:51 +0300 Subject: [PATCH 05/14] Use Unnamed Visualization as default name for new visualizations --- lib/galaxy/visualization/plugins/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy/visualization/plugins/plugin.py b/lib/galaxy/visualization/plugins/plugin.py index dfe625e53dcb..c53f7977834a 100644 --- a/lib/galaxy/visualization/plugins/plugin.py +++ b/lib/galaxy/visualization/plugins/plugin.py @@ -161,7 +161,7 @@ def _build_render_vars(self, config: Dict[str, Any], trans=None, **kwargs) -> Di render_vars.update( visualization_name=self.name, visualization_display_name=self.config["name"], - title=kwargs.get("title", None), + title=kwargs.get("title", "Unnamed Visualization"), saved_visualization=None, visualization_id=None, visualization_plugin=self.to_dict(), From 0fbb153ed5b967fc7876f78891157cd059eab710 Mon Sep 17 00:00:00 2001 From: guerler Date: Wed, 4 Sep 2024 07:29:56 +0300 Subject: [PATCH 06/14] Fix default visualization name test --- .../unit/app/visualizations/plugins/test_VisualizationPlugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/app/visualizations/plugins/test_VisualizationPlugin.py b/test/unit/app/visualizations/plugins/test_VisualizationPlugin.py index baf72fe065c8..ecab69c4554c 100644 --- a/test/unit/app/visualizations/plugins/test_VisualizationPlugin.py +++ b/test/unit/app/visualizations/plugins/test_VisualizationPlugin.py @@ -74,7 +74,7 @@ def test_build_render_vars_default(self): render_vars = plugin._build_render_vars(config) assert render_vars["visualization_name"] == plugin.name assert render_vars["visualization_display_name"] == plugin.config["name"] - assert render_vars["title"] is None + assert render_vars["title"] is "Unnamed Visualization" assert render_vars["saved_visualization"] is None assert render_vars["visualization_id"] is None assert render_vars["query"] == {} From 1a1e8a9e92a5f3250e4b8a6d0f9c7ec391f7d7bc Mon Sep 17 00:00:00 2001 From: guerler Date: Wed, 4 Sep 2024 09:55:23 +0300 Subject: [PATCH 07/14] Adjust script viz unit tests, fix typo --- .../common/templates/script_entry_point.mako | 2 +- lib/galaxy/app_unittest_utils/galaxy_mock.py | 10 ++++++++-- .../visualizations/plugins/test_VisualizationPlugin.py | 2 +- .../plugins/test_VisualizationsRegistry.py | 10 +++++----- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/config/plugins/visualizations/common/templates/script_entry_point.mako b/config/plugins/visualizations/common/templates/script_entry_point.mako index 677be72b02b5..d5a9946f9cf4 100644 --- a/config/plugins/visualizations/common/templates/script_entry_point.mako +++ b/config/plugins/visualizations/common/templates/script_entry_point.mako @@ -30,5 +30,5 @@ ## Add script tag <% script_src = script_attributes.get("src") %> <% script_type = script_attributes.get("type") or "module" %> - + diff --git a/lib/galaxy/app_unittest_utils/galaxy_mock.py b/lib/galaxy/app_unittest_utils/galaxy_mock.py index 95715c042543..47c44bd19384 100644 --- a/lib/galaxy/app_unittest_utils/galaxy_mock.py +++ b/lib/galaxy/app_unittest_utils/galaxy_mock.py @@ -430,8 +430,14 @@ def remove(self): class MockTemplateHelpers: - def js(*js_files): + def css(*css_files): pass - def css(*css_files): + def dumps(*kwargs): + return {} + + def js(*js_files): pass + + def url_for(*kwargs): + return "/" diff --git a/test/unit/app/visualizations/plugins/test_VisualizationPlugin.py b/test/unit/app/visualizations/plugins/test_VisualizationPlugin.py index ecab69c4554c..772c54bb925e 100644 --- a/test/unit/app/visualizations/plugins/test_VisualizationPlugin.py +++ b/test/unit/app/visualizations/plugins/test_VisualizationPlugin.py @@ -74,7 +74,7 @@ def test_build_render_vars_default(self): render_vars = plugin._build_render_vars(config) assert render_vars["visualization_name"] == plugin.name assert render_vars["visualization_display_name"] == plugin.config["name"] - assert render_vars["title"] is "Unnamed Visualization" + assert render_vars["title"] == "Unnamed Visualization" assert render_vars["saved_visualization"] is None assert render_vars["visualization_id"] is None assert render_vars["query"] == {} diff --git a/test/unit/app/visualizations/plugins/test_VisualizationsRegistry.py b/test/unit/app/visualizations/plugins/test_VisualizationsRegistry.py index 1c7f9707f047..7a95bf980589 100644 --- a/test/unit/app/visualizations/plugins/test_VisualizationsRegistry.py +++ b/test/unit/app/visualizations/plugins/test_VisualizationsRegistry.py @@ -15,7 +15,7 @@ glx_dir = galaxy_directory() template_cache_dir = os.path.join(glx_dir, "database", "compiled_templates") -addtional_templates_dir = os.path.join(glx_dir, "config", "plugins", "visualizations", "common", "templates") +additional_templates_dir = os.path.join(glx_dir, "config", "plugins", "visualizations", "common", "templates") vis_reg_path = "config/plugins/visualizations" config1 = """\ @@ -144,7 +144,7 @@ def test_script_entry(self): HistoryDatasetAssociation - + """ ) @@ -167,11 +167,11 @@ def test_script_entry(self): assert script_entry.serves_templates trans = galaxy_mock.MockTrans() - script_entry._set_up_template_plugin(mock_app_dir.root_path, [addtional_templates_dir]) - response = script_entry._render({}, trans=trans, embedded=True) + script_entry._set_up_template_plugin(mock_app_dir.root_path, [additional_templates_dir]) + response = script_entry.render(trans=trans, embedded=True) assert 'src="bler"' in response assert 'type="text/javascript"' in response - assert 'data-main="one"' in response + assert 'id="mycontainer"' in response mock_app_dir.remove() From ff08779efb913a3b3e94e8174d3affba495af857 Mon Sep 17 00:00:00 2001 From: guerler Date: Wed, 4 Sep 2024 14:02:49 +0300 Subject: [PATCH 08/14] Remove legacy example, add option to link remote script sources --- .../common/templates/script_entry_point.mako | 8 ++- .../visualizations/example/config/example.xml | 45 --------------- .../visualizations/example/package.json | 24 -------- .../visualizations/example/src/script.js | 54 ------------------ .../visualizations/example/static/logo.png | Bin 7438 -> 0 bytes lib/galaxy/app_unittest_utils/galaxy_mock.py | 3 + lib/galaxy/web/framework/helpers/__init__.py | 12 ++++ 7 files changed, 20 insertions(+), 126 deletions(-) delete mode 100644 config/plugins/visualizations/example/config/example.xml delete mode 100644 config/plugins/visualizations/example/package.json delete mode 100644 config/plugins/visualizations/example/src/script.js delete mode 100644 config/plugins/visualizations/example/static/logo.png diff --git a/config/plugins/visualizations/common/templates/script_entry_point.mako b/config/plugins/visualizations/common/templates/script_entry_point.mako index d5a9946f9cf4..80ad34908930 100644 --- a/config/plugins/visualizations/common/templates/script_entry_point.mako +++ b/config/plugins/visualizations/common/templates/script_entry_point.mako @@ -3,9 +3,10 @@ ## Add stylesheet <%def name="stylesheets()"> - <% css = script_attributes.get("css") %> - %if css is not None: - + <% script_css = script_attributes.get("css") %> + %if script_css is not None: + <% script_css = script_css if h.is_url(script_css) else f"{static_url}{script_css}" %> + %endif @@ -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" %> diff --git a/config/plugins/visualizations/example/config/example.xml b/config/plugins/visualizations/example/config/example.xml deleted file mode 100644 index cc2dd898fb79..000000000000 --- a/config/plugins/visualizations/example/config/example.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - This is a developer example which demonstrates how to implement and configure a basic d3-based plugin for charts. - - - HistoryDatasetAssociation - tabular.Tabular - tabular.CSV - dataset_id - - - - dataset_id - - - - - data_dialog - - data_dialog - false - - - - - x - - data_column - true - - - y - - data_column - true - - - z - - data_column - true - - - \ No newline at end of file diff --git a/config/plugins/visualizations/example/package.json b/config/plugins/visualizations/example/package.json deleted file mode 100644 index 199cab67b083..000000000000 --- a/config/plugins/visualizations/example/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "visualization", - "version": "0.2.0", - "keywords": [ - "galaxy", - "visualization" - ], - "license": "AFL-3.0", - "dependencies": { - "@galaxyproject/charts": "^0.1.0", - "babel-preset-env": "^1.6.1", - "backbone": "^1.3.3", - "bootstrap": "^3.3.7", - "d3": "^4.12.2", - "jquery": "^3.1.1", - "underscore": "^1.8.3" - }, - "scripts": { - "build": "parcel build src/script.js --dist-dir static" - }, - "devDependencies": { - "parcel": "2.11.0" - } -} diff --git a/config/plugins/visualizations/example/src/script.js b/config/plugins/visualizations/example/src/script.js deleted file mode 100644 index 4fda38c2380d..000000000000 --- a/config/plugins/visualizations/example/src/script.js +++ /dev/null @@ -1,54 +0,0 @@ -import * as d3 from "d3"; -import * as _ from "underscore"; -import { request as requestDatasets } from "@galaxyproject/charts/lib/utilities/datasets"; - -_.extend(window.bundleEntries || {}, { - load: function(options) { - var chart = options.chart; - var root = options.root; - requestDatasets({ - root: root, - dataset_id: chart.get("dataset_id"), - dataset_groups: chart.groups, - success: function(groups) { - var colors = d3.scaleOrdinal(d3.schemeCategory20); - var error = null; - _.each(groups, function(group, group_index) { - try { - $("#" + options.target).append(""); - var svg = d3.select("#myexample"); - var height = parseInt(svg.style("height")); - var width = parseInt(svg.style("width")); - var maxValue = d3.max(group.values, function(d) { - return Math.max(d.x, d.y); - }); - svg - .selectAll("bubbles") - .data(group.values) - .enter() - .append("circle") - .attr("r", function(d) { - return Math.abs(d.z) * 20 / maxValue; - }) - .attr("cy", function(d, i) { - return height * d.y / maxValue; - }) - .attr("cx", function(d) { - return width * d.x / maxValue; - }) - .style("stroke", colors(group_index)) - .style("fill", "white"); - } catch (err) { - error = err; - } - }); - if (error) { - chart.state("failed", error); - } else { - chart.state("ok", "Workshop chart has been drawn."); - } - options.process.resolve(); - } - }); - } -}); diff --git a/config/plugins/visualizations/example/static/logo.png b/config/plugins/visualizations/example/static/logo.png deleted file mode 100644 index 0c13459935bbbc23dec5b7c05450b19b106b22f4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7438 zcmb_>WmH_vwk;Oio#5^?5*!*05(tnW!J(mX8h1z_xJz*N;O+#1YY6VrI5h6i1bg|; zIq$r8|KB}E?W$TeYtCBrW39cbA~e(#aWG$FA|N2(C@aZ-{9AkdEn4WPf8WZOSGfoX z$mce4avI8Va&#Ilj+Qp|76=F;F)`X}jw@QkQW1`ZMWj-Bb+Nc4Q8n6{25pqDs|Hb( z6N?XIU$^~URxs2h^j{#CyrU#_qqZKS69%)|4TcV=9t# zTb8y?ybUaOs;<%eVKms9P~$JU?+HAc5|keLl(C(rOkoPWG!o2Bh|5h&5!a!|n2=$; zmM;13tJZGFgTyl!qB!4YLf-=wMq565adp=zD?w(;k+uIM`I+XzCLpOyyc&-Vs&IeK zzAm$RA+bfx!xF9w@=Dp}>Jy-%#S_syWHU>NDq3jb*kbN~65zYH$G)NpY+_XBK78Fi z=JUbhBm*?9+pezhG9l&+skky&n-KJ<>d*gGRL4!b8e5ep>%dVrhlAc#i|iL$mDKg(D?{$OzWU zXJixh8KsjgT`Nt(eUD=5CcAh~xmEY{zmOgkGM_3ste$vtu9Zo=%kkSBadZ%lV{q8eJZ9~i^yLZABO#t+UbKPGO}ut#_Y!= z@`w@;uEmM>Za|-Ne;Q8ZLb{-W&BP|bX)sl$8&Syd&^{geH#u-xbbu<9$uXgiDQcR) z#c8IQDr&-PZRz?7_-2xGn>uK$El0tG_^i@*da}m<`i|7@AtB3#GuI2PyAQW94f*0v z4bM|8=VhHNPls>A(IKI#L|IqaO4-dU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xn&h7hX z-H7h-N)*GGSziISR8zPdtwvya79;;i*!2QrF**1uq4k$Zceh6tC+XNu9I}dANa)A; zp-Z^)aB*}ThZV*1hxLt=np6Hq?!jbh9S%nf4oN?9ntCh~)`lLirC{>SpIt5z;Bp*1 z?v}Zbw`Oo5y7{-eeKX*#;-J||!+Uh&?{071nJnE(I) diff --git a/lib/galaxy/app_unittest_utils/galaxy_mock.py b/lib/galaxy/app_unittest_utils/galaxy_mock.py index 47c44bd19384..0fcec287878f 100644 --- a/lib/galaxy/app_unittest_utils/galaxy_mock.py +++ b/lib/galaxy/app_unittest_utils/galaxy_mock.py @@ -439,5 +439,8 @@ def dumps(*kwargs): def js(*js_files): pass + def is_url(*kwargs): + return True + def url_for(*kwargs): return "/" diff --git a/lib/galaxy/web/framework/helpers/__init__.py b/lib/galaxy/web/framework/helpers/__init__.py index 7fde6906cf19..49fff0ee72c7 100644 --- a/lib/galaxy/web/framework/helpers/__init__.py +++ b/lib/galaxy/web/framework/helpers/__init__.py @@ -6,6 +6,7 @@ GalaxyWebTransaction in galaxy/webapps/base/webapp.py """ +import re from datetime import ( datetime, timedelta, @@ -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. From 7827a2de8a2b689eba1d1cce27f011dd9573ee8b Mon Sep 17 00:00:00 2001 From: guerler Date: Wed, 4 Sep 2024 14:24:26 +0300 Subject: [PATCH 09/14] Remove legacy example from staging script --- client/gulpfile.js | 1 - 1 file changed, 1 deletion(-) diff --git a/client/gulpfile.js b/client/gulpfile.js index 873bae0c0bd8..2915734bad78 100644 --- a/client/gulpfile.js +++ b/client/gulpfile.js @@ -17,7 +17,6 @@ const STATIC_PLUGIN_BUILD_IDS = [ "cytoscape", "drawrna", "editor", - "example", "fits_image_viewer", "h5web", "heatmap/heatmap_default", From db22b485c6bcb09181e50c8382358586d6da7bc6 Mon Sep 17 00:00:00 2001 From: guerler Date: Wed, 4 Sep 2024 15:05:41 +0300 Subject: [PATCH 10/14] Add additional test conditions for script based plugins --- lib/galaxy/web/framework/helpers/__init__.py | 5 +++++ .../visualizations/plugins/test_VisualizationsRegistry.py | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/galaxy/web/framework/helpers/__init__.py b/lib/galaxy/web/framework/helpers/__init__.py index 49fff0ee72c7..f6f90bc54820 100644 --- a/lib/galaxy/web/framework/helpers/__init__.py +++ b/lib/galaxy/web/framework/helpers/__init__.py @@ -109,6 +109,11 @@ def is_true(val): def is_url(val): """ Regular expression to match common URL protocols + + >>> assert is_url(None) == False + >>> assert is_url("is_url") == False + >>> assert is_url("http://is_url") == True + >>> assert is_url("https://is_url") == True """ if val is not None: url_pattern = re.compile(r"^(https?:\/\/|ftp:\/\/)") diff --git a/test/unit/app/visualizations/plugins/test_VisualizationsRegistry.py b/test/unit/app/visualizations/plugins/test_VisualizationsRegistry.py index 7a95bf980589..ee87feb61f39 100644 --- a/test/unit/app/visualizations/plugins/test_VisualizationsRegistry.py +++ b/test/unit/app/visualizations/plugins/test_VisualizationsRegistry.py @@ -144,7 +144,7 @@ def test_script_entry(self): HistoryDatasetAssociation - + """ ) @@ -169,9 +169,9 @@ def test_script_entry(self): trans = galaxy_mock.MockTrans() script_entry._set_up_template_plugin(mock_app_dir.root_path, [additional_templates_dir]) response = script_entry.render(trans=trans, embedded=True) - assert 'src="bler"' in response - assert 'type="text/javascript"' in response - assert 'id="mycontainer"' in response + assert '