aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/server/www
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/server/www')
-rw-r--r--src/main/java/com/juick/server/www/WebApp.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main/java/com/juick/server/www/WebApp.java b/src/main/java/com/juick/server/www/WebApp.java
index 08c6188d..7282eeeb 100644
--- a/src/main/java/com/juick/server/www/WebApp.java
+++ b/src/main/java/com/juick/server/www/WebApp.java
@@ -25,6 +25,7 @@ import org.springframework.stereotype.Component;
import org.springframework.web.servlet.resource.ResourceUrlProvider;
import org.springframework.web.util.UriComponentsBuilder;
+import javax.annotation.PostConstruct;
import javax.inject.Inject;
import java.util.ArrayList;
import java.util.Arrays;
@@ -43,6 +44,12 @@ public class WebApp {
private ResourceUrlProvider resourceUrlProvider;
@Value("${img_url:http://localhost:8080/i/}")
private String baseImagesUri;
+ UriComponentsBuilder avatarBuilder;
+
+ @PostConstruct
+ public void init() {
+ avatarBuilder = UriComponentsBuilder.fromUriString(baseImagesUri);
+ }
public List<Tag> parseTags(String tagsStr) {
List<Tag> tags = new ArrayList<>();
@@ -79,4 +86,9 @@ public class WebApp {
}
return resourceUrlProvider.getForLookupPath("/av-96.png");
}
+
+ public String getAvatarUrl(User user) {
+ avatarBuilder.replacePath(getAvatarWebPath(user));
+ return avatarBuilder.build().toUriString();
+ }
}