aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-05-23 14:47:38 +0300
committerGravatar Vitaly Takmazov2017-05-23 15:50:32 +0300
commitbe30d843aab467aa628f1c3f3c7d194bfda54284 (patch)
tree4185a4e0c084aa1a0e0072af5153fd895edf440c
parent4c6f3ba0d539f63a83c18e20ed4219bdef849b81 (diff)
fix style
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/User.java99
-rw-r--r--juick-www/src/main/java/com/mitchellbosecke/pebble/extension/FormatterExtension.java2
-rw-r--r--juick-www/src/main/java/com/mitchellbosecke/pebble/extension/filters/TagsListFilter.java23
-rw-r--r--juick-www/src/main/static/style.css6
-rw-r--r--juick-www/src/main/webapp/WEB-INF/views/blog.html5
-rw-r--r--juick-www/src/main/webapp/WEB-INF/views/index.html2
-rw-r--r--juick-www/src/main/webapp/WEB-INF/views/macros/tags.html2
-rw-r--r--juick-www/src/main/webapp/WEB-INF/views/partial/usercolumn.html2
-rw-r--r--juick-www/src/main/webapp/WEB-INF/views/partial/usertags.html2
-rw-r--r--juick-www/src/main/webapp/WEB-INF/views/users.html17
10 files changed, 89 insertions, 71 deletions
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 b66c6fa1..8e22c654 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
@@ -39,10 +39,7 @@ import org.springframework.web.util.UriComponents;
import ru.sape.Sape;
import javax.inject.Inject;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
-import java.io.PrintWriter;
import java.net.URLEncoder;
import java.util.List;
import java.util.stream.Collectors;
@@ -152,7 +149,7 @@ public class User {
model.addAttribute("statsReplies", userService.getStatsReplies(user.getUid()));
model.addAttribute("iread", userService.getUserReadLeastPopular(user.getUid(), 8));
model.addAttribute("tagStats", tagService.getUserTagStats(user.getUid())
- .stream().map(t -> t.getTag().getName()).collect(Collectors.toList()));
+ .stream().sorted((e1, e2) -> Integer.compare(e2.getUsageCount(), e1.getUsageCount())).limit(20).map(t -> t.getTag().getName()).collect(Collectors.toList()));
model.addAttribute("paramTag", paramTag);
List<com.juick.Message> msgs = messagesService.getMessages(mids);
@@ -218,76 +215,56 @@ public class User {
}
@GetMapping("/{uname}/friends")
- protected void doGetFriends(HttpServletRequest request, HttpServletResponse response,
- @PathVariable String uname) throws IOException {
+ protected String doGetFriends(@PathVariable String uname, ModelMap model) throws IOException {
com.juick.User user = userService.getUserByName(uname);
com.juick.User visitor = UserUtils.getCurrentUser();
if (visitor.isBanned()) {
- throw new HttpForbiddenException();
+ throw new HttpNotFoundException();
}
+ model.addAttribute("title", "Подписки " + user.getName());
+ model.addAttribute("headers", "<meta name=\"robots\" content=\"noindex\"/>");
+ model.addAttribute("visitor", visitor);
+ model.addAttribute("user", user);
+ model.addAttribute("readonly", messagesService.isReadonly());
+ 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().map(t -> t.getTag().getName()).collect(Collectors.toList()));
+ model.addAttribute("users", userService.getUserFriends(user.getUid()));
- response.setContentType("text/html; charset=UTF-8");
- try (PrintWriter out = response.getWriter()) {
- String head = "<meta name=\"robots\" content=\"noindex\"/>";
- templates.pageHead(out, visitor, "Подписки " + user.getName(), head);
- templates.pageNavigation(out, visitor, null);
- //pageUserColumn(out, user, visitor);
-
- out.println("<section id=\"content\">");
- out.println("<table class=\"users\"><tr>");
-
- List<com.juick.User> friends = userService.getUserFriends(user.getUid());
- for (int i = 0; i < friends.size(); i++) {
- if (i % 3 == 0 && i > 0) {
- out.print("</tr><tr>");
- }
- out.print("<td><a href=\"/" + friends.get(i).getName()
- + "/\"><img src=\"//i.juick.com/as/" + friends.get(i).getUid() + ".png\"/>"
- + friends.get(i).getName() + "</a></td>");
- }
-
- out.println("</tr></table>");
- out.println("</section>");
-
- templates.pageFooter(request, out, visitor, false);
- templates.pageEnd(out);
- }
+ return "views/users";
}
@GetMapping("/{uname}/readers")
- protected void doGetReaders(HttpServletRequest request, HttpServletResponse response,
- @PathVariable String uname) throws IOException {
+ protected String doGetReaders(@PathVariable String uname, ModelMap model) throws IOException {
com.juick.User user = userService.getUserByName(uname);
com.juick.User visitor = UserUtils.getCurrentUser();
if (visitor.isBanned()) {
throw new HttpForbiddenException();
}
+ model.addAttribute("title", "Читатели " + user.getName());
+ model.addAttribute("headers", "<meta name=\"robots\" content=\"noindex\"/>");
+ model.addAttribute("visitor", visitor);
+ model.addAttribute("user", user);
+ model.addAttribute("readonly", messagesService.isReadonly());
+ 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().map(t -> t.getTag().getName()).collect(Collectors.toList()));
+ model.addAttribute("users", userService.getUserReaders(user.getUid()));
- response.setContentType("text/html; charset=UTF-8");
- try (PrintWriter out = response.getWriter()) {
- String head = "<meta name=\"robots\" content=\"noindex\"/>";
- templates.pageHead(out, visitor, "Читатели " + user.getName(), head);
- templates.pageNavigation(out, visitor, null);
- //pageUserColumn(out, user, visitor);
-
- out.println("<section id=\"content\">");
- out.println("<table class=\"users\"><tr>");
-
- List<com.juick.User> readers = userService.getUserReaders(user.getUid());
- for (int i = 0; i < readers.size(); i++) {
- if (i % 3 == 0 && i > 0) {
- out.print("</tr><tr>");
- }
- out.print("<td><a href=\"/" + readers.get(i).getName()
- + "/\"><img src=\"//i.juick.com/as/" + readers.get(i).getUid() + ".png\"/>"
- + readers.get(i).getName() + "</a></td>");
- }
-
- out.println("</tr></table>");
- out.println("</section>");
-
- templates.pageFooter(request, out, visitor, false);
- templates.pageEnd(out);
- }
+ return "views/users";
}
}
diff --git a/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/FormatterExtension.java b/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/FormatterExtension.java
index 220e0460..198e9668 100644
--- a/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/FormatterExtension.java
+++ b/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/FormatterExtension.java
@@ -2,6 +2,7 @@ package com.mitchellbosecke.pebble.extension;
import com.mitchellbosecke.pebble.extension.filters.FormatMessageFilter;
import com.mitchellbosecke.pebble.extension.filters.PrettyTimeFilter;
+import com.mitchellbosecke.pebble.extension.filters.TagsListFilter;
import java.util.HashMap;
import java.util.Map;
@@ -15,6 +16,7 @@ public class FormatterExtension extends AbstractExtension {
Map<String, Filter> filters = new HashMap<>();
filters.put("formatMessage", new FormatMessageFilter());
filters.put("prettyTime", new PrettyTimeFilter());
+ filters.put("tagsList", new TagsListFilter());
return filters;
}
}
diff --git a/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/filters/TagsListFilter.java b/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/filters/TagsListFilter.java
new file mode 100644
index 00000000..55c98307
--- /dev/null
+++ b/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/filters/TagsListFilter.java
@@ -0,0 +1,23 @@
+package com.mitchellbosecke.pebble.extension.filters;
+
+import com.juick.Tag;
+import com.mitchellbosecke.pebble.extension.Filter;
+
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * Created by vitalyster on 23.05.2017.
+ */
+public class TagsListFilter implements Filter {
+ @Override
+ public Object apply(Object input, Map<String, Object> args) {
+ return ((List<Tag>) input).stream().map(Tag::getName).collect(Collectors.toList());
+ }
+
+ @Override
+ public List<String> getArgumentNames() {
+ return null;
+ }
+}
diff --git a/juick-www/src/main/static/style.css b/juick-www/src/main/static/style.css
index d3e47dd1..d34da0e0 100644
--- a/juick-www/src/main/static/style.css
+++ b/juick-www/src/main/static/style.css
@@ -448,11 +448,13 @@ q {
.users {
margin: 10px 0;
width: 100%;
+ display: flex;
+ flex-wrap: wrap;
}
-.users td {
+.users > span {
overflow: hidden;
padding: 6px 0;
- width: 33%;
+ width: 200px;
}
.users img {
height: 32px;
diff --git a/juick-www/src/main/webapp/WEB-INF/views/blog.html b/juick-www/src/main/webapp/WEB-INF/views/blog.html
index 6672adff..f68ebf3e 100644
--- a/juick-www/src/main/webapp/WEB-INF/views/blog.html
+++ b/juick-www/src/main/webapp/WEB-INF/views/blog.html
@@ -7,9 +7,6 @@
{% if paramTag | default('') is not empty %}
<p class="page"><a href="/tag/{{ paramTag.name | urlencode }}">← Все записи с тегом <b>{{ paramTag.name | escape }}</b></a></p>
{% endif %}
-{% if paramTag | default('') is not empty %}
-<p class="page"><a href="/tag/{{ paramTag.name | urlencode }}">← Все записи с тегом <b>{{ paramTag.name | escape }}</b></a></p>
-{% endif %}
{% for msg in msgs %}
<article data-mid="{{ msg.mid }}">
<header class="h">@<a href="/{{ msg.user.name }}/">{{ msg.user.name }}</a>:
@@ -25,7 +22,7 @@
</a>
</div>
<div class="msg-tags">
- {{ tags(msg.user.name, msg.tags) }}
+ {{ tags(msg.user.name, msg.tags | tagsList) }}
</div>
</header>
diff --git a/juick-www/src/main/webapp/WEB-INF/views/index.html b/juick-www/src/main/webapp/WEB-INF/views/index.html
index 0bf2a2fd..88178cc5 100644
--- a/juick-www/src/main/webapp/WEB-INF/views/index.html
+++ b/juick-www/src/main/webapp/WEB-INF/views/index.html
@@ -22,7 +22,7 @@
</a>
</div>
<div class="msg-tags">
- {{ tags(msg.getUser().getName(), msg.getTags()) }}
+ {{ tags(msg.user.name, msg.tags | tagsList ) }}
</div>
</header>
<p>{{ msg | formatMessage }}</p>
diff --git a/juick-www/src/main/webapp/WEB-INF/views/macros/tags.html b/juick-www/src/main/webapp/WEB-INF/views/macros/tags.html
index b34e6ecc..167f9168 100644
--- a/juick-www/src/main/webapp/WEB-INF/views/macros/tags.html
+++ b/juick-www/src/main/webapp/WEB-INF/views/macros/tags.html
@@ -1,5 +1,5 @@
{% macro tags(uname="", tagsList) %}
{% for tag in tagsList %}
-<a href="/{{ uname }}/?tag={{ tag.name | urlencode }}">{{ tag.name }}</a>
+<a href="/{{ uname }}/?tag={{ tag | urlencode }}">{{ tag }}</a>
{% endfor %}
{% endmacro %} \ 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 7e3b8a64..9024dd81 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
@@ -1,7 +1,7 @@
<div id="ctitle"><a href="./">
<img src="//i.juick.com/as/{{ user.uid }}.png" alt=""/>{{ user.name }}</a></div>
{% if visitor is not empty and visitor.uid > 0 and visitor.uid != user.uid %}
-<ul id="ctoolbar">
+<ul class="toolbar">
{% if isSubscribed %}
<li>
<a href="/post?body=U+%40{{ user.name }}" title="Подписан">
diff --git a/juick-www/src/main/webapp/WEB-INF/views/partial/usertags.html b/juick-www/src/main/webapp/WEB-INF/views/partial/usertags.html
index 78e1416e..71d1303e 100644
--- a/juick-www/src/main/webapp/WEB-INF/views/partial/usertags.html
+++ b/juick-www/src/main/webapp/WEB-INF/views/partial/usertags.html
@@ -1,3 +1,3 @@
{% import "views/macros/tags" %}
-{{ tags(uname=user.name, tagsStats) }}
+{{ tags(user.name, tagStats) }}
<a href="/{{ user.name }}/tags" rel="nofollow">...</a> \ No newline at end of file
diff --git a/juick-www/src/main/webapp/WEB-INF/views/users.html b/juick-www/src/main/webapp/WEB-INF/views/users.html
new file mode 100644
index 00000000..0f66da54
--- /dev/null
+++ b/juick-www/src/main/webapp/WEB-INF/views/users.html
@@ -0,0 +1,17 @@
+{% extends "layouts/content" %}
+{% import "views/macros/tags" %}
+{% block content %}
+<div class="users">
+ {% for u in users %}
+ <span>
+ <a href="/{{ u.name }}/">
+ <img src="//i.juick.com/as/{{ u.uid }}.png" alt="{{ u.name }}"/>
+ {{ u.name }}
+ </a>
+ </span>
+ {% endfor %}
+</div>
+{% endblock %}
+{% block "column" %}
+{% include "views/partial/usercolumn" %}
+{% endblock %} \ No newline at end of file