Skip to content

Commit

Permalink
feat: implement new header
Browse files Browse the repository at this point in the history
  • Loading branch information
f-necas committed Nov 11, 2023
1 parent 18c1c89 commit 2ec3bc4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
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
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 2ec3bc4

Please sign in to comment.