Dear Gitlab users, due to maintenance reasons, Gitlab will not be available on Thursday 30.09.2021 from 5:00 pm to approximately 5:30 pm.

Commit 6f95fda0 authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

Merge branch 'release/4.0.0'

parents 6ab1554e c2faacb7
...@@ -6,6 +6,7 @@ local.build.properties ...@@ -6,6 +6,7 @@ local.build.properties
########################## ##########################
build/ build/
expath-pkg.xml expath-pkg.xml
test/
.DS_STORE .DS_STORE
======= =======
image: docker.gitlab.gwdg.de/fontane-notizbuecher/build:latest image: docker.gitlab.gwdg.de/fontane-notizbuecher/build:latest
variables:
EXIST_DB: "eXist-db-4.3.1"
stages: stages:
- build - build
- test - test
...@@ -12,6 +9,8 @@ build-develop: ...@@ -12,6 +9,8 @@ build-develop:
except: except:
- master - master
- tags - tags
only:
- develop
stage: build stage: build
script: script:
- ant - ant
...@@ -35,25 +34,27 @@ installation: ...@@ -35,25 +34,27 @@ installation:
- tags - tags
stage: test stage: test
script: script:
- wget --quiet --output-document=${EXIST_DB}.tar.gz https://bintray.com/existdb/releases/download_file?file_path=${EXIST_DB}.tar.gz - ant test
- tar -xzf ${EXIST_DB}.tar.gz; mkdir ${EXIST_DB}/lib/test - bash test/eXist-db-*/bin/startup.sh | tee output.log &
- ant dependencies
- cp build/*.xar ${EXIST_DB}/autodeploy
- bash ${EXIST_DB}/bin/startup.sh | tee output.log &
# wait for eXist # wait for eXist
- while [ $(curl -I -s http://localhost:8080 | grep -c "200 OK") == 0 ]; do sleep 2s; done - while [ $(curl -I -s http://localhost:8080 | grep -c "200 OK") == 0 ]; do sleep 2s; done
# shutdown eXist # shutdown eXist
- bash ${EXIST_DB}/bin/shutdown.sh - bash test/eXist-db-*/bin/shutdown.sh
- ls -al /tmp; mv /tmp/tests-* . || true - ls -al /tmp; mv /tmp/tests-* . || true
artifacts: artifacts:
paths: paths:
- output.log - output.log
- tests-*.xml - test/tests-*.xml
- ${EXIST_DB}/webapp/WEB-INF/logs/expath-repo.log - test/eXist-db-*/webapp/WEB-INF/logs/expath-repo.log
reports:
junit: test/tests-*.xml
upload: upload:
except: except:
- tags - tags
only:
- develop
- master
stage: deploy stage: deploy
script: script:
- FILENAME=$(ls build/*.xar) - FILENAME=$(ls build/*.xar)
......
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
#OUTDATED VERSION!
# About SADE # About SADE
The Scalable Architecture for Digital Editions (SADE) tries to meet the requirement for an easy to use publication system for electronic resources and Digital Editions. It is an attempt to provide a modular concept for publishing scholarly editions in a digital medium, based on open standards. Furthermore it is a distribution of open source software tools for the easy publication of Digital Editions and digitized texts in general out of the box. SADE is a scalable system that can be adapted by different projects which follow the TEI guidelines or other XML based formats. The Scalable Architecture for Digital Editions (SADE) tries to meet the requirement for an easy to use publication system for electronic resources and Digital Editions. It is an attempt to provide a modular concept for publishing scholarly editions in a digital medium, based on open standards. Furthermore it is a distribution of open source software tools for the easy publication of Digital Editions and digitized texts in general out of the box. SADE is a scalable system that can be adapted by different projects which follow the TEI guidelines or other XML based formats.
This is the modified version for Fontane Notizbücher. This is the modified version for Fontane Notizbücher. It is used together with several other packages (see dependencies) in addition to the TextGrid system.
# Fontane-Build # Distribution
* call `ant sade-dist-build` to build the latest supported eXist db and all SADE packages This package is available via the [DARIAH-DE eXist-repo](https://ci.de.dariah.eu/exist-repo/index.html). There are two flavors available: «SADE-fontane» (for production) and «SADE-fontane-develop».
* run `./dist-utils/antbuild/build/sade/bin/startup.sh`
* deploy the xar package from `SADE-Project-develop` # Development
* deployment needs approx. 45 min due to republication of all the data. this is because the TEI documents needs to be stored from in memory, anything else will place whitespaces in the rendered xhtml output. We follow the git-flow.
* there is fastdeploy build target that includes all non TEI-Data + Register and a single notebook (C07). deployment needs about 10 min.
* see http://localhost:8080/exist/apps/SADE/textgrid/index.html Find the git repo at [GWDG\`s GitLab](https://gitlab.gwdg.de/fontane-notizbuecher).
## Tests Use the issue tracker at [GWDG\`s GitLab](https://gitlab.gwdg.de/fontane-notizbuecher).
- [Markdown rendering](http://localhost:8080/exist/apps/SADE/textgrid/content.html?id=institutionen.md)
- [Dokuwiki (w/o reload)](http://localhost:8080/exist/apps/SADE/textgrid/doku.html) Go for local development with the ant tasks. In addition to the `*.xar` file containing this package all dependencies are loaded via `ant test`. This will place the version of eXist declared in `build.properties` and comes with all needed packages.
- [Dokuwiki (w reload)](http://localhost:8080/exist/apps/SADE/textgrid/doku.html?id=gesamtdokumentation_ii._tei-header) For a new up and running instance two commands are needed:
- [Image reload](http://localhost:8080/exist/apps/SADE/textgrid/doku.html?id=gesamtdokumentation_iii.3.21&reload) ```bash
- [Search](http://localhost:8080/exist/apps/SADE/textgrid/results.html?q=luther) ant test &&
- [Literaturverzeichnis](http://localhost:8080/exist/apps/SADE/textgrid/literaturvz.html) bash test/eXist-db-*/bin/startup.sh
- [Register](http://localhost:8080/exist/apps/SADE/textgrid/register.html) ```
- [Auth on develop (see cookie)](http://localhost:8080/exist/apps/SADE/textgrid/edition.html?id=/xml/data/16b00.xml&page=) This will result in local instance at [localhost:8080](http://localhost:8080/exist/).
- [TEI rendering](http://localhost:8080/exist/apps/SADE/textgrid/edition.html?id=/xml/data/16b00.xml&page=1r)
- [Cover](http://localhost:8080/exist/apps/SADE/textgrid/edition.html?id=/xml/data/16b00.xml&page=) CAUTION: A new build will remove the instance!
- [TBLE](http://localhost:8080/exist/apps/SADE/textgrid/edition.html?id=/xml/data/16b00.xml&page=60v)
- [single page]() # Build from source
- [XML-View](http://localhost:8080/exist/apps/SADE/textgrid/xml.html?id=/xml/data/16b00.xml) `ant` is used as build tool. The standard target will place a `*.xar` file in the build directory.
- [REST](http://localhost:8080/exist/apps/SADE/textgrid/rest/data/16b00.xml)
...@@ -4,8 +4,8 @@ let $params := ...@@ -4,8 +4,8 @@ let $params :=
<parameters> <parameters>
<param name="output" value="backup"/> <param name="output" value="backup"/>
<param name="zip" value="no"/> <param name="zip" value="no"/>
<param name="backup" value="yes"/> <param name="backup" value="yes"/>
<param name="incremental" value="yes"/> <param name="incremental" value="yes"/>
</parameters> </parameters>
return return
system:trigger-system-task("org.exist.storage.ConsistencyCheckTask", $params) system:trigger-system-task("org.exist.storage.ConsistencyCheckTask", $params)
project.name=http://textgrid.de/ns/SADE-fontane-develop project.name=http://textgrid.de/ns/SADE-fontane-develop
project.version=3.2.3 project.version=4.0.0
project.title=[Fontane] SADE project.title=[Fontane] SADE
project.abbrev=SADE-fontane-develop project.abbrev=SADE-fontane-develop
project.processorversion=4.3.1 project.processorversion=4.6.1
dependency.track=-develop
destfile=${build.dir}/${project.abbrev}-${project.version}.xar
test.dir=test
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project default="xar" name="SADE"> <project default="xar" name="SADE" xmlns:xdb="http://exist-db.org/ant">
<property environment="env"/>
<property file="local.build.properties"/> <property environment="env"/>
<property file="build.properties"/> <property name="build.dir" value="build"/>
<property name="build.dir" value="build"/> <property file="local.build.properties"/>
<xmlproperty file="expath-pkg.xml.tmpl"/> <property file="build.properties"/>
<xmlproperty file="expath-pkg.xml.tmpl"/>
<target name="xar">
<target name="xar" depends="cleanup">
<copy file="expath-pkg.xml.tmpl" tofile="expath-pkg.xml" filtering="true" overwrite="true"> <copy file="expath-pkg.xml.tmpl" tofile="expath-pkg.xml" filtering="true" overwrite="true">
<filterset> <filterset>
<filter token="project.version" value="${project.version}"/> <filter token="project.version" value="${project.version}"/>
...@@ -14,17 +15,36 @@ ...@@ -14,17 +15,36 @@
<filter token="project.abbrev" value="${project.abbrev}"/> <filter token="project.abbrev" value="${project.abbrev}"/>
<filter token="project.name" value="${project.name}"/> <filter token="project.name" value="${project.name}"/>
<filter token="project.processorversion" value="${project.processorversion}"/> <filter token="project.processorversion" value="${project.processorversion}"/>
<filter token="dependency.track" value="${dependency.track}"/>
</filterset> </filterset>
</copy> </copy>
<mkdir dir="${build.dir}"/> <mkdir dir="${build.dir}"/>
<zip basedir="." destfile="${build.dir}/${project.abbrev}-${project.version}.xar" <zip basedir="." destfile="${destfile}"
excludes="${build.dir}/*"/> excludes="${build.dir}/*,${test.dir}/*"/>
</target> </target>
<target name="dependencies"> <target name="cleanup">
<get src="https://ci.de.dariah.eu/exist-repo/find.zip?abbrev=cv&amp;processor=${project.processorversion}" dest="${build.dir}/codeview-latest.xar" verbose="on" ignoreerrors="true"/> <delete dir="${test.dir}"/>
<get src="http://exist-db.org/exist/apps/public-repo/find.zip?abbrev=markdown&amp;processor=${project.processorversion}" dest="${build.dir}/markdown-latest.xar" verbose="on" ignoreerrors="true"/> </target>
<get src="http://exist-db.org/exist/apps/public-repo/find.zip?abbrev=monex&amp;processor=${project.processorversion}" dest="${build.dir}/monex-latest.xar" verbose="on" ignoreerrors="true"/>
<target name="test" depends="xar">
<get src="https://bintray.com/existdb/releases/download_file?file_path=eXist-db-${project.processorversion}.tar.bz2" dest="${build.dir}/eXist-db-${project.processorversion}.tar.bz2" skipexisting="true" />
<untar src="${build.dir}/eXist-db-${project.processorversion}.tar.bz2" dest="${test.dir}" compression="bzip2" />
<get src="https://ci.de.dariah.eu/exist-repo/find.zip?abbrev=cv${dependency.track}&amp;processor=${project.processorversion}" dest="${test.dir}/eXist-db-${project.processorversion}/autodeploy/codeview-latest.xar" ignoreerrors="true"/>
<get src="https://ci.de.dariah.eu/exist-repo/find.zip?abbrev=tgconnect${dependency.track}&amp;processor=${project.processorversion}" dest="${test.dir}/eXist-db-${project.processorversion}/autodeploy/tgconnect${dependency.track}-latest.xar" ignoreerrors="true"/>
<get src="https://ci.de.dariah.eu/exist-repo/find.zip?abbrev=fontane${dependency.track}&amp;processor=${project.processorversion}" dest="${test.dir}/eXist-db-${project.processorversion}/autodeploy/fontane${dependency.track}-latest.xar" ignoreerrors="true"/>
<get src="https://ci.de.dariah.eu/exist-repo/find.zip?abbrev=fontane-lucene-exist-module&amp;processor=${project.processorversion}" dest="${test.dir}/eXist-db-${project.processorversion}/autodeploy/fontane-lucene-latest.xar" ignoreerrors="true"/>
<get src="https://ci.de.dariah.eu/exist-repo/find.zip?abbrev=openapi${dependency.track}&amp;processor=${project.processorversion}" dest="${test.dir}/eXist-db-${project.processorversion}/autodeploy/openapi${dependency.track}-latest.xar" ignoreerrors="true"/>
<get src="http://exist-db.org/exist/apps/public-repo/find.zip?abbrev=markdown&amp;processor=${project.processorversion}" dest="${test.dir}/eXist-db-${project.processorversion}/autodeploy/markdown-latest.xar" ignoreerrors="true"/>
<get src="http://exist-db.org/exist/apps/public-repo/find.zip?abbrev=xqjson&amp;processor=${project.processorversion}" dest="${test.dir}/eXist-db-${project.processorversion}/autodeploy/xqjson-latest.xar" ignoreerrors="true"/>
<get src="http://exist-db.org/exist/apps/public-repo/find.zip?abbrev=fundocs&amp;processor=${project.processorversion}" dest="${test.dir}/eXist-db-${project.processorversion}/autodeploy/fundocs-latest.xar" ignoreerrors="true"/>
<copy file="${destfile}" todir="${test.dir}/eXist-db-${project.processorversion}/autodeploy" />
<copy todir="${test.dir}/eXist-db-${project.processorversion}/tools/jetty/webapps/portal/public" preservelastmodified="true" failonerror="false">
<fileset dir="${basedir}/../static/public"/>
</copy>
</target> </target>
</project> </project>
...@@ -24,7 +24,7 @@ if ($exist:path eq '') then ...@@ -24,7 +24,7 @@ if ($exist:path eq '') then
(: forward requests without project to the first project listed :) (: forward requests without project to the first project listed :)
else if (empty($project)) then else if (empty($project)) then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist"> <dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<redirect url="{config:list-projects()[1]}/index.html"/> <redirect url="{config:list-projects()[1]}/index.html"/>
</dispatch> </dispatch>
...@@ -77,7 +77,7 @@ else if (tokenize($exist:path, '/') = "get") then ...@@ -77,7 +77,7 @@ else if (tokenize($exist:path, '/') = "get") then
case "trans.html" return case "trans.html" return
if($alternative) if($alternative)
then serialize($doc/xhtml:body/xhtml:div/xhtml:div[not(@class="teixml")][not(@class="facs")]) then serialize($doc/xhtml:body/xhtml:div/xhtml:div[not(@class="teixml")][not(@class="facs")])
=> replace("xhtml:", "") => replace('class="surface"', 'class="surface no-nesting"') => replace("xhtml:", "") => replace('class="surface', 'class="surface no-nesting')
else else
serialize($doc/xhtml:body/xhtml:div/xhtml:div[not(@class="teixml")][not(@class="facs")]) serialize($doc/xhtml:body/xhtml:div/xhtml:div[not(@class="teixml")][not(@class="facs")])
=> replace("xhtml:", "") => replace("xhtml:", "")
...@@ -107,7 +107,7 @@ else if( ...@@ -107,7 +107,7 @@ else if(
<dispatch xmlns="http://exist.sourceforge.net/NS/exist"> <dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<redirect url="login.html?redirect={$exist:path => substring-after("textgrid/")}?{request:get-query-string()}"/> <redirect url="login.html?redirect={$exist:path => substring-after("textgrid/")}?{request:get-query-string()}"/>
</dispatch> </dispatch>
else if (ends-with($exist:resource, ".html")) then else if ( $exist:path = "/" || $project || "/" || $exist:resource ) then
let $doc-path := $config:projects-dir || $project || config:get("template") || $exist:resource let $doc-path := $config:projects-dir || $project || config:get("template") || $exist:resource
return return
(: the html page is run through view.xql to expand templates :) (: the html page is run through view.xql to expand templates :)
...@@ -131,6 +131,23 @@ else if (contains($exist:path, "/$shared/")) then ...@@ -131,6 +131,23 @@ else if (contains($exist:path, "/$shared/")) then
</forward> </forward>
</dispatch> </dispatch>
else if (contains($exist:path, "/api/")) then
let $api-call := substring-after($exist:path, '/api/')
let $query-string := request:get-query-string()
let $path := if($query-string) then $api-call || "?" || $query-string else $api-call
return
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<redirect url="/exist/restxq/api/{$path}"/>
</dispatch>
else if (contains($exist:path, "/openapi/")) then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="/openapi/{ $exist:path => substring-after("/openapi/") => replace("json", "xq") }" method="get">
<add-parameter name="target" value="{ substring-after($exist:root, "://") || $exist:controller }"/>
<add-parameter name="register" value="false"/>
</forward>
</dispatch>
else else
(: check if the resource comes from the template or the data (: check if the resource comes from the template or the data
we try to leave the template manipulation as minimal as we try to leave the template manipulation as minimal as
......
...@@ -7,5 +7,6 @@ ...@@ -7,5 +7,6 @@
<title>@project.title@</title> <title>@project.title@</title>
<dependency processor="http://exist-db.org" semver-min="@project.processorversion@"/> <dependency processor="http://exist-db.org" semver-min="@project.processorversion@"/>
<dependency package="http://exist-db.org/apps/markdown"/> <dependency package="http://exist-db.org/apps/markdown"/>
<dependency package="http://bdn-edition.de/ns/code-view"/> <dependency package="http://www.functx.com"/>
<dependency package="http://bdn-edition.de/ns/code-view@dependency.track@"/>
</package> </package>
project.abbrev=SADE-fontane project.abbrev=SADE-fontane
project.name=http://textgrid.de/ns/SADE-fontane project.name=http://textgrid.de/ns/SADE-fontane
dependency.track=
\ No newline at end of file
...@@ -30,7 +30,7 @@ declare variable $config:app-root := ...@@ -30,7 +30,7 @@ declare variable $config:app-root :=
substring-before($modulePath, "/modules") substring-before($modulePath, "/modules")
; ;
declare variable $config:data-root := $config:app-root || "/data"; declare variable $config:data-root := "/db/sade-projects/textgrid/data/xml";
declare variable $config:repo-descriptor := doc(concat($config:app-root, "/repo.xml"))/repo:meta; declare variable $config:repo-descriptor := doc(concat($config:app-root, "/repo.xml"))/repo:meta;
......
...@@ -17,27 +17,30 @@ declare namespace xhtml="http://www.w3.org/1999/xhtml"; ...@@ -17,27 +17,30 @@ declare namespace xhtml="http://www.w3.org/1999/xhtml";
import module namespace rest="http://exquery.org/ns/restxq"; import module namespace rest="http://exquery.org/ns/restxq";
import module namespace config="http://textgrid.de/ns/SADE/config" at "../config/config.xqm"; import module namespace config="http://textgrid.de/ns/SADE/config" at "../config/config.xqm";
import module namespace ixp="http://fontane-nb.dariah.eu/index-processor" at "index-processor.xqm";
declare variable $index:dataPath := "/db/sade-projects/textgrid/data/xml/data"; declare variable $index:dataPath := "/db/sade-projects/textgrid/data/xml/data";
(:~ (:~
: resolves and lists all references on a given page based on their index data : resolves and lists all references on a given page based on their index data
: :
: @param $uri A valid TextGrid Base-URI without prefix : @param $uri A valid TextGrid Base-URI without prefix
: @param $surface – a string to match a tei:surface/@n in the document : @param $surface A string to match a tei:surface/@n in the document
: (use “-” as delimiter) : (use “-” as delimiter)
: @return a list with all entries : @return xhtml list with all entries
: @see http://localhost:8080/exist/restxq/fontane/index/16b00/62v : @see http://localhost:8080/exist/restxq/fontane/index/16b00/62v
: @see https://fontane-nb.dariah.eu/api/index/16b00/62v : @see https://fontane-nb.dariah.eu/api/index/16b00/62v
: :) : :)
declare declare
%rest:GET %rest:GET
%rest:path("fontane/index/{$uri}/{$surface}") %rest:path("/api/index/{$uri}/{$surface}")
%output:method("html") %output:method("html")
%test:name("entities per page") %test:name("entities per page")
%test:args("16b00", "2v") (: return empty sequence on interleaf :) %test:arg("uri", "16b00")
%test:arg("surface", "2v")
(: return empty sequence on interleaf :)
%test:assertEmpty %test:assertEmpty
%test:args("", "") (: return custom error INDEX-API1 :) %test:args("", "") (: return custom error INDEX-API1 :)
...@@ -100,7 +103,7 @@ return ...@@ -100,7 +103,7 @@ return
let $index := (collection($index:dataPath)/id($ref))[1] let $index := (collection($index:dataPath)/id($ref))[1]
let $name := string($index/*[1]) let $name := string($index/*[1])
let $list := index:get-list-by-id($ref) let $list := index:get-list-by-id($ref)
let $href := "register-" || $list || ".html?e=" || $ref let $href := "register.html?e=" || $ref
order by $name order by $name
return return
element xhtml:li { element xhtml:li {
...@@ -155,7 +158,7 @@ declare ...@@ -155,7 +158,7 @@ declare
function index:get-list-by-id($id as xs:string) function index:get-list-by-id($id as xs:string)
as xs:string { as xs:string {
let $entity := collection($index:dataPath)/id($id) let $entity := collection($index:dataPath)/id($id)[ not(. instance of element(tei:handNote) ) ]
let $test := if($entity[2]) then error(QName("FONTANE", "INDEX-API3"), "Entity »" || $id || "« has more then one occurence." ) else () let $test := if($entity[2]) then error(QName("FONTANE", "INDEX-API3"), "Entity »" || $id || "« has more then one occurence." ) else ()
return return
switch ( $entity/local-name() ) switch ( $entity/local-name() )
...@@ -176,11 +179,103 @@ return ...@@ -176,11 +179,103 @@ return
$list/local-name() || "-" || string($list/@type) $list/local-name() || "-" || string($list/@type)
}; };
declare function index:get-list-by-node($node as element(*))
as xs:string {
switch ( $node/local-name() )
case "event" return "listEvent"
case "org" return "listOrg"
case "place" return "listPlace"
case "person" return
if($node/ancestor::tei:item)
then index:get-list-by-id( ($node/ancestor::tei:item)[last()]/string(@xml:id) )
else "listPerson"
case "personGrp" return
if($node/ancestor::tei:item)
then index:get-list-by-id( ($node/ancestor::tei:item)[last()]/string(@xml:id) )
else "listPerson"
default return
let $list := ($node/ancestor::tei:list[@type])[last()]
return
$list/local-name() || "-" || string($list/@type)
};
declare declare
%rest:GET %rest:GET
%rest:path("fontane/index/entity/{$id}") %rest:path("/api/index/entity/{$id}")
%output:method("html") %output:method("html")
%test:arg("id", "Storm")
%test:assertTrue
function index:rendered-entity($id as xs:string) function index:rendered-entity($id as xs:string)
as element(xhtml:li)? { as item()* {
doc("/db/sade-projects/textgrid/data/xml/xhtml/index.xml")//xhtml:li[@id = $id] let $node := collection($index:dataPath)/id($id)
let $type := $node/root()//tei:body/*[1]/local-name()
(: listEvent, listPlace, listOrg, listPerson or list :)
return
switch ($type)
case "listEvent" return
ixp:prepare-event($node)
case "listOrg" return