aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/server/www/WebApp.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-11-20 16:37:42 +0300
committerGravatar Vitaly Takmazov2018-11-20 16:37:42 +0300
commita3ec3587e1fa33e4e08da9783d9d66c55ac84550 (patch)
tree9311de2f6511421eefed3e2e10bc821d2179dbd4 /src/main/java/com/juick/server/www/WebApp.java
parentd2b04d9b719b79a35e90b1c5569722ba5cbf794b (diff)
avatar public url
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();
+ }
}