Loading src/main/core/routes.xqm +43 −6 Original line number Diff line number Diff line Loading @@ -178,8 +178,6 @@ function routes:max-infos() as element(){ <meta charset="UTF-8"/> <title>MaX - infos</title> <link rel='stylesheet' type='text/css' href='static/max.css'/> <style> </style> </head> <body> Loading Loading @@ -215,10 +213,33 @@ function routes:max-infos() as element(){ } </ul> </section> <section> <h2>Bundles</h2> <ul> { for $b in file:list(utils:get-bundles-path()) let $name := replace($b,'/','') let $enabled := not(file:exists(utils:get-bundles-path() || $b || '.ignore')) return if($enabled) then <li>{$name} <input type="checkbox" checked="checked" title="désactiver le bundle" onclick="fetch('/setbundle?enabled=' + this.checked + '&bundle={$name}').then(() => window.location.reload(true));"/></li> else <li>{$name} <input type="checkbox" title="activer le bundle" onclick="fetch('/setbundle?enabled=' + this.checked + '&bundle={$name}').then(() => window.location.reload(true));"/></li> } </ul> </section> <section> <h2>Routes</h2> {routes:list()} </section> <section> <h2>Documentation</h2> <div> Loading @@ -234,20 +255,36 @@ function routes:max-infos() as element(){ (:~ : @return routes list as html :) declare %private function routes:list(){ declare %private function routes:list() as element(){ let $wadl:=rest:wadl() let $maxRoutes := <ul>{ for $r in $wadl//*:resource[@*:path] return let $path:= string($r/@*:path) return if(fn:contains($path,'max') or fn:contains($path,'$lang=') ) then <li>{$path}</li> else() let $method := string($r/*:method/@name) (:ignore other basex webapp routes:) return if(fn:starts-with($path,'/dba') or $path='' or fn:starts-with($path,'/chat') or not(contains($method,'GET'))) then () else if(not(contains($path, '$'))) then <li><a target="_blank" href="{$path}">{$path}</a></li> else <li>{$path}</li> }</ul> return $maxRoutes }; declare %rest:path("/setbundle") %rest:query-param("bundle","{$bundle}") %rest:query-param("enabled","{$enabled}") function routes:set-bundle-enabled($bundle as xs:string, $enabled as xs:boolean) as empty-sequence(){ let $ignorePath := utils:get-bundles-path() || $bundle || '/.ignore' return if($enabled) then file:delete($ignorePath) else file:write($ignorePath, '') }; (:~ : Returns a static file. Loading Loading
src/main/core/routes.xqm +43 −6 Original line number Diff line number Diff line Loading @@ -178,8 +178,6 @@ function routes:max-infos() as element(){ <meta charset="UTF-8"/> <title>MaX - infos</title> <link rel='stylesheet' type='text/css' href='static/max.css'/> <style> </style> </head> <body> Loading Loading @@ -215,10 +213,33 @@ function routes:max-infos() as element(){ } </ul> </section> <section> <h2>Bundles</h2> <ul> { for $b in file:list(utils:get-bundles-path()) let $name := replace($b,'/','') let $enabled := not(file:exists(utils:get-bundles-path() || $b || '.ignore')) return if($enabled) then <li>{$name} <input type="checkbox" checked="checked" title="désactiver le bundle" onclick="fetch('/setbundle?enabled=' + this.checked + '&bundle={$name}').then(() => window.location.reload(true));"/></li> else <li>{$name} <input type="checkbox" title="activer le bundle" onclick="fetch('/setbundle?enabled=' + this.checked + '&bundle={$name}').then(() => window.location.reload(true));"/></li> } </ul> </section> <section> <h2>Routes</h2> {routes:list()} </section> <section> <h2>Documentation</h2> <div> Loading @@ -234,20 +255,36 @@ function routes:max-infos() as element(){ (:~ : @return routes list as html :) declare %private function routes:list(){ declare %private function routes:list() as element(){ let $wadl:=rest:wadl() let $maxRoutes := <ul>{ for $r in $wadl//*:resource[@*:path] return let $path:= string($r/@*:path) return if(fn:contains($path,'max') or fn:contains($path,'$lang=') ) then <li>{$path}</li> else() let $method := string($r/*:method/@name) (:ignore other basex webapp routes:) return if(fn:starts-with($path,'/dba') or $path='' or fn:starts-with($path,'/chat') or not(contains($method,'GET'))) then () else if(not(contains($path, '$'))) then <li><a target="_blank" href="{$path}">{$path}</a></li> else <li>{$path}</li> }</ul> return $maxRoutes }; declare %rest:path("/setbundle") %rest:query-param("bundle","{$bundle}") %rest:query-param("enabled","{$enabled}") function routes:set-bundle-enabled($bundle as xs:string, $enabled as xs:boolean) as empty-sequence(){ let $ignorePath := utils:get-bundles-path() || $bundle || '/.ignore' return if($enabled) then file:delete($ignorePath) else file:write($ignorePath, '') }; (:~ : Returns a static file. Loading