Dear Gitlab Users, for our upcoming upgrade to Gitlab v14, Gitlab will be unavailable on Thursday, 05.08.2021 from 5:00 pm to approximately 7:00 pm. Note that with v14, certain breaking changes will be introduced (https://about.gitlab.com/blog/2021/06/04/gitlab-moving-to-14-breaking-changes/).

Commit 7d23ba24 authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

Merge branch 'release/5.1.0'

parents 8262a121 15039c7d
......@@ -8,5 +8,10 @@ build/
expath-pkg.xml
test/
# eXist init files #
####################
tests-*.log.xml
.DS_STORE
=======
......@@ -36,17 +36,17 @@ installation:
stage: test
script:
- ant test
- bash test/eXist-db-*/bin/startup.sh | tee output.log &
- bash test/bin/startup.sh | tee output.log &
# wait for eXist
- while [ $(curl -I -s http://localhost:8080 | grep -c "200 OK") == 0 ]; do sleep 2s; done
# shutdown eXist
- bash test/eXist-db-*/bin/shutdown.sh
- bash test/bin/shutdown.sh
- ls -al /tmp; mv /tmp/tests-* . || true
artifacts:
paths:
- output.log
- test/tests-*.xml
- test/eXist-db-*/webapp/WEB-INF/logs/expath-repo.log
- test/logs/expath-repo.log
reports:
junit: test/tests-*.xml
......
project.name=http://textgrid.de/ns/SADE-fontane-develop
project.version=5.0.0
project.version=5.1.0
project.title=[Fontane] SADE
project.abbrev=SADE-fontane-develop
project.processorversion=4.7.0
project.processorversion=5.2.0
dependency.track=-develop
......
......@@ -30,23 +30,30 @@
<target name="test" depends="xar">
<delete dir="${build.dir}">
<include name="eXist-db-*.tar.bz2"/>
<exclude name="eXist-db-${project.processorversion}.tar.bz2"/>
<exclude name="eXist-${project.processorversion}.tar.bz2"/>
</delete>
<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">
<get src="https://bintray.com/existdb/releases/download_file?file_path=exist-distribution-${project.processorversion}-unix.tar.bz2" dest="${build.dir}/eXist-${project.processorversion}.tar.bz2" skipexisting="true" quiet="true" />
<untar src="${build.dir}/eXist-${project.processorversion}.tar.bz2" dest="${test.dir}" compression="bzip2">
<cutdirsmapper dirs="1" />
</untar>
<setpermissions mode="755">
<fileset dir="${test.dir}">
<filename name="bin/*.sh"/>
</fileset>
</setpermissions>
<get src="https://ci.de.dariah.eu/exist-repo/find.zip?abbrev=cv${dependency.track}&amp;processor=${project.processorversion}" dest="${test.dir}/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}/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}/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}/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}/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}/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}/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}/autodeploy/fundocs-latest.xar" ignoreerrors="true"/>
<copy file="${destfile}" todir="${test.dir}/autodeploy" />
<copy todir="${test.dir}/etc/jetty/webapps/portal/public" preservelastmodified="true" failonerror="false">
<fileset dir="${basedir}/../static/public"/>
</copy>
</target>
......
......@@ -5,6 +5,8 @@ module namespace app="http://textgrid.de/ns/SADE/templates";
import module namespace templates="http://exist-db.org/xquery/templates" ;
import module namespace config="http://textgrid.de/ns/SADE/config" at "config/config.xqm";
declare namespace xhtml="http://www.w3.org/1999/xhtml";
(:~
: returns an html snippet with the current project title from conf.xml, can be
: can be a clickable title within a navbar that triggers a sidebar
......@@ -27,7 +29,10 @@ declare function app:project-id($node as node(), $model as map(*)) {
: @param $model a map containing arbitrary data - used to pass information between template calls
:)
declare function app:publications($node as node(), $model as map(*)) {
httpclient:get(xs:anyURI('https://www.uni-goettingen.de/de/publikationen/303721.html'), true(), ())//ul[@class="txtlist"][1]/li[position() < 4]
let $request := <hc:request method="get" href="https://www.uni-goettingen.de/de/publikationen/303721.html" />
let $response := hc:send-request($request)[2]
return
($response//*:li[@class="content"])[position() lt 5]
};
(:~
......@@ -38,7 +43,9 @@ httpclient:get(xs:anyURI('https://www.uni-goettingen.de/de/publikationen/303721.
: @param $model a map containing arbitrary data - used to pass information between template calls
:)
declare function app:presentations($node as node(), $model as map(*)) {
for $item in httpclient:get(xs:anyURI('https://www.uni-goettingen.de/de/vortr%C3%A4ge-und-pr%C3%A4sentationen/303717.html'), true(), ())//ul[@class="txtlist"][1]/li[position() < 5]
let $request := <hc:request method="get" href="https://www.uni-goettingen.de/de/vortr%C3%A4ge-und-pr%C3%A4sentationen/303717.html" />
let $response := hc:send-request($request)[2]
for $item in ($response//*:li[@class="content"])[position() lt 5]
return
element li { for $i in $item/node() return local:nodeTest($i) }
};
......
......@@ -78,10 +78,11 @@ declare variable $config:project :=
let $value:= try { request:get-url() => substring-after("SADE/") => substring-before("/") } catch * { "textgrid" }
return if($value="") then "textgrid" else $value;
declare variable $config:configDoc := doc( $config-params:projects-dir || $config:project || "/config.xml" );
declare variable $config:configMap := map:new(
for $param in $config:configDoc/config/*[./@key]
return map:entry(string($param/@key), string($param))
);
declare variable $config:configMap :=
map:merge(
for $param in $config:configDoc/config/*[./@key]
return map:entry(string($param/@key), string($param))
);
declare function config:get($key as xs:string) as xs:string {
let $return :=
......@@ -95,7 +96,7 @@ return
then $return
else
let $doc := doc( $config-params:projects-dir || $config:project || "/config.xml" )
let $map := map:new(for $param in $doc/config/*[./@key] return map:entry(string($param/@key), string($param)))
let $map := map:merge( for $param in $doc/config/*[./@key] return map:entry(string($param/@key), string($param)))
return
switch ($key)
case "data-dir" return $config-params:projects-dir || $config:project || "/" || $map($key)
......
......@@ -34,12 +34,12 @@ declare function fsearch:results($node as node(), $model as map(*)) as map()* {
return
map {
"facets" := fsearch:facets($model, $hits),
"hits" := subsequence($hitsordered,$start,$num),
"totalhits" := count($hits),
"start" := $start,
"page" := $page,
"pages" := $pages
"facets" : fsearch:facets($model, $hits),
"hits" : subsequence($hitsordered,$start,$num),
"totalhits" : count($hits),
"start" : $start,
"page" : $page,
"pages" : $pages
}
};
......@@ -162,7 +162,7 @@ function fsearch:result-id($node as node(), $model as map(*)) {
};
declare function fsearch:facets($model as map(*), $hits) as map() {
map:new(
map:merge(
for $facet in $config:configDoc//module[@key="faceted-search"]//facet
return
map:entry(xs:string($facet/@key), local:facet($model, $hits, $facet/@key, $facet//xpath/text()))
......@@ -170,7 +170,7 @@ declare function fsearch:facets($model as map(*), $hits) as map() {
};
declare function fsearch:list-facets($node as node(), $model as map(*)) as map(*){
map { "facetgroups" := $model("facet") }
map { "facetgroups" : $model("facet") }
};
declare
......
......@@ -175,7 +175,7 @@ return
case "place" return "listPlace"
case "person" return
if($entity/ancestor::tei:item)
then true()
then index:get-list-by-id( ($entity/ancestor::tei:item)[last()]/string(@xml:id) )
else "listPerson"
case "personGrp" return
if($entity/ancestor::tei:item)
......@@ -247,7 +247,7 @@ as item()* {
(:~
: Provides a simple API for searching the index entries. Used for autocompletion.
: Usually the query should be a simple string. No wildcards, nothing special,
: always case-insensitive.
: always case-insensitive. Only performed for strings larger than one char.
: @param $query A string to search all index entries (names, label, etc.)
: @return $index A list of indices to query, defaults to all, oneOf: listEvent,listOrg,listPerson,listPlace,list-works,list-fontane,list-periodicals.
:)
......@@ -265,7 +265,14 @@ declare
function index:search($query as xs:string, $index)
as array(*) {
let $query := $query => xmldb:decode-uri()
return if(string-length($query) lt 2) then () else
return
if(string-length($query) lt 2)
then []
(: an empty array. explicit array constructor fails in eXist returning somewhat
like a xs:string "Index: 0, Size: 0" from
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
:)
else (: continue :)
let $prepare := tokenize($index, ",")
let $hits :=
(
......
......@@ -125,7 +125,7 @@ declare function ixp:main-map($index as xs:string+)
as map() {
let $nodes := ixp:getNodes()
return
map:new(
map:merge(
for $n in 1 to array:size($nodes)
let $node := $nodes?($n)
let $localId := string-join(($node/local-name(), $node/@type), "-")
......@@ -146,11 +146,11 @@ map:new(
return
map:entry(
$localId,
map:new((
map:merge(
map:entry("content", $content)
))
)
)
)
)
};
declare function ixp:main-map()
......@@ -308,13 +308,12 @@ let $gndCollection := "/db/sade-projects/textgrid/data/xml/gnd/"
let $filename := $gndid || ".xml"
let $docname := $gndCollection || $filename
let $url := "https://d-nb.info/gnd/" || $gndid || "/about/lds.rdf"
let $persist := false()
let $request-headers := ()
let $request := <hc:request method="get" href="{$url}" />
let $response :=
if( doc-available( $docname ))
then doc( $docname )
else
httpclient:get(xs:anyURI($url), $persist, $request-headers)
hc:send-request($request)[2]
let $store :=
if(config:get("sade.develop") = "true")
then
......@@ -335,9 +334,8 @@ declare function ixp:wikidata-wikipedia($wikidata-id as xs:string)
as xs:string?{
let $query := escape-uri("SELECT ?s WHERE{?s schema:about wd:" || $wikidata-id || ".}", true())
let $url := "https://query.wikidata.org/sparql?query=" || $query
let $persist := false()
let $request-headers := ()
let $uris := httpclient:get(xs:anyURI($url), $persist, $request-headers)//*:uri/string()
let $request := <hc:request method="get" href="{$url}" />
let $uris := hc:send-request($request)[2]//*:uri/string()
return (
$uris[matches(., "de\.wikipedia")],
$uris[matches(., "en\.wikipedia")],
......@@ -661,7 +659,9 @@ for $bibl in $bibls
declare function ixp:get-gnd-data($url as xs:string)
as element(rdf:RDF){
httpclient:get(xs:anyURI($url || "/about/rdf"), false(), ())//rdf:RDF
let $request := <hc:request method="get"/>
return
hc:send-request($request, $url || "/about/rdf")[2]//rdf:RDF
};
(: ################################################### :)
......
......@@ -185,7 +185,7 @@ return
declare function local:login($col) {
(: check for db availability :)
if(httpclient:get(xs:anyURI("http://localhost:8080"), false(), ())/@statusCode = 200)
if(hc:send-request(<hc:request method="get"/>, "http://localhost:8080")[1]/@status = 200)
then
if(false() = xmldb:login($col, config:get('sade.user'), config:get("sade.password")))
then (xmldb:login($col, "admin", ""))
......
......@@ -522,14 +522,14 @@ declare function f-misc:textgridStatus($node as node(), $model as map(*)) {
let $getStatus :=
if( $needUpdate )
then
let $status := httpclient:get(xs:anyURI($url), false(), ())//xhtml:div[contains(@class, 'repstatus')][not( contains(@class, 'ok') )]
let $status := hc:send-request(<hc:request method="get" href="{$url}"/>)[2]//xhtml:div[contains(@class, 'repstatus')][not( contains(@class, 'ok') )]
let $status := if( exists( $status ) ) then $status else <ok/>
return
(xmldb:login($col, config:get("sade.user"), config:get("sade.password")),
xmldb:store($col, $res, $status))
else if($active and $lastMod < (current-dateTime() - xs:dayTimeDuration("PT2H")))
then
let $status := httpclient:get(xs:anyURI($url), false(), ())//xhtml:div[contains(@class, 'repstatus')][not( contains(@class, 'ok') )]
let $status := hc:send-request(<hc:request method="get" href="{$url}"/>)[2]//xhtml:div[contains(@class, 'repstatus')][not( contains(@class, 'ok') )]
let $status := if( exists( $status ) ) then $status else <ok/>
return
(xmldb:login($col, config:get("sade.user"), config:get("sade.password")), xmldb:store($col, $res, $status))
......@@ -562,14 +562,14 @@ declare function f-misc:serverStatus($node as node(), $model as map(*)) {
let $getStatus :=
if( $needUpdate )
then
let $status := httpclient:get(xs:anyURI($url), false(), ())//*:li[contains(., "Fontane")]/ancestor::*:div[contains(@class, "alert")]
let $status := hc:send-request(<hc:request method="get" href="{$url}"/>)[2]//*:li[contains(., "Fontane")]/ancestor::*:div[contains(@class, "alert")]
let $status := if( exists( $status ) ) then $status else <ok/>
return
(xmldb:login($col, config:get("sade.user"), config:get("sade.password")),
xmldb:store($col, $res, $status))
else if($active and $lastMod < (current-dateTime() - xs:dayTimeDuration("PT2H")))
then
let $status := httpclient:get(xs:anyURI($url), false(), ())//*:li[contains(., "Fontane")]/ancestor::*:div[contains(@class, "alert")]
let $status := hc:send-request(<hc:request method="get" href="{$url}"/>)[2]//*:li[contains(., "Fontane")]/ancestor::*:div[contains(@class, "alert")]
let $status := if( exists( $status ) ) then $status else <ok/>
return
(xmldb:login($col, config:get("sade.user"), config:get("sade.password")), xmldb:store($col, $res, $status))
......
......@@ -41,8 +41,9 @@ declare
function tbleapi:stream-image($uri as xs:string, $xmlid as xs:string, $format as xs:string)
{
let $url := tbleapi:get-url($uri, $xmlid, $format)
let $request := httpclient:get($url, false(), ())
let $data := $request/httpclient:body/text()
let $request := <hc:request method="get" href="{ $url }" />
let $response := hc:send-request($request)
let $data := $response[2]
let $binary-data :=
try { $data => xs:base64Binary() }
catch * {
......@@ -50,7 +51,7 @@ let $binary-data :=
QName("err", "load1"),
string-join(("&#10;Could not load data from TextGrid: ", $data, $err:code, $err:description), "&#10;"))
}
let $mime := string($request/httpclient:body/@mimetype)
let $mime := string($response[1]/hc:body/@media-type)
return
$binary-data
......
......@@ -274,7 +274,7 @@ element xhtml:div {
declare function mviewer:tei-paging($doc, $page as xs:integer) {
let $doc := if ($page > 0 and ($doc//tei:pb)[$page]) then
util:parse(util:get-fragment-between(($doc//tei:pb)[$page], ($doc//tei:pb)[$page+1], true(), true()))
parse-xml(util:get-fragment-between(($doc//tei:pb)[$page], ($doc//tei:pb)[$page+1], true(), true()))
(: Kann das funktionieren, wenn page als integer übergeben wird? müsste man nicht tei:pb/@n auswerten? :)
else
$doc
......
......@@ -18,7 +18,7 @@ function nav:navitems($node as node(), $model as map(*)) as map(*) {
doc( $confLocation)//navigation/*
else
$model("config")//module[string(@key)=$nav:module-key]//navigation/*
return map { "navitems" := $navitems }
return map { "navitems" : $navitems }
};
......@@ -40,7 +40,7 @@ declare function nav:head($node as node(), $model as map(*)) {
declare
%templates:wrap
function nav:subitems($node as node(), $model as map(*)) as map(*) {
map{ "subitems" := $model("item")/*}
map{ "subitems" : $model("item")/*}
};
declare
......
......@@ -39,8 +39,6 @@ declare function wiki:dokuwiki($node as node(), $model as map(*), $id as xs:stri
as node()* {
(: check for valid id and replace id not in whitelist :)
let $id:= if($id = doc('/db/sade-projects/textgrid/data/xml/data/2shfj.xml')//text()) then $id else 'gesamtdokumentation'
(: trigger image reload :)
let $imageLoad := if( request:get-parameter-names() = "reload" ) then wiki:dokuwikiImageReload($id) else false()
let $doc :=
doc(
......@@ -80,28 +78,6 @@ return
}
};
(:~
: Gets the currently stored revision number in the database for a given id
: @param $id A pagename in the wikispace according to config.xml
: @return the revision number stored in the database
:)
declare function wiki:revision-local($id as xs:string)
as xs:int {
let $document-name as xs:string? :=
xmldb:get-child-resources('/sade-projects/textgrid/data/xml/doku/')
[substring-before(., '.rev') = $id]
[not(ends-with(., ".lock.xml"))]
return
if(not($document-name))
then xs:int(-1)
else
$document-name
=> substring-after('.rev')
=> substring-before('.xml')
=> xs:int()
};
(:~
: Gets the last revision number from the wikis feed and removes an old version
: in the database. TODO: move remove operation somewhere else
......@@ -113,13 +89,15 @@ declare function wiki:revision-remote($id as xs:string)
as xs:int {
let $wikiList :=
try {
((xs:anyURI(config:get("dokuwiki.url")
|| '/feed.php?type=rss2&amp;num=500&amp;ns=fontane&amp;minor=1&amp;mode=list&amp;u='
|| config:get("dokuwiki.user")
|| '&amp;p='
|| config:get("dokuwiki.password"))
=> httpclient:get(false(), ()))/httpclient:body/node()
)
let $url :=
config:get("dokuwiki.url")
|| '/feed.php?type=rss2&amp;num=500&amp;ns=fontane&amp;minor=1&amp;mode=list&amp;u='
|| config:get("dokuwiki.user")
|| '&amp;p='
|| config:get("dokuwiki.password")
let $request := <hc:request method="get" href="{ $url }" />
return
hc:send-request($request)[2]
} catch * {
error(QName("FONTANE", "DOKU05"), "Unable to connect to RSS feed. Are there valid credentials provided?" )
}
......@@ -135,17 +113,37 @@ return
else xs:int(-1)
};
(:~
: Gets the currently stored revision number in the database for a given id
: @param $id A pagename in the wikispace according to config.xml
: @return the revision number stored in the database
:)
declare function wiki:revision-local($id as xs:string)
as xs:int {
let $document-name as xs:string? :=
xmldb:get-child-resources('/sade-projects/textgrid/data/xml/doku/')
[substring-before(., '.rev') = $id]
[not(ends-with(., ".lock.xml"))]
return
if(not($document-name))
then xs:int(-1)
else
$document-name
=> substring-after('.rev')
=> substring-before('.xml')
=> xs:int()
};
declare function wiki:lastModProcessor() {
xmldb:last-modified("/db/apps/SADE/modules/wiki", "wiki.xqm")
};
declare function wiki:lock-resource($id as xs:string) {
wiki:login(),
xmldb:store('/sade-projects/textgrid/data/xml/doku/', $id || ".lock.xml", <lock/>)
};
declare function wiki:unlock-resource($id as xs:string) {
wiki:login(),
xmldb:remove('/sade-projects/textgrid/data/xml/doku/', $id || ".lock.xml")
};
......@@ -166,6 +164,7 @@ declare
function wiki:reload($id as xs:string) {
let $remote := wiki:revision-remote($id)
let $local := wiki:revision-local($id)
return
if( $remote le wiki:revision-local($id) )
then
......@@ -176,51 +175,30 @@ return
error(QName("FONTANE", "DOKU02"), "Resource is locked." )
else (: proceed :)
let $lock := wiki:lock-resource($id)
let $url as xs:anyURI :=
(config:get("dokuwiki.url")
let $url :=
config:get("dokuwiki.url")
|| '/doku.php?id=fontane:' || $id
|| '&amp;rev=' || $remote
||'&amp;u='|| config:get("dokuwiki.user")
||'&amp;p='|| config:get("dokuwiki.password")
||'&amp;do=export_xhtml')
=> xs:anyURI(),
$persist := false(),
$request-headers:= (),
$options:= <options><property name="http://cyberneko.org/html/properties/default-encoding" value="UTF-8"/></options>,
|| '&amp;u='|| config:get("dokuwiki.user")
|| '&amp;p='|| config:get("dokuwiki.password")
|| '&amp;do=export_xhtml',
$export :=
try {
httpclient:get($url, $persist, $request-headers, $options)//*[@class="dokuwiki export"]
hc:send-request(<hc:request method="get" href="{ $url }" />)[2]//*[@class="dokuwiki export"]
} catch * {
error(QName("FONTANE", "DOKU04"), "unable to load resource." )
},
$result := if( $export//DIV )
then wiki:HTML2html($export)
else $export,
$result := $export,
$result := <div>{wiki:dokuwikiparser( $result/*[not(@id='dw__toc')] )}</div>,
$login := wiki:login(),
$remove := if($local = -1) then true() else
xmldb:remove('/sade-projects/textgrid/data/xml/doku/', $id || '.rev' || $local || '.xml'),
$store := xmldb:store( '/sade-projects/textgrid/data/xml/doku/', $id || '.rev' || $remote || '.xml' , $result ),
$imageReload := wiki:dokuwikiImageReload($id)
$store := xmldb:store( '/sade-projects/textgrid/data/xml/doku/', $id || '.rev' || $remote || '.xml' , $result )
let $unlock := wiki:unlock-resource($id)
let $unlock := wiki:unlock-resource($id)
return
<true/>
};
(:~
: Helper function to recursivly translate upper case element names to lower case
:)
declare function wiki:HTML2html($node as node())
as node() {
for $node in $node
return
typeswitch ( $node )
case element() return
element { lower-case($node/local-name()) } { $node/@*, wiki:HTML2html($node/node()) }
default return $node
};
declare function wiki:dokuwikiparser($nodes as node()*){
wiki:dokuwikiparser($nodes, false())
};
......@@ -229,46 +207,46 @@ declare function wiki:dokuwikiparser($nodes as node()*, $char as xs:boolean){
let $char := false()
for $node in $nodes return
typeswitch($node)
case element(h1)
case element(xhtml:h1)
return
element xhtml:h2 {
<div class="block-header">
<h2><span class="title">{wiki:dokuwikiparser($node/text(), $char)}</span><span class="decoration"></span><span class="decoration"></span><span class="decoration"></span></h2>
<div id="toggleToc"><i class="fa fa-caret-down" aria-hidden="true"></i></div>
<div id="dokuToc">
{ wiki:dokuwikiTOC( $node/parent::div/div[@id="dw__toc"]/div/ul/li/ul) }
{ $node/root()//xhtml:div[@id="dw__toc"]/xhtml:div/xhtml:ul/xhtml:li/xhtml:ul ! wiki:dokuwikiTOC(.) }
</div>
</div>
}
case element(h2)
case element (xhtml:h2)
return
element xhtml:h3 {
$node/@id,
<span class="dokuLink"><a href="#{$node/@id}"> <i class="fa fa-link" aria-hidden="true"></i></a></span>,
wiki:dokuwikiparser($node/node(), $char)
}
case element(h3)
case element (xhtml:h3)
return
element xhtml:h4 {
$node/@id,
<span class="dokuLink"><a href="#{$node/@id}"> <i class="fa fa-link" aria-hidden="true"></i></a></span>,
wiki:dokuwikiparser($node/node(), $char)
}
case element(h4)
case element (xhtml:h4)
return
element xhtml:h5 {
$node/@id,
<span class="dokuLink"><a href="#{$node/@id}"> <i class="fa fa-link" aria-hidden="true"></i></a></span>,
wiki:dokuwikiparser($node/node(), $char)
}
case element(h5)
case element (xhtml:h5)
return
element xhtml:h6 {
$node/@id,
<span class="dokuLink"><a href="#{$node/@id}"> <i class="fa fa-link" aria-hidden="true"></i></a></span>,
wiki:dokuwikiparser($node/node(), $char)
}
case element(h6)
case element(xhtml:h6)
return
element xhtml:h7 {
$node/@id,
......@@ -276,49 +254,49 @@ for $node in $nodes return
wiki:dokuwikiparser($node/node(), $char)
}
case attribute(class) return ()
case element(div)
case element (xhtml:div)
return
element xhtml:div {(
if($node/@class = "noteimportant")
if(contains($node/@class, "noteimportant"))
then
attribute class { 'note' }
else (),
wiki:dokuwikiparser($node/node(), $char)
)}
case element(br) return
case element(xhtml:br) return
element xhtml:br {}
case element(table)
case element (xhtml:table)
return
element xhtml:table {
attribute class {'table'},
wiki:dokuwikiparser($node/node(), $char)
}
case element (thead)
case element (xhtml:thead)
return
element xhtml:thead {
wiki:dokuwikiparser($node/node(), $char)
}
case element (th)
case element (xhtml:th)
return
element xhtml:th {
wiki:dokuwikiparser($node/node(), $char)
}
case element (tr)
case element (xhtml:tr)
return
element xhtml:tr {
wiki:dokuwikiparser($node/node(), $char)
}
case element (tbody)
case element (xhtml:tbody)
return
element xhtml:tbody {
wiki:dokuwikiparser($node/node(), $char)