Ejemplo n.º 1
0
  // 生成删除文章的文章html代码
  public String generateAdminArticleDelHtml(List<TArticle> articles) {
    String listHtml = "";
    int size = articles.size();
    for (int i = 0; i < size; i++) {
      TArticle article = articles.get(i);
      String item = "";

      item += "<tr id='" + article.getArticle_ID() + "' class='noteItem'>";
      item += "	<td>";
      item += "		<div class='checker'>";
      item += "			<span>";
      item += "				<input class='checkboxes' type='checkbox' value='1'>";
      item += "			</span>";
      item += "		</div>";
      item += "	</td>";
      item += "	<td>" + article.getArticle_ID() + "</td>";
      item += "	<td>" + article.getArticle_Title() + "</td>";
      item += "	<td>" + article.getSort_Name() + "</td>";
      item += "	<td>" + article.getRecommend_Num() + "</td>";
      item += "	<td>" + article.getRead_Num() + "</td>";
      item += "	<td>" + article.getArticle_Date() + "</td>";
      item += "	<td>";
      item +=
          "		<a class='delete' onclick='oneDel("
              + article.getArticle_ID()
              + ")' href='javascript:void(0)'>删除</a>";
      item += "	</td>";
      item += "</tr>";

      listHtml += item;
    }
    return listHtml;
  }
Ejemplo n.º 2
0
  // 生成修改文章的文章html代码
  public String generateAdminArticleUpdateHtml(List<TArticle> articles) {
    String listHtml = "";
    int size = articles.size();
    for (int i = 0; i < size; i++) {
      TArticle article = articles.get(i);
      String item = "";

      item += "<tr id='" + article.getArticle_ID() + "' class='noteItem'>";
      item += "	<td>" + article.getArticle_ID() + "</td>";
      item += "	<td>" + article.getArticle_Title() + "</td>";
      item += "	<td>" + article.getSort_Name() + "</td>";
      item += "	<td>" + article.getRecommend_Num() + "</td>";
      item += "	<td>" + article.getRead_Num() + "</td>";
      item += "	<td>" + article.getArticle_Date() + "</td>";
      item += "	<td>";
      item +=
          "		<a class='update' onclick='update("
              + article.getArticle_ID()
              + ")' href='javascript:void(0)'>修改</a>";
      item += "	</td>";
      item += "</tr>";

      listHtml += item;
    }
    return listHtml;
  }
Ejemplo n.º 3
0
  // 根据文章生成它的标签html代码
  public String generateArticleTagsHtml(TArticle article) throws UnsupportedEncodingException {

    String tagsHtml = "";
    String[] tags = article.getArticle_Tag().split(",");
    for (int j = 0; j < tags.length; j++) {
      String tag = URLEncoder.encode(URLEncoder.encode(tags[j], "utf-8"));
      if (j == 0) {
        tagsHtml +=
            "<a title='"
                + tags[j]
                + "' rel='tag' href='/doit/search/"
                + tag
                + "/0/2/search'>"
                + tags[j]
                + "</a>";
      } else {
        tagsHtml +=
            " , <a title='"
                + tags[j]
                + "' rel='tag' href='/doit/search/"
                + tag
                + "/0/2/search'>"
                + tags[j]
                + "</a>";
      }
    }

    return tagsHtml;
  }
Ejemplo n.º 4
0
  // 生成文章展示页面的下一条文章链接html代码
  public String generateNextArticleHtml(TArticle article) {

    String nextHtml = "";
    if (article.getArticle_ID() == null) {
      nextHtml +=
          "<span>坐等站主更新~</span><i class='hand link right icon' style='font-size: 18px;'></i>";
    } else {
      nextHtml +=
          "<a href='/doit/show/"
              + article.getArticle_ID()
              + "'>"
              + article.getArticle_Title()
              + "<i class='hand link right icon' style='font-size: 18px;'></i></a>";
    }

    return nextHtml;
  }
