Commit fed9d8f4 authored by Jérôme Chauveau's avatar Jérôme Chauveau
Browse files

remove useless code

parent 611b88aa
Loading
Loading
Loading
Loading
+20 −35
Changes for app/app.xqm: 20 added lines, 35 removed lines.
Original line number Diff line number Diff line
xquery version "3.1";
module namespace app = "app";

(:declare:)
(:%rest:GET:)
(:%output:method("html"):)
(:%output:html-version('5'):)
(:%rest:path("/xsltinfos"):)
(:function app:xslt-infos(){:)
(:    <ul>:)
(:        <li>Processor : {xslt:processor()} </li>:)
(:        <li>Version : {xslt:version()} </li>:)
(:    </ul>:)
(:};:)

declare
%rest:GET
@@ -19,33 +8,18 @@ declare
%output:html-version('5')
%rest:path("/test")
function app:test(){
    app:render(<p>This is a test ! </p>)
};


declare %private function app:make-menu(){
        let $transUrl := request:scheme() || '://' || request:hostname() || ':' || request:port() || '/translations'
        let $xml := db:get('test','MANIFEST.xml')
    return xslt:transform(
        let $content := xslt:transform(
                    $xml,
                doc('xsl/menu.xsl'),
                map {'lang' : 'fr', 'translationsUrl': $transUrl}
                    doc('xsl/example.xsl'),
                    map {'translationsUrl': $transUrl}
                )
        let $menu := xslt:transform(
                    <dummy/>,
                    doc('xsl/example.xsl'),
                    map {'translationsUrl': $transUrl}
                    )
};


declare
%rest:GET
%output:method("html")
%output:html-version('5')
%rest:path("/translations")
function app:get-translations(){
    db:get('test','translations.xml')
};


declare %private function app:render($content as node()){
    let $menu := app:make-menu()
        return
            <html lang="en">
                <head>
@@ -53,13 +27,24 @@ declare %private function app:render($content as node()){
                    <title>Title</title>
                </head>
                <body>
                <nav>{$menu}</nav>
                    <nav>
                        {$menu}
                    </nav>
                    <main>
                        {$content}
                    </main>
                </body>
            </html>
};


declare
%rest:GET
%output:method("html")
%output:html-version('5')
%rest:path("/translations")
function app:get-translations(){
    db:get('test','translations.xml')
};

app/xsl/example.xsl

0 → 100644
+31 −0
Changes for app/xsl/example.xsl: 31 added lines, 0 removed lines.
Original line number Diff line number Diff line
<xsl:stylesheet version="3.1"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:mets="http://www.loc.gov/METS/"
                xmlns:xlink="http://www.w3.org/1999/xlink"
                xmlns:i18n="app/test/i18n"
                exclude-result-prefixes="xsl mets xlink i18n">


    <xsl:output method="xml" indent="yes"/>

    <xsl:param name="translationsUrl"/>

    <xsl:import href="i18n.xsl"/>

    <xsl:template match="/">
        <section>
            <xsl:apply-templates select="//mets:div"/>
        </section>

    </xsl:template>


    <xsl:template match="//mets:div">
        <div>
            <xsl:value-of select="i18n:trans('hello', $translationsUrl)"/>
        </div>

    </xsl:template>


</xsl:stylesheet>
 No newline at end of file

app/xsl/menu.xsl

deleted100644 → 0
+0 −189
Changes for app/xsl/menu.xsl: 0 added lines, 189 removed lines.
Original line number Diff line number Diff line
<xsl:stylesheet version="3.1"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:mets="http://www.loc.gov/METS/"
                xmlns:xlink="http://www.w3.org/1999/xlink"
                xmlns:i18n="app/test/i18n"
                exclude-result-prefixes="xsl mets xlink i18n">


    <xsl:output method="xml" indent="yes"/>

    <xsl:param name="base_uri"/>
    <xsl:param name="project_id"/>
    <xsl:param name="lang"/>
    <xsl:param name="with_index"/>
    <xsl:param name="with_figure"/>

    <xsl:param name="translationsUrl"/>

    <xsl:import href="i18n.xsl"/>

    <xsl:template match="/">
        <xsl:apply-templates select="//mets:structMap"/>
    </xsl:template>


    <xsl:template match="//mets:structMap">
        <div class="d-flex justify-content-between flex-grow-1">
        <ul class="navbar-nav">
            <xsl:apply-templates select="./mets:div[@TYPE='livre']/mets:div"/>

            <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle"
                   href="#" role="button" data-bs-toggle="dropdown"
                   aria-expanded="true">
                    <xsl:value-of select="i18n:trans('menu.navtools',translationsUrl)"/>
                </a>
                <ul class="dropdown-menu" data-bs-popper="static">
                    <li class="nav-item">
                        <a class="nav-link">
                            <xsl:attribute name="href">
                                <xsl:value-of select="concat($base_uri, $project_id,'/',$lang,'/','plan.html')"/>
                            </xsl:attribute>
                            <xsl:value-of select="i18n:trans('menu.toc', $translationsUrl)"/>
                        </a>
                    </li>
                    <xsl:if test="$with_index='true'">
                        <li>
                            <a class="nav-link">
                                <xsl:attribute name="href">
                                    <xsl:value-of select="concat($base_uri, $project_id,'/',$lang,'/','g-index.html')"/>
                                </xsl:attribute>
                                <xsl:value-of select="i18n:trans('menu.index',$translationsUrl)"/>
                            </a>
                        </li>
                    </xsl:if>
                    <xsl:if test="$with_figure='true'">
                        <li>
                            <a class="nav-link">
                                <xsl:attribute name="href">
                                    <xsl:value-of select="concat($base_uri, $project_id,'/',$lang,'/','g-figures.html')"/>
                                </xsl:attribute>
                                <xsl:value-of select="i18n:trans('menu.figures', $translationsUrl)"/>
                            </a>
                        </li>
                    </xsl:if>
                </ul>
            </li>
        </ul>
        </div>
    </xsl:template>


    <!-- entrées de menu de premier niveau -->
    <xsl:template match="//mets:div[@TYPE='livre']/mets:div[@LABEL]">
        <li class="nav-item" data-type="livre">
            <xsl:choose>
                <!-- cas particulier de l'entrée de menu qui pointe vers la tdm @subtype=edition -->
                <xsl:when test="./[@TYPE]='edition'">
                    <a class="nav-link" data-type="toc">
                        <xsl:attribute name="href">
                            <xsl:value-of
                                select="concat($base_uri, $project_id,'/',$lang,'/','sommaire/',string(@DMDID),'.html')"/>
                       </xsl:attribute>

                        <xsl:attribute name="data-tocid">
                            <xsl:value-of select="string(@DMDID)"/>
                        </xsl:attribute>

                        <xsl:value-of select="i18n:trans(./@LABEL/data(), $translationsUrl)"/>
                    </a>
                </xsl:when>

                <!-- entrée de menu avec lien direct vers fichier -->
                <xsl:when test="count(./mets:fptr)=1">
                     <a class="nav-link" aria-disabled="true">
                        <xsl:variable name="pointer">
                            <xsl:value-of select="./mets:fptr/@FILEID/data()"/>
                        </xsl:variable>
                        <xsl:attribute name="href">
                            <xsl:value-of
                                    select="replace(concat($base_uri, $project_id,'/',$lang,'/',replace(./ancestor::*//mets:fileGrp[@ID='tei_files']/mets:file[@ID=$pointer]/mets:FLocat/@xlink:href/data(),'sources/','')),'.xml','.html')"/>
                        </xsl:attribute>

                        <xsl:value-of select="i18n:trans(./@LABEL/data(), $translationsUrl)"/>
                    </a>
                </xsl:when>

                <!-- div avec des sous-divs -> dropdown menu -->
                <xsl:when test="count(./mets:div[@LABEL]) > 0">
                    <xsl:attribute name="class">
                        <xsl:text>nav-item dropdown</xsl:text>
                    </xsl:attribute>
                    <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown"
                       aria-expanded="false">
                        <xsl:value-of select="i18n:trans(./@LABEL/data(), $translationsUrl)"/>
                    </a>
                    <ul class="dropdown-menu">
                        <xsl:apply-templates select="./mets:div[@LABEL]"/>
                    </ul>
                </xsl:when>

                <!-- index généré en entrée principal de menu -->
                <xsl:when test="count(./*) = 0 and @TYPE='index'">
                    <a class="nav-link" aria-disabled="true">
                        <xsl:attribute name="href">
                            <xsl:value-of select="concat($base_uri, $project_id, '/', $lang, '/indexes/', string(./@LABEL), '.html')"/>
                        </xsl:attribute>
                        <xsl:attribute name="data-type">index</xsl:attribute>
                        <xsl:value-of select="i18n:trans(./@LABEL/data(), $translationsUrl)"/>
                    </a>
                </xsl:when>

            </xsl:choose>
        </li>

    </xsl:template>


    <!-- sous-entrées -->
    <xsl:template match="//mets:div[@TYPE='livre']/mets:div[@LABEL]//mets:div[@LABEL]">
        <xsl:choose>
            <xsl:when test="@TYPE='souspartie'">
                <li class="nav-item" data-type="souspartie">
                    <a class="nav-link" aria-disabled="true">
                        <xsl:attribute name="href">
                            <xsl:variable name="dmid">
                                <xsl:value-of select="@DMDID"/>
                            </xsl:variable>
                            <xsl:value-of
                                    select="concat($base_uri, $project_id,'/',$lang,'/','sommaire/', $dmid, '.html')"/>
                        </xsl:attribute>
                        <xsl:attribute name="data-tocid"><xsl:value-of select="string(@DMDID)"/></xsl:attribute>

                        <xsl:value-of select="./@LABEL/data()"/>
                    </a>
                </li>
            </xsl:when>
            <xsl:otherwise>
                <li class="nav-item">
                    <a class="nav-link" aria-disabled="true">
                        <xsl:if test="./mets:fptr[@FILEID]">
                             <xsl:variable name="pointer">
                                    <xsl:value-of select="./mets:fptr/@FILEID/data()"/>
                             </xsl:variable>
                            <xsl:attribute name="href">
                                <xsl:value-of
                                        select="replace(replace(concat($base_uri,$project_id,'/',$lang,'/', ./ancestor::*//mets:fileGrp[@ID='tei_files']/mets:file[@ID=$pointer]/mets:FLocat/@xlink:href/data()),'.xml','.html'), 'sources/','')"/>
                            </xsl:attribute>
                            <xsl:attribute name="data-fileid"><xsl:value-of select="./mets:fptr/@FILEID"/></xsl:attribute>
                            <xsl:attribute name="data-href"><xsl:value-of select="./ancestor::*//mets:fileGrp[@ID='tei_files']/mets:file[@ID=$pointer]/mets:FLocat/@xlink:href/data()"/></xsl:attribute>
                        </xsl:if>

                        <xsl:if test="@TYPE='index'">
                            <xsl:attribute name="href">
                                <xsl:value-of select="concat($base_uri, $project_id, '/', $lang, '/indexes/', string(./@LABEL), '.html')"/>
                            </xsl:attribute>
                            <xsl:attribute name="data-type">index</xsl:attribute>
                        </xsl:if>

                        <xsl:value-of select="i18n:trans(./@LABEL/data(), $translationsUrl)"/>

                    </a>
                </li>
            </xsl:otherwise>
        </xsl:choose>

    </xsl:template>

</xsl:stylesheet>
 No newline at end of file
+0 −4
Changes for data/translations.xml: 0 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -2,8 +2,4 @@
        <translation xml:lang="fr" key="hello">salut</translation>
        <translation xml:lang="fr" key="gm">bonjour</translation>
        <translation xml:lang="fr" key="ge">bonsoir</translation>
        <translation xml:lang="fr" key="meta.dir">directeur</translation>
        <translation xml:lang="fr" key="meta.language">directeur</translation>
        <translation xml:lang="fr" key="meta.abstract">résumé</translation>
        <translation xml:lang="fr" key="meta.keywords">mots-clés</translation>
    </translations>
 No newline at end of file