From 216a0dd1474268f29e73f725192e8fb5af0e462f Mon Sep 17 00:00:00 2001 From: Pierre Mauduit Date: Wed, 10 Apr 2024 17:11:18 +0200 Subject: [PATCH] login - do not hardcode header's script url (#117) Use the value from datadir's default.properties instead. Adding some doc in what is configureable about the header and how tu customize the login page. Also removing the commented out footer url. --- docs/ui-customization.adoc | 38 +++++++++ .../app/GeorchestraGatewayApplication.java | 5 +- .../src/main/resources/templates/login.html | 82 +++++++++---------- .../resources/test-datadir/default.properties | 1 + 4 files changed, 80 insertions(+), 46 deletions(-) create mode 100644 docs/ui-customization.adoc diff --git a/docs/ui-customization.adoc b/docs/ui-customization.adoc new file mode 100644 index 00000000..9a50bb56 --- /dev/null +++ b/docs/ui-customization.adoc @@ -0,0 +1,38 @@ += UI customizations + +:toc: +:toc-placement!: + +toc::[] + +== Main principles + +If you need to e.g. customize the login page / error pages, you can copy the templates provided under gateway/src/main/resources/templates into another directory, modify the templates to suit +your needs, then reconfigure the gateway to point to the newly created directory: + +[source,yaml] +---- +spring: + thymeleaf: + prefix: file:/path/to/templates/ +---- + +See also the <>. + +== header + +The header being integrated by default to every geOrchestra pages is also present onto the login page provided by the Gateway. If you look into the `login.html` template, you should see a `` html tag somewhere in the file. + +The web component is sourced from a Javascript file defined in the `default.properties` file from the geOrchestra datadir. Below is a list of variables which can be configured to tweak the header integration: + +[source,yaml] +---- +# From georchestra datadir's default.properties +# URL to the Javascript definition of the web component +headerScript: https://cdn.jsdelivr.net/gh/georchestra/header@dist/header.js + + +# From the gateway's yaml configuration +# includes or disables the web component +georchestra.gateway.headerEnabled: true +---- \ No newline at end of file diff --git a/gateway/src/main/java/org/georchestra/gateway/app/GeorchestraGatewayApplication.java b/gateway/src/main/java/org/georchestra/gateway/app/GeorchestraGatewayApplication.java index d7c3d736..555f90d1 100644 --- a/gateway/src/main/java/org/georchestra/gateway/app/GeorchestraGatewayApplication.java +++ b/gateway/src/main/java/org/georchestra/gateway/app/GeorchestraGatewayApplication.java @@ -70,7 +70,8 @@ public class GeorchestraGatewayApplication { private @Autowired(required = false) OAuth2ClientProperties oauth2ClientConfig; private @Value("${georchestra.gateway.headerEnabled:true}") boolean headerEnabled; - private @Value("${georchestra.gateway.footerUrl:#{null}}") String georchestraFooterUrl; + // defined in georchestra datadir's default.properties + private @Value("${headerScript:https://cdn.jsdelivr.net/gh/georchestra/header@dist/header.js}") String headerScript; private @Value("${spring.messages.basename:}") String messagesBasename; public static void main(String[] args) { @@ -121,7 +122,7 @@ public String loginPage(@RequestParam Map allRequestParams, Mode }); } mdl.addAttribute("header_enabled", headerEnabled); - mdl.addAttribute("footer_url", georchestraFooterUrl); + mdl.addAttribute("header_script", headerScript); mdl.addAttribute("ldapEnabled", ldapEnabled); mdl.addAttribute("oauth2LoginLinks", oauth2LoginLinks); boolean expired = "expired_password".equals(allRequestParams.get("error")); diff --git a/gateway/src/main/resources/templates/login.html b/gateway/src/main/resources/templates/login.html index 7158d908..cae0bad7 100644 --- a/gateway/src/main/resources/templates/login.html +++ b/gateway/src/main/resources/templates/login.html @@ -6,7 +6,7 @@ Please sign in - + @@ -14,48 +14,42 @@
-
- -
- - - - -
- -
-
- +
+ +
+ + + + +
+ +
+
diff --git a/gateway/src/test/resources/test-datadir/default.properties b/gateway/src/test/resources/test-datadir/default.properties index 141180ce..dd472fbb 100644 --- a/gateway/src/test/resources/test-datadir/default.properties +++ b/gateway/src/test/resources/test-datadir/default.properties @@ -4,6 +4,7 @@ instanceName=geOrchestra language=en headerHeight=90 headerUrl=/header/ +headerScript=/public/header.js administratorEmail=georchestra@georchestra-127-0-1-1.traefik.me ### PostgreSQL properties pgsqlHost=database