Package ru.org.linux.site

Examples of ru.org.linux.site.Template


      section = null;
    }

    TagName.checkTag(tag);

    Template tmpl = Template.getTemplate(request);

    TopicListController.setExpireHeaders(response, null, null);

    String title = getTitle(tag, section);

    modelAndView.addObject("navtitle", title);
    modelAndView.addObject("ptitle", title);

    offset = topicListService.fixOffset(offset);

    List<Topic> topics = topicListService.getTopicsFeed(
            section,
            null,
            tag,
            offset,
            null,
            null,
            20
    );

    List<PersonalizedPreparedTopic> preparedTopics = prepareService.prepareMessagesForUser(
            topics,
            request.isSecure(),
            tmpl.getCurrentUser(),
            tmpl.getProf(),
            false
    );

    modelAndView.addObject(
            "messages",
            preparedTopics
    );

    modelAndView.addObject("offsetNavigation", true);

    modelAndView.addObject("tag", tag);
    modelAndView.addObject("section", sectionId);
    modelAndView.addObject("offset", offset);
    modelAndView.addObject("sectionList", sectionService.getSectionList());

    if (tmpl.isSessionAuthorized()) {
      modelAndView.addObject(
              "isShowFavoriteTagButton",
              !userTagService.hasFavoriteTag(tmpl.getCurrentUser(), tag)
      );

      modelAndView.addObject(
              "isShowUnFavoriteTagButton",
              userTagService.hasFavoriteTag(tmpl.getCurrentUser(), tag)
      );

      if (!tmpl.isModeratorSession()) {
        modelAndView.addObject(
                "isShowIgnoreTagButton",
                !userTagService.hasIgnoreTag(tmpl.getCurrentUser(), tag)
        );
        modelAndView.addObject(
                "isShowUnIgnoreTagButton",
                userTagService.hasIgnoreTag(tmpl.getCurrentUser(), tag)
        );
      }
    }

    TagInfo tagInfo = tagService.getTagInfo(tag, true);
View Full Code Here


  @RequestMapping(value = "/remove-box.jsp", method = RequestMethod.POST)
  public String doRemove(@ModelAttribute("form") EditBoxesRequest form, BindingResult result,
                         SessionStatus status, HttpServletRequest request)
    throws Exception {
    Template tmpl = Template.getTemplate(request);

    if (!tmpl.isSessionAuthorized()) {
      throw new AccessViolationException("Not authorized");
    }

    ValidationUtils.rejectIfEmptyOrWhitespace(result, "position", "position.empty", "Не указанa позиция бокслета");
    if (result.hasErrors()) {
      return "remove-box";
    }

    if (result.hasErrors()) {
      return "remove-box";
    }

    List<String> boxlets = new ArrayList<>(tmpl.getProf().getBoxlets());

    if (!boxlets.isEmpty()) {
      if (boxlets.size() > form.position) {
        boxlets.remove(form.position.intValue());
        tmpl.getProf().setBoxlets(boxlets);

        profileDao.writeProfile(tmpl.getCurrentUser(), tmpl.getProf());
      }
    }
   
    status.setComplete();
    return "redirect:/edit-boxes.jsp";
View Full Code Here

      result.addError(new FieldError("boxName", "boxName.invalid", "Неверный бокслет"));
    }
    if (result.hasErrors()) {
      return "add-box";
    }
    Template t = Template.getTemplate(request);

    if (result.hasErrors()) {
      return "add-box";
    }

    if (form.getPosition() == null) {
      form.setPosition(0);
    }

    List<String> boxlets = Lists.newArrayList(
            Iterables.filter(t.getProf().getBoxlets(), DefaultProfile.boxPredicate())
    );

    if (boxlets.size() > form.position) {
      boxlets.add(form.position, form.boxName);
    } else {
      boxlets.add(form.boxName);
    }
   
    t.getProf().setBoxlets(boxlets);

    profileDao.writeProfile(t.getCurrentUser(), t.getProf());

    status.setComplete();
    return "redirect:/edit-boxes.jsp";
  }
