Skip to content

Commit

Permalink
applied patch 0a1cb79
Browse files Browse the repository at this point in the history
  • Loading branch information
peterstadler committed Aug 5, 2013
1 parent a479940 commit 1eb35b3
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 53 deletions.
28 changes: 14 additions & 14 deletions webapp/controller.xql
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ else if (matches($exist:path, '^/[Ii]ndex(\.(htm|html|xml)|/)?$')) then
</dispatch>

else if (matches($exist:path, '^/(en/|de/)(Index)?$')) then
let $js := if(request:parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
let $js := if(request:get-parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
return
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="/xql/index.xql">
Expand Down Expand Up @@ -146,7 +146,7 @@ else if (matches($exist:path, concat('^/', $lang,'/', $indices, '(/(', $persons,

(: Editorial Guidelines :)
else if (matches($exist:path, concat('^/', $lang, '/', $editorialGuidelines, '/?$'))) then
let $js := if(request:parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
let $js := if(request:get-parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
return
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="/xql/var.xql">
Expand All @@ -160,7 +160,7 @@ else if (matches($exist:path, concat('^/', $lang, '/', $editorialGuidelines, '/?

(: Impressum :)
else if ($exist:path eq '/en/About' or $exist:path eq '/de/Impressum') then
let $js := if(request:parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
let $js := if(request:get-parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
return
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="/xql/var.xql">
Expand All @@ -172,7 +172,7 @@ else if ($exist:path eq '/en/About' or $exist:path eq '/de/Impressum') then

(: Ausführliche Weber-Biographie :)
else if ($exist:path eq '/en/Biography' or $exist:path eq '/de/Biographie') then
let $js := if(request:parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
let $js := if(request:get-parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
return
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="/xql/var.xql">
Expand All @@ -186,7 +186,7 @@ else if ($exist:path eq '/en/Biography' or $exist:path eq '/de/Biographie') then

(: Help :)
else if (matches($exist:path, concat('^/', $lang, '/', $help, '/?$'))) then
let $js := if(request:parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
let $js := if(request:get-parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
return
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="/xql/var.xql">
Expand All @@ -200,7 +200,7 @@ else if (matches($exist:path, concat('^/', $lang, '/', $help, '/?$'))) then

(: Project Description :)
else if (matches($exist:path, concat('^/', $lang, '/', $projectDescription, '/?$'))) then
let $js := if(request:parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
let $js := if(request:get-parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
return
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="/xql/var.xql">
Expand All @@ -214,7 +214,7 @@ else if (matches($exist:path, concat('^/', $lang, '/', $projectDescription, '/?$

(: Kontakt :)
else if (matches($exist:path, concat('^/', $lang, '/', wega:getVarURL('A070009',$lang), '/?$'))) then
let $js := if(request:parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
let $js := if(request:get-parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
return
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="/xql/var.xql">
Expand All @@ -226,7 +226,7 @@ else if (matches($exist:path, concat('^/', $lang, '/', wega:getVarURL('A070009',

(: Editionsrichtlinien Werkausgabe :)
(:else if (matches($exist:path, concat('^/', $lang, '/', wega:getVarURL('A070010',$lang), '/?$'))) then
let $js := if(request:parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
let $js := if(request:get-parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
return
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="/xql/var.xql">
Expand All @@ -238,7 +238,7 @@ else if (matches($exist:path, concat('^/', $lang, '/', wega:getVarURL('A070009',

(: Weber-Studien Einzelansicht:)
else if ($isWeberPublication and matches($exist:path, concat('^/', $lang, '/', $publications, '/', $weberStudies, '/', 'A11\d{4}/?$'))) then
let $js := if(request:parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
let $js := if(request:get-parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
return
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="/xql/var.xql">
Expand Down Expand Up @@ -346,7 +346,7 @@ else if (matches($exist:path, concat('^/', $lang, '/A002068/', $diaries, '/?$'))

(: Personen - Einzelansicht :)
else if (matches($exist:path, concat('^/', $lang, '/A00\d{4}/?$'))) then
let $js := if(request:parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
let $js := if(request:get-parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
let $person := wega:doc($exist:resource)/tei:person
return if(exists($person)) then
if($person/tei:ref) then (
Expand All @@ -366,7 +366,7 @@ else if (matches($exist:path, concat('^/', $lang, '/A00\d{4}/?$'))) then

(: Brief - Einzelansicht :)
else if (matches($exist:path, concat('^/', $lang, '/', $authorID,'/', $correspondence,'/', 'A04\d{4}/?$'))) then
let $js := if(request:parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
let $js := if(request:get-parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
let $doc := wega:doc($exist:resource)/tei:TEI
return if(exists($doc)) then
if($doc/tei:ref) then
Expand All @@ -385,7 +385,7 @@ else if (matches($exist:path, concat('^/', $lang, '/', $authorID,'/', $correspon

(: Schriften - Einzelansicht :)
else if (matches($exist:path, concat('^/', $lang, '/', $authorID,'/', $writings, '/', 'A03\d{4}/?$'))) then
let $js := if(request:parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
let $js := if(request:get-parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
let $doc := wega:doc($exist:resource)/tei:TEI
return if(exists($doc)) then
if($doc/tei:ref) then
Expand All @@ -404,7 +404,7 @@ else if (matches($exist:path, concat('^/', $lang, '/', $authorID,'/', $writings,

(: Tagebuch - Einzelansicht :)
else if (matches($exist:path, concat('^/', $lang, '/', 'A002068', '/', $diaries, '/', 'A06\d{4}/?$'))) then
let $js := if(request:parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
let $js := if(request:get-parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
return
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="/xql/diary_singleView.xql">
Expand All @@ -416,7 +416,7 @@ else if (matches($exist:path, concat('^/', $lang, '/', 'A002068', '/', $diaries,

(: News - Einzelansicht :)
else if (matches($exist:path, concat('^/', $lang, '/', $authorID,'/', $news, '/', 'A05\d{4}/?$'))) then
let $js := if(request:parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
let $js := if(request:get-parameter-names() = $ajaxCrawlerParameter) then 'false' else 'true'
let $doc := wega:doc($exist:resource)/tei:TEI
return if(exists($doc)) then
if($doc/tei:ref) then
Expand Down
40 changes: 22 additions & 18 deletions webapp/xql/modules/ajax.xqm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
xquery version "1.0" encoding "UTF-8";
xquery version "3.0" encoding "UTF-8";

(:~
: WeGA AJAX XQuery-Module
Expand Down Expand Up @@ -39,7 +39,7 @@ import module namespace jsonToXML="http://xqilla.sourceforge.net/Functions" at "
: @param $lang the current language (de|en)
: @return element
:)

declare function ajax:createHtmlListEntry($type,$persName,$letter,$sender,$addressee,$entryYear,$date,$lang) {
let $isRound := (year-from-date($date) - $entryYear) mod 25 = 0
let $formatedYear := <span>{wega:formatYear($entryYear cast as xs:int, $lang)}</span>
Expand Down Expand Up @@ -183,9 +183,10 @@ declare function ajax:getPersonCorrespondents($id as xs:string, $lang as xs:stri
else()
return
for $i in $letterList
group $i as $partition by $i/@key as $key
order by count($partition) descending
return <person>{$key, count($partition)}</person>
(: group $i as $partition by $i/@key as $key:)
group by $key := $i/@key
order by count($i) descending
return <person key="{$key}" count="{count($i)}"/>
};

(:~
Expand All @@ -210,20 +211,23 @@ declare function ajax:printCorrespondents($id as xs:string, $lang as xs:string,
let $key := $x/string(@key)
let $doc := wega:doc($key)
let $persNameSelected := wega:getRegName($key) (:wega:cleanString($person/tei:persName[@type='reg']):)
let $persNameSelectedCount := $x cast as xs:int
let $persNameSelectedCount := $x/@count cast as xs:int
order by $persNameSelectedCount descending, $persNameSelected ascending
return element a {
attribute href {wega:createLinkToDoc($doc, $lang)},
attribute title {
if ($persNameSelectedCount gt 1) then concat($persNameSelected, ' (', $persNameSelectedCount, ' ', wega:getLanguageString('letters',$lang), ')')
else concat($persNameSelected, ' (', $persNameSelectedCount, ' ', wega:getLanguageString('letter',$lang), ')')},
element img {
attribute src {wega:getPortraitPath($doc/tei:person, (40, 55), $lang)},
attribute alt {$persNameSelected},
attribute width {'40'},
attribute height {'55'}
}
}
return
if(exists($doc)) then
element a {
attribute href {wega:createLinkToDoc($doc, $lang)},
attribute title {
if ($persNameSelectedCount gt 1) then concat($persNameSelected, ' (', $persNameSelectedCount, ' ', wega:getLanguageString('letters',$lang), ')')
else concat($persNameSelected, ' (', $persNameSelectedCount, ' ', wega:getLanguageString('letter',$lang), ')')},
element img {
attribute src {wega:getPortraitPath($doc/tei:person, (40, 55), $lang)},
attribute alt {$persNameSelected},
attribute width {'40'},
attribute height {'55'}
}
}
else ()
return element div{$linkElements}
};

Expand Down
29 changes: 15 additions & 14 deletions webapp/xql/modules/facets.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ declare function facets:createFilter($checked as xs:string*) as element(facets:f
:)

declare function facets:sortColl($coll as item()*) as item()* {
if(wega:isPerson($coll[1]/string(@xml:id))) then for $i in $coll order by $i//tei:persName[@type = 'reg'] ascending return $i
if(wega:isPerson($coll[1]/string(@xml:id))) then for $i in $coll order by $i/tei:persName[@type = 'reg'] ascending return $i
else if(wega:isLetter($coll[1]/string(@xml:id))) then for $i in $coll order by wega:getOneNormalizedDate($i//tei:dateSender/tei:date[1], false()) ascending, $i//tei:dateSender/tei:date[1]/@n ascending return $i
else if(wega:isWriting($coll[1]/string(@xml:id))) then for $i in $coll order by wega:getOneNormalizedDate($i//tei:imprint/tei:date[1], false()) ascending return $i
else if(wega:isDiary($coll[1]/string(@xml:id))) then for $i in $coll order by $i/xs:date(@n) ascending return $i
Expand Down Expand Up @@ -514,7 +514,7 @@ declare function facets:getFirstOrLastDocumentInMonth($entriesSessionName as xs:
:)

declare function facets:getFirstOrLastDocumentInSeries($collIDs as xs:string*, $seriesNo as xs:int, $first as xs:boolean) as xs:string {
let $docIDs := wega:getNormDates('works')//entry[. = $seriesNo][./@docID=$collIDs]
let $docIDs := wega:getNormDates('works')//entry[. = $seriesNo][@docID=$collIDs]
return
if($first) then $docIDs[1]/string(@docID)
else $docIDs[last()]/string(@docID)
Expand Down Expand Up @@ -600,13 +600,13 @@ declare function facets:createChronoList($docType as xs:string, $lang as xs:stri
let $coll := session:get-attribute($sessionCollName)
let $normDates := wega:getNormDates($docType)//entry
let $undatedKeys :=
if($docType eq 'diaries') then $normDates[not(./node())][@docID = $coll//tei:ab/@xml:id]/string(@docID) (: Bei keinem Treffer wird der leere String zurückgegeben :)
else if($docType eq 'biblio') then $normDates[not(./node())][@docID = $coll//tei:biblStruct/@xml:id]/string(@docID)
else $normDates[not(./node())][@docID = $coll//tei:TEI/@xml:id]/string(@docID)
if($docType eq 'diaries') then $normDates[not(./node())][@docID = $coll/@xml:id]/string(@docID) (: Bei keinem Treffer wird der leere String zurückgegeben :)
else if($docType eq 'biblio') then $normDates[not(./node())][@docID = $coll/@xml:id]/string(@docID)
else $normDates[not(node())][@docID = $coll/@xml:id]/string(@docID)
let $dated :=
if($docType eq 'diaries') then $normDates[@docID = $coll//tei:ab/@xml:id][./node()]
else if($docType eq 'biblio') then $normDates[@docID = $coll//tei:biblStruct/@xml:id][./node()]
else $normDates[@docID = $coll//tei:TEI/@xml:id][./node()]
if($docType eq 'diaries') then $normDates[@docID = $coll/@xml:id][./node()]
else if($docType eq 'biblio') then $normDates[@docID = $coll/@xml:id][./node()]
else $normDates[@docID = $coll/@xml:id][./node()]
let $distinctYears := for $i in distinct-values($dated/@year) return $i cast as xs:int
let $saveDated := session:set-attribute($datedSessionName, $dated)
let $saveUndated := session:set-attribute($undatedSessionName, $undatedKeys)
Expand Down Expand Up @@ -712,8 +712,8 @@ declare function facets:getSeries($docType as xs:string, $lang as xs:string) as
let $sessionCollName := facets:getCollName($docType, false())
let $coll := session:get-attribute($sessionCollName)
let $distinctSeries := facets:getDistinctSeries($coll)
let $collIDs := $coll//mei:mei/string(@xml:id)
let $activeIDs := wega:getNormDates('works')//entry[./@docID=$collIDs]/string(@docID)
let $collIDs := $coll/string(@xml:id)
let $activeIDs := wega:getNormDates('works')//entry[@docID=$collIDs]/string(@docID)
let $docType := 'works'
let $category := 'series'
return
Expand Down Expand Up @@ -759,7 +759,7 @@ declare function facets:createAlphabetList($docType as xs:string, $lang as xs:st
let $sessionCollName := facets:getCollName($docType, false())
let $coll := session:get-attribute($sessionCollName)
let $normDates := wega:getNormDates($docType)//entry
let $persons := $normDates[@docID = $coll//tei:person/@xml:id]
let $persons := $normDates[@docID = $coll/@xml:id]
let $countPersons := count($persons)
let $savePersons := session:set-attribute($entriesSessionName, $persons)
let $saveFromTo := session:set-attribute($fromToSessionName, (1,$countPersons))
Expand All @@ -782,20 +782,21 @@ declare function facets:createAlphabetList($docType as xs:string, $lang as xs:st
:)
declare function facets:createAlphabetListUl($entriesSessionName as xs:string, $fromToSessionName as xs:string, $lang as xs:string, $recusionDepth as xs:int) as element(ul) {
let $maxRows := xs:int(wega:getOption('listViewMaxRows'))
let $persons := session:get-attribute($entriesSessionName)//entry
let $persons := session:get-attribute($entriesSessionName)
let $from := session:get-attribute($fromToSessionName)[1]
let $to := session:get-attribute($fromToSessionName)[2]
let $countPersons := $to - $from +1
let $myDivisor := if (round($countPersons div $maxRows) eq 0) then 1 else xs:int(round($countPersons div $maxRows)) (: 9/7 :)
let $numberOfRows := if(ceiling($countPersons div $myDivisor) gt $maxRows) then $maxRows else xs:int(ceiling($countPersons div $myDivisor))
let $threshold := 30
(: let $log := util:log-system-out(session:get-attribute($entriesSessionName)):)
return (
element ul {
for $i at $count in (1 to $numberOfRows)
let $fromPosition := ($i - 1) * ($myDivisor) + $from
let $toPosition := if ((($i * $myDivisor + $from -1) gt $to) or ($i eq $numberOfRows)) then $to else $i * $myDivisor + $from -1
let $startEntry := functx:substring-before-match(normalize-space($persons[$fromPosition]), '[\s,]')
let $endEntry := functx:substring-before-match(normalize-space($persons[$toPosition]), '[\s,]')
let $startEntry := functx:substring-before-match(normalize-space($persons[$fromPosition]), '[\s,]') (:'Start':)
let $endEntry := functx:substring-before-match(normalize-space($persons[$toPosition]), '[\s,]') (:'Ende':)
let $countPersonsInInterval := $toPosition - $fromPosition +1
let $newFromToSessionName := concat($fromToSessionName, $count)
let $saveFromTo := session:set-attribute($newFromToSessionName, ($fromPosition,$toPosition))
Expand Down
14 changes: 7 additions & 7 deletions webapp/xql/modules/wega.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -2570,7 +2570,7 @@ declare function wega:createLetterNormDates() {
<dictionary xmlns=""> {
attribute xml:id {$xmlID},
for $i in $coll
let $docID := $i//tei:TEI/string(@xml:id)
let $docID := $i/string(@xml:id)
let $normDate := wega:getOneNormalizedDate($i//tei:dateSender/tei:date, false())
let $n := $i//tei:dateSender/tei:date/string(@n)
(: let $senderID := $i//tei:sender/tei:persName[1]/string(@key):)
Expand Down Expand Up @@ -2610,8 +2610,8 @@ declare function wega:createWritingNormDates() {
<dictionary xmlns=""> {
attribute xml:id {$xmlID},
for $i in $coll
let $docID := $i//tei:TEI/string(@xml:id)
let $normDate := wega:getOneNormalizedDate($i//tei:sourceDesc/tei:*/tei:monogr/tei:imprint/tei:date, false())
let $docID := $i/string(@xml:id)
let $normDate := wega:getOneNormalizedDate($i//tei:imprint/tei:date, false())
let $n := string-join($i//tei:monogr/tei:title[@level = 'j'], '. ')
order by $normDate, $n
return
Expand Down Expand Up @@ -2645,7 +2645,7 @@ declare function wega:createWorkNormDates() {
<dictionary xmlns=""> {
attribute xml:id {$xmlID},
for $i in $coll
let $docID := $i//mei:mei/string(@xml:id)
let $docID := $i/string(@xml:id)
let $normDate := $i//mei:seriesStmt/mei:title[@level='s']/xs:int(@n)
let $n := $i//mei:altId[@type = 'WeV']
let $sortCategory02 := $i//mei:altId[@type = 'WeV']/string(@subtype)
Expand Down Expand Up @@ -2679,8 +2679,8 @@ declare function wega:createDiaryNormDates() {
<dictionary xmlns=""> {
attribute xml:id {$xmlID},
for $i in $coll
let $docID := $i//tei:ab/string(@xml:id)
let $normDate := $i//tei:ab/string(@n)
let $docID := $i/string(@xml:id)
let $normDate := $i/string(@n)
order by $normDate
return
element entry {
Expand Down Expand Up @@ -2712,7 +2712,7 @@ declare function wega:createNewsNormDates() {
<dictionary xmlns=""> {
attribute xml:id {$xmlID},
for $i in $coll
let $docID := $i//tei:TEI/string(@xml:id)
let $docID := $i/string(@xml:id)
let $normDate := datetime:date-from-dateTime($i//tei:publicationStmt/tei:date/xs:dateTime(@when))
(:let $log := util:log-system-out($normDate):)
order by $normDate descending
Expand Down

0 comments on commit 1eb35b3

Please sign in to comment.