core-geonetwork icon indicating copy to clipboard operation
core-geonetwork copied to clipboard

PDF export link from logo will not work using default ui settings.

Open ianwallen opened this issue 1 year ago • 5 comments

Describe the bug This bug is related to PR #7532 which missed a certain case.

If the UI setting is set for the search home page and it is a relative path then the link header in the PDF will not be correct.

To Reproduce Steps to reproduce the behavior:

  1. Go to settings and set ui setting and ensure that you have the home url set - using relative path. (Also ensure that logo or name is shown in the header) image

  2. Create a metadata record

  3. export the metadata record as PDF

  4. Click on the header of the PDF - it will go to /geonetwork/srv/api/records/srv/eng/catalog.search#/home

Expected behavior Expect link to work

Additional context The issue seems to be here

https://github.com/geonetwork/core-geonetwork/blob/ca3513be87110ee6396bf36e7a1739eb7ce0efb8/web/src/main/webapp/xslt/skin/default/skin.xsl#L70-L76

Possible fix

  • Apply work around of putting a fully qualified url in mods.home.appUrl instead of relative url like ../../{{node}}/{{lang}}/catalog.search#/home - i.e. we could use /geonetwork/{{node}}/{{lang}}/catalog.search#/home. This works however not ideal.
  • We could modify geonet:updateUrlPlaceholder(util:getUiConfigurationJsonProperty so that is supports a new parameter called context_root. Then we can change the default to {{context_root}}/{{node}}/{{lang}}/catalog.search#/home and it would automatically replace {{context_root}} with the application server context root /geonetwork. - This is similar to the first option but would be the default - so it would work on any new ui configurations. But it would still fail with users who upgrade.
  • Modify geonet:updateUrlPlaceholder so that it ensure that it returns a full url based the url supplied instead of just replacing the placeholders. It would skip the logic if the url started with http/https.
  • Maybe there is another way? 

ianwallen avatar Jan 11 '24 11:01 ianwallen

Duplicate of #7521 - issue was not fully resolved.

ianwallen avatar Jan 11 '24 16:01 ianwallen

@ianwallen I would apply other solution, remove the logo link in the PDF export :-)

josegar74 avatar Jan 19 '24 06:01 josegar74

Another option that we may be able to test. Since the error only occurs when there is a ui setting because the ui settings generally use relative path.

Maybe the condition should be something like

<xsl:variable name="appUrl"
                                select="if(output != 'pdf' and util:getUiConfigurationJsonProperty(/root/request/ui, 'mods.home.appUrl'))
                                    then geonet:updateUrlPlaceholder(util:getUiConfigurationJsonProperty(/root/request/ui, 'mods.home.appUrl'), /root/gui/nodeId, $lang)
                                    else /root/gui/nodeUrl"/>

The idea would be to always use /root/gui/nodeUrl when printing PDF as I believe /root/gui/nodeUrl is a full URL instead of a relative URL.

ianwallen avatar Jan 21 '24 11:01 ianwallen

@ianwallen @josegar74

I tried this code from our own DevOps and it seems working. Although I have some issue with my localhost setup.

But the code I deployed to our dev server worked just fine.

I will try to fix my local configuration and do it again from localhost.

wangf1122 avatar Jan 25 '24 17:01 wangf1122

@josegar74 @ianwallen

I created a PR https://github.com/geonetwork/core-geonetwork/pull/7667

Applied the suggested code and it works from my localhost for the home page enabled scenario

wangf1122 avatar Jan 26 '24 17:01 wangf1122

Closing, https://github.com/geonetwork/core-geonetwork/pull/7667 was merged.

josegar74 avatar Mar 25 '24 12:03 josegar74