add filter to citation page and a on/off button

to display only sentences with citations,
while maintaining the sentence number.
Make the filtered list the default in search result citation link
pull/1/head
reger 11 years ago
parent afd5bd5f5f
commit f5967dfedf

@ -13,9 +13,18 @@
<li><a href="#[url]#">#[url]#</a></li>
#{/links}#</ul>
#(/similar)#
<form action="#" name="" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
<form action="citation.html?url=#[url]#" name="" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
<fieldset>
<legend><label>List of Sentences in #[url]#</label></legend>
<table width="100%">
<tr>
<td>
<legend><label>List of #(filter)#::Cited#(/filter)# Sentences in #[url]#</label></legend>
</td>
<td align="right">
<button type="submit" name="filter" class="btn btn-default btn-sm" value="#(filter)#true::false#(/filter)#">#(filter)#filter cited sentences::filter off#(/filter)#</button>
</td>
</tr>
</table>
<dl>#{sentences}#
<dt>#[dt]#</dt><dd>#[dd]#</dd>
#{/sentences}#</dl>

@ -61,6 +61,7 @@ public class citation {
String url = "";
String hash = "";
int ch = 10;
boolean filter = false; // show cited sentences only
if (post != null) {
if (post.containsKey("url")) {
url = post.get("url");
@ -78,8 +79,9 @@ public class citation {
if (post.containsKey("ch")) {
ch = post.getInt("ch", ch);
}
filter = post.getBoolean("filter");
}
prop.put("filter", filter);
if (url.length() > 0) {
try {
uri = new DigestURL(url, null);
@ -152,20 +154,37 @@ public class citation {
// iterate the sentences
int i = 0;
int sentenceNr = 0;
for (Map.Entry<String, Set<DigestURL>> se: sentenceOcc.entrySet()) {
prop.put("sentences_" + i + "_dt", i);
StringBuilder dd = new StringBuilder(se.getKey());
Set<DigestURL> app = se.getValue();
if (app != null && app.size() > 0) {
dd.append("<br/>appears in:");
for (DigestURL u: app) {
if (u != null) {
dd.append(" <a href=\"").append(u.toNormalform(false)).append("\">").append(u.getHost()).append("</a>");
if (filter) { // prepare list, only include sentence with citation
if (app != null && app.size() > 0) {
StringBuilder dd = new StringBuilder(se.getKey());
prop.put("sentences_" + i + "_dt", sentenceNr);
dd.append("<br/>appears in:");
for (DigestURL u : app) {
if (u != null) {
dd.append(" <a href=\"").append(u.toNormalform(false)).append("\">").append(u.getHost()).append("</a>");
}
}
prop.put("sentences_" + i + "_dd", dd.toString());
i++;
}
} else { // prepare list, include all sentences
StringBuilder dd = new StringBuilder(se.getKey());
prop.put("sentences_" + i + "_dt", sentenceNr);
if (app != null && app.size() > 0) {
dd.append("<br/>appears in:");
for (DigestURL u : app) {
if (u != null) {
dd.append(" <a href=\"").append(u.toNormalform(false)).append("\">").append(u.getHost()).append("</a>");
}
}
}
prop.put("sentences_" + i + "_dd", dd.toString());
i++;
}
prop.put("sentences_" + i + "_dd", dd.toString());
i++;
sentenceNr++;
}
prop.put("sentences", i);

@ -28,7 +28,7 @@
#(showSize)#::&nbsp;|&nbsp;#[sizename]##(/showSize)#
#(showMetadata)#::&nbsp;|&nbsp;<a href="solr/select?q=id:%22#[urlhash]#%22&defType=edismax&start=0&rows=1&core=collection1&wt=html" target="_blank" onclick="return hs.htmlExpand(this, { objectType: 'ajax'} )">Metadata</a>#(/showMetadata)#
#(showParser)#::&nbsp;|&nbsp;<a href="ViewFile.html?urlHash=#[urlhash]#&amp;words=#[words]#" target="_blank">Parser</a>#(/showParser)#
#(showCitation)#::&nbsp;|&nbsp;<a href="api/citation.html?hash=#[urlhash]#" target="_blank">Citations</a>#(/showCitation)#
#(showCitation)#::&nbsp;|&nbsp;<a href="api/citation.html?hash=#[urlhash]#&filter=true" target="_blank">Citations</a>#(/showCitation)#
#(showPictures)#::&nbsp;|&nbsp;<a href="yacysearch.html?contentdom=image&amp;url=#[link]#&amp;query=#[former]# inurl:#[link]#" target="_blank">Pictures</a>#(/showPictures)#
#(showCache)#::&nbsp;|&nbsp;<a href="CacheResource_p.html?url=#[link]#" target="_blank">Cache</a>#(/showCache)#
#(showProxy)#::&nbsp;|&nbsp;<a href="proxy.html?url=#[link]#" target="_blank">Augmented Browsing</a>#(/showProxy)#

Loading…
Cancel
Save