Commit d7f02193 authored by dje's avatar dje
Browse files

simplication ++: suppression de la notion de route. Il en reste sûrement des traces...

parent 5ff489fb
Loading
Loading
Loading
Loading
+7 −16
Changes for max.xq: 7 added lines, 16 removed lines.
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ module namespace max = 'pddn/max';
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.route = 'pddn/max/route' at 'rxq/route.xqm';
import module namespace max.toc = 'pddn/max/toc' at 'rxq/toc.xqm';
import module namespace max.cons = 'pddn/max/cons' at 'rxq/cons.xqm';
import module namespace max.api = 'pddn/max/max_api' at 'rxq/max_api.xqm';
import module namespace max.plugin.pager = 'pddn/max/plugin/pager' at 'plugins/pager/pager.xqm';
@@ -32,9 +32,9 @@ declare
function max:page($project, $page){
  try{
   switch($page)
   case "parcours"
   case "sommaire"
       return 
         let $content := max.route:HTMLRouteList($project)
         let $content := max.toc:getProjectTOC($project)
         return max.html:render($project, $page, $content)     
   case "accueil"
     (:if 'accueil' frag does not exists -> display route list by default:)
@@ -50,7 +50,7 @@ function max:page($project, $page){
       }
      catch *{
        admin:write-log('Page/fragment "'||$page ||'" introuvable ou mal formé', 'INFO'),
        let $content := max.route:HTMLRouteList($project)
        let $content := max.toc:getProjectTOC($project)
        return max.html:render($project, $page, $content)
      }

@@ -72,14 +72,9 @@ declare
%rest:GET
%output:method("html")
%output:indent("no")
%rest:path("/editions/{$project}/parcours/{$routeDoc=[^plugins].*\.xml|.*\.svg}")
function max:document($project,$routeDoc){
   let $f:= max.route:getRouteQueryFile($project, $routeDoc)
   return
     if(not(file:exists($f)))
       then web:redirect("../doc/" || $routeDoc)
     else
       max.html:render($project, "parcours", max.route:getRouteEntriesAsHTML($project, $routeDoc))   
%rest:path("/editions/{$project}/sommaire/{$doc=[^plugins].*\.xml|.*\.svg}")
function max:documentTOC($project,$doc){
    max.html:render($project, "sommaire", max.toc:getDocumentTOC($project, $doc))
};

(:gets a project's XML fragment + a navigation bar(wrapped in an html skeleton):)
@@ -337,7 +332,3 @@ declare





+2 −3
Changes for plugins/search/search.xqm: 2 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@
module namespace max.plugin.search = 'pddn/max/plugin/search';
import module namespace max.config = 'pddn/max/config' at '../../rxq/config.xqm';
import module namespace max.html = 'pddn/max/html' at '../../rxq/html.xqm';
import module namespace max.route = 'pddn/max/route' at '../../rxq/route.xqm';
import module namespace max.cons = 'pddn/max/cons' at '../../rxq/cons.xqm';
import module namespace max.util = 'pddn/max/util' at '../../rxq/util.xqm';
import module namespace max.i18n = 'pddn/max/i18n' at '../../rxq/i18n.xqm';
@@ -27,14 +26,14 @@ function max.plugin.search:searchPage($project){
    return 
        let $docName := if(contains($route,'/page/'))(:dirty hack for pager href:)
                    then
                      tokenize(substring-before(string($route),'/page/'), $max.cons:ROUTE||'/')[last()]
                      tokenize(substring-before(string($route),'/page/'), $max.cons:TOC||'/')[last()]
                    else    
                      tokenize($route,'/')[last()]
    return  
      if(max.config:isIgnored($docName, $project))
        then ()
      else
        <option value="{tokenize($route, $max.cons:ROUTE||'/')[last()]}">{$docName}</option>  
        <option value="{tokenize($route, $max.cons:TOC||'/')[last()]}">{$docName}</option>  
  }
  </select>
  return
+16 −13
Changes for rxq/alignment.xqm: 16 added lines, 13 removed lines.
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ module namespace max.alignment = 'pddn/max/alignment';
import module namespace max.config = 'pddn/max/config' at 'config.xqm';
import module namespace max.html = 'pddn/max/html' at 'html.xqm';
import module namespace max.util = 'pddn/max/util' at 'util.xqm';
import module namespace max.route = 'pddn/max/route' at 'route.xqm';

(:
  returns 2 identified fragments in an aligned layout
@@ -13,20 +12,20 @@ import module namespace max.route = 'pddn/max/route' at 'route.xqm';
declare
%rest:GET
%output:method("html")
%rest:path("/editions/{$project}/{$routeDoc}/{$id1}/{$id2}")
function max.alignment:alignedHTML($project, $routeDoc, $id1, $id2){
%rest:path("/editions/{$project}/{$doc}/{$id1}/{$id2}")
function max.alignment:alignedHTML($project, $doc, $id1, $id2){
   let $dbPath := max.config:getProjectDBPath($project)
   let $xsltDoc := max.util:buildXSLTDoc(
                                     max.config:getDefaultTextXSL($project),
                                     max.config:getXSLTAddons($project, $routeDoc))                               
                                     max.config:getXSLTAddons($project, $doc))                               
                                     
   let $xsltParams := max.config:getXSLTParams($project, $routeDoc)
   let $xml := max.alignment:runAlignmentQuery($project, $routeDoc, $id1, $id2)
   let $xsltParams := max.config:getXSLTParams($project, $doc)
   let $xml := max.alignment:runAlignmentQuery($project, $doc, $id1, $id2)
   
   let $html:= <div>{xslt:transform($xml, $xsltDoc, $xsltParams)}</div>
                         
   return 
     max.html:render($project,$routeDoc,  $html, $id1)
   (: return <div>{$xsltParams}</div> :)
   return  max.html:render($project,$doc, $html , $id1) 

};

@@ -39,13 +38,17 @@ declare function max.alignment:runAlignmentQuery($project, $routeId, $id1 as xs:
      if($queryFile)
        then xquery:invoke(
            $queryFile, 
            map:merge((map{
            map{
                'fragmentId':$id1,
                'firstPrefix': max.config:getFirstAlignmentPrefix($routeId),
                      'secondPrefix': max.config:getSecondAlignmentPrefix($routeId)
                       }, 
                       max.route:getRouteQueryBindings($project, $routeId)
                       ))
                'secondPrefix': max.config:getSecondAlignmentPrefix($routeId),
                'project':$project,
                'baseURI': max.config:getBaseURI(),
                'dbPath': max.config:getProjectDBPath($project),
                'document': $routeId
                }
                (: max.route:getRouteQueryBindings($project, $routeId) :)
                       
          )
        else max.alignment:runDefaultAlignmentQuery($project, $routeId, $id1, $id2)

+8 −7
Changes for rxq/config.xqm: 8 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -131,7 +131,8 @@ declare function max.config:isWithPager($project) as xs:boolean{
  Checks if a route needs alignment functions
:)
declare function max.config:isAlignedRoute($routeDoc) as xs:boolean{
  string(doc($max.config:CONFIGURATION_FILE)//route[@document=$routeDoc]/@align) = "true"
  count(doc($max.config:CONFIGURATION_FILE)//alignment[@document=$routeDoc]) = 1
  (: string(doc($max.config:CONFIGURATION_FILE)//route[@document=$routeDoc]/@align) = "true" :)
};

(:
@@ -149,18 +150,18 @@ declare function max.config:getRouteTOCBindings($routeDoc){
Returns route's first alignment prefix
:)
declare function max.config:getFirstAlignmentPrefix($routeDoc){
  string(doc($max.config:CONFIGURATION_FILE)//route[@document=$routeDoc]/@first-prefix)
  string(doc($max.config:CONFIGURATION_FILE)//alignment[@document=$routeDoc]/@first-prefix)
};

(:
Returns route's second alignment prefix
:)
declare function max.config:getSecondAlignmentPrefix($routeDoc){
  string(doc($max.config:CONFIGURATION_FILE)//route[@document=$routeDoc]/@second-prefix)
  string(doc($max.config:CONFIGURATION_FILE)//alignment[@document=$routeDoc]/@second-prefix)
};

declare function max.config:getTextAlignmentQueryFile($routeDoc){
  let $filePath:= doc($max.config:CONFIGURATION_FILE)//route[@document=$routeDoc and @align='true']/@align-xquery-file
  let $filePath:= doc($max.config:CONFIGURATION_FILE)//alignment[@document=$routeDoc and @align='true']/@align-xquery-file
  return if($filePath)
         then string("../" || $filePath) 
         else()   
@@ -228,9 +229,9 @@ declare function max.config:getXSLTAddons($project, $routeDoc) as xs:string *{
    )
};

declare function max.config:getXSLTParams($project, $routeDoc){
declare function max.config:getXSLTParams($project, $doc){
  let $alignParams := map:merge(
    for $attr in doc($max.config:CONFIGURATION_FILE)//route[@document=$routeDoc]/@*[local-name(.)='first-prefix' or local-name(.)='second-prefix'] 
    for $attr in doc($max.config:CONFIGURATION_FILE)//alignment[@document=$doc]/@*[local-name(.)='first-prefix' or local-name(.)='second-prefix'] 
    return map:entry(local-name($attr),$attr/string())
  )
  (:Plugin's xslt parameters:)
@@ -243,7 +244,7 @@ declare function max.config:getXSLTParams($project, $routeDoc){
                   map{
                     'baseuri' : max.config:getBaseURI(),
                     'pluginsuri' : max.config:getPluginsBaseURI($project),
                     'route': if($routeDoc) then $routeDoc else '',
                     'route': if($doc) then $doc else '',
                     'project' : $project}))
};

+9 −1
Changes for rxq/cons.xqm: 9 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -10,7 +10,11 @@ declare variable $max.cons:BASE_DIR := "/editions";
declare variable $max.cons:PLUGINS_BASE_DIR := "/plugins";

(: route path name (in URLs):)
declare variable $max.cons:ROUTE := "parcours";
(: declare variable $max.cons:ROUTE := "parcours"; :)

(: TOC path name (in URLs):)
declare variable $max.cons:TOC := "sommaire";


(: MENU file path. :)
declare variable $max.cons:MENU_FILE := "menu.xml";
@@ -18,6 +22,10 @@ declare variable $max.cons:MENU_FILE := "menu.xml";
(: plugins' folder. :)
declare variable $max.cons:PLUGIN_FOLDER_NAME := "plugins";


(: document toc query :)
declare variable $max.cons:DOCUMENT_TOC_QUERY_FILEPATH := "xq/document_toc.xq";

(: Route query file path "editionName" sub directory :)
declare variable $max.cons:ROUTE_QUERY_FILEPATH := "xq/route.xq";

Loading