From 8f2788121f88bb47b72f5112b935f3b47b57798c Mon Sep 17 00:00:00 2001 From: Simon Li Date: Mon, 4 Jul 2016 11:56:38 +0100 Subject: [PATCH 1/4] Add option to build link-to weburls with client-side javascript --- components/tools/OmeroWeb/omeroweb/settings.py | 6 ++++++ .../templates/webclient/annotations/metadata_general.html | 2 ++ components/tools/OmeroWeb/omeroweb/webclient/views.py | 7 +++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/components/tools/OmeroWeb/omeroweb/settings.py b/components/tools/OmeroWeb/omeroweb/settings.py index b1d03fb9548..36d39cd7ac5 100644 --- a/components/tools/OmeroWeb/omeroweb/settings.py +++ b/components/tools/OmeroWeb/omeroweb/settings.py @@ -663,6 +663,12 @@ def leave_none_unset_int(s): " 'webtest/webclient_plugins/center_plugin.overlay.js.html'," " 'channel_overlay_panel']``. " "The javascript loads data into ``$('#div_id')``.")], + "omero.web.ui.use_client_host": + ["WEB_URL_USE_CLIENT_HOST", + False, + bool, + ("If True build link-to URLs using client-side javascript, otherwise" + " use the server side HOST header")], } DEPRECATED_SETTINGS_MAPPINGS = { diff --git a/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/annotations/metadata_general.html b/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/annotations/metadata_general.html index 26a3af22f0a..1779a5b995c 100644 --- a/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/annotations/metadata_general.html +++ b/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/annotations/metadata_general.html @@ -105,6 +105,8 @@ $("#link_info_popup").show(); {% if webclient_path %} var lnk = "{{ webclient_path }}"; + {% elif webclient_pathname %} + var lnk = location.protocol + "//" + location.host + "{{ webclient_pathname }}"; {% else %} var lnk = location.href.substring(0,location.href.length - location.search.length); if (lnk.charAt( lnk.length-1 ) == "#") { lnk = lnk.substring(0, lnk.length-1)} diff --git a/components/tools/OmeroWeb/omeroweb/webclient/views.py b/components/tools/OmeroWeb/omeroweb/webclient/views.py index 1204f959943..40a0c128109 100755 --- a/components/tools/OmeroWeb/omeroweb/webclient/views.py +++ b/components/tools/OmeroWeb/omeroweb/webclient/views.py @@ -1537,8 +1537,11 @@ def load_metadata_details(request, c_type, c_id, conn=None, share_id=None, context['figScripts'] = figScripts context['template'] = template - context['webclient_path'] = request.build_absolute_uri( - reverse('webindex')) + if settings.WEB_URL_USE_CLIENT_HOST: + context['webclient_pathname'] = reverse('webindex') + else: + context['webclient_path'] = request.build_absolute_uri( + reverse('webindex')) return context From ea0e6082dfc07c5ceda9d0d155e16315fc86efc9 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Fri, 19 Aug 2016 20:14:15 +0100 Subject: [PATCH 2/4] Always use client-side javascript for link-to URL This removes the need for another config property --- components/tools/OmeroWeb/omeroweb/settings.py | 6 ------ .../templates/webclient/annotations/metadata_general.html | 4 +--- components/tools/OmeroWeb/omeroweb/webclient/views.py | 6 +----- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/components/tools/OmeroWeb/omeroweb/settings.py b/components/tools/OmeroWeb/omeroweb/settings.py index 36d39cd7ac5..b1d03fb9548 100644 --- a/components/tools/OmeroWeb/omeroweb/settings.py +++ b/components/tools/OmeroWeb/omeroweb/settings.py @@ -663,12 +663,6 @@ def leave_none_unset_int(s): " 'webtest/webclient_plugins/center_plugin.overlay.js.html'," " 'channel_overlay_panel']``. " "The javascript loads data into ``$('#div_id')``.")], - "omero.web.ui.use_client_host": - ["WEB_URL_USE_CLIENT_HOST", - False, - bool, - ("If True build link-to URLs using client-side javascript, otherwise" - " use the server side HOST header")], } DEPRECATED_SETTINGS_MAPPINGS = { diff --git a/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/annotations/metadata_general.html b/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/annotations/metadata_general.html index 1779a5b995c..df6ed83145f 100644 --- a/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/annotations/metadata_general.html +++ b/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/annotations/metadata_general.html @@ -104,9 +104,7 @@ $("#show_link_btn").click(function(){ $("#link_info_popup").show(); {% if webclient_path %} - var lnk = "{{ webclient_path }}"; - {% elif webclient_pathname %} - var lnk = location.protocol + "//" + location.host + "{{ webclient_pathname }}"; + var lnk = location.protocol + "//" + location.host + "{{ webclient_path }}"; {% else %} var lnk = location.href.substring(0,location.href.length - location.search.length); if (lnk.charAt( lnk.length-1 ) == "#") { lnk = lnk.substring(0, lnk.length-1)} diff --git a/components/tools/OmeroWeb/omeroweb/webclient/views.py b/components/tools/OmeroWeb/omeroweb/webclient/views.py index 40a0c128109..09a1a777946 100755 --- a/components/tools/OmeroWeb/omeroweb/webclient/views.py +++ b/components/tools/OmeroWeb/omeroweb/webclient/views.py @@ -1537,11 +1537,7 @@ def load_metadata_details(request, c_type, c_id, conn=None, share_id=None, context['figScripts'] = figScripts context['template'] = template - if settings.WEB_URL_USE_CLIENT_HOST: - context['webclient_pathname'] = reverse('webindex') - else: - context['webclient_path'] = request.build_absolute_uri( - reverse('webindex')) + context['webclient_path'] = reverse('webindex') return context From bbf9887c1697e07971b48d3aa2c2c33af4c7dc0a Mon Sep 17 00:00:00 2001 From: Simon Li Date: Tue, 5 Jul 2016 11:50:13 +0100 Subject: [PATCH 3/4] Use client-side JS for batch-annotate URL --- .../webclient/annotations/includes/toolbar.html | 10 ++++------ components/tools/OmeroWeb/omeroweb/webclient/views.py | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/annotations/includes/toolbar.html b/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/annotations/includes/toolbar.html index 2e65d80f1cd..27a5415bd04 100644 --- a/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/annotations/includes/toolbar.html +++ b/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/annotations/includes/toolbar.html @@ -33,10 +33,12 @@ $(this).css('visibility', 'hidden'); }).hide(); + {% if link_string %} + $("#link_info_popup_string").val(location.protocol + "//" + location.host + "{{ webclient_path }}?show={{ link_string }}"); + {% endif %} // We do this here and in batch_annotate panel OME.initToolbarDropdowns(); - }); @@ -54,11 +56,7 @@ diff --git a/components/tools/OmeroWeb/omeroweb/webclient/views.py b/components/tools/OmeroWeb/omeroweb/webclient/views.py index 09a1a777946..4dfb0f94428 100755 --- a/components/tools/OmeroWeb/omeroweb/webclient/views.py +++ b/components/tools/OmeroWeb/omeroweb/webclient/views.py @@ -2053,7 +2053,7 @@ def batch_annotate(request, conn=None, **kwargs): context['differentGroups'] = True # E.g. don't run scripts etc context['canDownload'] = manager.canDownload(objs) context['template'] = "webclient/annotations/batch_annotate.html" - context['webclient_path'] = request.build_absolute_uri(reverse('webindex')) + context['webclient_path'] = reverse('webindex') return context From 649b33ba20bfaa745eb36b7cd118d30c6adad1c1 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Thu, 7 Jul 2016 16:00:57 +0100 Subject: [PATCH 4/4] Assume webclient_path will always be defined --- .../templates/webclient/annotations/metadata_general.html | 5 ----- 1 file changed, 5 deletions(-) diff --git a/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/annotations/metadata_general.html b/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/annotations/metadata_general.html index df6ed83145f..51a22036690 100644 --- a/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/annotations/metadata_general.html +++ b/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/annotations/metadata_general.html @@ -103,12 +103,7 @@ // show a link to the current object $("#show_link_btn").click(function(){ $("#link_info_popup").show(); - {% if webclient_path %} var lnk = location.protocol + "//" + location.host + "{{ webclient_path }}"; - {% else %} - var lnk = location.href.substring(0,location.href.length - location.search.length); - if (lnk.charAt( lnk.length-1 ) == "#") { lnk = lnk.substring(0, lnk.length-1)} - {% endif %} var obj_type = "{{manager.obj_type}}"; if (obj_type === "acquisition") { obj_type = "run";
- +