Commit 154a782c authored by chauveau's avatar chauveau
Browse files

plugin indexation v1 + modifs ordre chargement CSS + i18n sous-menus

parent 6b532d32
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
  "main": "gulpfile.js",
  "dependencies": {
    "fs": "0.0.2",
    "gulp-util": "^3.0.7",
    "readline": "^1.3.0",
    "xmldom": "^0.1.21"
  },
+1 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ The fact that you are presently reading this means that you have had
knowledge of the CeCILL-B license and that you accept its terms.
-->

<xsl:stylesheet	version="1.0" 
<xsl:stylesheet	version="2.0" 
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:tei="http://www.tei-c.org/ns/1.0"
                exclude-result-prefixes="tei xsl">
+28 −0
Original line number Diff line number Diff line
.index-letter-block{
  list-style-type: none;
  clear:both;
  font-size:10px;
  border-top: 2px solid #aaa;
}
.index-letter-block > ul > li{
  list-style-type: none;
  width:24%;
  float: left;
  border:1px solid #ccc;
  margin:2px;
  min-height: 200px;
  padding:2px;
  background-color: #eee;
}

li.fr:nth-of-type(1){
  color: green;
}

.index-block{
  display:flex;
  flex-direction: column;
  justify-content:space-between;
}

a.index-link:after{content:" | "}
 No newline at end of file
+168 −0
Original line number Diff line number Diff line
(:
Copyright Université de Caen Normandie
Esplanade de la paix
CS 14032
14032 Caen CEDEX 5
Contributeur : Jérôme Chauveau,
2016

jerome.chauveau@unicaen.fr

Ce logiciel est un programme informatique servant à [rappeler les
caractéristiques techniques de votre logiciel]. 

Ce logiciel est régi par la licence CeCILL-B soumise au droit français et
respectant les principes de diffusion des logiciels libres. Vous pouvez
utiliser, modifier et/ou redistribuer ce programme sous les conditions
de la licence CeCILL-B telle que diffusée par le CEA, le CNRS et l'INRIA 
sur le site "http://www.cecill.info".

En contrepartie de l'accessibilité au code source et des droits de copie,
de modification et de redistribution accordés par cette licence, il n'est
offert aux utilisateurs qu'une garantie limitée.  Pour les mêmes raisons,
seule une responsabilité restreinte pèse sur l'auteur du programme,  le
titulaire des droits patrimoniaux et les concédants successifs.

A cet égard  l'attention de l'utilisateur est attirée sur les risques
associés au chargement,  à l'utilisation,  à la modification et/ou au
développement et à la reproduction du logiciel par l'utilisateur étant 
donné sa spécificité de logiciel libre, qui peut le rendre complexe à 
manipuler et qui le réserve donc à des développeurs et des professionnels
avertis possédant  des  connaissances  informatiques approfondies.  Les
utilisateurs sont donc invités à charger  et  tester  l'adéquation  du
logiciel à leurs besoins dans des conditions permettant d'assurer la
sécurité de leurs systèmes et ou de leurs données et, plus généralement, 
à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. 

Le fait que vous puissiez accéder à cet en-tête signifie que vous avez 
pris connaissance de la licence CeCILL-B, et que vous en avez accepté les
termes.
=========================================================================
Copyright Université de Caen Normandie
Esplanade de la paix
CS 14032
14032 Caen CEDEX 5
Contributor : Jérôme Chauveau,
2016

jerome.chauveau@unicaen.fr

This software is a computer program whose purpose is to [describe
functionalities and technical features of your software].

This software is governed by the CeCILL-B license under French law and
abiding by the rules of distribution of free software.  You can  use, 
modify and/ or redistribute the software under the terms of the CeCILL-B
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info". 

As a counterpart to the access to the source code and  rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty  and the software's author,  the holder of the
economic rights,  and the successive licensors  have only  limited
liability. 

In this respect, the user's attention is drawn to the risks associated
with loading,  using,  modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean  that it is complicated to manipulate,  and  that  also
therefore means  that it is reserved for developers  and  experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or 
data to be ensured and,  more generally, to use and operate it in the 
same conditions as regards security. 

The fact that you are presently reading this means that you have had
knowledge of the CeCILL-B license and that you accept its terms.
:)
module namespace max.plugin.index = 'pddn/max/plugin/index';
import module namespace max.config = 'pddn/max/config' at '../../rxq/config.xqm';
import module namespace max.html = 'pddn/max/html' at '../../rxq/html.xqm';

