Commit 7520ddeb authored by Jerome Chauveau's avatar Jerome Chauveau
Browse files

fetch:xml -> fetch:doc

parent 8be087fc
Loading
Loading
Loading
Loading
+14 −48
Original line number Diff line number Diff line
@@ -49,10 +49,6 @@ function max:favicon(){
};


(:
declare option db:chop 'false';
:)

(:Project's home:)
declare
%rest:GET
@@ -86,12 +82,13 @@ function max:page($project, $page){
        if (not($dbPath))
        then max:max-error(
                ' Configuration manquante pour le projet "'||$project||'" (fichier configuration/configuration.xml)',
                (), (), ())
                (), (), (), ())

        else
        if (not(db:exists($dbPath)))
            then max:max-error(
                    "Oups... La base '"|| $dbPath ||"' n'existe pas !",
                    (), (), ())
                    (), (), (), ())
        else
            try {
                switch ($page)
@@ -122,10 +119,10 @@ function max:page($project, $page){
                            max.util:error404()
                        }
            }
            catch err:config {max:max-error('', $err:description, $err:module, $err:line-number)}
            catch err:FODC0002 {max:max-error('', $err:description, $err:module, $err:line-number)}
            catch err:FODC0007 {max:max-error('Édition inconnue - Veuillez vérifier votre fichier de configuration.', $err:description, $err:module, $err:line-number)}
            catch err:XPTY0004 {max:max-error('Configuration dupliquée - Veuillez vérifier votre fichier de configuration.', $err:description, $err:module, $err:line-number)}
            catch err:config {max:max-error('', $err:description, $err:module, $err:line-number, $err:additional)}
            catch err:FODC0002 {max:max-error('', $err:description, $err:module, $err:line-number, $err:additional)}
            catch err:FODC0007 {max:max-error('Édition inconnue - Veuillez vérifier votre fichier de configuration.', $err:description, $err:module, $err:line-number, $err:additional)}
            catch err:XPTY0004 {max:max-error('Configuration dupliquée - Veuillez vérifier votre fichier de configuration.', $err:description, $err:module, $err:line-number, $err:additional)}
};


@@ -173,7 +170,7 @@ function max:fragmentToHTMLPage($project, $routeDoc, $id, $search as xs:string ?
                return max:applySearchMarkup($html, $search, $focus)
            }
            catch * {
                max:max-error("Erreur code " || $err:code, $err:description, $err:module, $err:line-number)
                max:max-error("Erreur code " || $err:code, $err:description, $err:module, $err:line-number, $err:additional)
            }
};

@@ -296,7 +293,8 @@ declare
%rest:error-param("desc", "{$desc}")
%rest:error-param("module", "{$module}")
%rest:error-param("line", "{$line}")
function max:max-error($message, $desc, $module, $line)
%rest:error-param("stacktrace", "{$stacktrace}")
function max:max-error($message, $desc, $module, $line, $stacktrace)
{
    admin:write-log('MaX error - ' || $message),
    <html>
@@ -317,6 +315,7 @@ function max:max-error($message, $desc, $module, $line)
                                {if ($desc) then <li>Description : <span>{$desc}</span></li> else ()}
                                {if ($module) then <li>Module : <span>{$module}</span></li> else ()}
                                {if ($line) then <li>Line : <span>{$line}</span></li> else ()}
                                {if ($stacktrace) then <li>stacktrace : <span>{$stacktrace}</span></li> else ()}
                            </ul>
                        </div>
                    else ()
@@ -326,6 +325,7 @@ function max:max-error($message, $desc, $module, $line)
    </html>
};


declare
%rest:GET
%output:method("xml")
@@ -357,39 +357,5 @@ declare %private function max:invokePluginXQueries($project, $routeDoc, $id){
            else ()
        return $pluginsHTML
    }
    catch * {max:max-error("Erreur code " || $err:code, $err:description, $err:module, $err:line-number)}
    catch * {max:max-error("Erreur code " || $err:code, $err:description, $err:module, $err:line-number, $err:additional)}
};
 No newline at end of file



(:Call the check plugin method (on a specified project:)
(:declare:)
(:%rest:GET:)
(:%output:method("html"):)
(:%output:html-version("5.0"):)
(:%output:indent("no"):)
(:%output:encoding("UTF-8"):)
(:%rest:path("/{$project}/checkplugins.html"):)
(:function max:checkPlugin($project){:)
(:    let $plugins := max.config:getEnabledPluginNames($project):)
(:    return:)
(:        if (not($plugins)):)
(:        then <div id='pluginsReport'>Aucun plugin pour {$project}.</div>:)
(:        else:)
(:            let $reports :=:)
(:                <ul>{for $plugin in $plugins:)
(:                return:)
(:                    try:)
(:                    {:)
(:                        xquery:invoke(request:uri() || "/../" || $plugin || "/report"):)
(:                    }:)
(:                    catch err:FODC0002 {<div>Méthode {$plugin || "/report"} manquante.</div>}:)
(:                }:)
(:                </ul>:)
(:            let $report :=:)
(:                <div id='pluginsReport'>:)
(:                    <div>Installed plugin(s): {string-join($plugins, ', ')}</div>:)
(:                    {$reports}:)
(:                </div>:)
(:            return $report:)
(:};:)
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ function max.plugin.index:index($project,$type, $focus as xs:string?){
	return
		if(file:exists($indexFilePath))
		then 
			let $content := fetch:xml($indexFilePath, map {'chop' : false()})
			let $content := fetch:doc($indexFilePath)
			let $content := <div id='content'>{$content}</div> 
			let $html := max.html:render($project, 'index/'||$type, $content)
			return if($focus)
+2 −2
Original line number Diff line number Diff line
@@ -217,7 +217,7 @@ as element(div){
    (:on conserve la méthode fetch/parse html en commentaire au cas où ...:)
    (: let $content :=  fetch:xml($fragmentPath, map { 'parser': 'html','htmlparser': map { 'html': false(), 'nodefaults': true() }}) :)
    (: let $contentBody := $content//*:body/*[1] :)
    let $content := fetch:xml($fragmentPath, map {'chop' : false()})
    let $content := fetch:doc($fragmentPath)
    return <div>{$content}</div>
};

@@ -233,7 +233,7 @@ as element(){
declare function max.html:getFooter($project){
    try {
        let $footerPath := max.util:maxHome() || "/editions/" || $project || "/" || $max.cons:EDITION_FOOTER_PATH
        let $content := fetch:xml($footerPath, map {'chop' : false()})
        let $content := fetch:doc($footerPath)
        return $content
    }
    catch * {