Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new app function app:breadcrumb-var2 (#325) #328

Merged
merged 6 commits into from
Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
close #325
  • Loading branch information
jakosch committed Nov 27, 2019
commit de896b7925df7312ae05fc3fb41dfbbc77301a29
12 changes: 12 additions & 0 deletions modules/app.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,18 @@ declare
}
};

declare
%templates:default("lang", "en")
function app:breadcrumb-var2($node as node(), $model as map(*), $lang as xs:string) as element() {
let $docID := $model('docID')
let $breadcrumb := $controller:projectNav[?docID=$docID]?title
return
element {node-name($node)} {
$node/@*,
lang:get-language-string($breadcrumb,$lang)
}
};

declare
%templates:wrap
%templates:default("lang", "en")
Expand Down
60 changes: 51 additions & 9 deletions modules/controller.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,54 @@ import module namespace wdt="http://xquery.weber-gesamtausgabe.de/modules/wdt" a
import module namespace gl="http://xquery.weber-gesamtausgabe.de/modules/gl" at "gl.xqm";
import module namespace functx="http://www.functx.com";



declare variable $controller:projectNav :=
map {
'docID' := 'A070001',
'title' := 'editorialGuidelines'
},
map {
'docID' := 'A070002',
'title' := 'about'
},
map {
'docID' := 'A070003',
'title' := 'bio'
},
map {
'docID' := 'A070004',
'title' := 'faq'
},
map {
'docID' := 'A070006',
'title' := 'projectDescription'
},
map {
'docID' := 'A070009',
'title' := 'contact'
},
map {
'docID' := 'A070010',
'title' := 'editorialGuidelines'
},
map {
'docID' := 'A070011',
'title' := 'volContents'
},
map {
'docID' := 'A070012',
'title' := 'apiDocumentation'
},
map {
'docID' := 'A070013',
'title' := 'credits'
},
map {
'docID' := 'A070090',
'title' := 'specialVolume'
};

(:~
: HTML output. Forwards to a given template and takes care of ETag caching
:
Expand Down Expand Up @@ -195,13 +243,8 @@ declare function controller:dispatch-project($exist-vars as map(*)) as element(e
switch($a)
case 'bibliography' case 'news' return controller:dispatch-register($exist-vars)
(: Need to inject the corresponding IDs of special pages here :)
case 'projectDescription' return controller:forward-html('/templates/var.html', map:merge(($exist-vars, map:entry('docID', 'A070006'), map:entry('docType', 'var'))))
case 'editorialGuidelines-text' return controller:forward-html('/templates/var.html', map:merge(($exist-vars, map:entry('docID', 'A070001'), map:entry('docType', 'var'))))
case 'editorialGuidelines-music' return controller:forward-html('/templates/var.html', map:merge(($exist-vars, map:entry('docID', 'A070010'), map:entry('docType', 'var'))))
case 'contact' return controller:forward-html('/templates/var.html', map:merge(($exist-vars, map:entry('docID', 'A070009'), map:entry('docType', 'var'))))
case 'about' return controller:forward-html('/templates/var.html', map:merge(($exist-vars, map:entry('docID', 'A070002'), map:entry('docType', 'var'))))
case 'volContents' return controller:forward-html('/templates/var.html', map:merge(($exist-vars, map:entry('docID', 'A070011'), map:entry('docType', 'var'))))
case 'credits' return controller:forward-html('/templates/var.html', map:merge(($exist-vars, map:entry('docID', 'A070013'), map:entry('docType', 'var'))))
case 'projectDescription' case 'editorialGuidelines-text' case 'editorialGuidelines-music' case 'contact' case 'volContents' case 'credits'
return controller:forward-html('/templates/var.html', map:merge(($exist-vars, map:entry('docID', $controller:projectNav[?title=$a]?docID), map:entry('docType', 'var'))))
default return controller:error($exist-vars, 404)
};

Expand All @@ -215,8 +258,7 @@ declare function controller:dispatch-help($exist-vars as map(*)) as element(exis
return
switch($a)
(: Need to inject the corresponding IDs of special pages here :)
case 'faq' return controller:forward-html('/templates/var.html', map:merge(($exist-vars, map:entry('docID', 'A070004'), map:entry('docType', 'var'))))
case 'apiDocumentation' return controller:forward-html('/templates/var.html', map:merge(($exist-vars, map:entry('docID', 'A070012'), map:entry('docType', 'var'))))
case 'faq' case 'apiDocumentation' return controller:forward-html('/templates/var.html', map:merge(($exist-vars, map:entry('docID', $controller:projectNav[?title=$a]?docID), map:entry('docType', 'var'))))
default return controller:error($exist-vars, 404)
};

Expand Down
4 changes: 2 additions & 2 deletions templates/var.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ <h1 data-template="app:document-title">CARL MARIA VON WEBER AN
<div class="col-sm-10">
<ol class="breadcrumb" data-template="app-shared:if-matches" data-template-key="docType" data-template-value="var">
<li><a href="$link/index">Home</a></li>
<li data-template="app-shared:if-not-matches" data-template-key="docID" data-template-value="A070003"><span data-template="app:breadcrumb-var"/></li>
<li data-template="app-shared:if-not-matches" data-template-key="docID" data-template-value="A070003 A070090"><span data-template="app:breadcrumb-var"/></li>
<li data-template="app-shared:if-matches" data-template-key="docID" data-template-value="A070003"><a href="$link/A002068.html">Carl Maria von Weber</a></li>
<li data-template="app-shared:if-not-matches" data-template-key="docID" data-template-value="A070090"><span data-template="app:document-title"></span></li>
<li><span data-template="app:breadcrumb-var2"/></li>
</ol>
<ol class="breadcrumb" data-template="app-shared:if-matches" data-template-key="docType" data-template-value="thematicCommentaries">
<li><a href="$link/index">Home</a></li>
Expand Down