From 0c23950cb28772e038c33ea77cea2add0c037dbc Mon Sep 17 00:00:00 2001 From: guerler Date: Wed, 4 Sep 2024 14:02:49 +0300 Subject: [PATCH] Remove legacy example, add option to link remote script sources --- .../common/templates/script_entry_point.mako | 2 + .../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, 17 insertions(+), 123 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..0563a58b14f8 100644 --- a/config/plugins/visualizations/common/templates/script_entry_point.mako +++ b/config/plugins/visualizations/common/templates/script_entry_point.mako @@ -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}" %> %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=4nM)Q+UE3$)?aQZ6$LD%lIh?phA2Y*)KZd zJ_|p;Nv9WNZ;$8}X0zX73q&@$tT43VFlLbzTIJ;RB&lSQU98;>7f*xK6%S>&7F-AZ z0j>r&hEsqyzd7l_m0KD77!9Md=eGCFua1L!4CeUX|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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.