Skip to content

Commit

Permalink
backport custom scripts and header enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
edevosc2c committed Dec 1, 2023
1 parent 67c0205 commit cf0c95a
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 2 deletions.
34 changes: 34 additions & 0 deletions core/src/main/java/org/fao/geonet/util/XslUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ public static MultiPolygon toMultiPolygon(Geometry geometry) {

private static String headerUrl;
private static String headerHeight;
private static String useLegacyHeader;
private static String headerScript;


public static String getGeorchestraHeaderUrl(){
Expand Down Expand Up @@ -298,6 +300,38 @@ public static String getGeorchestraHeaderHeight(){
return XslUtil.headerHeight;
}

public static String getGeorchestraUseLegacyHeader(){

if(XslUtil.useLegacyHeader == null) {

// Set default value
XslUtil.useLegacyHeader = "false";

// Load value from datadir
Properties properties = XslUtil.loadDatadirProperties();
if (properties.containsKey("useLegacyHeader"))
XslUtil.useLegacyHeader = properties.getProperty("useLegacyHeader");
}

return XslUtil.useLegacyHeader;
}

public static String getGeorchestraHeaderScript(){

if(XslUtil.headerScript == null) {

// Set default value
XslUtil.headerScript = "https://cdn.jsdelivr.net/gh/georchestra/header@dist/header.js";

// Load value from datadir
Properties properties = XslUtil.loadDatadirProperties();
if (properties.containsKey("headerScript"))
XslUtil.headerScript = properties.getProperty("headerScript");
}

return XslUtil.headerScript;
}

private static Properties loadProperties(File path, Properties prop) throws IOException {
try(FileInputStream fisProp = new FileInputStream(path)) {
InputStreamReader isrProp = new InputStreamReader(fisProp, "UTF8");
Expand Down
2 changes: 2 additions & 0 deletions web/src/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ COPY --chown=jetty:jetty . /
# Temporary switch to root
USER root

RUN mkdir -p /docker-entrypoint.d
RUN chown jetty:jetty /docker-entrypoint.d
RUN mkdir -p /mnt/geonetwork_datadir && \
chown jetty:jetty /mnt/geonetwork_datadir

Expand Down
12 changes: 11 additions & 1 deletion web/src/docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@

DIR=/docker-entrypoint.d

# Executing custom scripts located in CUSTOM_SCRIPTS_DIRECTORY if environment variable is set
if [[ -z "${CUSTOM_SCRIPTS_DIRECTORY}" ]]; then
echo "[INFO] No CUSTOM_SCRIPTS_DIRECTORY env variable set"
else
echo "[INFO] CUSTOM_SCRIPTS_DIRECTORY env variable set to ${CUSTOM_SCRIPTS_DIRECTORY}"
cp -v "${CUSTOM_SCRIPTS_DIRECTORY}"/* "$DIR"
echo "[INFO] End copying custom scripts"
fi

if [[ -d "$DIR" ]]
then
/bin/run-parts --verbose "$DIR"
# Regex is needed to execute all kind of files, including sh files. Warning : --regex not available in alpine images.
/bin/run-parts --verbose "$DIR" --regex='.*'
fi

exec "$@"
3 changes: 2 additions & 1 deletion web/src/main/webapp/xslt/base-layout.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
title="{concat($env/system/site/name, ' - ', $env/system/site/organization)}"/>

<xsl:call-template name="css-load"/>
<script src="{$headerScript}"></script>
</head>


Expand All @@ -68,7 +69,7 @@
and a facet search to get main site information.
-->
<body data-ng-controller="GnCatController" data-ng-class="[isHeaderFixed ? 'gn-header-fixed' : 'gn-header-relative', isLogoInHeader ? 'gn-logo-in-header' : 'gn-logo-in-navbar', isFooterEnabled ? 'gn-show-footer' : 'gn-hide-footer']">
<iframe src="{$headerUrl}?active=geonetwork" style="width:100%;height:{$headerHeight}px;border:none;overflow:hidden;" scrolling="no" frameborder="0"></iframe>
<geor-header active-app="geonetwork" legacy-header="{$useLegacyHeader}" legacy-url="{$headerUrl}" style="width:100%;height:{$headerHeight}px;border:none;"></geor-header>

<div data-gn-alert-manager=""></div>

Expand Down
2 changes: 2 additions & 0 deletions web/src/main/webapp/xslt/common/base-variables.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

<xsl:variable name="headerUrl" select="util:getGeorchestraHeaderUrl()"/>
<xsl:variable name="headerHeight" select="util:getGeorchestraHeaderHeight()"/>
<xsl:variable name="useLegacyHeader" select="util:getGeorchestraUseLegacyHeader()"/>
<xsl:variable name="headerScript" select="util:getGeorchestraHeaderScript()"/>

<!--
-->
Expand Down

0 comments on commit cf0c95a

Please sign in to comment.