Commit f669a3cd authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

closes #9

parent 8d6deb98
......@@ -40,7 +40,6 @@
<property name="fontane.sadeproject.git" value="https://gitlab.gwdg.de/fontane-notizbuecher/SADE-Project.git"/>
<property name="fontane.sadeproject.git.branch" value="develop"/>
<property name="fontane.sadeproject.dest" value="${build.dir}/fontane"/>
<property name="fontane.sadeproject.credentials" value="${sade.src}../SADE-Project/credentials.txt"/>
<property name="fontane.sadeproject.target" value="fastdeploy"/>
<!-- ^ path to credentials text file -->
......@@ -216,7 +215,7 @@
<then>
<git:git directory="${tg.defp.dest}" verbose="false">
<git:checkout branchName="${tg.defp.git.branch}" />
<git:pull />
<git:pull/>
</git:git>
</then>
<else>
......@@ -326,7 +325,7 @@
</exec>
</target-->
<target name="project-data">
<target name="project-data" depends="ant-dependencies">
<!--property name="fontane.sadeproject.git" value="http://gitlab.gwdg.de/fontane-notizbuecher/SADE-Project.git"/>
<property name="fontane.sadeproject.git.branch" value="develop"/>
<property name="fontane.sadeproject.dest" value="${build.dir}/fontane"/-->
......@@ -334,7 +333,8 @@
<available file="${fontane.sadeproject.dest}" type="dir" />
<then>
<echo message="[fontane] updating project data git repository" />
<git:git directory="${fontane.sadeproject.dest}" verbose="false">
<git:git directory="${fontane.sadeproject.dest}" verbose="true">
<git:checkout branchName="develop" />
<git:pull uri="${fontane.sadeproject.git}"/>
</git:git>
</then>
......
......@@ -153,15 +153,22 @@ let
else <xhtml:div>The requested document is not available.</xhtml:div>
else mviewer:choose-xsl-and-transform($doc, $model)
let $toc:= fontaneTransfo:toc($doc)
let $toc:= fontaneTransfo:toc($EXtei)
return
if(local-name($html[1]) = "html") then
<div class="teiXsltView">{$html//xhtml:div[@id='sourceDoc']}</div>
<xhtml:div class="teiXsltView">{$html//xhtml:div[@id='sourceDoc']}</xhtml:div>
else
<div class="teiXsltView">{$toc, $html}</div>
<xhtml:div class="teiXsltView">{$toc}
<xhtml:div class="TEI clearfix">
<xhtml:div id="{$html//xhtml:div[@class="facs"]/xhtml:a/string(@href)}" class="sourceDoc">{$html}</xhtml:div>
</xhtml:div>
</xhtml:div>
};
declare function local:getNotebookName($uri as xs:string) as xs:string {
()
};
declare function mviewer:renderMarkdown($node as node(), $model as map(*), $docpath as xs:string) as item()* {
let $inputDoc := util:binary-doc( $docpath )
......@@ -194,84 +201,7 @@ return
}
};
declare function mviewer:renderXml($node as node(), $model as map(*), $docpath as xs:string) as item()* {
let
$doc := doc($docpath),
(: $config := map { "config" := config:config('textgrid') },:)
$tgurl := 'http://textgridlab.org/1.0/tgcrud/rest/textgrid:',
(: $sid := tgclient:getSidCached($config),:)
$baseuri := substring-before(substring-before(substring-after(request:get-parameter('id', ''), '/xml/data/'), '.'), '.'),
$uri := substring-before(substring-after(request:get-parameter('id', ''), '/xml/data/'), '.'),
$EXid := request:get-parameter('id', ''),
$EXid := if (contains($EXid, '/')) then $EXid else replace($EXid, '%2F', '/'),
$EXuri := tokenize( tokenize($EXid, '/')[last()], '\.')[1],
(: $reqUrl := string-join(($tgurl,"/",$uri,"/data?sessionId=", $sid),""),:)
(: $reqData := <http:request href="{$tgurl|| $EXuri ||'/data?sessionId='|| $sid}" method="get">:)
(: <http:header name="Connection" value="close"/>:)
(: </http:request>,:)
(: $reqMeta := <http:request href="{$tgurl|| $EXuri ||'/metadata?sessionId='|| $sid}" method="get">:)
(: <http:header name="Connection" value="close"/>:)
(: </http:request>,:)
(: $EXtei := http:send-request($reqData)[2]//tei:TEI,:)
(: $meta := http:send-request($reqMeta)[2]//tgmd:MetadataContainerType,:)
$EXtei := doc($docpath)//tei:TEI,
$meta := doc(replace($docpath, 'data', 'meta')),
$page := if(request:get-parameter-names() = 'page') then if(request:get-parameter('page', '') = '') then 'outer_front_cover' else request:get-parameter('page', '') else '',
$html :=
if ( (request:get-parameter('test', '') = '1') and ($page = '') )
then (: test if we can use a cached html :)
let $datacol := substring-before($docpath, '/xml/data/') || '/xml'
let $dbDocName := substring-after($docpath, 'xml/data/')
let $dbDocNameXhtml := replace($dbDocName, 'xml', 'xhtml')
let $metadata := xs:dateTime($meta//tgmd:lastModified)
let $lastChangeXhtml :=
if ( doc-available($datacol||'/xhtml/' || $dbDocNameXhtml) )
then( xmldb:last-modified('/db/sade-projects/textgrid/data/xml/xhtml', $dbDocNameXhtml) )
else( xs:dateTime('2005-09-28T21:38:18.089+02:00') )
let $lastChangeProcessing := xmldb:last-modified('/db/apps/SADE/modules/multiviewer','fontane.xqm')
return
if($metadata gt $lastChangeXhtml or $lastChangeProcessing gt $lastChangeXhtml)
then (let $transfo := fontaneTransfo:magic($EXtei)
let $store := (
xmldb:login(substring-before($docpath, '/xml/data/') || '/xml/xhtml', fconfig:get('sade.user'), fconfig:get('sade.password')),
xmldb:store( substring-before($docpath, '/xml/data/') || '/xml/xhtml' , $dbDocNameXhtml, <xhtml:body>{$transfo}</xhtml:body>)
(: ,:)
(: session:invalidate():)
)
return $transfo
)
else doc('/db/sade-projects/textgrid/data/xml/xhtml/'||$dbDocNameXhtml)//xhtml:body/*
else
if ( (request:get-parameter('test', '') = '1') and ($page != '') )
then
let $extract := fontaneSfEx:extract( $EXtei, $page )
let $rendered := fontaneTransfo:magic($extract)
(: let $xhtml := <xhtml:body>{$rendered}</xhtml:body>:)
(: let $collection := if(xmldb:collection-available('/db/sade-projects/textgrid/data/xml/xhtml/'|| $EXuri)) :)
(: then () :)
(: else xmldb:create-collection('/db/sade-projects/textgrid/data/xml/xhtml/', $EXuri):)
(: let $store := xmldb:store('/db/sade-projects/textgrid/data/xml/xhtml/'||$EXuri, $page||'.xml', $xhtml):)
return $rendered
else if(request:get-parameter-names() != 'test') then
if($EXuri = xmldb:get-child-collections('/db/sade-projects/textgrid/data/xml/xhtml')) then
let $path := '/db/sade-projects/textgrid/data/xml/xhtml/' || $EXuri || '/' || $page || '.xml'
return
doc($path)/xhtml:body/*
else <xhtml:div>The requested document is not available.</xhtml:div>
else mviewer:choose-xsl-and-transform($doc, $model)
let $toc:= fontaneTransfo:toc($EXtei)
return
if(local-name($html[1]) = "html") then
<xhtml:div class="teiXsltView">{$html//xhtml:div[@id='sourceDoc']}</xhtml:div>
else
<xhtml:div class="teiXsltView">{$toc, $html}</xhtml:div>
};
declare function mviewer:renderTILE($node as node(), $model as map(*), $docpath as xs:string) as item()* {
let $doc := doc($docpath)
......@@ -305,8 +235,12 @@ let
else <xhtml:div>The requested document is not available.</xhtml:div>,
$toc := doc('/db/sade-projects/textgrid/data/xml/xhtml/' || $uri || '/toc.xml')/*
return
<xhtml:div class="teiXsltView">{$toc, $html}</xhtml:div>
<xhtml:div class="teiXsltView">{$toc}
<xhtml:div class="TEI clearfix">
<xhtml:div id="{$html//xhtml:div[@class="facs"]/xhtml:a/substring-before( substring-after(@href, "digilib/"), "_")}" class="sourceDoc">{$html}</xhtml:div>
</xhtml:div>
</xhtml:div>
};
declare function local:toc($doc) {
......
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