Ejemplo n.º 5
0
  // 生成文章展示页面的上一条文章链接html代码
  public String generatePrevArticleHtml(TArticle article) {

    String prevHtml = "";
    if (article.getArticle_ID() == null) {
      prevHtml +=
          "<i class='hand link left icon' style='font-size: 18px;'></i><span>第一篇了, 亲~</span>";
    } else {
      prevHtml +=
          "<a href='/doit/show/"
              + article.getArticle_ID()
              + "'><i class='hand link left icon' style='font-size: 18px;'></i>"
              + article.getArticle_Title()
              + "</a>";
    }

    return prevHtml;
  }
Ejemplo n.º 6
0
  // 生成热门笔记列表html代码
  public String generateTopNoteHtml(List<TArticle> articles) {
    String listHtml = "";
    if (articles == null) {
      return listHtml;
    }
    int size = articles.size();
    for (int i = 0; i < size; i++) {
      TArticle article = articles.get(i);

      String item = "";
      item += "<p>";
      item += "	<span>●</span>";
      item +=
          "	<a href='/doit/show/"
              + article.getArticle_ID()
              + "'>"
              + article.getArticle_Title()
              + "</a>";
      item += "</p>";

      listHtml += item;
    }
    return listHtml;
  }
Ejemplo n.º 7
0
  // 生成笔记列表html代码
  public String generateNoteHtml(List<TArticle> articles) throws Exception {
    String listHtml = "";
    if (articles == null) {
      listHtml =
          "<div style='margin-bottom: 100px; font-size: 30px; text-align: center; margin-top: 20px;'>此分类下暂时没有笔记</div>";
      return listHtml;
    }
    int size = articles.size();
    for (int i = 0; i < size; i++) {
      TArticle article = articles.get(i);

      // 组织标签的html
      String tagsHtml = "";
      String[] tags = article.getArticle_Tag().split(",");
      for (int j = 0; j < tags.length; j++) {
        String tag = URLEncoder.encode(URLEncoder.encode(tags[j], "utf-8"));
        if (j == 0) {
          tagsHtml +=
              "<a title='"
                  + tags[j]
                  + "' rel='tag' href='/doit/search/"
                  + tag
                  + "/0/2/search' style='font-size:13px;'>"
                  + tags[j]
                  + "</a>";
        } else {
          tagsHtml +=
              " , <a title='"
                  + tags[j]
                  + "' rel='tag' href='/doit/search/"
                  + tag
                  + "/0/2/search' style='font-size:13px;'>"
                  + tags[j]
                  + "</a>";
        }
      }

      String item = "";
      item += "<div id='item" + article.getArticle_ID() + "' class='ui stacked segment'>";
      item += "	<h2 class='article_title'>";
      item +=
          "		<a href='/doit/show/"
              + article.getArticle_ID()
              + "' style='font-size:24px;'>"
              + article.getArticle_Title()
              + "</a>";
      item += "	</h2>";
      item += "	<div class='article_date'>";
      item +=
          "		<span property='dc:date dc:created' content='2013-11-10T12:30:01+08:00' datatype='xsd:dateTime' rel='sioc:has_creator' style='margin-right:20px;'>	发布时间 : "
              + article.getArticle_Date()
              + " </span>";
      item += "		<span style='color:#434A54;'>Tags : </span>";
      item += tagsHtml;
      item += "	</div>";
      item += "	<h2></h2>";
      item += "	<div id='artContent'" + article.getArticle_ID() + " class='article_content'></div>";
      item += "</div>";

      listHtml += item;
    }
    return listHtml;
  }
