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

projectToc with urlPrefix instead of getDocumentToc

parent 995ebcbd
Loading
Loading
Loading
Loading
+2 −2
Changes for plugins/side_toc/side_toc.js: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -10,8 +10,8 @@ class SideTocPlugin extends Plugin{

  run(){
    console.log("plugin side toc running");

    fetch(`${baseURI}side_toc.html?doc=${route}`).then((res) => res.text().then((toc) => {
    const urlPrefix = baseURI.replace(projectId +'/', '')
    fetch(`${baseURI}side_toc.html?urlPrefix=${urlPrefix}`).then((res) => res.text().then((toc) => {
            document.querySelector('.plugins-wrapper').innerHTML+=toc;
      }))

+3 −3
Changes for plugins/side_toc/side_toc.xqm: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -3,10 +3,10 @@ import module namespace max.toc = 'pddn/max/toc' at '../../rxq/toc.xqm';
declare
%rest:GET
%output:method("html")
%rest:query-param("doc", "{$doc}")
%rest:query-param("urlPrefix", "{$urlPrefix}")
%rest:path("/{$project}/side_toc.html")
function max.plugin.side_toc:toc($project, $doc){
    let $toc := max.toc:getDocumentTOC($project, $doc)
function max.plugin.side_toc:toc($project, $urlPrefix){
    let $toc := max.toc:getProjectTOC($project, $urlPrefix)
(:    let $input := <input type="hidden" name="currentTocItem" value="{$project}/{$doc}/{$id}"></input>:)
    return <div class='side-toc'>{$toc}</div>
};
 No newline at end of file
+5 −1
Changes for rxq/toc.xqm: 5 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -8,6 +8,10 @@ import module namespace max.i18n = 'pddn/max/i18n' at 'i18n.xqm';

(:get project table of contents:)
declare function max.toc:getProjectTOC($project){
    max.toc:getProjectTOC($project, max.util:getRelativeRootPath(()))
};

declare function max.toc:getProjectTOC($project, $urlPrefix){

    let $tocFile := max.util:getResourceFilePath($project, "editions/"||$project ||'/'||$max.cons:TOC_QUERY_FILEPATH)
    let $xml :=
@@ -16,7 +20,7 @@ declare function max.toc:getProjectTOC($project){
            xquery:eval(xs:anyURI($tocFile),map
            {
            'project':$project,
            'baseURI': max.util:getRelativeRootPath(()),
            'baseURI': $urlPrefix,
            'dbPath':max.config:getProjectDBPath($project),
            'locale': max.i18n:getLang($project)
            })