This commit is contained in:
parent
2e206b2600
commit
deaa24cc81
4 changed files with 54 additions and 2 deletions
|
@ -80,6 +80,8 @@ public class ViewHelper implements Serializable {
|
|||
|
||||
public int titleLength = 50;
|
||||
|
||||
public int sitePathLength = 50;
|
||||
|
||||
public boolean encodeUrlLink = false;
|
||||
|
||||
public String urlLinkEncoding = Constants.UTF_8;
|
||||
|
@ -163,7 +165,7 @@ public class ViewHelper implements Serializable {
|
|||
return StringUtil.EMPTY;
|
||||
}
|
||||
|
||||
protected String escapeHighlight(String text) {
|
||||
protected String escapeHighlight(final String text) {
|
||||
return S2Functions.h(text)
|
||||
.replaceAll(escapedSolrHighlightPre, solrHighlightTagPre)
|
||||
.replaceAll(escapedSolrHighlightPost, solrHighlightTagPost);
|
||||
|
@ -495,6 +497,16 @@ public class ViewHelper implements Serializable {
|
|||
return buf.toString();
|
||||
}
|
||||
|
||||
public Object getSitePath(final Map<String, Object> docMap) {
|
||||
final Object urlLink = docMap.get("urlLink");
|
||||
if (urlLink != null) {
|
||||
return StringUtils.abbreviate(
|
||||
urlLink.toString().replaceFirst("^[a-zA-Z0-9]*:/?/*", ""),
|
||||
sitePathLength);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isUseSession() {
|
||||
return useSession;
|
||||
}
|
||||
|
|
|
@ -151,6 +151,7 @@ public class QueryResponseList implements List<Map<String, Object>> {
|
|||
docMap.put("contentDescription",
|
||||
viewHelper.getContentDescription(docMap));
|
||||
docMap.put("urlLink", viewHelper.getUrlLink(docMap));
|
||||
docMap.put("sitePath", viewHelper.getSitePath(docMap));
|
||||
}
|
||||
|
||||
parent.add(docMap);
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<div class="body">
|
||||
<div class="description">${doc.contentDescription}</div>
|
||||
<div class="site ellipsis">
|
||||
<cite>${f:h(doc.site)}</cite>
|
||||
<cite>${f:h(doc.sitePath)}</cite>
|
||||
<c:if test="${doc.hasCache_s_s=='true'}">
|
||||
<a href="cache?docId=${doc.docId}${appendHighlightQueries}" class="cache"><bean:message
|
||||
key="labels.search_result_cache" /></a>
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
|
||||
package jp.sf.fess.helper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.seasar.extension.unit.S2TestCase;
|
||||
|
||||
public class ViewHelperTest extends S2TestCase {
|
||||
|
@ -105,4 +108,40 @@ public class ViewHelperTest extends S2TestCase {
|
|||
|
||||
}
|
||||
|
||||
public void test_getSitePath() {
|
||||
String urlLink;
|
||||
String sitePath;
|
||||
final Map<String, Object> docMap = new HashMap<>();
|
||||
|
||||
urlLink = "http://www.yahoo.co.jp";
|
||||
sitePath = "www.yahoo.co.jp";
|
||||
docMap.put("urlLink", urlLink);
|
||||
assertEquals(sitePath, viewHelper.getSitePath(docMap));
|
||||
|
||||
urlLink = "https://www.jp.websecurity.symantec.com/";
|
||||
sitePath = "www.jp.websecurity.symantec.com/";
|
||||
docMap.put("urlLink", urlLink);
|
||||
assertEquals(sitePath, viewHelper.getSitePath(docMap));
|
||||
|
||||
urlLink = "http://www.dfasdfaskdfkakdfadfsd.jp";
|
||||
sitePath = "www.dfasdfaskdfkakdfadfsd.jp";
|
||||
docMap.put("urlLink", urlLink);
|
||||
assertEquals(sitePath, viewHelper.getSitePath(docMap));
|
||||
|
||||
urlLink = "www.yahoo.co.jp";
|
||||
sitePath = "www.yahoo.co.jp";
|
||||
docMap.put("urlLink", urlLink);
|
||||
assertEquals(sitePath, viewHelper.getSitePath(docMap));
|
||||
|
||||
urlLink = "smb://123.45.678.91/kyoyu1";
|
||||
sitePath = "123.45.678.91/kyoyu1";
|
||||
docMap.put("urlLink", urlLink);
|
||||
assertEquals(sitePath, viewHelper.getSitePath(docMap));
|
||||
|
||||
urlLink = "file://home/taro/";
|
||||
sitePath = "home/taro/";
|
||||
docMap.put("urlLink", urlLink);
|
||||
assertEquals(sitePath, viewHelper.getSitePath(docMap));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue