Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
dvglc committed Mar 8, 2020
2 parents adcdecc + 66fc591 commit 5109b56
Show file tree
Hide file tree
Showing 79 changed files with 13,038 additions and 13,089 deletions.
3 changes: 3 additions & 0 deletions admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ <h2>Works</h2>
<p>
<span data-template="admin:needsTxtCorpusZip">boing</span>
</p>
<p>
<span data-template="admin:needsStats">boing</span>
</p>
</div>

<div class="row" data-template="app:loadListOfAuthors">
Expand Down
5 changes: 5 additions & 0 deletions collection.xconf
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@

</range>
</index>

<triggers>
<trigger class="org.exist.extensions.exquery.restxq.impl.RestXqTrigger"/>
</triggers>

</collection>
105 changes: 34 additions & 71 deletions controller.xql
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import module namespace xmldb = "http://exist-db.org/xquery/xmldb";
import module namespace console = "http://exist-db.org/xquery/console";
import module namespace util = "http://exist-db.org/xquery/util";
import module namespace functx = "http://www.functx.com";
import module namespace config = "http://salamanca/config" at "modules/config.xqm";
import module namespace net = "http://salamanca/net" at "modules/net.xql";
import module namespace render = "http://salamanca/render" at "modules/render.xql";
import module namespace iiif = "http://salamanca/iiif" at "modules/iiif.xql";
import module namespace rest = "http://exquery.org/ns/restxq";

import module namespace config = "http://www.salamanca.school/xquery/config" at "modules/config.xqm";
import module namespace net = "http://www.salamanca.school/xquery/net" at "modules/net.xqm";
import module namespace iiif = "http://www.salamanca.school/xquery/iiif" at "modules/iiif.xqm";

declare namespace exist = "http://exist.sourceforge.net/NS/exist";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
Expand All @@ -24,13 +25,8 @@ declare option output:indent "yes";
declare option output:omit-xml-declaration "no";
declare option output:encoding "utf-8";

