Skip to content

Commit

Permalink
Resolve #80
Browse files Browse the repository at this point in the history
  • Loading branch information
dvglc committed Dec 5, 2019
1 parent 90cab2e commit 3b28a11
Show file tree
Hide file tree
Showing 35 changed files with 1,033 additions and 2,569 deletions.
18 changes: 9 additions & 9 deletions controller.xql
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ return
let $debug := if ($config:debug = ("trace", "info")) then console:log("Homepage requested: " || $net:forwardedForServername || $exist:path || $parameterString || ".") else ()
let $absolutePath :=
concat( $config:proto, "://", if ($net:forwardedForServername) then $net:forwardedForServername else "www." || $config:serverdomain, '/', $lang, '/index.html',
if (count(config:inject-requestParameter('', '')) gt 0) then '?' else (),
string-join(config:inject-requestParameter('', ''), '&')
if (count(net:inject-requestParameter('', '')) gt 0) then '?' else (),
string-join(net:inject-requestParameter('', ''), '&')
)
return net:redirect($absolutePath, $netVars)

Expand Down Expand Up @@ -257,7 +257,7 @@ return
(: HTML files should have a path component - we parse that and put view.xql in control :)
else if (ends-with($exist:resource, ".html") and substring($exist:path, 1, 4) = ("/de/", "/en/", "/es/")) then
let $debug := if ($config:debug = "info") then console:log ("[CONTROLLER] HTML requested: " || $net:forwardedForServername || $exist:path || $parameterString || ".") else ()
let $debug := if ($config:debug = "trace") then console:log ("[CONTROLLER] HTML requested, translating language path component to a request attribute - $exist:path: " || $exist:path || ", redirect to: " || $exist:controller || substring($exist:path, 4) || ", parameters: [" || string-join(config:inject-requestParameter((), ()), "&") || "], attributes: [].") else ()
let $debug := if ($config:debug = "trace") then console:log ("[CONTROLLER] HTML requested, translating language path component to a request attribute - $exist:path: " || $exist:path || ", redirect to: " || $exist:controller || substring($exist:path, 4) || ", parameters: [" || string-join(net:inject-requestParameter((), ()), "&") || "], attributes: [].") else ()
(: For now, we don't use net:forward here since we need a nested view/forwarding. :)
let $resource := lower-case($exist:resource)
return
Expand Down Expand Up @@ -298,8 +298,8 @@ return
(: If there is no language path component, redirect to a version of the site where there is one :)
else if (ends-with($exist:resource, ".html")) then
let $absolutePath := concat($config:proto, '://', $net:forwardedForServername, '/', $lang, $exist:path,
if (count(config:inject-requestParameter('', '')) gt 0) then '?' else (),
string-join(config:inject-requestParameter('', ''), '&'))
if (count(net:inject-requestParameter('', '')) gt 0) then '?' else (),
string-join(net:inject-requestParameter('', ''), '&'))
let $debug := if ($config:debug = ("trace", "info")) then console:log("HTML requested: " || $net:forwardedForServername || $exist:path || $parameterString || ", redirecting to " || $absolutePath || "...") else ()
return net:redirect($absolutePath, $netVars)

Expand Down Expand Up @@ -348,14 +348,14 @@ return
let $debug :=
if ($config:debug = ("trace", "info")) then console:log("Page not found: " || $net:forwardedForServername || $exist:path || $parameterString || "."
|| " Absolute path:" || concat($config:proto, "://", $net:forwardedForServername, '/', $lang, '/index.html',
if (count(config:inject-requestParameter('', '')) gt 0) then '?' else (),
string-join(config:inject-requestParameter('', ''), '&'))
if (count(net:inject-requestParameter('', '')) gt 0) then '?' else (),
string-join(net:inject-requestParameter('', ''), '&'))
)
else ()

let $absolutePath :=
concat($config:proto, "://", $net:forwardedForServername, '/', $lang, '/index.html',
if (count(config:inject-requestParameter('', '')) gt 0) then '?' else (),
string-join(config:inject-requestParameter('', ''), '&'))
if (count(net:inject-requestParameter('', '')) gt 0) then '?' else (),
string-join(net:inject-requestParameter('', ''), '&'))
(: return net:redirect($absolutePath, $netVars):)
return net:error(404, $netVars, ())
15 changes: 8 additions & 7 deletions error-handler.xql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import module namespace net = "http://www.salamanca.school/xquery/net"
import module namespace app = "http://www.salamanca.school/xquery/app" at "modules/app.xql";
import module namespace iiif = "http://www.salamanca.school/xquery/iiif" at "modules/iiif.xql";
import module namespace i18n = "http://exist-db.org/xquery/i18n" at "i18n.xql";
import module namespace gui = "http://www.salamanca.school/xquery/gui" at "modules/gui.xqm";

declare namespace exist = "http://exist.sourceforge.net/NS/exist";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
Expand Down Expand Up @@ -57,10 +58,10 @@ let $html-in :=
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="author" content=""/>
{config:meta-description(<meta/>, $dummyMap, $lang, (), (), ())}
{config:meta-title(<title/>, $dummyMap, $lang, (), (), ())}
{config:canonical-url(<link/>, $dummyMap, $lang, (), (), ())}
{config:hreflang-url(<link/>, $dummyMap, $lang, (), (), ())}
{gui:metaDescription(<meta/>, $dummyMap, $lang, (), (), ())}
{gui:metaTitle(<title/>, $dummyMap, $lang, (), (), ())}
{gui:canonicalUrl(<link/>, $dummyMap, $lang, (), (), ())}
{gui:hreflangUrl(<link/>, $dummyMap, $lang, (), (), ())}

<!-- ==== CSS ==== -->
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"/>
Expand Down Expand Up @@ -100,8 +101,8 @@ let $html-in :=
</div>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
{config:logo(<a/>, $dummyMap, $lang)}
{config:app-header(<div/>, $dummyMap, $lang, (), (), (), (), ())}
{gui:logo(<a/>, $dummyMap, $lang)}
{gui:header(<div/>, $dummyMap, $lang, (), (), (), (), ())}
</div>
</div>

Expand All @@ -117,7 +118,7 @@ let $html-in :=
<h2/>
<div id="footer">
<div class="container">
{config:footer (<div/>, $dummyMap, $lang)}
{gui:footer (<div/>, $dummyMap, $lang)}
</div>
</div>

Expand Down
12 changes: 6 additions & 6 deletions factory/works/html.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import module namespace util = "http://exist-db.org/xquery/util";
import module namespace console = "http://exist-db.org/xquery/console";
import module namespace config = "http://www.salamanca.school/xquery/config" at "../../modules/config.xqm";
import module namespace app = "http://www.salamanca.school/xquery/app" at "../../modules/app.xql";
import module namespace sal-util = "http://www.salamanca.school/xquery/sal-util" at "../../modules/sal-util.xql";
import module namespace sutil = "http://www.salamanca.school/xquery/sutil" at "../../modules/sutil.xql";
import module namespace index = "https://www.salamanca.school/factory/works/index" at "index.xqm";
import module namespace txt = "https://www.salamanca.school/factory/works/txt" at "txt.xqm";