Ejemplo n.º 8
0
  // 生成home页面的主文章列表html代码
  public String generateHomeMainHtml(List<TArticle> articles) throws Exception {
    String listHtml = "";
    if (articles != null) {
      int size = articles.size();
      for (int i = 0; i < size; i++) {
        TArticle article = articles.get(i);

        // 组织标签的html
        String tagsHtml = "";
        String[] tags = article.getArticle_Tag().split(",");
        for (int j = 0; j < tags.length; j++) {
          String tag = URLEncoder.encode(URLEncoder.encode(tags[j], "utf-8"));
          if (j == 0) {
            tagsHtml +=
                "<a title='"
                    + tags[j]
                    + "' rel='tag' href='/doit/search/"
                    + tag
                    + "/0/2/search' style='font-size:13px;'>"
                    + tags[j]
                    + "</a>";
          } else {
            tagsHtml +=
                " , <a title='"
                    + tags[j]
                    + "' rel='tag' href='/doit/search/"
                    + tag
                    + "/0/2/search' style='font-size:13px;'>"
                    + tags[j]
                    + "</a>";
          }
        }

        OperateString operateString = new OperateString();
        String contentHtml = article.getArticle_Content();
        // String contentHtml = "dsafkjbsdkds<pre class='brush: js;'>function
        // helloSyntaxHighlighter(){return 'hi!';}</pre><div class='ui segment '><img src='123.png'
        // /><IMG src='456.png' /></div>afkjbsdkdsafkjbsdk中文结尾";
        // 过滤图片
        OperateImage operateImage = new OperateImage();
        contentHtml = operateImage.filterImage(contentHtml);
        // 过滤html所有标签
        contentHtml = operateString.filterHtmlTag(contentHtml);
        // 截取字符串
        contentHtml = operateString.interceptCharacters(contentHtml, 0, 200);

        String item = "";
        item += "<div id='item" + article.getArticle_ID() + "' class='ui stacked segment'>";
        item += "	<h2 class='article_title'>";
        item +=
            "		<a href='/doit/show/"
                + article.getArticle_ID()
                + "' style='font-size:24px;'>"
                + article.getArticle_Title()
                + "</a>";
        item += "	</h2>";
        item += "	<h2></h2>";
        item += "	<div class='article_date'>";
        item +=
            "		<span property='dc:date dc:created' content='2013-11-10T12:30:01+08:00' datatype='xsd:dateTime' rel='sioc:has_creator' style='margin-right:20px;'>	发布时间 : "
                + article.getArticle_Date()
                + " </span>";
        item += "		<span style='color:#434A54;'>Tags : </span>";
        item += tagsHtml;
        item += "	</div>";
        item += "	<div class='row'>";
        item +=
            "		<a class='thumbnail' href='/doit/show/"
                + article.getArticle_ID()
                + "' style='float:left;width:240px;oveflow:hidden;'>";
        item +=
            "			<img src='"
                + article.getArticle_Cover()
                + "' style='height: 175px; width: 100%; display: block;' data-src='holder.js/100%x175'>";
        item += "		</a>";
        item +=
            "		<span id='artContent"
                + article.getArticle_ID()
                + "' class='sDiv article_content'>"
                + contentHtml
                + "</span>";
        item += "	</div>";
        item += "</div>";

        listHtml += item;
      }
    }
    System.out.println(listHtml);
    return listHtml;
  }
