Ticket #32 (closed 需求: 已处理)

Opened 14 years ago

Last modified 14 years ago

电脑网产品论坛,发帖时,外链添加nofollowe标签

Reported by: chenyang Owned by: chenyang
Priority: 重要的(3) Milestone:
Component: 电脑网产品论坛 Version:
Keywords: Cc:
Due Date: 27/06/2012

Description


Change History

comment:1 Changed 14 years ago by chenyang

1.cn.pconline.bbs6.ubb.node.UrlNode类中添加,判断是否是内链结的方法

private static boolean isSelfDomain(String href){

return href.contains("pconline")
href.contains("pcauto")
href.contains("pcgames") href.contains("pcbaby")
href.contains("pclady")
href.contains("pckids")

href.contains("pchouse");

}

2.在解析node链接内容的方法getText方法中为外链添加nofollow标签
public StringBuilder? getText(java.util.LinkedList?<Node> stack) {

StringBuilder? sb = new StringBuilder?();
boolean isAttach = false;
Attachment attach = null;
sb.append("<a target=\"_blank\" href=\"");
if (attribute != null) {

attribute.trim();

if (isAttach(attribute)) {

attach = getAttach(attribute);
if (attach != null) {

sb.insert(0, "<img src=' http://img.pconline.com.cn/images/upload/upc/tx/bbs6/1005/25/c1/4001835_1274784331214_1024x1024.png' border='0'>&nbsp;");
sb.append(attribute);
isAttach = true;

} else {

EscapeUtils?.appendAttribute(attribute, sb);

}

} else {

EscapeUtils?.appendAttribute(attribute, sb);

}

} else {

sb.append(text);

}

sb.append("\"");

if(!isSelfDomain(attribute)){
sb.append(" rel=\"nofollow\"" );
}

sb.append(">").append(text).append("</a>");
if (isAttach) {

sb.append(" - (文件大小:").append(formatFileSize(attach.getFileSize()));
sb.append(")");
sb.append(",下载次数:").append(attach.getDownloadCount()).append(")");

}

return sb;

}

Last edited 14 years ago by chenyang (previous) (diff)

comment:2 Changed 14 years ago by chenyang

  • Status changed from new to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.