From d0d3ac3743204c33153ea2354b3d672f147a14c1 Mon Sep 17 00:00:00 2001 From: Killy Date: Tue, 7 Nov 2017 05:14:57 +0300 Subject: www: tag state accessible from web --- .../java/com/juick/www/controllers/Messages.java | 25 ++++++++-------- juick-www/src/main/webapp/WEB-INF/views/index.html | 4 ++- .../webapp/WEB-INF/views/partial/tagcolumn.html | 33 ++++++++++++++++++++++ 3 files changed, 50 insertions(+), 12 deletions(-) create mode 100644 juick-www/src/main/webapp/WEB-INF/views/partial/tagcolumn.html (limited to 'juick-www/src') diff --git a/juick-www/src/main/java/com/juick/www/controllers/Messages.java b/juick-www/src/main/java/com/juick/www/controllers/Messages.java index 75e81b94..ce00433b 100644 --- a/juick-www/src/main/java/com/juick/www/controllers/Messages.java +++ b/juick-www/src/main/java/com/juick/www/controllers/Messages.java @@ -418,6 +418,15 @@ public class Messages { String title = "*" + StringEscapeUtils.escapeHtml4(paramTag.getName()); model.addAttribute("title", title); List mids = messagesService.getTag(paramTag.TID, visitor_uid, before, (visitor_uid == 0) ? 40 : 20); + List msgs = messagesService.getMessages(mids); + if (visitor.getUid() != 0) { + List blUIDs = userService.checkBL( + visitor.getUid(), + msgs.stream().map(m -> m.getUser().getUid()).collect(Collectors.toList()) + ); + msgs.forEach(m -> m.ReadOnly |= blUIDs.contains(m.getUser().getUid())); + fillUserModel(model, visitor, visitor); + } String head = StringUtils.EMPTY; if (tagService.getTagNoIndex(paramTag.TID)) { @@ -427,21 +436,15 @@ public class Messages { } model.addAttribute("headers", head); model.addAttribute("visitor", visitor); - - List msgs = messagesService.getMessages(mids); - - if (visitor.getUid() != 0) { - List blUIDs = userService.checkBL(visitor.getUid(), - msgs.stream().map(m -> m.getUser().getUid()).collect(Collectors.toList())); - msgs.forEach(m -> m.ReadOnly |= blUIDs.contains(m.getUser().getUid())); - fillUserModel(model, visitor, visitor); - } + model.addAttribute("tag", paramTag); + model.addAttribute("title", title); model.addAttribute("msgs", msgs); model.addAttribute("tags", tagService.getPopularTags()); - model.addAttribute("headers", head); model.addAttribute("noindex", before > 0); - model.addAttribute("showAdv",before == 0 && visitor.getUid() == 0); + model.addAttribute("showAdv", before == 0 && visitor.getUid() == 0); model.addAttribute("isModerator", visitor.getUid() == 3694); + model.addAttribute("isSubscribed", tagService.isSubscribed(visitor, paramTag)); + model.addAttribute("isInBL", tagService.isInBL(visitor, paramTag)); if (mids.size() >= 20) { String nextpage = "/tag/" + URLEncoder.encode(paramTag.getName(), CharEncoding.UTF_8) + "?before=" + mids.get(mids.size() - 1); model.addAttribute("nextpage", nextpage); 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 23d208b6..10539c44 100644 --- a/juick-www/src/main/webapp/WEB-INF/views/index.html +++ b/juick-www/src/main/webapp/WEB-INF/views/index.html @@ -12,7 +12,9 @@ {% endif %} {% endblock %} {% block "column" %} -{% if visitor.uid > 0 %} +{% if tag | default('') is not empty %} +{% include "views/partial/tagcolumn" %} +{% elseif visitor.uid > 0 %} {% include "views/partial/usercolumn" %} {% else %} {% include "views/partial/homecolumn" %} diff --git a/juick-www/src/main/webapp/WEB-INF/views/partial/tagcolumn.html b/juick-www/src/main/webapp/WEB-INF/views/partial/tagcolumn.html new file mode 100644 index 00000000..949a186a --- /dev/null +++ b/juick-www/src/main/webapp/WEB-INF/views/partial/tagcolumn.html @@ -0,0 +1,33 @@ + +{% if visitor is not empty and visitor.uid > 0 %} + +{% endif %} -- cgit v1.2.3