Commit 27ca40c5 authored by dje's avatar dje
Browse files

simplication ++ table des matières: fichier toc.xq

parent f216929c
Loading
Loading
Loading
Loading
+20 −1
Changes for max.xq: 20 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -10,6 +10,25 @@ 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';
import module namespace request = "http://exquery.org/ns/request";


(:MaX Home:)
declare
%rest:GET
%output:method("html")
%rest:path( "/max")
function max:home(){
   <html>
     <head>
       <title>MaX - Moteur d&#39;affichage XML</title>
       <link rel="stylesheet" type="text/css" href='{max.config:getBaseURI() || "/max/core/ui/css/max.css"}'/>
     </head>
     <body class='maxhome'>
       <div>MaX</div>
     </body>
   </html>
};


(:
declare option db:chop 'false';
:)
@@ -19,7 +38,7 @@ declare
%rest:GET
%output:method("html")
%rest:path( "/editions/{$project}")
function max:home($project){
function max:projectHome($project){
   web:redirect(request:uri() || '/accueil')
};

+4 −4
Changes for package.json: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -10,13 +10,13 @@
    "bootstrap": "^4.3.1",
    "jquery": "^3.3.1",
    "popper.js": "^1.14.7"

  },
  "license": "CECILL",
  "private": true,
  "scripts": {
  },
  "scripts": {},
  "dependencies": {
    "install": "^0.12.1"
    "install": "^0.12.1",
    "readline": "^1.3.0",
    "xmldom": "^0.1.27"
  }
}
+2 −5
Changes for rxq/config.xqm: 2 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -91,14 +91,11 @@ declare function max.config:getPluginsBaseURI($project) as xs:string{
(:
  gets a project toc  type from config file
:)
declare function max.config:getTOCType($projectId) as xs:string{
  (: try{ :)
(: declare function max.config:getTOCType($projectId) as xs:string{
     max.config:checkConfiguration($projectId),
     let $type := string(doc($max.config:CONFIGURATION_FILE)//edition[@xml:id=$projectId]/toc/@type)
     return if($type) then $type else 'auto'
   (: }
   catch *{fn:error(xs:QName("err:config"), "Please check your MaX configuration file (duplicate inclusion, wrong inclusion path ...) ")} :)
};
}; :)

(:
  gets a project route list from config file
+2
Changes for rxq/cons.xqm: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ declare variable $max.cons:MENU_FILE := "menu.xml";
(: plugins' folder. :)
declare variable $max.cons:PLUGIN_FOLDER_NAME := "plugins";

(: project toc query :)
declare variable $max.cons:TOC_QUERY_FILEPATH := "xq/toc.xq";

(: document toc query :)
declare variable $max.cons:DOCUMENT_TOC_QUERY_FILEPATH := "xq/document_toc.xq";
+16 −5
Changes for rxq/toc.xqm: 16 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -9,12 +9,23 @@ import module namespace max.util = 'pddn/max/util' at 'util.xqm';

(:get project table of contents:)
declare function max.toc:getProjectTOC($project){
    let $tocType := max.config:getTOCType($project)
  let $tocFile := file:parent(file:parent(static-base-uri()))
                       ||'editions/'
                       ||$project
                       ||'/'
                       ||$max.cons:TOC_QUERY_FILEPATH

  return 
       if(file:exists($tocFile))
           then
             let $query := file:read-text($tocFile)
              return xquery:invoke($tocFile,map 
                  { 'project':$project,
                    'baseURI': max.config:getBaseURI(),
                    'dbPath':max.config:getProjectDBPath($project)
                  })  
           else
               let $resources := max.util:list-db-resources(max.config:getProjectDBPath($project), $max.cons:TOC || '/')
    return switch ($tocType)
           case $max.cons:AUTO_TOC
                  return <div id='routeList'>{$resources}</div>
           default
               return <div id='routeList'>{$resources}</div>
             
};
Loading