Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use header config file #311

Open
wants to merge 1 commit into
base: georchestra-gn4.4.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 13 additions & 48 deletions core/src/main/java/org/fao/geonet/util/XslUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -274,30 +274,11 @@ public static MultiPolygon toMultiPolygon(Geometry geometry) {
private static final char CS_WKT = ' ';
private static ThreadLocal<Boolean> allowScripting = new InheritableThreadLocal<Boolean>();

private static String headerUrl;
private static String headerHeight;
private static String useLegacyHeader;
private static String headerScript;
private static String logoUrl;
private static String headerConfigFile;
private static String georchestraStylesheet;


public static String getGeorchestraHeaderUrl(){

if(XslUtil.headerUrl == null) {

// Set default value
XslUtil.headerUrl = "/header/";

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

return XslUtil.headerUrl;
}

public static String getGeorchestraHeaderHeight(){

if(XslUtil.headerHeight == null) {
Expand All @@ -314,22 +295,6 @@ 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) {
Expand All @@ -346,36 +311,36 @@ public static String getGeorchestraHeaderScript(){
return XslUtil.headerScript;
}

public static String getGeorchestraHeaderLogo(){
public static String getGeorchestraHeaderStylesheet(){

if(XslUtil.logoUrl == null) {
if(XslUtil.georchestraStylesheet == null) {

// Set default value
XslUtil.logoUrl = "https://www.georchestra.org/public/georchestra-logo.svg";
XslUtil.georchestraStylesheet = "";

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

return XslUtil.logoUrl;
return XslUtil.georchestraStylesheet;
}

public static String getGeorchestraHeaderStylesheet(){
public static String getGeorchestraHeaderConfigFile(){

if(XslUtil.georchestraStylesheet == null) {
if(XslUtil.headerConfigFile == null) {

// Set default value
XslUtil.georchestraStylesheet = "";
XslUtil.headerConfigFile = "";

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

return XslUtil.georchestraStylesheet;
return XslUtil.headerConfigFile;
}

private static Properties loadProperties(File path, Properties prop) throws IOException {
Expand Down
2 changes: 1 addition & 1 deletion web/src/main/webapp/xslt/base-layout.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,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']">
<geor-header active-app="geonetwork" legacy-header="{$useLegacyHeader}" legacy-url="{$headerUrl}" style="width:100%;height:{$headerHeight}px;border:none;" logo-url="{$logoUrl}" stylesheet="{$georchestraStylesheet}"></geor-header>
<geor-header active-app="geonetwork" config-file="{$headerConfigFile}" stylesheet="{$georchestraStylesheet}" height="{$headerHeight}"></geor-header>

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

Expand Down
6 changes: 2 additions & 4 deletions web/src/main/webapp/xslt/common/base-variables.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@
<xsl:output name="default-indent-mode" indent="yes"
omit-xml-declaration="yes"/>

<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()"/>
<xsl:variable name="logoUrl" select="util:getGeorchestraHeaderLogo()"/>
<xsl:variable name="headerConfigFile" select="util:getGeorchestraHeaderConfigFile()"/>
<xsl:variable name="georchestraStylesheet" select="util:getGeorchestraHeaderStylesheet()"/>
<xsl:variable name="headerHeight" select="util:getGeorchestraHeaderHeight()"/>

<!--
-->
Expand Down
Loading