Commit f5cf4227 authored by Anne Goloubkoff-Duponchel's avatar Anne Goloubkoff-Duponchel
Browse files

plugin pour gérer les métadonnées

parent 10c2ba69
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
# metadata

Affichage d'une balise unique qui n'a pas d'identifiant par défaut, comme eadheader ou archdesc.
L'url metadata déclenche une route qui permet de récupérer les données xml nécessaires, grâce à la xquery, et de gérer l'affichage avec une xsl par défaut, que le responsable du projet peut surcharger dans son dossier.
+20 −0
Original line number Diff line number Diff line
div#citation {
  margin-top: 10%;
  text-align:left;
  font-size: 95%;
 margin-left:7em;
 margin-right: 12em;
 font-family: "alegreya-sans-server";
font-size: 12px;
}

div#citation .max-doc-title, div#citation .fragmentTitle {
  display: inline;
  white-space: unset;
  overflow: unset;
  max-width:unset;
  text-overflow:unset;
}


+85 −0
Original line number Diff line number Diff line
xquery version "3.0";

module namespace max.plugin.metadata = 'pddn/max/plugin/metadata';
import module namespace max.config = 'pddn/max/config' at '../../rxq/config.xqm';
import module namespace max.util = 'pddn/max/util' at '../../rxq/util.xqm';
import module namespace max.html = 'pddn/max/html' at '../../rxq/html.xqm';
import module namespace max.max = 'pddn/max' at '../../max.xq';
import module namespace max.i18n = 'pddn/max/i18n' at '../../rxq/i18n.xqm';

declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace ead="urn:isbn:1-931666-22-9";

declare variable $max.plugin.metadata:PLUGIN_ID := "metadata";


declare
%rest:GET
%output:method("html")
%output:html-version("5.0")
%output:indent("no")
%output:encoding("UTF-8")
%rest:query-param("search", "{$search}")
%rest:query-param("focus", "{$focus}")
%rest:path("/{$project}/{$doc=.*}/info/{$tag}.html")
function max.plugin.metadata:getMetadataDocument($project, $doc, $tag, $search as xs:string ?, $focus as xs:string ?){
    let $xml := max.plugin.metadata:getXMLByTag($project, $doc, $tag) 
    let $projectXSL := 
         if ($tag='header') 
            then
            file:parent(file:parent(file:parent(static-base-uri())))||"editions/"||$project||"/ui/xsl/ead/ead_header.xsl"
            else (file:parent(file:parent(file:parent(static-base-uri())))||"editions/"||$project||"/ui/xsl/ead/ead_archdesc.xsl")
    (: let $pluginXSL := file:parent(static-base-uri()) || '_metadata.xsl' :)
    let $maxXSL := max.util:getDefaultTextXSL($project)
    let $xsl := if (file:exists($projectXSL))
                then $projectXSL
                else $maxXSL
    let $html := max.html:render(
            $project, $doc,
            <div>
                <div>{max.html:invokePluginXQueries($project, $doc, ())}</div>
                <div id='text'>
                  {xslt:transform(
                    $xml, 
                    $xsl,
                    map {
                        'project' : $project,
                        'locale': max.i18n:getLang($project)
                        })}  
                </div>
            </div>)
            return $html 
};

declare function max.plugin.metadata:getXMLByTag($project, $doc, $tag){
     switch ($tag)
        case "header" return
            try{
                    let $queryHeader := 'doc("'||$project || '/' || $doc ||'")//*:ead/*:eadheader'
                    return 
                    xquery:eval($queryHeader,map
                        {
                        'project':$project,
                        'locale': max.i18n:getLang($project)
                        })
                }
                catch *{
                <div class='error'>{'Error [' || $err:code || '/' || $err:module || '/' || $err:line-number ||']: ' || $err:description}</div>
                }
        case "description" return
            try{
                
                    let $queryArchdesc := '<div>{doc("'||$project || '/' || $doc ||'")/*:ead/*:archdesc/* except doc("'||$project || '/' || $doc ||'")/*:ead/*:archdesc/*:dsc}</div>'
                    return 
                    xquery:eval($queryArchdesc,map
                        {
                        'project':$project,
                        'locale': max.i18n:getLang($project)
                        })
                }
                catch *{
                <div class='error'>{'Error [' || $err:code || '/' || $err:module || '/' || $err:line-number ||']: ' || $err:description}</div>
                }
        default return
            "MaX - Erreur = Vérifier l'URL" 
};
 No newline at end of file