Commit b65d6e3e authored by Mathias Goebel's avatar Mathias Goebel 🎠 Committed by mrodzis

closes #75 and #78

parent bd293d2e
......@@ -239,8 +239,8 @@ declare function local:facet($model as map(*), $hits as node()*, $key as xs:stri
</li>
else
<li>
<a class="facet-minus" href="{ $search-html }?q={ $query }&amp;facet={ $key }:!{ xmldb:encode($facet) },{ $facetReq }&amp;order={ $order }&amp;order-by={ $order-by }"><i class="fas fa-plus"></i></a>
<a href="{ $search-html }?q={ $query }&amp;facet={ $key }:{ xmldb:encode($facet) },{ $facetReq }&amp;order={ $order }&amp;order-by={ $order-by }">{ $facet } </a> ({ $freq })
<a class="facet-minus" href="{ $search-html }?q={ $query }&amp;facet={ $key }:!{ xmldb:encode($facet) },{ $facetReq }&amp;order={ $order }&amp;order-by={ $order-by }"><i class="fas fa-minus" title="exclude"></i></a>
<a title="exclude all others" href="{ $search-html }?q={ $query }&amp;facet={ $key }:{ xmldb:encode($facet) },{ $facetReq }&amp;order={ $order }&amp;order-by={ $order-by }">{ $facet } </a> ({ $freq })
</li>
};
......@@ -264,8 +264,10 @@ declare function local:deselected-for-key($model, $key as xs:string) {
let $facetRemoveQuery := replace($facetReq, $key || ":" || $parts[2] || "," , "")
return
<li class="facet-deselected">
<a class="facet-plus" href="{$search-html}?q={$query}&amp;facet={$facetRemoveQuery}&amp;order={$order}&amp;order-by={$order-by}">+</a>
{xmldb:decode(substring-after($parts[2], "!"))}
<a class="facet-plus" href="{$search-html}?q={$query}&amp;facet={$facetRemoveQuery}&amp;order={$order}&amp;order-by={$order-by}">
<i class="fa fa-plus"></i>
</a>
{" " || xmldb:decode(substring-after($parts[2], "!"))}
</li>
else
()
......@@ -302,15 +304,12 @@ declare function local:construct-facet-query($model as map(*)) as xs:string {
for $fquery in tokenize($facet, ",")
let $parts := tokenize($fquery, ":")
let $select :=
for $xpath in config:get("facets", "faceted-search")//cf:facet[@key = $parts[1]]//cf:xpath
for $xpath in config:get("facets", "faceted-search")[@key = $parts[1]]//cf:xpath
let $val := xmldb:decode($parts[2])
let $op := if(starts-with($val, "!"))
then " ne "
else " eq "
let $op := if(starts-with($val, "!"))
then " ne "
else " eq "
let $val := replace($val, "!", "")
return if(starts-with($xpath, ".") or starts-with($xpath, "/"))
(: to escpae quotes, you have to double them :)
then $xpath || $op || """" || $val || """"
......
<div data-template="templates:surround" data-template-with="templates/page_index.html" data-template-at="content-container">
<div class="row faceted-search" data-template="fsearch:results">
<?xml version="1.0" encoding="UTF-8"?>
<div data-template="templates:surround" data-template-with="templates/page_index.html"
data-template-at="content-container">
<div class="row faceted-search" data-template="fsearch:results">
<ul class="col-md-3 facet-area">
<div data-template="fsearch:facet"/>
</ul>
......@@ -14,22 +16,23 @@
<div class="search-input">
<form class="form-inline">
<div class="form-group mx-sm-3 mb-2" action="search.html">
<label for="inputTerm" class="sr-only">Neue Suche</label>
<input type="text" class="form-control" id="inputTerm" placeholder="Neue Suche" data-template="lang:translate" data-template-content="Search" name="q" />
</div>
<button type="submit" class="btn btn-primary mb-2">
<div class="form-group mx-sm-3 mb-2" action="search.html">
<label for="inputTerm" class="sr-only">Neue Suche</label>
<input type="text" class="form-control" id="inputTerm"
placeholder="Neue Suche" data-template="lang:translate"
data-template-content="Search" name="q"/>
</div>
<button type="submit" class="btn btn-primary mb-2">
<i class="fas fa-search fa-lg" style="color:white"/>
</button>
</form>
</div>
</div>
<div>
<ul class="paginator pull-right"/>
Zeige Treffer <span id="hitstart" data-template="fsearch:hitstart"/> -
<span id="hitend" data-template="fsearch:hitend"/> von
<span id="hitcount" data-template="fsearch:hitcount"/> Treffern
</div>
<ul class="paginator pull-right"/> Zeige Treffer <span id="hitstart"
data-template="fsearch:hitstart"/> - <span id="hitend"
data-template="fsearch:hitend"/> von <span id="hitcount"
data-template="fsearch:hitcount"/> Treffern </div>
<form class="form-horizontal" role="form">
<div class="form-group">
<label class="col-sm-3 control-label">Sortierung nach</label>
......@@ -48,12 +51,13 @@
</div>
</div>
</form>
<div data-template="templates:each" data-template-from="hits" data-template-to="hit" class="row">
<div data-template="templates:each" data-template-from="hits" data-template-to="hit"
class="row">
<div class="col-md-10">
<div data-template="fsearch:result-xslt"/>
<p data-template="fsearch:result-kwic">KWIC matches</p>
<a href="#" data-template="fsearch:result-source">Source</a>
<!-- <div data-template="fsearch:result-tble-links"/>-->
<!-- <div data-template="fsearch:result-tble-links"/>-->
<hr/>
</div>
<div class="col-md-2">
......@@ -61,61 +65,24 @@
</div>
</div>
<div>
<ul class="paginator pull-right"/>
Zeige Treffer <span id="hitstart" data-template="fsearch:hitstart"/> -
<span id="hitend" data-template="fsearch:hitend"/> von
<span id="hitcount" data-template="fsearch:hitcount"/> Treffern
</div>
<ul class="paginator pull-right"/> Zeige Treffer <span id="hitstart"
data-template="fsearch:hitstart"/> - <span id="hitend"
data-template="fsearch:hitend"/> von <span id="hitcount"
data-template="fsearch:hitcount"/> Treffern </div>
</div>
</div>
</div>
<script>
$(function() {
// http://www.samaxes.com/2011/09/change-url-parameters-with-jquery/
/*
* queryParameters -&gt; handles the query string parameters
* queryString -&gt; the query string without the fist '?' character
* re -&gt; the regular expression
* m -&gt; holds the string matching the regular expression
*/
var queryParameters = {}, queryString = location.search.substring(1),
re = /([^&amp;=]+)=([^&amp;]*)/g, m;
// Creates a map with the query string parameters
while (m = re.exec(queryString)) {
// queryParameters[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
queryParameters[m[1]] = m[2];
}
$('.paginator').bootstrapPaginator({
bootstrapMajorVersion: 3,
currentPage: $('#page').text(),
totalPages: $('#pages').text(),
pageUrl: function(type, page, current){
queryParameters['page'] = page;
var querystring = "";
$.each(queryParameters, function(key, val) {
querystring += key + "=" + val + "&amp;";
})
querystring = querystring.substring(0, querystring.length-1)
return window.location.pathname + '?' + querystring;
}
})
//$('.paginator').bootstrapPaginator("show", 10);
$('.facet-minus').each(function() {
$(this).html($('&lt;span class="glyphicon glyphicon-minus-sign" /&gt;'));
});
$('.facet-plus').each(function() {
$(this).html($('&lt;span class="glyphicon glyphicon-plus-sign" /&gt;'));
});
});
</script>
<script> $(function() { // http://www.samaxes.com/2011/09/change-url-parameters-with-jquery/ /*
* queryParameters -&gt; handles the query string parameters * queryString -&gt; the query
string without the fist '?' character * re -&gt; the regular expression * m -&gt; holds the
string matching the regular expression */ var queryParameters = {}, queryString =
location.search.substring(1), re = /([^&amp;=]+)=([^&amp;]*)/g, m; // Creates a map with the
query string parameters while (m = re.exec(queryString)) { //
queryParameters[decodeURIComponent(m[1])] = decodeURIComponent(m[2]); queryParameters[m[1]]
= m[2]; } $('.paginator').bootstrapPaginator({ bootstrapMajorVersion: 3, currentPage:
$('#page').text(), totalPages: $('#pages').text(), pageUrl: function(type, page, current){
queryParameters['page'] = page; var querystring = ""; $.each(queryParameters, function(key,
val) { querystring += key + "=" + val + "&amp;"; }) querystring = querystring.substring(0,
querystring.length-1) return window.location.pathname + '?' + querystring; } }) });
</script>
</div>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment