Skip to content

Commit

Permalink
a little rework of the subversion history integration
Browse files Browse the repository at this point in the history
  • Loading branch information
peterstadler committed Feb 19, 2014
1 parent 596c337 commit 6b268da
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 55 deletions.
20 changes: 18 additions & 2 deletions webapp/modules/config.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ declare variable $config:app-root as xs:string :=
declare variable $config:catalogues-collection-path as xs:string := $config:app-root || '/catalogues';
declare variable $config:options-file-path as xs:string := $config:catalogues-collection-path || '/options.xml';
declare variable $config:options-file as document-node() := doc($config:options-file-path);
declare variable $config:data-collection-path as xs:string := '/db/apps/WeGA-data';
declare variable $config:svn-change-history-file as document-node()? :=
if(doc-available($config:catalogues-collection-path || '/svnChangeHistory.xml')) then doc($config:catalogues-collection-path || '/svnChangeHistory.xml')
if(doc-available($config:data-collection-path || '/subversionHistory.xml')) then doc($config:data-collection-path || '/subversionHistory.xml')
else ();
declare variable $config:data-collection-path as xs:string := '/db/apps/WeGA-data';
declare variable $config:tmp-collection-path as xs:string := $config:app-root || '/tmp';
declare variable $config:xsl-collection-path as xs:string := $config:app-root || '/xsl';

Expand Down Expand Up @@ -341,6 +341,22 @@ declare function config:getCurrentSvnRev() as xs:int? {
else ()
};

(:~
: Retrieves some subversion properties (latest revision, author, dateTime) for a given document ID
:
: @author Peter Stadler
: @param $docID the document ID
: @return map()
:)

declare function config:get-svn-props($docID as xs:string) as map() {
map:new(
for $prop in $config:svn-change-history-file//id($docID)/@*
return map:entry(local-name($prop), data($prop))
)
};


(:~
: Create parameters for xsl transformations
:
Expand Down
2 changes: 1 addition & 1 deletion webapp/modules/core.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ declare function core:change-namespace($element as element(), $targetNamespace a
:)
declare function core:link-to-current-app($relLink as xs:string?) as xs:string {
(: templates:link-to-app($config:expath-descriptor/@name, $relLink):)
replace(string-join((request:get-context-path(), request:get-attribute("$exist:prefix"), request:get-attribute('$exist:controller'), $relLink), "/"), "/+", "/")
core:join-path-elements((request:get-context-path(), request:get-attribute("$exist:prefix"), request:get-attribute('$exist:controller'), $relLink))
};

(:~
Expand Down
32 changes: 0 additions & 32 deletions webapp/modules/wega.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -2022,38 +2022,6 @@ declare function wega:getIDByPND($pnd as xs:string) as xs:string {
collection(config:get-option('persons'))//tei:idno[.=$pnd][@type='gnd']/parent::tei:person/string(@xml:id)
};

(:~
: Retrieves the latest (subversion) author for a given document ID
:
: @author Peter Stadler
: @param $docName the document name
: @return xs:string
:)

declare function wega:getLastAuthorOfDocument($docPath as xs:string) as xs:string? {
let $docHash := util:hash($docPath, 'md5')
let $entry := doc(config:get-option('svnChangeHistoryFile'))//id(concat('_',$docHash))
return
if(exists($entry/@author)) then wega:dictionaryLookup(string($entry/@author),'svnUsers')
else ()
};

(:~
: Retrieves the latest (subversion) modify date for a given document ID
:
: @author Peter Stadler
: @param $docName the document name
: @return xs:dateTime
:)

declare function wega:getLastModifyDateOfDocument($docPath as xs:string) as xs:dateTime? {
let $docHash := util:hash($docPath, 'md5')
let $entry := doc(config:get-option('svnChangeHistoryFile'))//id(concat('_',$docHash))
return
if($entry/@dateTime castable as xs:dateTime) then $entry/@dateTime cast as xs:dateTime
else ()
};

(:~
: Creates lightbox anchor
:
Expand Down
33 changes: 13 additions & 20 deletions webapp/modules/xho.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 XHTML XQuery-Modul
Expand All @@ -12,12 +12,10 @@ declare default collation "?lang=de;strength=primary";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace xhtml="http://www.w3.org/1999/xhtml";
declare namespace exist="http://exist.sourceforge.net/NS/exist";
declare namespace session = "http://exist-db.org/xquery/session";
declare namespace xmldb = "http://exist-db.org/xquery/xmldb";
declare namespace cache = "http://exist-db.org/xquery/cache";
declare namespace request = "http://exist-db.org/xquery/request";
import module namespace functx="http://www.functx.com";
import module namespace wega="http://xquery.weber-gesamtausgabe.de/modules/wega" at "wega.xqm";
import module namespace facets="http://xquery.weber-gesamtausgabe.de/modules/facets" at "facets.xqm";
import module namespace config="http://xquery.weber-gesamtausgabe.de/modules/config" at "config.xqm";
import module namespace core="http://xquery.weber-gesamtausgabe.de/modules/core" at "core.xqm";
import module namespace lang="http://xquery.weber-gesamtausgabe.de/modules/lang" at "lang.xqm";
Expand Down Expand Up @@ -85,23 +83,17 @@ declare function xho:createHeadContainer($lang as xs:string) as element()* {

declare function xho:createFooter($lang as xs:string, $docPath as xs:string) as element(xhtml:div) {
let $docID := substring-before(functx:substring-after-last($docPath, '/'), '.')
let $docHash := util:hash($docPath, 'md5')
(: let $log := util:log-system-out($docPath):)
let $entry := doc(config:get-option('svnChangeHistoryFile'))//id(concat('_',$docHash))
let $author := if(exists($entry/@author))
then wega:dictionaryLookup(data($entry/@author), xs:ID('svnUsers'))
else ()
let $date := if(exists($entry/@dateTime))
then datetime:date-from-dateTime($entry/@dateTime)
else ()
let $rev := data($entry/@rev)
let $svnProps := config:get-svn-props($docID)
let $author := map:get($svnProps, 'author')
let $date := map:get($svnProps, 'dateTime') cast as xs:dateTime
let $rev := map:get($svnProps, 'rev')
let $dateFormat := if($lang eq 'en')
then '%B %d, %Y'
else '%d. %B %Y'
let $encryptedBugEmail := wega:encryptString(config:get-option('bugEmail'), ())
let $version := concat(config:get-option('version'), if($config:isDevelopment) then 'dev' else '')
let $versionDate := wega:strftime($dateFormat, xs:date(config:get-option('versionDate')), $lang)
let $permalink := core:join-path-elements((config:get-option('baseHref'), $docID))
let $permalink := 'http://' || request:get-server-name() || core:link-to-current-app($docID)
return
if(exists($author) and exists($date)) then
<xhtml:div id="footer">
Expand Down Expand Up @@ -241,7 +233,7 @@ declare function xho:createHtmlHead($stylesheets as xs:string*, $jscripts as xs:
declare function xho:createBreadCrumb($doc as item(), $lang as xs:string) as element(xhtml:div) {
let $docID := $doc/root()/*/@xml:id cast as xs:string
let $baseHref := config:get-option('baseHref')
let $isDiary := starts-with($docID, 'A06') (: Diverse Sonderbehandlungen fürs Tagebuch :)
let $isDiary := config:is-diary($docID) (: Diverse Sonderbehandlungen fürs Tagebuch :)
let $authors := if($isDiary)
then wega:createPersonLink('A002068', $lang, 'fs')
else for $i in $doc//tei:titleStmt//tei:author return wega:printCorrespondentName($i, $lang, 'fs')
Expand Down Expand Up @@ -337,17 +329,18 @@ declare function xho:createWorksDocumentsUL($id as xs:string, $lang as xs:string
:)
declare function xho:collectCommonMetaData($doc as node()?) as element(wega:metaData) {
let $docPath := if(exists($doc)) then document-uri($doc/root()) else ()
let $docID := $doc/*/data(@xml:id)
let $contributors :=
if(exists($doc//tei:fileDesc/tei:titleStmt/(tei:author | tei:editor))) then for $i in $doc//tei:fileDesc/tei:titleStmt/(tei:author | tei:editor) return <xhtml:meta name="DC.contributor" content="{$i}"/>
else (<xhtml:meta name="DC.contributor" content="Joachim Veit"/>,<xhtml:meta name="DC.contributor" content="Peter Stadler"/>)
return
<wega:metaData>
<xhtml:link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"/>
<xhtml:link rel="schema.DCTERMS" href="http://purl.org/dc/terms/"/>
{if(exists($docPath)) then (
<xhtml:meta name="DC.creator" content="{wega:getLastAuthorOfDocument($docPath)}"/>,
<xhtml:meta name="DC.date" content="{wega:getLastModifyDateOfDocument($docPath)}" scheme="DCTERMS.W3CDTF"/> )
{if($docID) then (
<xhtml:meta name="DC.creator" content="{map:get(config:get-svn-props($docID), 'author')}"/>,
<xhtml:meta name="DC.date" content="{map:get(config:get-svn-props($docID), 'dateTime')}" scheme="DCTERMS.W3CDTF"/>
)
else ()
}
<xhtml:meta name="DC.publisher" content="Carl-Maria-von-Weber-Gesamtausgabe"/>
Expand Down

0 comments on commit 6b268da

Please sign in to comment.