Skip to content

Commit

Permalink
new app function app:breadcrumb-var2 (closes #325) (#328)
Browse files Browse the repository at this point in the history
* new app function app:breadcrumb-var2 (#325)

* update expected results
  • Loading branch information
jakosch authored and peterstadler committed Nov 27, 2019
1 parent 518412b commit 6d3ef8b
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 23 deletions.
12 changes: 12 additions & 0 deletions modules/app.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,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
64 changes: 52 additions & 12 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-text'
},
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-music'
},
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 @@ -192,17 +240,10 @@ declare function controller:dispatch-project($exist-vars as map(*)) as element(e
let $request := request:get-uri()
let $a := distinct-values($project-nav/@href[controller:encode-path-segments-for-uri(controller:resolve-link(.,$exist-vars)) = $request]/parent::*)
return
switch($a)
case 'bibliography' case 'news' return controller:dispatch-register($exist-vars)
if($a = ('bibliography', 'news')) then 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'))))
default return controller:error($exist-vars, 404)
else if($a = $controller:projectNav?title) then controller:forward-html('/templates/var.html', map:merge(($exist-vars, map:entry('docID', $controller:projectNav[?title=$a]?docID), map:entry('docType', 'var'))))
else controller:error($exist-vars, 404)
};

(:~
Expand All @@ -215,8 +256,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
5 changes: 2 additions & 3 deletions templates/var.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,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="A070003"><span data-template="app-shared:print" data-template-key="docID">A040080</span></li>
<li data-template="app-shared:if-matches" data-template-key="docID" data-template-value="A070003"><span data-template="lang:translate">bio</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
2 changes: 1 addition & 1 deletion testing/expected-results/var/API_Dokumentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ <h1>API Dokumentation</h1>
<li><a href="/exist/apps/WeGA-WebApp/de/Index">Home</a></li>
<li><span>Hilfe</span></li>

<li><span>A070012</span></li>
<li><span>API Dokumentation</span></li>

</ol>

Expand Down
2 changes: 1 addition & 1 deletion testing/expected-results/var/Band%C3%BCbersicht.html
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ <h1>Übersicht über die einzelnen Serien und Bände</h1>
<li><a href="/exist/apps/WeGA-WebApp/de/Index">Home</a></li>
<li><span>Projekt</span></li>

<li><span>A070011</span></li>
<li><span>Bandübersicht</span></li>

</ol>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ <h1>Editionsrichtlinien für die Notenbände</h1>
<li><a href="/exist/apps/WeGA-WebApp/de/Index">Home</a></li>
<li><span>Projekt</span></li>

<li><span>A070010</span></li>
<li><span>Editionsrichtlinien Musik</span></li>

</ol>

Expand Down
2 changes: 1 addition & 1 deletion testing/expected-results/var/Editionsrichtlinien_Text.html
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ <h1>Editionsrichtlinien zur Ausgabe der Briefe, Tagebücher und Dokumente Webers
<li><a href="/exist/apps/WeGA-WebApp/de/Index">Home</a></li>
<li><span>Projekt</span></li>

<li><span>A070001</span></li>
<li><span>Editionsrichtlinien Text</span></li>

</ol>

Expand Down
2 changes: 1 addition & 1 deletion testing/expected-results/var/FAQ.html
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ <h1>Frequently Asked Questions (FAQ)</h1>
<li><a href="/exist/apps/WeGA-WebApp/de/Index">Home</a></li>
<li><span>Hilfe</span></li>

<li><span>A070004</span></li>
<li><span>FAQ</span></li>

</ol>

Expand Down
2 changes: 1 addition & 1 deletion testing/expected-results/var/Impressum.html
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ <h1>Impressum</h1>
<li><a href="/exist/apps/WeGA-WebApp/de/Index">Home</a></li>
<li><span>Projekt</span></li>

<li><span>A070002</span></li>
<li><span>Impressum</span></li>

</ol>

Expand Down
2 changes: 1 addition & 1 deletion testing/expected-results/var/Kontakt.html
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ <h1>Kontakt</h1>
<li><a href="/exist/apps/WeGA-WebApp/de/Index">Home</a></li>
<li><span>Projekt</span></li>

<li><span>A070009</span></li>
<li><span>Kontakt</span></li>

</ol>

Expand Down
2 changes: 1 addition & 1 deletion testing/expected-results/var/Projektbeschreibung.html
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ <h1>Projektbeschreibung</h1>
<li><a href="/exist/apps/WeGA-WebApp/de/Index">Home</a></li>
<li><span>Projekt</span></li>

<li><span>A070006</span></li>
<li><span>Projektbeschreibung</span></li>

</ol>

Expand Down

0 comments on commit 6d3ef8b

Please sign in to comment.