diff --git a/components/tools/OmeroWeb/omeroweb/settings.py b/components/tools/OmeroWeb/omeroweb/settings.py index c2b374d113b..00bd6e5bd85 100644 --- a/components/tools/OmeroWeb/omeroweb/settings.py +++ b/components/tools/OmeroWeb/omeroweb/settings.py @@ -675,6 +675,13 @@ 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.external_link_baseurl": + ["WEB_EXTERNAL_LINK_BASEURL", + None, + identity, + ("Use this host (including protocol) for absolute HTML urls " + "in the client, such as social media links. This does not include " + "client-side generated URLs.")], } DEPRECATED_SETTINGS_MAPPINGS = { 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/templates/webclient/annotations/metadata_general.html b/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/annotations/metadata_general.html index f05d151a1b6..af2ba444603 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 = "{{ 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 lnk = location.protocol + "//" + location.host + "{{ webclient_path }}"; var obj_type = "{{manager.obj_type}}"; if (obj_type === "acquisition") { obj_type = "run"; diff --git a/components/tools/OmeroWeb/omeroweb/webclient/views.py b/components/tools/OmeroWeb/omeroweb/webclient/views.py index 3f24338d948..ce19f854f48 100755 --- a/components/tools/OmeroWeb/omeroweb/webclient/views.py +++ b/components/tools/OmeroWeb/omeroweb/webclient/views.py @@ -1566,8 +1566,7 @@ 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')) + context['webclient_path'] = reverse('webindex') return context @@ -2095,7 +2094,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 diff --git a/components/tools/OmeroWeb/omeroweb/webgateway/views.py b/components/tools/OmeroWeb/omeroweb/webgateway/views.py index 4059ef4d0ef..af4b77a9303 100644 --- a/components/tools/OmeroWeb/omeroweb/webgateway/views.py +++ b/components/tools/OmeroWeb/omeroweb/webgateway/views.py @@ -1974,12 +1974,16 @@ def full_viewer(request, iid, conn=None, **kwargs): prefix = kwargs.get( 'thumbprefix', 'webgateway.views.render_thumbnail') - def urlprefix(iid): - return reverse(prefix, args=(iid,)) + def reverse_urlprefix(p, iid): + r = reverse(p, args=(iid,)) + if settings.WEB_EXTERNAL_LINK_BASEURL: + return "%s%s" % ( + settings.WEB_EXTERNAL_LINK_BASEURL, r) + else: + return request.build_absolute_uri(r) - image_preview = request.build_absolute_uri(urlprefix(iid)) - page_url = request.build_absolute_uri(reverse( - 'webgateway.views.full_viewer', args=(iid,))) + image_preview = reverse_urlprefix(prefix, iid) + page_url = reverse_urlprefix('webgateway.views.full_viewer', iid) d = {'blitzcon': conn, 'image': image,
- +