diff options
author | Vitaly Takmazov | 2024-02-09 19:29:22 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2024-02-09 19:43:46 +0300 |
commit | aee5780150a7347838e113b17312f3636c2701f2 (patch) | |
tree | ed0a32f9d40d88a4025317c67fd90079484aa99b /src/main | |
parent | 70d9f8d2b20cbff4eb5aa22fba2faf45a9044a3e (diff) |
site: use base url in page layout
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/juick/www/WebApp.java | 9 | ||||
-rw-r--r-- | src/main/resources/templates/layouts/default.html | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/main/java/com/juick/www/WebApp.java b/src/main/java/com/juick/www/WebApp.java index a7c5eb8b..74e0d822 100644 --- a/src/main/java/com/juick/www/WebApp.java +++ b/src/main/java/com/juick/www/WebApp.java @@ -42,6 +42,8 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.springframework.web.servlet.resource.ResourceUrlProvider; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; +import org.springframework.web.util.UriComponents; import org.springframework.web.util.UriComponentsBuilder; /** @@ -58,6 +60,8 @@ public class WebApp { private PebbleEngine pebbleEngine; @Value("${img_url:http://localhost:8080/i/}") private String baseImagesUri; + @Value("${web_domain:localhost}") + private String webDomain; UriComponentsBuilder avatarBuilder; @PostConstruct @@ -106,6 +110,11 @@ public class WebApp { return avatarBuilder.build().toUriString(); } + public String getBaseUrl() { + UriComponents builder = ServletUriComponentsBuilder.fromCurrentRequest().replacePath("/").replaceQuery("").build(); + return builder.toUriString(); + } + public Optional<String> renderPlaintext(String body, String messageUrl) { PebbleTemplate noteTemplate = pebbleEngine.getTemplate("email/plaintext"); Map<String, Object> context = new HashMap<>(); diff --git a/src/main/resources/templates/layouts/default.html b/src/main/resources/templates/layouts/default.html index c9b4625a..17f6e76f 100644 --- a/src/main/resources/templates/layouts/default.html +++ b/src/main/resources/templates/layouts/default.html @@ -5,6 +5,7 @@ <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="ermp-site-verification" value="6714D81C-9EEF-4283-A726-166680B6ABC8" /> + <base href="{{ beans.webApp.baseUrl }}" /> <script type="text/javascript" src="{{ beans.webApp.scriptsUrl }}"></script> <link rel="stylesheet" type="text/css" href="{{ beans.webApp.styleUrl }}" /> {% block headers %} |