(: *** Todo (especially in api):
*** - API landing page / default return values (depending on formats)? - currently simply redirecting to www.s.s
*** - Add 'meta' endpoint with json-ld, (mets/mods)
*** - Add iiif endpoints (not really working atm)
*** - Add passage identifiers to filenames on downloads (see deliverTXT, e.g.)
(: *** Todo:
*** - Why are no hashes handled? Some are needed but lost. (http://bla.com/bla/bla.html?bla<#THISHERE!>)
*** - Implement collections/lists of resources and their filters (e.g. `/texts?q=lex` resulting in a list of texts) - but which format(s)?
*** - Make JSON-LD the fundamental output format (encapsulate html/xml in a json field) and diverge only when explicitly asked to do so (really?)
*** - Content negotiate X-Forwarded-Host={serverdomain} without subdomain
:)
Expand Down Expand Up @@ -119,67 +115,6 @@ return
return net:redirect($absolutePath, $netVars)


(: *** API (X-Forwarded-Host='api.{serverdomain}') *** :)
else if (request:get-header('X-Forwarded-Host') = "api." || $config:serverdomain) then
let $debug := if ($config:debug = ("trace", "info")) then console:log("[API] request at: " || $net:forwardedForServername || $exist:path || $parameterString || ".") else ()
(: We have the following API areas, accessible by path component:
1. /v1/texts
a. /v1/search (Forwards to opensphinxsearch.)
b. /v1/codesharing (To expose TEI tag usage. See https://api.{$config:serverdomain}/codesharing/codesharing.html or https://mapoflondon.uvic.ca/BLOG10.htm)
c. /v1/xtriples (Extract rdf from xml with xtriples. See https://api.{$config:serverdomain}/v1/xtriples/xtriples.html or http://xtriples.spatialhumanities.de/index.html)
:)
let $netVars := map:put($netVars, 'format', net:format())
let $pathComponents := tokenize(lower-case($exist:path), "/") (: Since $exist:path starts with a slash, $pathComponents[1] is an empty string :)
let $debug := if ($config:debug = ("trace")) then console:log("[API] This translates to API version " || $pathComponents[2] || ", endpoint " || $pathComponents[3] || ".") else ()
return if ($pathComponents[3] = $config:apiEndpoints($pathComponents[2])) then (: Check if we support the requested endpoint/version :)
switch($pathComponents[3])
case "texts" return
let $path := substring-after($exist:path, '/texts/')
let $textsRequest := net:APIparseTextsRequest($path, $netVars)
return
if (not($textsRequest('is_well_formed'))) then net:error(400, $netVars, ())
else
if ($textsRequest('validation') eq 1) then (: fully valid request :)
switch ($textsRequest('format'))
case 'html' return net:APIdeliverTextsHTML($textsRequest, $netVars)
case 'rdf' return net:APIdeliverRDF($textsRequest, $netVars)
case 'tei' return net:APIdeliverTEI($textsRequest,$netVars)
case 'txt' return net:APIdeliverTXT($textsRequest,$netVars)
case 'jpg' return net:APIdeliverJPG($textsRequest, $netVars)
case 'iiif' return net:APIdeliverIIIF($textsRequest, $netVars)
(: TODO: case 'application/ld+json': deliver iiif ? :)
default return net:APIdeliverTextsHTML($textsRequest, $netVars)
else if ($textsRequest('validation') eq 0) then (: one or more resource(s) not yet available :)
if ($textsRequest('format') eq 'html') then net:APIdeliverTextsHTML($textsRequest, $netVars)
else net:error(404, $netVars, ()) (: resource(s) not found :)
else net:error(404, $netVars, ()) (: well-formed, but invalid resource(s) requested :)
case "search" return
let $debug := if ($config:debug = ("trace", "info")) then console:log("Search requested: " || $net:forwardedForServername || $exist:path || $parameterString || ".") else ()
let $absolutePath := concat($config:searchserver, '/', substring-after($exist:path, '/search/'))
return net:redirect($absolutePath, $netVars)
case "codesharing" return
let $debug := if ($config:debug = ("trace", "info")) then console:log("Codesharing requested: " || $net:forwardedForServername || $exist:path || $parameterString || ".") else ()
let $parameters := <exist:add-parameter name="outputType" value="html"/>
return
if ($pathComponents[last()] = 'codesharing_protocol.xhtml') then
net:forward('/services/codesharing/codesharing_protocol.xhtml', $netVars) (: Protocol description html file. :)
else
net:forward('/services/codesharing/codesharing.xql', $netVars, $parameters) (: Main service HTML page. :)
case "xtriples" return
let $debug := if ($config:debug = ("trace", "info")) then console:log("XTriples requested: " || $net:forwardedForServername || $exist:path || $parameterString || " ...") else ()
return
if (tokenize($pathComponents[last()], '\?')[1] = ("extract.xql", "createconfig.xql", "xtriples.html", "changelog.html", "documentation.html", "examples.html")) then
let $debug := if ($config:debug = ("trace", "info")) then console:log("Forward to: /services/lod/" || tokenize($exist:path, "/")[last()] || ".") else ()
return net:forward('/services/lod/' || tokenize($exist:path, "/")[last()], $netVars)
else net:error(404, $netVars, ())
case "stats" return
let $debug := if ($config:debug = ("trace", "info")) then console:log("Stats requested: " || $net:forwardedForServername || $exist:path || $parameterString || ".") else ()
return net:APIdeliverStats($netVars)
default return net:error(404, $netVars, ())
else if ($pathComponents[3]) then net:error(404, $netVars, ()) (: or 400, 405? :)
else net:redirect-with-303($config:webserver)


(: *** Entity resolver (X-Forwarded-Host = 'id.{$config:serverdomain}') *** :)
else if (request:get-header('X-Forwarded-Host') = "id." || $config:serverdomain) then
let $debug1 := if ($config:debug = ("trace", "info")) then console:log("Id requested: " || $net:forwardedForServername || $exist:path || $parameterString || ". (" || net:negotiateContentType($net:servedContentTypes, '') || ')') else ()
Expand Down Expand Up @@ -227,6 +162,33 @@ return


(: *** The rest is html and defaults and miscellaneous stuff... :)

(: Request for the codesharing, xtriples, or search service :)
(: some of these functionalities are also covered by the RestXQ API,
but they remain here for backwards compatibility; also, the API needs
endpoints here to redirect codesharing and xtriples xql transformations to :)
else if (starts-with($exist:path, "/codesharing/")) then
(: let $debug := if ($config:debug = ("trace", "info")) then console:log("Codesharing requested: " || $net:forwardedForServername || $exist:path || $parameterString || ".") else ():)
let $parameters := <exist:add-parameter name="outputType" value="html"/>
return
if (lower-case($exist:resource) eq 'codesharing_protocol.xhtml') then
net:forward('/services/codesharing/codesharing_protocol.xhtml', $netVars) (: Protocol description html file. :)
else
net:forward('/services/codesharing/codesharing.xql', $netVars, $parameters) (: Main service HTML page. :)
else if (starts-with($exist:path, "/xtriples/")) then
(: Extract rdf from xml with xtriples. See https://api.{$config:serverdomain}/v1/xtriples/xtriples.html or http://xtriples.spatialhumanities.de/index.html) :)
(:let $debug := if ($config:debug = ("trace", "info")) then console:log("XTriples requested: " || $net:forwardedForServername || $exist:path || $parameterString || " ...") else ()
return:)
if ($exist:resource = ("extract.xql", "createConfig.xql", "xtriples.html", "changelog.html", "documentation.html", "examples.html")) then
let $debug := if ($config:debug = ("trace", "info")) then console:log("Forward to: /services/lod/" || $exist:resource || ".") else ()
return net:forward('/services/lod/' || $exist:resource, $netVars)
else net:error(404, $netVars, ())
else if (starts-with($exist:path, "/search/")) then
(: let $debug := if ($config:debug = ("trace", "info")) then console:log("Search requested: " || $net:forwardedForServername || $exist:path || $parameterString || ".") else ():)
let $absolutePath := concat($config:searchserver, '/', substring-after($exist:path, '/search/'))
return net:redirect($absolutePath, $netVars)


(: If the request is for an xql file, strip/bypass language selection logic :)
else if (ends-with($exist:resource, ".xql")) then
let $finalPath1 := replace($exist:path, '/de/', '/')
Expand All @@ -253,6 +215,7 @@ return
let $debug := if ($config:debug = ("trace", "info")) then console:log("File download requested: " || $net:forwardedForServername || $exist:path || $parameterString || ", redirecting to " || $finalPath || '?' || string-join($netVars('params'), '&amp;') || ".") else ()
return net:forward($finalPath, $netVars)


(: HTML files should have a path component - we parse that and put view.xql in control :)
else if (ends-with($exist:resource, ".html") and substring($exist:path, 1, 4) = ("/de/", "/en/", "/es/")) then
let $debug := if ($config:debug = "info") then console:log ("[CONTROLLER] HTML requested: " || $net:forwardedForServername || $exist:path || $parameterString || ".") else ()
Expand Down
16 changes: 16 additions & 0 deletions data/i18n/collection_de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
<msg key="researchInterests">Forschungsinteressen</msg>
<msg key="selectedPublications">Publikationen (Auswahl)</msg>
<msg key="toOverview">Zur Übersicht über die Projektbeteiligten</msg>
<msg key="participantsContrib">Mitarbeit bei der Digitalen Quellensammlung</msg>

<!-- general language abbreviations, conjunctions, phrases, etc. -->
<msg key="inLow">in</msg>
Expand Down Expand Up @@ -273,10 +274,12 @@
<msg key="tei-ms-section">Abschnitt</msg>
<msg key="tei-front">Titelei</msg>
<msg key="tei-back"/>
<msg key="tei-argument">Zusammenfassung</msg>
<msg key="tei-p">Absatz</msg>
<msg key="tei-signed">Signatur</msg>
<msg key="tei-head">Titel</msg>
<msg key="tei-label">Titel</msg>
<msg key="tei-table">Tabelle</msg>
<msg key="tei-titlePage">Titelseite</msg>
<msg key="tei-note">Marginalnote</msg>
<msg key="tei-list">Liste</msg>
Expand All @@ -285,4 +288,17 @@
<msg key="tei-text-work_volume">Band</msg>
<msg key="tei-generic">Abschnitt</msg>

<!-- stats -->
<msg key="editFacsLow">digital edierte Druckseiten</msg>
<msg key="editFacsUp">Digital edierte Druckseiten</msg>
<msg key="digiFacsLow">digitalisierte Faksimiles</msg>
<msg key="digiFacsUp">Digitalisierte Faksimiles</msg>
<msg key="charsUp">Zeichen</msg>
<msg key="tokensLow">Tokens</msg>
<msg key="tokensUp">Tokens</msg>
<msg key="wordsLow">Wörter</msg>
<msg key="wordsUp">Wörter</msg>
<msg key="wordFormsLow">Wortformen</msg>
<msg key="wordFormsUp">Wortformen</msg>

</catalogue>
16 changes: 15 additions & 1 deletion data/i18n/collection_en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@
<msg key="researchInterests">Research Interests</msg>
<msg key="selectedPublications">Publications (Selection)</msg>
<msg key="toOverview">Overview of project participants</msg>
<msg key="participantsContrib">Contribution to the Digital Collection of Sources</msg>

<!-- general language abbreviations, conjunctions, phrases, etc. -->
<msg key="inLow">in</msg>
Expand Down Expand Up @@ -436,9 +437,11 @@
<msg key="tei-ms-section">Section</msg>
<msg key="tei-front">Front Matter</msg>
<msg key="tei-back">Back Matter</msg>
<msg key="tei-argument">Summary</msg>
<msg key="tei-p">Paragraph</msg>
<msg key="tei-signed">Signature</msg>
<msg key="tei-head">Heading</msg>
<msg key="tei-table">Table</msg>
<msg key="tei-label">Titel</msg>
<msg key="tei-titlePage">Title Page</msg>
<msg key="tei-note">Note</msg>
Expand All @@ -448,6 +451,17 @@
<msg key="tei-text-work_volume">Volume</msg>
<msg key="tei-generic">Passage</msg>


<!-- stats -->
<msg key="editFacsLow">digitally edited print pages</msg>
<msg key="editFacsUp">Digitally Edited Print Pages</msg>
<msg key="digiFacsLow">digitized facsimiles</msg>
<msg key="digiFacsUp">Digitized Facsimiles</msg>
<msg key="charsUp">Characters</msg>
<msg key="tokensLow">tokens</msg>
<msg key="tokensUp">Tokens</msg>
<msg key="wordsLow">words</msg>
<msg key="wordsUp">Words</msg>
<msg key="wordFormsLow">word forms</msg>
<msg key="wordFormsUp">Word Forms</msg>

</catalogue>
16 changes: 16 additions & 0 deletions data/i18n/collection_es.xml
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@
<msg key="researchInterests">Intereses investigativos </msg>
<msg key="selectedPublications">Publicaciones (selección)</msg>
<msg key="toOverview">Resumen del equipo del proyecto y de sus consultantes</msg>
<msg key="participantsContrib">Contribución a la Colección Digital de Fuentes</msg>

<!-- general language abbreviations, conjunctions, phrases, etc. -->
<msg key="inLow">en</msg>
Expand Down Expand Up @@ -443,10 +444,12 @@
<msg key="tei-ms-section">Section</msg>
<msg key="tei-front">Parte preliminar</msg>
<msg key="tei-back">Apéndice</msg>
<msg key="tei-argument">Resumen</msg>
<msg key="tei-p">Párrafo</msg>
<msg key="tei-signed">Firma</msg>
<msg key="tei-head">Título</msg>
<msg key="tei-label">Etiqueta</msg>
<msg key="tei-table">Tabla</msg>
<msg key="tei-titlePage">Portada</msg>
<msg key="tei-note">Nota</msg>
<msg key="tei-list">Lista</msg>
Expand All @@ -455,4 +458,17 @@
<msg key="tei-text-work_volume">Volumen</msg>
<msg key="tei-generic">Pasaje</msg>

<!-- stats -->
<msg key="editFacsLow">páginas imprimidas editadas</msg>
<msg key="editFacsUp">Páginas imprimidas editadas</msg>
<msg key="digiFacsLow">facsímiles digitalizadas</msg>
<msg key="digiFacsUp">Facsímiles digitalizadas</msg>
<msg key="charsUp">Caracteres</msg> <!-- TODO -->
<msg key="tokensLow">tokens</msg>
<msg key="tokensUp">Tokens</msg>
<msg key="wordsLow">palabras</msg>
<msg key="wordsUp">Palabras</msg>
<msg key="wordFormsLow">formas de palabra</msg>
<msg key="wordFormsUp">Formas de palabra</msg>

</catalogue>

0 comments on commit 5109b56

Please sign in to comment.