aboutsummaryrefslogtreecommitdiff
path: root/juick-www
diff options
context:
space:
mode:
Diffstat (limited to 'juick-www')
-rw-r--r--juick-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java2
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/User.java75
-rw-r--r--juick-www/src/main/resources/messages.properties1
-rw-r--r--juick-www/src/main/resources/messages_ru.properties1
-rw-r--r--juick-www/src/main/webapp/WEB-INF/views/partial/usercolumn.html3
5 files changed, 41 insertions, 41 deletions
diff --git a/juick-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java b/juick-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java
index 12960cfb..23bec18b 100644
--- a/juick-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java
+++ b/juick-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java
@@ -70,7 +70,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
http.addFilterAfter(hashParamAuthenticationFilter(), BasicAuthenticationFilter.class);
http
.authorizeRequests()
- .antMatchers("/settings", "/pm/**").authenticated()
+ .antMatchers("/settings", "/pm/**", "/**/bl").authenticated()
.anyRequest().permitAll()
.and()
.anonymous().principal(JuickUser.ANONYMOUS_USER).authorities(JuickUser.ANONYMOUS_AUTHORITY)
diff --git a/juick-www/src/main/java/com/juick/www/controllers/User.java b/juick-www/src/main/java/com/juick/www/controllers/User.java
index 443f7b08..532e0caa 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/User.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/User.java
@@ -62,6 +62,20 @@ public class User {
@Inject
private Sape sape;
+ void fillUserModel(ModelMap model, com.juick.User user, com.juick.User visitor) {
+ model.addAttribute("isSubscribed", userService.isSubscribed(visitor.getUid(), user.getUid()));
+ model.addAttribute("isInBL", userService.isInBL(visitor.getUid(), user.getUid()));
+ model.addAttribute("isInBLAny", userService.isInBLAny(user.getUid(), visitor.getUid()));
+ model.addAttribute("statsIRead", userService.getStatsIRead(user.getUid()));
+ model.addAttribute("statsMyReaders", userService.getStatsMyReaders(user.getUid()));
+ model.addAttribute("statsMyBL", userService.getUserBLUsers(user.getUid()).size());
+ model.addAttribute("statsMessages", userService.getStatsMessages(user.getUid()));
+ model.addAttribute("statsReplies", userService.getStatsReplies(user.getUid()));
+ model.addAttribute("iread", userService.getUserReadLeastPopular(user.getUid(), 8));
+ model.addAttribute("tagStats", tagService.getUserTagStats(user.getUid())
+ .stream().sorted((e1, e2) -> Integer.compare(e2.getUsageCount(), e1.getUsageCount())).limit(20).map(t -> t.getTag().getName()).collect(Collectors.toList()));
+ }
+
@GetMapping("/{uname}/")
protected String doGetBlog(
@RequestParam(required = false, name = "show") String paramShow,
@@ -138,16 +152,7 @@ public class User {
model.addAttribute("visitor", visitor);
model.addAttribute("user", user);
model.addAttribute("noindex", paramShow == null && before == 0);
- model.addAttribute("isSubscribed", userService.isSubscribed(visitor.getUid(), user.getUid()));
- model.addAttribute("isInBL", userService.isInBL(visitor.getUid(), user.getUid()));
- model.addAttribute("isInBLAny", userService.isInBLAny(user.getUid(), visitor.getUid()));
- model.addAttribute("statsIRead", userService.getStatsIRead(user.getUid()));
- model.addAttribute("statsMyReaders", userService.getStatsMyReaders(user.getUid()));
- model.addAttribute("statsMessages", userService.getStatsMessages(user.getUid()));
- model.addAttribute("statsReplies", userService.getStatsReplies(user.getUid()));
- model.addAttribute("iread", userService.getUserReadLeastPopular(user.getUid(), 8));
- model.addAttribute("tagStats", tagService.getUserTagStats(user.getUid())
- .stream().sorted((e1, e2) -> Integer.compare(e2.getUsageCount(), e1.getUsageCount())).limit(20).map(t -> t.getTag().getName()).collect(Collectors.toList()));
+ fillUserModel(model, user, visitor);
model.addAttribute("paramTag", paramTag);
List<com.juick.Message> msgs = messagesService.getMessages(mids);
@@ -199,16 +204,7 @@ public class User {
model.addAttribute("headers", "<meta name=\"robots\" content=\"noindex,nofollow\"/>");
model.addAttribute("visitor", visitor);
model.addAttribute("user", user);
- model.addAttribute("isSubscribed", userService.isSubscribed(visitor.getUid(), user.getUid()));
- model.addAttribute("isInBL", userService.isInBL(visitor.getUid(), user.getUid()));
- model.addAttribute("isInBLAny", userService.isInBLAny(user.getUid(), visitor.getUid()));
- model.addAttribute("statsIRead", userService.getStatsIRead(user.getUid()));
- model.addAttribute("statsMyReaders", userService.getStatsMyReaders(user.getUid()));
- model.addAttribute("statsMessages", userService.getStatsMessages(user.getUid()));
- model.addAttribute("statsReplies", userService.getStatsReplies(user.getUid()));
- model.addAttribute("iread", userService.getUserReadLeastPopular(user.getUid(), 8));
- model.addAttribute("tagStats", tagService.getUserTagStats(user.getUid())
- .stream().sorted((e1, e2) -> Integer.compare(e2.getUsageCount(), e1.getUsageCount())).limit(20).map(t -> t.getTag().getName()).collect(Collectors.toList()));
+ fillUserModel(model, user, visitor);
model.addAttribute("tags", tagService.getUserTagStats(user.getUid()).stream()
.sorted((e1, e2) -> Integer.compare(e2.getUsageCount(), e1.getUsageCount())).map(t -> t.getTag().getName()).collect(Collectors.toList()));
@@ -226,16 +222,7 @@ public class User {
model.addAttribute("headers", "<meta name=\"robots\" content=\"noindex\"/>");
model.addAttribute("visitor", visitor);
model.addAttribute("user", user);
- model.addAttribute("isSubscribed", userService.isSubscribed(visitor.getUid(), user.getUid()));
- model.addAttribute("isInBL", userService.isInBL(visitor.getUid(), user.getUid()));
- model.addAttribute("isInBLAny", userService.isInBLAny(user.getUid(), visitor.getUid()));
- model.addAttribute("statsIRead", userService.getStatsIRead(user.getUid()));
- model.addAttribute("statsMyReaders", userService.getStatsMyReaders(user.getUid()));
- model.addAttribute("statsMessages", userService.getStatsMessages(user.getUid()));
- model.addAttribute("statsReplies", userService.getStatsReplies(user.getUid()));
- model.addAttribute("iread", userService.getUserReadLeastPopular(user.getUid(), 8));
- model.addAttribute("tagStats", tagService.getUserTagStats(user.getUid())
- .stream().sorted((e1, e2) -> Integer.compare(e2.getUsageCount(), e1.getUsageCount())).limit(20).map(t -> t.getTag().getName()).collect(Collectors.toList()));
+ fillUserModel(model, user, visitor);
model.addAttribute("users", userService.getUserFriends(user.getUid()));
return "views/users";
@@ -252,18 +239,26 @@ public class User {
model.addAttribute("headers", "<meta name=\"robots\" content=\"noindex\"/>");
model.addAttribute("visitor", visitor);
model.addAttribute("user", user);
- model.addAttribute("isSubscribed", userService.isSubscribed(visitor.getUid(), user.getUid()));
- model.addAttribute("isInBL", userService.isInBL(visitor.getUid(), user.getUid()));
- model.addAttribute("isInBLAny", userService.isInBLAny(user.getUid(), visitor.getUid()));
- model.addAttribute("statsIRead", userService.getStatsIRead(user.getUid()));
- model.addAttribute("statsMyReaders", userService.getStatsMyReaders(user.getUid()));
- model.addAttribute("statsMessages", userService.getStatsMessages(user.getUid()));
- model.addAttribute("statsReplies", userService.getStatsReplies(user.getUid()));
- model.addAttribute("iread", userService.getUserReadLeastPopular(user.getUid(), 8));
- model.addAttribute("tagStats", tagService.getUserTagStats(user.getUid())
- .stream().sorted((e1, e2) -> Integer.compare(e2.getUsageCount(), e1.getUsageCount())).limit(20).map(t -> t.getTag().getName()).collect(Collectors.toList()));
+ fillUserModel(model, user, visitor);
model.addAttribute("users", userService.getUserReaders(user.getUid()));
return "views/users";
}
+
+ @GetMapping("/{uname}/bl")
+ protected String doGetBL(@PathVariable String uname, ModelMap model) throws IOException {
+ com.juick.User user = userService.getUserByName(uname);
+ com.juick.User visitor = UserUtils.getCurrentUser();
+ if (visitor.isBanned() || visitor.getUid() != user.getUid()) {
+ throw new HttpForbiddenException();
+ }
+ model.addAttribute("title", "Черный список " + user.getName());
+ model.addAttribute("headers", "<meta name=\"robots\" content=\"noindex\"/>");
+ model.addAttribute("visitor", visitor);
+ model.addAttribute("user", user);
+ fillUserModel(model, user, visitor);
+ model.addAttribute("users", userService.getUserBLUsers(user.getUid()));
+
+ return "views/users";
+ }
}
diff --git a/juick-www/src/main/resources/messages.properties b/juick-www/src/main/resources/messages.properties
index c4f795e2..bddc56eb 100644
--- a/juick-www/src/main/resources/messages.properties
+++ b/juick-www/src/main/resources/messages.properties
@@ -55,5 +55,6 @@ blog.recommendations=Recommendations
blog.photos=Photos
blog.iread=I read
blog.readers=My readers
+blog.bl=My blacklist
blog.messages=Messages
blog.comments=Comments \ No newline at end of file
diff --git a/juick-www/src/main/resources/messages_ru.properties b/juick-www/src/main/resources/messages_ru.properties
index 5c00055e..2e22659d 100644
--- a/juick-www/src/main/resources/messages_ru.properties
+++ b/juick-www/src/main/resources/messages_ru.properties
@@ -55,5 +55,6 @@ blog.recommendations=Рекомендации
blog.photos=Фотографии
blog.iread=Я читаю
blog.readers=Мои подписчики
+blog.bl=Черный список
blog.messages=Сообщения
blog.comments=Комментарии \ No newline at end of file
diff --git a/juick-www/src/main/webapp/WEB-INF/views/partial/usercolumn.html b/juick-www/src/main/webapp/WEB-INF/views/partial/usercolumn.html
index 9024dd81..463ad2ca 100644
--- a/juick-www/src/main/webapp/WEB-INF/views/partial/usercolumn.html
+++ b/juick-www/src/main/webapp/WEB-INF/views/partial/usercolumn.html
@@ -58,6 +58,9 @@
<ul>
<li><a href="/{{ user.name }}/friends">{{ i18n("messages","blog.iread") }}: {{ statsIRead }}</a></li>
<li><a href="/{{ user.name }}/readers">{{ i18n("messages","blog.readers") }}: {{ statsMyReaders }}</a></li>
+ {% if statsMyBL > 0 and visitor.uid == user.uid %}
+ <li><a href="/{{ user.name }}/bl">{{ i18n("messages","blog.bl") }}: {{ statsMyBL }}</a></li>
+ {% endif %}
<li>{{ i18n("messages","blog.messages") }}: {{ statsMessages }}</li>
<li>{{ i18n("messages","blog.comments") }}: {{ statsReplies }}</li>
</ul>