Package ru.org.linux.site

Examples of ru.org.linux.site.Template


  @RequestMapping(method = {RequestMethod.GET, RequestMethod.HEAD})
  public ModelAndView tagPage(
          HttpServletRequest request,
          @PathVariable String tag
  ) throws Exception {
    Template tmpl = Template.getTemplate(request);

    if (!TagName.isGoodTag(tag)) {
      throw new TagNotFoundException();
    }

    ModelAndView mv = new ModelAndView("tag-page");

    mv.addObject("tag", tag);
    mv.addObject("title", WordUtils.capitalize(tag));

    TagInfo tagInfo = tagService.getTagInfo(tag, true);

    mv.addObject("counter", tagInfo.topicCount());

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

      mv.addObject(
              "showUnFavoriteTagButton",
              userTagService.hasFavoriteTag(tmpl.getCurrentUser(), tag)
      );
    }

    int tagId = tagInfo.id();
View Full Code Here


    return mv;
  }

  private Map<String, Object> getNewsSection(HttpServletRequest request, String tag) throws TagNotFoundException {
    Template tmpl = Template.getTemplate(request);

    Section newsSection = sectionService.getSection(Section.SECTION_NEWS);

    List<Topic> newsTopics = topicListService.getTopicsFeed(
            newsSection,
            null,
            tag,
            0,
            null,
            null,
            TOTAL_NEWS_COUNT
    );

    List<Topic> fullNewsTopics = headOrEmpty(newsTopics);
    List<Topic> briefNewsTopics = tailOrEmpty(newsTopics);

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

    ImmutableListMultimap<String, Topic> briefNews = datePartition(briefNewsTopics, COMMITDATE_EXTRACTOR);
View Full Code Here

    this.var = var;
  }

  @Override
  public int doStartTag() throws JspException {
    Template t = Template.getTemplate(pageContext.getRequest());

    List<String> boxnames = ImmutableList.copyOf(
            Iterables.filter(t.getProf().getBoxlets(), DefaultProfile.boxPredicate())
    );

    pageContext.setAttribute(var, boxnames);
    return EVAL_BODY_INCLUDE;
  }
View Full Code Here

  ) throws Exception {
    if (add.getTopic() == null) {
      throw new ServletParameterException("тема на задана");
    }

    Template tmpl = Template.getTemplate(request);

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

    if (add.getMode() == null) {
      add.setMode(tmpl.getFormatMode());
    }

    commentService.prepareReplyto(add, params, request);

    int postscore = topicPermissionService.getPostscore(add.getTopic());
View Full Code Here

  @RequestMapping("/comment-message.jsp")
  public ModelAndView showFormTopic(
    @ModelAttribute("add") @Valid CommentRequest add,
    HttpServletRequest request
  ) throws AccessViolationException {
    Template tmpl = Template.getTemplate(request);

    PreparedTopic preparedTopic = messagePrepareService.prepareTopic(add.getTopic(), request.isSecure(), tmpl.getCurrentUser());

    if (!topicPermissionService.isCommentsAllowed(preparedTopic.getGroup(), add.getTopic(), tmpl.getCurrentUser())) {
      throw new AccessViolationException("Это сообщение нельзя комментировать");
    }

    if (add.getMode() == null) {
      add.setMode(tmpl.getFormatMode());
    }

    return new ModelAndView(
      "comment-message",
      "preparedMessage",
View Full Code Here

    if (commentRequest.getMsg() == null) {
      errors.rejectValue("msg", null, "комментарий не задан");
      commentRequest.setMsg("");
    }

    Template tmpl = Template.getTemplate(request);

    if (commentRequest.getMode() == null) {
      commentRequest.setMode(tmpl.getFormatMode());
    }

    if (!commentRequest.isPreviewMode() &&
      (!tmpl.isSessionAuthorized() || ipBlockInfo.isCaptchaRequired())) {
      captcha.checkCaptcha(request, errors);
    }

    if (!commentRequest.isPreviewMode() && !errors.hasErrors()) {
      CSRFProtectionService.checkCSRF(request, errors);
View Full Code Here

  public User getCommentUser(
    CommentRequest commentRequest,
    HttpServletRequest request,
    Errors errors
  ) {
    Template tmpl = Template.getTemplate(request);

    User currentUser = tmpl.getCurrentUser();

    if (currentUser!=null) {
      return currentUser;
    }
View Full Code Here

    @RequestParam("reason") String reason,
    @RequestParam("time") String time,
    @RequestParam(value="allow_posting", required = false, defaultValue="false") boolean allowPosting,
    @RequestParam(value="captcha_required", required = false, defaultValue="false") boolean captchaRequired
  ) throws Exception {
    Template tmpl = Template.getTemplate(request);

    if (!tmpl.isModeratorSession()) {
      throw new IllegalAccessException("Not authorized");
    }

    Calendar calendar = Calendar.getInstance();
    calendar.setTime(new Date());

    if ("hour".equals(time)) {
      calendar.add(Calendar.HOUR_OF_DAY, 1);
    } else if ("day".equals(time)) {
      calendar.add(Calendar.DAY_OF_MONTH, 1);
    } else if ("month".equals(time)) {
      calendar.add(Calendar.MONTH, 1);
    } else if ("3month".equals(time)) {
      calendar.add(Calendar.MONTH, 3);
    } else if ("6month".equals(time)) {
      calendar.add(Calendar.MONTH, 6);
    } else if ("remove".equals(time)) {
    } else if ("custom".equals(time)) {
      int days = ServletRequestUtils.getRequiredIntParameter(request, "ban_days");

      if (days <= 0 || days > 180) {
        throw new UserErrorException("Invalid days count");
      }

      calendar.add(Calendar.DAY_OF_MONTH, days);
    }

    Timestamp ts;
    if ("unlim".equals(time)) {
      ts = null;
    } else {
      ts = new Timestamp(calendar.getTimeInMillis());
    }

    User user = tmpl.getCurrentUser();

    user.checkCommit();

    ipBlockDao.blockIP(ip, user, reason, ts, allowPosting, captchaRequired);
View Full Code Here

      throws IOException, ServletException {

    WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
    HttpServletRequest request = (HttpServletRequest) req;
    request.setAttribute("configuration", ctx.getBean(SiteConfig.class));
    request.setAttribute("template", new Template(ctx));
    request.setCharacterEncoding("utf-8"); // блядский tomcat
    CSRFManipulation(request, (HttpServletResponse) res);
    forWikiManipulation(request, (HttpServletResponse) res);
    chain.doFilter(req, res);
  }
View Full Code Here

  @RequestMapping(value = {"/remove-box.jsp", "/add-box.jsp"}, method = RequestMethod.GET)
  public ModelMap showRemove(@RequestParam(required = false) Integer pos,
                             ServletRequest request)
    throws AccessViolationException {
    Template tmpl = Template.getTemplate(request);

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

    ModelMap result = new ModelMap();
    EditBoxesRequest form = new EditBoxesRequest();
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.