Commit 7460ca8b authored by Jerome Chauveau's avatar Jerome Chauveau
Browse files

Merge branch 'op/tei2pdf' into 'master'

Modif du plugin tei2pdf

See merge request pdn-certic/MaX!102
parents 26467b17 04a48676
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -10,10 +10,11 @@ import module namespace max.util = 'pddn/max/util' at '../../rxq/util.xqm';
declare
%rest:GET
%rest:produces("application/pdf")
%rest:path("/{$project}/{$routeDoc=.*\.xml}/{$id}.pdf")
function max.plugins.tei2pdf:fragmentToPDF($project, $routeDoc, $id){
%rest:path("/{$project}/{$id}.pdf")
function max.plugins.tei2pdf:fragmentToPDF($project, $id){
    let $dbPath := max.config:getProjectDBPath($project)
    let $teiHeader := doc($dbPath || '/' || $routeDoc)//*:teiHeader
    let $doc := base-uri(root(collection($dbPath)//*[@xml:id=$id or @id=$id]))
    let $teiHeader := doc($doc)//*:teiHeader
    let $content:= max.api:getXMLByID($dbPath, $id)
    let $wrappedContent :=
        if($content//self::*:TEI)
@@ -21,9 +22,10 @@ function max.plugins.tei2pdf:fragmentToPDF($project, $routeDoc, $id){
        else(
        <TEI xmlns="http://www.tei-c.org/ns/1.0">
            <teiHeader>{$teiHeader}</teiHeader>
            <text>{$content}</text>
            <text>{max.api:getXMLByID($dbPath, $id)}</text>
        </TEI>
        )
    
    let $pdf := max.util:xml2pdf($wrappedContent, max.util:getProjectFoXsl($project),$project,$id)
    return
        (<rest:response>
+2 −2
Original line number Diff line number Diff line

declare variable $project external;
declare variable $id external;

<div class="tei2pdf">
    <a role="button" title="Export pdf" target="_blank" href="./{$id}.pdf">
    <a role="button" title="Export pdf" target="_blank" href="/{$project}/{$id}.pdf">
        &#8682;<span class="texte">PDF</span>
    </a>
</div>