Fixed search result Snapshots link.

Previously rendered as a broken URL containing the absolute file path of
a snapshot on the search server.

Now rendered as a valid URL linking to the /api/snapshot API to provide
available snapshot content. Snapshot format is selected among the
available ones in the following order of preference  : JPG/PNG, PDF, and
XML.
pull/135/head
luccioman 7 years ago
parent 34ca73d61b
commit 4da15db998

@ -258,7 +258,7 @@ var solr= $.getJSON("solr/collection1/select?q=*:*&defType=edismax&start=0&rows=
<td><span role="separator" aria-orientation="vertical">&nbsp;|&nbsp;</span><a id="cacheLink" href="CacheResource_p.html" target="LayouTest">Cache</a></td>
<td><span role="separator" aria-orientation="vertical">&nbsp;|&nbsp;</span><a id="proxyLink" href="proxy.html" target="LayouTest">View via Proxy</a></td>
<td><span role="separator" aria-orientation="vertical">&nbsp;|&nbsp;</span><a id="browseIndexLink" href="HostBrowser.html" target="LayouTest"><img src="env/grafics/minitree.png" width="15" height="8" title="Browse index" alt="Browse index"/></a></td>
<td><span role="separator" aria-orientation="vertical">&nbsp;|&nbsp;</span><a id="snapshotsLink" href="yacysearch.html" target="LayouTest">Snapshots</a></td>
<td><span role="separator" aria-orientation="vertical">&nbsp;|&nbsp;</span><a id="snapshotsLink" href="yacysearch.html" target="LayouTest">JPG Snapshot</a></td>
#(search.result.show.ranking)#::<td><span role="separator" aria-orientation="vertical">&nbsp;|&nbsp;</span><span title="Raw ranking score value">Ranking: 1.12195955E9</span>#(/search.result.show.ranking)#
</tr>
<tr>

@ -49,7 +49,7 @@
#(showProxy)#::<span role="separator" aria-orientation="vertical">&nbsp;|&nbsp;</span><a href="proxy.html?url=#[link]#" target="_blank">View via proxy</a>#(/showProxy)#
#(showHostBrowser)#::<span role="separator" aria-orientation="vertical">&nbsp;|&nbsp;</span><a href="HostBrowser.html?path=#[link]#"><img src="env/grafics/minitree.png" width="15" height="8" title="Browse index" alt="Browse index"/></a>#(/showHostBrowser)#
#(showVocabulary)#::<br/>#{vocabulary}##[name]#:#[terms]# #{/vocabulary}##(/showVocabulary)#
#(showSnapshots)#::<a href="#[link]#">Snapshots</a>#(/showSnapshots)#
#(showSnapshots)#::<span role="separator" aria-orientation="vertical">&nbsp;|&nbsp;</span><a href="#[link]#" target="_blank">#[extension]# Snapshot</a>#(/showSnapshots)#
#(showRanking)#::<span role="separator" aria-orientation="vertical">&nbsp;|&nbsp;</span><span title="Raw ranking score value">Ranking: #[ranking]#</span>#(/showRanking)#
</p>
</div>

@ -33,6 +33,7 @@ import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.Locale;
import java.util.StringTokenizer;
import net.yacy.cora.date.GenericFormatter;
@ -338,7 +339,27 @@ public class yacysearchitem {
prop.put("content_showVocabulary", 0);
}
if (snapshotPaths != null && snapshotPaths.size() > 0) {
prop.put("content_showSnapshots_link", snapshotPaths.iterator().next().getAbsolutePath());
/* Only add a link to the eventual snapshot file in the format it is stored (no resource fetching and conversion here) */
String selectedExt = null, ext;
for(final File snapshot : snapshotPaths) {
ext = MultiProtocolURL.getFileExtension(snapshot.getName());
if("jpg".equals(ext) || "png".equals(ext)) {
/* Prefer snapshots in jpeg or png format */
selectedExt = ext;
break;
} else if("pdf".equals(ext)) {
selectedExt = ext;
} else if("xml".equals(ext) && selectedExt == null) {
/* Use the XML metadata snapshot in last resort */
selectedExt = ext;
}
}
if(selectedExt != null) {
prop.putHTML("content_showSnapshots_extension", selectedExt.toUpperCase(Locale.ROOT));
prop.putHTML("content_showSnapshots_link", "api/snapshot." + selectedExt + "?url=" + resultURL);
} else {
prop.put("content_showSnapshots", 0);
}
}
prop.put("content_showRanking_ranking", Float.toString(result.score()));
prop.put("content_ranking", Float.toString(result.score()));

@ -590,7 +590,7 @@ Maximum range (in days)==Période maximale (en jours)
Maximum days number in the histogram. Beware that a large value may trigger high CPU loads both on the server and on the browser with large result sets.==Nombre maximum de jours de l'histogramme. Veuillez noter qu'une valeur élevée peut déclencher des charges CPU importantes tant sur le serveur que sur le navigateur lorsqu'il y a un grand nombre de résultats.
keyword subject keyword2 keyword3==mot-clé sujet mot-clé2 mot-clé3
View via Proxy==Ouvrir via le proxy
>Snapshots<==>Captures<
>JPG Snapshot<==>Capture JPG<
"Raw ranking score value"=="Score de classement brut"
Ranking: 1.12195955E9==Score: 1.12195955E9
"Delete navigator"=="Supprimer le groupe"

@ -2172,7 +2172,7 @@
<source>View via Proxy</source>
</trans-unit>
<trans-unit id="43d1a9cb" xml:space="preserve" approved="no" translate="yes">
<source>&gt;Snapshots&lt;</source>
<source>&gt;JPG Snapshot&lt;</source>
</trans-unit>
<trans-unit id="f5192903" xml:space="preserve" approved="no" translate="yes">
<source>"Raw ranking score value"</source>

Loading…
Cancel
Save