" + txt + "
"); - if (msg.getAttachmentType() != null) { - out.println(" "); - } - out.print(" "); - - out.print(" "); - out.print("Теги:
"); - printUserTags(out, visitor); - out.println(""); - for (int i = 0; i < tags.size(); i++) { - if (i > 0) { - out.print(" "); - } - String taglink = StringUtils.EMPTY; - try { - taglink = "" + StringEscapeUtils.escapeHtml4(tags.get(i).getTag().getName()) + ""; - } catch (UnsupportedEncodingException e) { - } - int usagecnt = tags.get(i).getUsageCount(); - if (usagecnt <= max / 5 + min) { - out.print("" + taglink + ""); - } else if (usagecnt <= max / 5 * 2 + min) { - out.print(taglink); - } else if (usagecnt <= max / 5 * 3 + min) { - out.print("" + taglink + ""); - } else if (usagecnt <= max / 5 * 4 + min) { - out.print("" + taglink + ""); - } else { - out.print("" + taglink + ""); + model.addAttribute("visitor", visitor); + if (body == null) { + body = StringUtils.EMPTY; + } else { + if (body.length() > 4096) { + body = body.substring(0, 4096); } + body = StringEscapeUtils.escapeHtml4(body); } - out.println("
"); + model.addAttribute("body", body); + model.addAttribute("visitor", visitor); + model.addAttribute("tags", tagService.getUserTagStats(visitor.getUid()).stream() + .sorted((e1, e2) -> Integer.compare(e2.getUsageCount(), e1.getUsageCount())).map(t -> t.getTag().getName()).collect(Collectors.toList())); + return "views/post"; } @PostMapping("/post") - public void doPostMessage(HttpServletRequest request, HttpServletResponse response, @RequestParam(required = false) String img, + public String postResult(@RequestParam(required = false) String img, @RequestParam String body, - @RequestParam(required = false) MultipartFile attach) throws IOException { + @RequestParam(required = false, name = "tags") String tagsStr, + @RequestParam(required = false) MultipartFile attach, ModelMap model) throws IOException { com.juick.User visitor = UserUtils.getCurrentUser(); if (visitor.getUid() == 0) { - response.sendError(HttpServletResponse.SC_FORBIDDEN); - return; + throw new HttpForbiddenException(); } if (body == null || body.length() < 1 || body.length() > 4096) { - response.sendError(HttpServletResponse.SC_BAD_REQUEST); - return; + throw new HttpBadRequestException(); } body = body.replace("\r", StringUtils.EMPTY); - ListПоделитесь своим новым постом в социальных сетях:
"); - if (crosspostService.getTwitterTokens(visitor.getUid()).isPresent()) { - out.println(" "); - } - out.println(" "); - out.println(" "); - if (crosspostService.getFacebookToken(visitor.getUid()).isPresent()) { - out.println(" "); - } - out.println(" "); - out.println("Ссылка на сообщение: http://juick.com/" + mid + "
"); - out.println("Чтобы добавлять сообщения и комментарии, представьтесь.
"); - } - out.println("" + txt + "
"); - if (msg.getAttachmentType() != null) { - out.println(" "); - } - out.print(" "); - - out.print(" "); - out.print("