Ejemplo n.º 9
0
  // 生成个人作品页面的作品列表html代码
  public String generateWorksMainHtml(List<TArticle> articles) throws UnsupportedEncodingException {
    String listHtml = "";
    if (articles != null) {
      int size = articles.size();
      for (int i = 0; i < size; i++) {

        if (i % 2 != 0) { // 奇数
          TArticle prevArticle = articles.get(i - 1); // 获得这一行的第一个
          TArticle nowArticle = articles.get(i); // 获得这一行的第二个

          // 获取封面
          String prevCoverHtml = "";
          String nowCoverHtml = "";
          if (prevArticle.getArticle_Cover() == "") {
            prevCoverHtml = "/doit/common/images/cover_default.png";
          } else {
            prevCoverHtml = prevArticle.getArticle_Cover();
          }
          if (nowArticle.getArticle_Cover() == "") {
            nowCoverHtml = "/doit/common/images/cover_default.png";
          } else {
            nowCoverHtml = nowArticle.getArticle_Cover();
          }

          // 组织html
          String rowItem = "";
          rowItem += "<div class='row'>";
          rowItem += "	<div class='col-md-6'>";
          rowItem +=
              "		<a class='works_item' href='/doit/show/" + prevArticle.getArticle_ID() + "'>";
          rowItem += "			<div class='works_pic'>";
          rowItem +=
              "				<img class='img-responsive' xsalt='Responsive image' src='"
                  + prevCoverHtml
                  + "' />";
          rowItem += "			</div>";
          rowItem += "			<div class='works_info'>";
          rowItem += "				<div class='works_name'>" + prevArticle.getArticle_Title() + "</div>";
          rowItem += "				<div class='works_others'>";
          rowItem += "					<span class='works_others_guide'>";
          rowItem += "						<span>" + prevArticle.getArticle_Tag() + "</span>";
          rowItem += "					</span>";
          rowItem += "					<span class='works_others_info'>";
          rowItem +=
              "						<i class='unhide icon' style='margin:0 2px 0 20px;'></i>"
                  + prevArticle.getRead_Num()
                  + "";
          rowItem +=
              "						<i class='heart icon' style='margin:0 2px 0 10px;'></i>"
                  + prevArticle.getRecommend_Num()
                  + "";
          rowItem += "					</span>";
          rowItem += "				</div>";
          rowItem += "			</div>";
          rowItem += "		</a>";
          rowItem += "	</div>";
          rowItem += "	<div class='col-md-6'>";
          rowItem +=
              "		<a class='works_item' href='/doit/show/" + nowArticle.getArticle_ID() + "'>";
          rowItem += "			<div class='works_pic'>";
          rowItem +=
              "				<img class='img-responsive' xsalt='Responsive image' src='"
                  + nowCoverHtml
                  + "' />";
          rowItem += "			</div>";
          rowItem += "			<div class='works_info'>";
          rowItem += "				<div class='works_name'>" + nowArticle.getArticle_Title() + "</div>";
          rowItem += "				<div class='works_others'>";
          rowItem += "					<span class='works_others_guide'>";
          rowItem += "						<span>" + nowArticle.getArticle_Tag() + "</span>";
          rowItem += "					</span>";
          rowItem += "					<span class='works_others_info'>";
          rowItem +=
              "						<i class='unhide icon' style='margin:0 2px 0 20px;'></i>"
                  + nowArticle.getRead_Num()
                  + "";
          rowItem +=
              "						<i class='heart icon' style='margin:0 2px 0 10px;'></i>"
                  + nowArticle.getRecommend_Num()
                  + "";
          rowItem += "					</span>";
          rowItem += "				</div>";
          rowItem += "			</div>";
          rowItem += "		</a>";
          rowItem += "	</div>";
          rowItem += "</div>";

          listHtml += rowItem;
        } else { // 偶数
          if (i + 1 == size) { // 最后一个
            TArticle nowArticle = articles.get(i); // 获得这一行的第二个

            // 获取封面
            String nowCoverHtml = "";
            if (nowArticle.getArticle_Cover() == "") {
              nowCoverHtml = "/doit/common/images/cover_default.png";
            } else {
              nowCoverHtml = nowArticle.getArticle_Cover();
            }

            // 组织html
            String rowItem = "";
            rowItem += "<div class='row'>";
            rowItem += "	<div class='col-md-6'>";
            rowItem +=
                "		<a class='works_item' href='/doit/show/" + nowArticle.getArticle_ID() + "'>";
            rowItem += "			<div class='works_pic'>";
            rowItem +=
                "				<img class='img-responsive' xsalt='Responsive image' src='"
                    + nowCoverHtml
                    + "' />";
            rowItem += "			</div>";
            rowItem += "			<div class='works_info'>";
            rowItem += "				<div class='works_name'>" + nowArticle.getArticle_Title() + "</div>";
            rowItem += "				<div class='works_others'>";
            rowItem += "					<span class='works_others_guide'>";
            rowItem += "						<span>" + nowArticle.getArticle_Tag() + "</span>";
            rowItem += "					</span>";
            rowItem += "					<span class='works_others_info'>";
            rowItem +=
                "						<i class='unhide icon' style='margin:0 2px 0 20px;'></i>"
                    + nowArticle.getRead_Num()
                    + "";
            rowItem +=
                "						<i class='heart icon' style='margin:0 2px 0 10px;'></i>"
                    + nowArticle.getRecommend_Num()
                    + "";
            rowItem += "					</span>";
            rowItem += "				</div>";
            rowItem += "			</div>";
            rowItem += "		</a>";
            rowItem += "	</div>";
            rowItem += "</div>";

            listHtml += rowItem;
          }
        }
      }
    }
    return listHtml;
  }