(:
returns index fragment if exists (already generated)
returns a news generated one if not
:)
declare
%rest:GET
%output:method("html")
%rest:path("/editions/{$project}/index")
function max.plugin.index:index($project){
  let $indexFilePath :=file:parent(file:parent(file:parent(static-base-uri()))) || '/editions/'||$project||'/fragments/index.frag.html'
  return
    if(file:exists($indexFilePath))
    then 
          let $content := <div id='content'>{doc($indexFilePath)}</div>
          return max.html:wrapInHTML($project, 'index', $content)
    else max.plugin.index:generateIndex($project)
};

declare
%rest:GET
%output:method("html")
%rest:path("/editions/{$project}/generateindex")
function max.plugin.index:generateIndex($project){
  try{
    let $indexFilePath :=file:parent(file:parent(file:parent(static-base-uri()))) || '/editions/'||$project||'/fragments/index.frag.html'
    let $dbPath := max.config:getProjectDBPath($project)
    let $backToTextPath := max.config:getPluginParameterValue($project, 'index', 'backToText')
    let $persons := <listPerson>
    {
      for $i at $p in collection($dbPath)//*:name[@*:type='personne' and @*:ref]
        group by $ref:=$i/@*:ref
        return if(starts-with($ref,'http'))
        then ()
        else
        let $id := substring-after($ref,'#')
        return if(not($id))
                         then error(xs:QName('max.error'),'ID IS -' || $ref)
                else
                let $url := max.config:getPluginParameterValue($project, 'index', 'url') || $id ||'.xml'
                let $request :=
                <http:request href='{$url}' 
                  method='post' username="{max.config:getPluginParameterValue($project, 'index', 'login')}"
                  password="{max.config:getPluginParameterValue($project, 'index', 'password')}" send-authorization='true'>
                  <http:body media-type='application/xml'>
                    <query xmlns="http://basex.org/rest">
                      <text><![CDATA[
                          <person xml:id='{//*:TEI/@xml:id/string()}'>{//*:TEI//*:person}
                          </person>
                          ]]></text>
                    </query>
                  </http:body>
                </http:request>
               let $person := http:send-request($request)
               let $occurs:=
                       <div type='occurs'>{
                         for $n at $j in collection($dbPath)//*:name[@*:type='personne' and @*:ref=$ref]
                           let $target:=substring-after(base-uri($n),$dbPath)||'/'||xquery:eval($backToTextPath, map { '': $n})
                           return <a target="./{$target}">{$j}</a>
                         }
                       </div>
               return
                 <item>{$person}{$occurs}</item>

     }</listPerson>
     let $HTMLIndex := xslt:transform($persons, 'indexing.xsl', ())
     (:return file:write($indexFilePath, <div class='index'>{$HTMLIndex}</div>), max.plugin.index:index($project):)
     return  max.html:wrapInHTML($project, 'index', <div class='index'>{$HTMLIndex}</div>)
   }
   catch experr:HC0001{<div>Check your Index Plugin Config- TRACE:  {$err:description} -  {$err:module} - {$err:line-number}</div>}      
            (:
               <person>          
                 <name>{($person//*:persName[@xml:lang='fr'])[1]/text()} - FR</name>
                 <name>{($tei//*:persName[@xml:lang='la'])[1]/text()} - LA</name>
                 {
                   if($i/@*:nymRef)
                   then <li>TODO / nymRef</li>
                   else ()
                 }
               </person>  
              :)
   
 (: for $i in collection($project)//*:name[@*:type='personne' and @*:ref]
  return <li>{$i} - {$i/@*:ref/string()}</li>
  
  :)
};
 No newline at end of file
+141 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright Université de Caen Normandie
Esplanade de la paix
CS 14032
14032 Caen CEDEX 5
Contributeur : Jérôme Chauveau,
2016

jerome.chauveau@unicaen.fr

Ce logiciel est un programme informatique servant à [rappeler les
caractéristiques techniques de votre logiciel]. 

Ce logiciel est régi par la licence CeCILL-B soumise au droit français et
respectant les principes de diffusion des logiciels libres. Vous pouvez
utiliser, modifier et/ou redistribuer ce programme sous les conditions
de la licence CeCILL-B telle que diffusée par le CEA, le CNRS et l'INRIA 
sur le site "http://www.cecill.info".

En contrepartie de l'accessibilité au code source et des droits de copie,
de modification et de redistribution accordés par cette licence, il n'est
offert aux utilisateurs qu'une garantie limitée.  Pour les mêmes raisons,
seule une responsabilité restreinte pèse sur l'auteur du programme,  le
titulaire des droits patrimoniaux et les concédants successifs.

A cet égard  l'attention de l'utilisateur est attirée sur les risques
associés au chargement,  à l'utilisation,  à la modification et/ou au
développement et à la reproduction du logiciel par l'utilisateur étant 
donné sa spécificité de logiciel libre, qui peut le rendre complexe à 
manipuler et qui le réserve donc à des développeurs et des professionnels
avertis possédant  des  connaissances  informatiques approfondies.  Les
utilisateurs sont donc invités à charger  et  tester  l'adéquation  du
logiciel à leurs besoins dans des conditions permettant d'assurer la
sécurité de leurs systèmes et ou de leurs données et, plus généralement, 
à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. 

Le fait que vous puissiez accéder à cet en-tête signifie que vous avez 
pris connaissance de la licence CeCILL-B, et que vous en avez accepté les
termes.
=========================================================================
Copyright Université de Caen Normandie
Esplanade de la paix
CS 14032
14032 Caen CEDEX 5
Contributor : Jérôme Chauveau,
2016

jerome.chauveau@unicaen.fr

This software is a computer program whose purpose is to [describe
functionalities and technical features of your software].

This software is governed by the CeCILL-B license under French law and
abiding by the rules of distribution of free software.  You can  use, 
modify and/ or redistribute the software under the terms of the CeCILL-B
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info". 

As a counterpart to the access to the source code and  rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty  and the software's author,  the holder of the
economic rights,  and the successive licensors  have only  limited
liability. 

In this respect, the user's attention is drawn to the risks associated
with loading,  using,  modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean  that it is complicated to manipulate,  and  that  also
therefore means  that it is reserved for developers  and  experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or 
data to be ensured and,  more generally, to use and operate it in the 
same conditions as regards security. 

The fact that you are presently reading this means that you have had
knowledge of the CeCILL-B license and that you accept its terms.
-->

<xsl:stylesheet	version="2.0" 
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:tei="http://www.tei-c.org/ns/1.0"
                exclude-result-prefixes="tei xsl">
                
                <xsl:output method="xml" encoding="utf-8"/>
<xsl:template match='/'>  
  <ul>
    <xsl:for-each-group select="//tei:person" group-by="substring(normalize-space(string-join(.//tei:persName//text(),'')),1,1)">
      <xsl:sort select="current-grouping-key()" />
      <li class="index-letter-block">
        <h2><xsl:value-of select="current-grouping-key()"/></h2>
            <ul>
              <xsl:for-each select="current-group()">
                <xsl:sort select="." />          
                <li class='index-block'><h3><xsl:value-of select="./ancestor::*:person[last()]/@xml:id"/></h3>
                  <ul>
                    <xsl:apply-templates />
                  </ul>
                  <xsl:apply-templates select="./ancestor::*:item[last()]/*:div[@*:type='occurs']"/>
                </li>
             </xsl:for-each>
           </ul>
        </li>
    </xsl:for-each-group>
  </ul>
</xsl:template>
     
<xsl:template match='tei:persName'>
  <xsl:variable name='class'><xsl:value-of select="@xml:lang"/></xsl:variable>
  <!--<xsl:if test="$class='fr'">
    <li>ID = <xsl:value-of select="./ancestor::*:person[last()]/@xml:id"/></li>
  </xsl:if>-->
  <li class='{$class}'><xsl:value-of select="."/><span class='lang'> [<xsl:value-of select="$class"/>]</span></li>
</xsl:template>     
     
<xsl:template match='tei:birth'>
  <li class='birth'>Né(e) le <xsl:value-of select="."/></li>
</xsl:template> 
<xsl:template match='tei:death'>
  <li class='death'>Décédé(e) le <xsl:value-of select="."/></li>
</xsl:template>

<xsl:template match='div'>
  <div class='occurs'><xsl:apply-templates /></div>
</xsl:template>
<xsl:template match='a'>
  <a class='index-link' href='{./@target}'><xsl:value-of select="."/></a>
</xsl:template>

<xsl:template match='tei:occupation | tei:note'>
<!-- TODO -->
</xsl:template>


<!--  
           
<xsl:for-each-group select="record" group-by="info/date">
</xsl:for-each-group>
  -->
</xsl:stylesheet>
 No newline at end of file
Loading