Expand Down Expand Up @@ -73,7 +73,7 @@ declare function html:generateTocFromDiv($nodes as element()*, $wid as xs:string
for $node in $nodes/(tei:div[@type="work_part"]/tei:div[index:isIndexNode(.)]
|tei:div[not(@type="work_part")][index:isIndexNode(.)]
|*/tei:milestone[@unit ne 'other'][index:isIndexNode(.)]) return
let $fragTrail := sal-util:getNodetrail($wid, $node, 'citetrail')
let $fragTrail := sutil:getNodetrail($wid, $node, 'citetrail')
let $fragId := $config:idserver || '/texts/' || $wid || ':' || $fragTrail || '?format=html'
let $section := $node/@xml:id/string()
let $i18nKey :=
Expand Down Expand Up @@ -299,8 +299,8 @@ declare function html:makeSectionToolbox($node as element()) as element(div) {
declare function html:makePagination($node as node()?, $model as map(*)?, $wid as xs:string?, $lang as xs:string?) {
let $workId :=
if ($wid) then
if (contains($wid, '_')) then substring-before(sal-util:normalizeId($wid), '_')
else sal-util:normalizeId($wid)
if (contains($wid, '_')) then substring-before(sutil:normalizeId($wid), '_')
else sutil:normalizeId($wid)
else substring-before($model('currentWorkId'), '_')
return
<ul id="later" class="dropdown-menu scrollable-menu" role="menu" aria-labelledby="dropdownMenu1">{
Expand Down Expand Up @@ -376,7 +376,7 @@ declare function html:resolveCanvasID($pb as element(tei:pb)) as xs:string {
return
if (matches($facs, '^facs:W[0-9]{4}-[A-z]-[0-9]{4}$')) then
let $index := string(count($pb/preceding::tei:pb[not(@sameAs) and substring(@facs, 1, 12) eq substring($facs, 1, 12)]) + 1)
return $config:imageserver || '/iiif/presentation/' || sal-util:convertVolumeID(substring($facs,6,7)) || '/canvas/p' || $index
return $config:imageserver || '/iiif/presentation/' || sutil:convertVolumeID(substring($facs,6,7)) || '/canvas/p' || $index
else if (matches($facs, '^facs:W[0-9]{4}-[0-9]{4}$')) then
let $index := string(count($pb/preceding::tei:pb[not(@sameAs)]) + 1)
return $config:imageserver || '/iiif/presentation/' || substring($facs,6,5) || '/canvas/p' || $index
Expand Down Expand Up @@ -434,7 +434,7 @@ declare function html:transformToLink($node as element(), $uri as xs:string) {
~ For a node, make a full-blown URI including the citetrail of the node
:)
declare function html:makeCitetrailURI($node as element()) as xs:string? {
let $citetrail := sal-util:getNodetrail($node/ancestor::tei:TEI/@xml:id, $node, 'citetrail')
let $citetrail := sutil:getNodetrail($node/ancestor::tei:TEI/@xml:id, $node, 'citetrail')
let $workId := $node/ancestor::tei:TEI/@xml:id
return
if ($citetrail) then $config:idserver || '/texts/' || $workId || ':' || $citetrail
Expand Down
4 changes: 2 additions & 2 deletions factory/works/iiif.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import module namespace config = "http://www.salamanca.school/xquery/config"
import module namespace app = "http://www.salamanca.school/xquery/app" at "../../modules/app.xql";
import module namespace console = "http://exist-db.org/xquery/console";
import module namespace util = "http://exist-db.org/xquery/util";
import module namespace sal-util = "http://www.salamanca.school/xquery/sal-util" at "sal-util.xql";
import module namespace sutil = "http://www.salamanca.school/xquery/sutil" at "sutil.xql";



Expand All @@ -27,7 +27,7 @@ a single volume within a multi-volume work) or a collection resource (for a mult
@param $wid: the ID of the work or volume which the manifest is requested for
@return: the iiif manifest/collection :)
declare function iiif:createResource($targetWorkId as xs:string) as map(*) {
let $tei := doc($config:tei-works-root || '/' || sal-util:normalizeId($targetWorkId) || '.xml')//tei:TEI
let $tei := doc($config:tei-works-root || '/' || sutil:normalizeId($targetWorkId) || '.xml')//tei:TEI
let $iiifResource :=
if ($tei) then
(: dataset exists: :)
Expand Down
15 changes: 8 additions & 7 deletions factory/works/index.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ declare namespace sal = "http://salamanca.adwmainz.de";
import module namespace util = "http://exist-db.org/xquery/util";
import module namespace console = "http://exist-db.org/xquery/console";
import module namespace config = "http://www.salamanca.school/xquery/config" at "../../modules/config.xqm";
import module namespace sal-util = "http://www.salamanca.school/xquery/sal-util" at "../../modules/sal-util.xql";
import module namespace sutil = "http://www.salamanca.school/xquery/sutil" at "../../modules/sutil.xql";
import module namespace txt = "https://www.salamanca.school/factory/works/txt" at "txt.xqm";


Expand Down Expand Up @@ -173,7 +173,7 @@ declare function index:getCitableParent($node as node()) as node()? {
(: Marginal citetrails: "nX" where X is the anchor used (if it is alphanumeric) and "nXY" where Y is the number of times that X occurs inside the current div
(important: nodes are citetrail children of div (not of p) and are counted as such) :)
declare function index:makeMarginalCitetrail($node as element()) as xs:string {
let $currentSection := sal-util:copy(index:getCitableParent($node))
let $currentSection := sutil:copy(index:getCitableParent($node))
let $currentNode := $currentSection//*[@xml:id eq $node/@xml:id]
let $label :=
if (matches($currentNode/@n, '^[A-Za-z0-9\[\]]+$')) then
Expand Down Expand Up @@ -288,6 +288,7 @@ declare function index:isPageNode($node as node()) as xs:boolean {
~ Marginal nodes occur within structural or main nodes.
~ (NOTE: should work with on-the-fly copying of sections. )
:)
(: TODO: if this is changed, we also need to change txt:isMarginalNode() :)
declare function index:isMarginalNode($node as node()) as xs:boolean {
boolean(
$node/@xml:id and
Expand Down Expand Up @@ -727,7 +728,7 @@ declare function index:list($node as element(tei:list), $mode as xs:string) {
case 'citetrail' return
(: dictionaries, indices and summaries get their type prepended to their number :)
if(index:isNamedCitetrailNode($node)) then
let $currentSection := sal-util:copy($node/(ancestor::tei:div|ancestor::tei:body|ancestor::tei:front|ancestor::tei:back)[last()])
let $currentSection := sutil:copy($node/(ancestor::tei:div|ancestor::tei:body|ancestor::tei:front|ancestor::tei:back)[last()])
let $currentNode := $currentSection//tei:list[@xml:id eq $node/@xml:id]
return
concat(
Expand Down Expand Up @@ -787,7 +788,7 @@ declare function index:milestone($node as element(tei:milestone), $mode as xs:st

case 'citetrail' return
(: "XY" where X is the unit and Y is the anchor or the number of milestones where this occurs :)
let $currentSection := sal-util:copy(index:getCitableParent($node))
let $currentSection := sutil:copy(index:getCitableParent($node))
let $currentNode := $currentSection//tei:milestone[@xml:id eq $node/@xml:id]
return
if ($node/@n[matches(., '[a-zA-Z0-9]')]) then
Expand All @@ -810,7 +811,7 @@ declare function index:milestone($node as element(tei:milestone), $mode as xs:st
let $num :=
if ($node/@n[matches(., '^[0-9\[\]]+$')]) then $node/@n (:replace($node/@n, '[\[\]]', '') ? :)
else
let $currentSection := sal-util:copy($node/ancestor::*[index:isPassagetrailNode(.) and not(self::tei:p)][1])
let $currentSection := sutil:copy($node/ancestor::*[index:isPassagetrailNode(.) and not(self::tei:p)][1])
let $currentNode := $currentSection//tei:milestone[@xml:id eq $node/@xml:id]
let $position := count($currentSection//tei:milestone[@unit eq $currentNode/@unit and index:isPassagetrailNode(.)]
intersect $currentNode/preceding::tei:milestone[@unit eq $currentNode/@unit and index:isPassagetrailNode(.)]) + 1
Expand All @@ -827,7 +828,7 @@ declare function index:note($node as element(tei:note), $mode as xs:string) {
switch($mode)
case 'title' return
normalize-space(
let $currentSection := sal-util:copy(index:getCitableParent($node))
let $currentSection := sutil:copy(index:getCitableParent($node))
let $currentNode := $currentSection//tei:note[@xml:id eq $node/@xml:id]
return
if ($node/@n) then
Expand All @@ -852,7 +853,7 @@ declare function index:note($node as element(tei:note), $mode as xs:string) {
case 'passagetrail' return
if (index:isPassagetrailNode($node)) then
(: passagetrail parents of note are div, not p :)
let $currentSection := sal-util:copy($node/ancestor::*[index:isPassagetrailNode(.) and not(self::tei:p)][1])
let $currentSection := sutil:copy($node/ancestor::*[index:isPassagetrailNode(.) and not(self::tei:p)][1])
let $currentNode := $currentSection//tei:note[@xml:id eq $node/@xml:id]
let $prefix := $config:citationLabels(local-name($node))?('abbr')
let $label :=
Expand Down
Loading

0 comments on commit 3b28a11

Please sign in to comment.