Skip to content

Commit

Permalink
Final fixes to refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
wsalesky committed Jan 31, 2019
1 parent cfceafe commit d7c3ba0
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 63 deletions.
3 changes: 2 additions & 1 deletion documentation/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<div xmlns="http://www.w3.org/1999/xhtml" xmlns:xi="http://www.w3.org/2001/XInclude" data-template="templates:surround" data-template-with="templates/page.html" data-template-at="content">
<h1 class="banner indent top-padding bhse">Digital Syriac Corpus Documentation</h1>
<xi:include href="../banner.html"/>
<h1 class="banner indent bhse">Digital Syriac Corpus Documentation</h1>
<div class="container documentation">
<div class="row">
<div class="col-md-4 col-md-offset-2">
Expand Down
3 changes: 2 additions & 1 deletion documentation/wiki.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<div xmlns="http://www.w3.org/1999/xhtml" xmlns:xi="http://www.w3.org/2001/XInclude" data-template="templates:surround" data-template-with="templates/page.html" data-template-at="content">
<h1 class="banner indent top-padding bhse">Digital Syriac Corpus Documentation</h1>
<xi:include href="../banner.html"/>
<h1 class="banner indent bhse">Digital Syriac Corpus Documentation</h1>
<div class="container">
<div class="container">
<div data-template="app:get-wiki">
Expand Down
8 changes: 1 addition & 7 deletions expath-pkg.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://expath.org/ns/pkg" name="http://syriac-corpus.org/syriac-corpus" abbrev="syriac-corpus" version="3.00" spec="1.0">
<package xmlns="http://expath.org/ns/pkg" name="http://syriac-corpus.org/syriac-corpus" abbrev="syriac-corpus" version="3.15" spec="1.0">
<title>Digital Syriac Corpus</title>
<!-- TEI data -->
<dependency package="http://syriac-corpus.org/syriaca-corpus-data"/>
<!-- eXist shared resources -->
<dependency package="http://exist-db.org/apps/shared"/>
<!-- JSON Parser and Serializer for XQuery -->
<dependency package="http://xqilla.sourceforge.net/pkg/xqjson"/>
<!-- Functx -->
<dependency package="http://www.functx.com"/>
</package>
3 changes: 2 additions & 1 deletion modules/content-negotiation/tei2html.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,10 @@ declare function tei2html:summary-view-generic($nodes as node()*, $id as xs:stri
<span class="results-list-desc uri"><span class="srp-label">URI: </span><a href="{replace($id,$config:base-uri,$config:nav-base)}">{$id}</a></span>
else()
}
</div>
</div>
};


