Package ru.org.linux.util.bbcode.nodes

Examples of ru.org.linux.util.bbcode.nodes.RootNode


      node.setParameter("");
    } else {
      node.setParameter(node.getParameter().trim());
    }
    TagNode tagNode = (TagNode)node;
    RootNode rootNode = tagNode.getRootNode();
    if (rootNode.isComment()) { // коментарий, просто содержимое
      return node.renderChildrenXHtml();
    } else if (rootNode.isTopicMaximized()) { // топик не свернутым cut, содежимое в div
      return "<div id=\"cut" + Integer.toString(rootNode.getCutCount()) + "\">" + node.renderChildrenXHtml() + "</div>";
    } else if(rootNode.isTopicMinimized()) { // топик со свернутым cut, вместо содержимого ссылка
      URI uri = rootNode.getCutURI();
      try {
        uri.setFragment("cut"+Integer.toString(rootNode.getCutCount()));
        if (!node.getParameter().isEmpty()) {
          ToHtmlFormatter formatter = rootNode.getToHtmlFormatter();
          String parameter;
          if(formatter != null) {
            parameter = rootNode.getToHtmlFormatter().simpleFormat(node.getParameter().replaceAll("\"", ""));
          } else {
             parameter = Parser.escape(node.getParameter().replaceAll("\"", ""));
          }
          return String.format("<p>( <a href=\"%s\">%s</a> )</p>", uri.getEscapedURIReference(), parameter);
        } else {
View Full Code Here


    if (linkText.isEmpty()) {
      linkText = url;
    }
    String escapedUrl = URLUtil.fixURL(url);
    TagNode tagNode = (TagNode)node;
    RootNode rootNode = tagNode.getRootNode();
    ToHtmlFormatter formatter = rootNode.getToHtmlFormatter();

   if(formatter != null) {
      StringBuilder out = new StringBuilder();

      try {
        formatter.processUrl(
                rootNode.isSecure(),
                rootNode.isNofollow(),
                out,
                escapedUrl,
                linkText
        );

        ret.append(out);
      } catch (URIException e) {
        ret.append("<s>");
        ret.append(Parser.escape(url));
        ret.append("</s>");
      }
    } else {
      String formattedText = Parser.escape(linkText);

      if (URLUtil.isUrl(escapedUrl)) {
        ret.append("<a href=\"");
        ret.append(escapedUrl);

        ret.append('\"');

        if (rootNode.isNofollow()) {
          ret.append(" rel=nofollow");
        }

        ret.append(">");
        ret.append(formattedText);
View Full Code Here

      return "";
    }
    TextNode txtNode = (TextNode) node.getChildren().iterator().next();
    String memberName = Parser.escape(txtNode.getText()).trim();
    TagNode tagNode = (TagNode)node;
    RootNode rootNode = tagNode.getRootNode();
    ToHtmlFormatter toHtmlFormatter = rootNode.getToHtmlFormatter();
    boolean secure = rootNode.isSecure();
    UserDao userDao = rootNode.getUserDao();
    String result;
    try {
      if(userDao != null && toHtmlFormatter != null){
        User user = rootNode.getUserDao().getUser(memberName);
        if (!user.isBlocked()) {
          result = String.format(" <span style=\"white-space: nowrap\"><img src=\"/img/tuxlor.png\"><a style=\"text-decoration: none\" href=\"%s\">%s</a></span>",
              toHtmlFormatter.memberURL(user, secure), Parser.escape(memberName));
          rootNode.addReplier(user);
        } else {
          result = String.format(" <span style=\"white-space: nowrap\"><img src=\"/img/tuxlor.png\"><s><a style=\"text-decoration: none\" href=\"%s\">%s</a></s></span>",
              toHtmlFormatter.memberURL(user, secure), Parser.escape(memberName));
        }
      }else{
View Full Code Here

    } else {
      node.setParameter(node.getParameter().trim());
    }

    TagNode tagNode = (TagNode)node;
    RootNode rootNode = tagNode.getRootNode();

    boolean rss = rootNode.isRss();
    ToHtmlFormatter formatter = rootNode.getToHtmlFormatter();

    if (!node.getParameter().isEmpty()) {
      if(rss) {
        ret.append(citeHeaderRSS);
      } else {
View Full Code Here

   * Возвращает множество пользователей упомянутых в сообщении
   * @param text сообщение
   * @return множество пользователей
   */
  public Set<User> getReplierFromMessage(String text) {
    RootNode rootNode = defaultParser.parseRoot(prepareCommentRootNode(false, false, false), text);
    rootNode.renderXHtml();
    return rootNode.getReplier();
  }
View Full Code Here

  public String parseTopic(String text, boolean secure, boolean nofollow) {
    return defaultParser.parseRoot(prepareTopicRootNode(false, null, secure, nofollow), text).renderXHtml();
  }

  private RootNode prepareCommentRootNode(boolean secure, boolean rss, boolean nofollow) {
    RootNode rootNode = defaultParser.getRootNode();
    rootNode.setCommentCutOptions();
    rootNode.setUserDao(userDao);
    rootNode.setSecure(secure);
    rootNode.setToHtmlFormatter(toHtmlFormatter);
    rootNode.setRss(rss);
    rootNode.setNofollow(nofollow);

    return rootNode;
  }
View Full Code Here

    return rootNode;
  }

  private RootNode prepareTopicRootNode(boolean minimizeCut, String cutURL, boolean secure, boolean nofollow) {
    RootNode rootNode = defaultParser.getRootNode();
    if(minimizeCut) {
      try {
        LorURL lorCutURL = new LorURL(siteConfig.getMainURI(), cutURL);
        if(lorCutURL.isTrueLorUrl()) {
          URI fixURI = new URI(lorCutURL.fixScheme(secure), true, "UTF-8");
          rootNode.setMinimizedTopicCutOptions(fixURI);
        } else {
          rootNode.setMaximizedTopicCutOptions();
        }
      } catch (Exception e) {
        rootNode.setMaximizedTopicCutOptions();
      }
    } else {
      rootNode.setMaximizedTopicCutOptions();
    }
    rootNode.setUserDao(userDao);
    rootNode.setSecure(secure);
    rootNode.setToHtmlFormatter(toHtmlFormatter);
    rootNode.setNofollow(nofollow);

    return rootNode;
  }
View Full Code Here

  }

  @Before
  public void setUp() {
    parser = new Parser(new DefaultParserParameters());
    rootNode = new RootNode(new DefaultParserParameters());
  }
View Full Code Here

TOP

Related Classes of ru.org.linux.util.bbcode.nodes.RootNode

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.