View Full Code Here

  public Map<String, Integer> add(
          ServletRequest request,
          @RequestParam("msgid") int msgid,
          @RequestParam("watch") boolean watch
  ) throws Exception {
    Template tmpl = Template.getTemplate(request);

    if (!tmpl.isSessionAuthorized()) {
      throw new AccessViolationException("Not authorized");
    }

    User user = tmpl.getCurrentUser();
    user.checkBlocked();
    user.checkAnonymous();

    Topic topic = messageDao.getById(msgid);
    if (topic.isDeleted()) {
View Full Code Here

  @RequestMapping(value = "/memories.jsp", params = {"remove"}, method = RequestMethod.POST)
  public int remove(
          ServletRequest request,
          @RequestParam("id") int id
  ) throws Exception {
    Template tmpl = Template.getTemplate(request);

    if (!tmpl.isSessionAuthorized()) {
      throw new AccessViolationException("Not authorized");
    }

    User user = tmpl.getCurrentUser();
    user.checkBlocked();
    user.checkAnonymous();

    MemoriesListItem m = memoriesDao.getMemoriesListItem(id);
View Full Code Here

          HttpServletRequest request,
          HttpServletResponse response,
          String groupName,
          int msgid) throws Exception {
    Topic topic = messageDao.getById(msgid);
    Template tmpl = Template.getTemplate(request);

    Map<String, Object> params = new HashMap<>();

    List<TagRef> tags = topicTagService.getTagRefs(topic);

    MessageText messageText = msgbaseDao.getMessageText(topic.getId());

    PreparedTopic preparedMessage = messagePrepareService.prepareTopic(
            topic,
            tags,
            request.isSecure(),
            tmpl.getCurrentUser(),
            messageText
    );

    Group group = preparedMessage.getGroup();
View Full Code Here

  private ModelAndView jumpMessage(
          HttpServletRequest request,
          int msgid,
          int cid) throws Exception {
    Template tmpl = Template.getTemplate(request);
    Topic topic = messageDao.getById(msgid);

    CommentList comments = commentService.getCommentList(topic, false);
    CommentNode node = comments.getNode(cid);

    boolean deleted = false;

    if (node==null && tmpl.isModeratorSession()) {
      comments = commentService.getCommentList(topic, true);
      node = comments.getNode(cid);
      deleted = true;
    }

    if (node == null) {
      throw new MessageNotFoundException(topic, cid, "Сообщение #" + cid + " было удалено или не существует");
    }

    int pagenum = deleted?0:comments.getCommentPage(node.getComment(), tmpl.getProf());

    TopicLinkBuilder redirectUrl =
            TopicLinkBuilder
                    .pageLink(topic, pagenum)
                    .lastmod(tmpl.getProf().getMessages())
                    .comment(cid);

    if (deleted) {
      redirectUrl = redirectUrl.showDeleted();
    }

    if (tmpl.isSessionAuthorized() && !deleted) {
      Set<Integer> ignoreList = ignoreListDao.get(tmpl.getCurrentUser());

      Set<Integer> hideSet = commentService.makeHideSet(
              comments,
              getDefaultFilter(tmpl.getProf(), ignoreList.isEmpty()),
              ignoreList
      );

      if (hideSet.contains(node.getComment().getId())) {
        redirectUrl = redirectUrl.filter(CommentFilter.FILTER_NONE);
View Full Code Here

  @RequestMapping(method = RequestMethod.GET)
  public ModelAndView deleteForm(
          @RequestParam(required = true) int id,
          HttpServletRequest request
  ) throws Exception {
    Template tmpl = Template.getTemplate(request);

    Image image = imageDao.getImage(id);
    Topic topic = topicDao.getById(image.getTopicId());
    PreparedTopic preparedTopic = prepareService.prepareTopic(topic, request.isSecure(), tmpl.getCurrentUser());

    checkDelete(preparedTopic, tmpl.getCurrentUser());

    ModelAndView mv = new ModelAndView("delete_image");

    mv.addObject("image", image);
    mv.addObject("preparedTopic", preparedTopic);
View Full Code Here

  @RequestMapping(method = RequestMethod.POST)
  public RedirectView deleteImage(
          @RequestParam(required = true) int id,
          HttpServletRequest request
  ) throws Exception {
    Template tmpl = Template.getTemplate(request);

    Image image = imageDao.getImage(id);
    Topic topic = topicDao.getById(image.getTopicId());
    PreparedTopic preparedTopic = prepareService.prepareTopic(topic, request.isSecure(), tmpl.getCurrentUser());

    checkDelete(preparedTopic, tmpl.getCurrentUser());

    imageService.deleteImage(tmpl.getCurrentUser(), image);

    return new RedirectView(TopicLinkBuilder.baseLink(topic).forceLastmod().build());
  }
View Full Code Here

  @RequestMapping(value="/delete.jsp", method= RequestMethod.GET)
  public ModelAndView showForm(
    @RequestParam("msgid") int msgid,
    HttpServletRequest request
  ) throws Exception {
    Template tmpl = Template.getTemplate(request);

    if (!tmpl.isSessionAuthorized()) {
      throw new AccessViolationException("Not authorized");
    }

    Topic msg = messageDao.getById(msgid);

    if (msg.isDeleted()) {
      throw new UserErrorException("Сообщение уже удалено");
    }

    if (!permissionService.isDeletable(msg, tmpl.getCurrentUser())) {
      throw new AccessViolationException("Вы не можете удалить это сообщение");
    }

    Section section = sectionService.getSection(msg.getSectionId());
View Full Code Here

TOP

Related Classes of ru.org.linux.site.Template

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.