declare function tei2html:summary-view-bibl($nodes as node()*, $id as xs:string?) as item()* {
let $title := if($nodes/descendant-or-self::tei:title[@syriaca-tags='#syriaca-headword'][@xml:lang='en']) then
$nodes/descendant-or-self::tei:title[@syriaca-tags='#syriaca-headword'][@xml:lang='en'][1]/text()
Expand Down
4 changes: 2 additions & 2 deletions modules/lib/facet.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ return
if($facet:fq) then concat('fq=',$facet:fq,$facet-query)
else concat('fq=',normalize-space($facet-query))
let $active := if(contains($facet:fq,concat(';fq-',string($f/@name),':',string($key/@value)))) then 'active' else ()
return <a href="?{$new-fq}{facet:url-params()}" class="facet-label btn btn-default {$active}">{string($key/@label)} <span class="count"> ({string($key/@count)})</span></a>
return <a href="?{$new-fq}{facet:url-params()}" class="facet-label btn btn-default {$active}">{string($key/@label)} <span class="count" dir="ltr"> ({string($key/@count)})</span></a>
}
</div>
<div class="facet-list collapse" id="{concat('show',replace(string($f/@name),' ',''))}">{
Expand All @@ -285,7 +285,7 @@ return
let $new-fq :=
if($facet:fq) then concat('fq=',$facet:fq,$facet-query)
else concat('fq=',$facet-query)
return <a href="?{$new-fq}{facet:url-params()}" class="facet-label btn btn-default">{string($key/@label)} <span class="count"> ({string($key/@count)})</span></a>
return <a href="?{$new-fq}{facet:url-params()}" class="facet-label btn btn-default">{string($key/@label)} <span class="count" dir="ltr"> ({string($key/@count)})</span></a>
}
</div>
{if($count gt ($f/@show - 1)) then
Expand Down
94 changes: 66 additions & 28 deletions modules/search/search.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ declare namespace tei="http://www.tei-c.org/ns/1.0";
(: Variables:)
declare variable $search:start {request:get-parameter('start', 1) cast as xs:integer};
declare variable $search:perpage {request:get-parameter('perpage', 20) cast as xs:integer};
declare variable $search:q {request:get-parameter('q', '') cast as xs:string};
declare variable $search:persName {request:get-parameter('persName', '') cast as xs:string};
declare variable $search:placeName {request:get-parameter('placeName', '') cast as xs:string};
declare variable $search:title {request:get-parameter('title', '') cast as xs:string};
declare variable $search:bibl {request:get-parameter('bibl', '') cast as xs:string};
declare variable $search:idno {request:get-parameter('uri', '') cast as xs:string};
declare variable $search:sort-element {request:get-parameter('sort-element', '') cast as xs:string};
declare variable $search:collection {request:get-parameter('collection', '') cast as xs:string};

(:~
: Builds search result, saves to model("hits") for use in HTML display
Expand All @@ -32,7 +40,7 @@ declare variable $search:perpage {request:get-parameter('perpage', 20) cast as x
: Search results stored in map for use by other HTML display functions
data:search($collection)
:)
declare %templates:wrap function search:search-data($node as node(), $model as map(*), $collection as xs:string?){
declare %templates:wrap function search:search-data($node as node(), $model as map(*), $collection as xs:string?, $view as xs:string?){
let $coll := if($search:collection != '') then $search:collection else $collection
let $keyword-query := data:keyword-search()
let $eval-string := concat(search:query-string($collection),facet:facet-filter(global:facet-definition-file($collection)))
Expand Down Expand Up @@ -62,7 +70,7 @@ declare %templates:wrap function search:search-data($node as node(), $model as m
: Builds general search string from main syriaca.org page and search api.
:)
declare function search:query-string($collection as xs:string?) as xs:string?{
concat("collection('",$global:data-root,"')//tei:TEI",
concat("collection('",$config:data-root,"')//tei:TEI",
data:keyword-search(),
data:element-search('author',request:get-parameter('author', '')),
data:element-search('title',request:get-parameter('title', '')),
Expand Down Expand Up @@ -114,7 +122,7 @@ declare function search:bibl(){
normalize-space($search:bibl)
else
string-join(distinct-values(
for $r in collection($global:data-root || '/bibl')//tei:body[ft:query(.,$terms, data:search-options())]/ancestor::tei:TEI/descendant::tei:publicationStmt/tei:idno[starts-with(.,'http://syriaca.org')][1]
for $r in collection($config:data-root || '/bibl')//tei:body[ft:query(.,$terms, data:search-options())]/ancestor::tei:TEI/descendant::tei:publicationStmt/tei:idno[starts-with(.,'http://syriaca.org')][1]
return concat(substring-before($r,'/tei'),'(\s|$)')),'|')
return concat("[descendant::tei:bibl/tei:ptr[@target[matches(.,'",$ids,"')]]]")
else ()
Expand All @@ -129,7 +137,7 @@ declare function search:idno(){
};

declare function search:catalog-limit(){
for $r in collection($global:data-root)//tei:titleStmt/tei:title[@level="s"]
for $r in collection($config:data-root)//tei:titleStmt/tei:title[@level="s"]
group by $group := $r/@ref
order by global:build-sort-string($r[1]/text(),'')
return <option value="{concat(';fq-Catalog:',$group)}">{$r[1]/text()}</option>
Expand Down Expand Up @@ -161,11 +169,11 @@ function search:show-hits($node as node()*, $model as map(*), $collection as xs:
</div>
<div class="col-md-9" xml:lang="en">
{(tei2html:summary-view($hit, (), $id[1])) }
{(:
{
if($expanded//exist:match) then
tei2html:output-kwic($expanded, $id)
else ()
:)()}
}
</div>
</div>
</div>
Expand Down Expand Up @@ -252,6 +260,7 @@ declare function search:build-form($search-config) {
</form>
};


(:~
: Simple default search form to us if not search-config.xml file is present. Can be customized.
:)
Expand Down Expand Up @@ -293,30 +302,59 @@ declare function search:default-search-form() {
</div>
</div>
</div>
<!-- Title-->
<div class="form-group">
<label for="title" class="col-sm-2 col-md-3 control-label">Title: </label>
<div class="col-sm-10 col-md-9 ">
<div class="input-group">
<input type="text" id="title" name="title" class="form-control keyboard"/>
<div class="input-group-btn">
{global:keyboard-select-menu('title')}
</div>
</div>
</div>
<!-- Author-->
<div class="form-group">
<label for="author" class="col-sm-2 col-md-3 control-label">Author: </label>
<div class="col-sm-10 col-md-9 ">
<div class="input-group">
<input type="text" id="author" name="author" class="form-control keyboard"/>
<div class="input-group-btn">
{global:keyboard-select-menu('author')}
</div>
</div>
</div>
<!-- Place Name-->
<div class="form-group">
<label for="placeName" class="col-sm-2 col-md-3 control-label">Place Name: </label>
<div class="col-sm-10 col-md-9 ">
<div class="input-group">
<input type="text" id="placeName" name="placeName" class="form-control keyboard"/>
<div class="input-group-btn">
{global:keyboard-select-menu('placeName')}
</div>
</div>
</div>
</div>
<div class="form-group">
<label for="title" class="col-sm-2 col-md-3 control-label">Title: </label>
<div class="col-sm-10 col-md-9">
<div class="input-group">
<input type="text" id="title" name="title" class="form-control keyboard"/>
<div class="input-group-btn">
{global:keyboard-select-menu('title')}
</div>
<div class="input-group-btn" style="width:50%;">
<select name="fq" class="form-control">
<option value=""> -- Limit by Catalog -- </option>
{search:catalog-limit()}
</select>
</div>
</div>
</div>
</div>
<div class="form-group">
<label for="section" class="col-sm-2 col-md-3 control-label">Section number: </label>
<div class="col-sm-10 col-md-9 ">
<input type="text" id="section" name="section" class="form-control"/>
</div>
</div>
<div class="form-group">
<label for="corpus-uri" class="col-sm-2 col-md-3 control-label">Corpus URI: </label>
<div class="col-sm-10 col-md-9 ">
<input type="text" id="corpus-uri" name="corpus-uri" class="form-control"/>
</div>
</div>
<div class="form-group">
<label for="syriaca-uri" class="col-sm-2 col-md-3 control-label">Syriaca URI: </label>
<div class="col-sm-10 col-md-9 ">
<input type="text" id="syriaca-uri" name="syriaca-uri" class="form-control"/>
</div>
</div>
<div class="form-group">
<label for="text-id" class="col-sm-2 col-md-3 control-label">Text ID Number: </label>
<div class="col-sm-10 col-md-9 ">
<input type="text" id="text-id" name="text-id" class="form-control"/>
</div>
</div>
<!-- end col -->
</div>
<!-- end row -->
Expand Down
28 changes: 15 additions & 13 deletions modules/sparql-requests.xql
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
xquery version "3.0";
xquery version "3.1";

import module namespace http="http://expath.org/ns/http-client";

(:
: Take posted SPARQL query and send it to Syriaca.org sparql endpoint
(:~
: Take posted SPARQL query and send it to the Syriaca.org SPARQL endpoint
: Returns JSON
: This will hopefully get around the javascript issues with http/https and same origin.
:)
let $query := if(request:get-parameter('query', '')) then request:get-parameter('query', '')
else if(not(empty(request:get-data()))) then request:get-data()
else ()
let $subject-sparql-results :=
let $query :=
if(request:get-parameter('query', '')) then request:get-parameter('query', '')
else if(not(empty(request:get-data()))) then request:get-data()
else ()
let $results :=
try{
util:base64-decode(http:send-request(<http:request href="http://wwwb.library.vanderbilt.edu/exist/apps/srophe/api/sparql?format=json&amp;query={fn:encode-for-uri($query)}" method="get"/>)[2])
} catch * {<error>Caught error {$err:code}: {$err:description}</error>}

return (response:set-header("Content-Type", "application/json"),$subject-sparql-results)
if($query != '') then
util:base64-decode(http:send-request(<http:request href="http://wwwb.library.vanderbilt.edu/exist/apps/srophe/api/sparql?format=json&amp;query={fn:encode-for-uri($query)}" method="get"/>)[2])
else <message>No query data</message>
} catch * {
<error>Caught error {$err:code}: {$err:description}</error>
}
return (response:set-header("Content-Type", "application/json"), $results)

2 changes: 1 addition & 1 deletion repo-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<!-- Web Site URL -->
<url>http://syriac-corpus.org/</url>
<!-- Root of app for building dynamic links. Default is eXist app root -->
<nav-base>/exist/apps/syriac-corpus</nav-base>
<nav-base></nav-base>
<!-- eXist app root for app deployment-->
<app-root>syriac-corpus</app-root>
<!-- eXist data app root for gazetteer data -->
Expand Down
6 changes: 3 additions & 3 deletions resources/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ h3.syr{
}

h4 {font-size: 1em; margin-top:1em;}
h5 {margin: 1em 0 0 0;}
h5 {margin: 1em 0 0 0; font-weight:600;}

.h5-inline {font-size: 1em; font-weight:500;}
.h5-inline {font-size: 1em; font-weight:600;}

.hi {background-color:yellow;}

Expand Down Expand Up @@ -861,7 +861,7 @@ pre {
}
.tei-footnote {display:none; font-size:x-small;}
.tei-footnote.display {display:inline;}
.text-number.display {display:inline;}
/*.text-number.display {display:inline;}*/

/* Table of Contents */
.toc {display:block; margin-left:.75em;}
Expand Down
12 changes: 6 additions & 6 deletions search.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
<div class="container">
<!-- To do -->
<div class="col-md-12">
<div data-template="search:show-form"/>
<div data-template="search:get-results" class="search-results">
<div data-template="search:search-form"/>
<div data-template="search:search-data" class="search-results">
<!-- Calls paging and search parameters string -->
<div data-template="search:pageination" data-template-sort-options="relevance,title"/>
<div data-template="app:pageination" data-template-sort-options="relevance,title"/>
<!-- Prints search results -->
<div class="row">
<div class="col-md-4">
<div data-template="search:display-facets"/>
<div data-template="app:display-facets"/>
</div>
<div class="col-md-8">
<div data-template="search:build-page"/>
<div data-template="search:show-hits"/>
</div>
</div>
<div class="page-bottom">
<div data-template="search:pageination" data-template-sort-options="relevance,title"/>
<div data-template="app:pageination" data-template-sort-options="relevance,title"/>
</div>
</div>
</div>
Expand Down

0 comments on commit d7c3ba0

Please sign in to comment.