aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/server/www/WebApp.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/server/www/WebApp.java')
-rw-r--r--src/main/java/com/juick/server/www/WebApp.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main/java/com/juick/server/www/WebApp.java b/src/main/java/com/juick/server/www/WebApp.java
index d2729c89..3ab09de2 100644
--- a/src/main/java/com/juick/server/www/WebApp.java
+++ b/src/main/java/com/juick/server/www/WebApp.java
@@ -20,12 +20,12 @@ import com.juick.Tag;
import com.juick.User;
import com.juick.service.TagService;
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.util.UriComponentsBuilder;
-import javax.annotation.PostConstruct;
import javax.inject.Inject;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -41,6 +41,8 @@ public class WebApp {
private TagService tagService;
@Inject
private ResourceUrlProvider resourceUrlProvider;
+ @Value("${img_url:http://localhost:8080/i/}")
+ private String baseImagesUri;
public List<Tag> parseTags(String tagsStr) {
List<Tag> tags = new ArrayList<>();
@@ -70,11 +72,15 @@ public class WebApp {
public String getScriptsUrl() {
return resourceUrlProvider.getForLookupPath("/scripts.js");
}
- public String getAvatarUrl(User user) {
+ public String getAvatarWebPath(User user) {
String avatarUri = resourceUrlProvider.getForLookupPath(String.format("/i/a/%d.png", user.getUid()));
if (StringUtils.isNotEmpty(avatarUri)) {
return avatarUri;
}
return resourceUrlProvider.getForLookupPath("/av-96.png");
}
+ public String getAvatarPublicUrl(User user) {
+ UriComponentsBuilder uri = UriComponentsBuilder.fromUriString(baseImagesUri);
+ return uri.replacePath(getAvatarWebPath(user)).toUriString();
+ }
}