Skip to content

Commit

Permalink
feat: add FRUS history docs & articles to search
Browse files Browse the repository at this point in the history
  • Loading branch information
joewiz committed May 2, 2024
1 parent e4e9cb1 commit 0a4e470
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 23 deletions.
12 changes: 9 additions & 3 deletions controller.xql
Original file line number Diff line number Diff line change
Expand Up @@ -201,17 +201,23 @@ else switch($path-parts[1])
local:render-page("historicaldocuments/frus-history/events/index.xml")
case "documents" return
if (empty($path-parts[4])) then
local:render-page("historicaldocuments/frus-history/documents/index.xml")
local:render-page("historicaldocuments/frus-history/documents/index.xml", map{
"publication-id": "frus-history-documents"
})
else
local:render-page("historicaldocuments/frus-history/documents/document.xml", map{
"publication-id": "frus-history-documents",
"document-id": $path-parts[4]
})
case "research" return
if (empty($path-parts[4])) then
local:render-page("historicaldocuments/frus-history/research/index.xml")
local:render-page("historicaldocuments/frus-history/research/index.xml", map{
"publication-id": "frus-history-articles"
})
else
local:render-page("historicaldocuments/frus-history/research/article.xml", map{
"article-id": $path-parts[4]
"publication-id": "frus-history-articles",
"document-id": $path-parts[4]
})
case "appendix-a" return
local:render-page("historicaldocuments/frus-history/appendix-a.xml", map{
Expand Down
8 changes: 5 additions & 3 deletions modules/config.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -355,21 +355,23 @@ declare variable $config:PUBLICATIONS :=
)
}
},
"articles": map {
"frus-history-articles": map {
"collection": $config:FRUS_HISTORY_ARTICLES_COL,
"document-last-modified": function($document-id) { xmldb:last-modified($config:FRUS_HISTORY_ARTICLES_COL, $document-id || '.xml') },
"section-last-modified": function($document-id, $section-id) { xmldb:last-modified($config:FRUS_HISTORY_ARTICLES_COL, $document-id || '.xml') },
"document-created": function($document-id) { xmldb:created($config:FRUS_HISTORY_ARTICLES_COL, $document-id || '.xml') },
"section-created": function($document-id, $section-id) {xmldb:created($config:FRUS_HISTORY_ARTICLES_COL, $document-id || '.xml') },
"select-document": function($document-id) { doc($config:FRUS_HISTORY_ARTICLES_COL || '/' || $document-id || '.xml') },
"select-section": function($document-id, $section-id) { doc($config:FRUS_HISTORY_ARTICLES_COL || '/' || $document-id || '.xml')//tei:body },
"select-section": function($document-id, $section-id) { doc($config:FRUS_HISTORY_ARTICLES_COL || '/' || $document-id || '.xml')/id($section-id) },
"next": frus-history:get-next-article#1,
"previous": frus-history:get-previous-article#1,
"html-href": function($document-id, $section-id) { "$app/frus-history/" || string-join(($document-id, $section-id), '/') },
"odd": "frus.odd",
"transform": function($xml, $parameters) { pm-frus:transform($xml, $parameters) },
"base-path": function($document-id, $section-id) { "frus150" },
"breadcrumb-title":
function($parameters as map(*)) as xs:string? {
config:tei-short-breadcrumb-title($parameters?publication-id, $parameters?article-id)
config:tei-short-breadcrumb-title($parameters?publication-id, $parameters?document-id)
}
},
"about": map {
Expand Down
75 changes: 63 additions & 12 deletions modules/frus-history-html.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,52 @@ declare function fhh:document-list($node, $model) {
)
};

declare function fhh:get-next-article($model) {
let $div := $model?data/ancestor-or-self::tei:TEI
let $documents := collection($fhh:FRUS_HISTORY_ARTICLES_COL)/tei:TEI
let $col :=
for $doc in $documents
let $created := $doc//tei:publicationStmt/tei:date/@when
order by $created
return $doc
let $index := index-of($col, $div)
let $size := count($col)
let $data :=
switch($index)
case $size return ()
default return ($col[$index + 1]//tei:body)[1]
let $href := if ($data) then "$app/historicaldocuments/frus-history/research/" || substring-before(util:document-name($data), '.xml') else ()
return
if ($data) then
map{
"data": $data,
"href": $href
}
else ()
};

declare function fhh:get-previous-article($model) {
let $div := $model?data/ancestor-or-self::tei:TEI
let $documents := collection($fhh:FRUS_HISTORY_ARTICLES_COL)/tei:TEI
let $col :=
for $doc in $documents
let $created := $doc//tei:publicationStmt/tei:date/@when
order by $created
return $doc
let $index := index-of($col, $div)
let $data :=
switch($index)
case 1 return ()
default return ($col[$index - 1]//tei:body)[1]
let $href := if ($data) then "$app/historicaldocuments/frus-history/research/" || substring-before(util:document-name($data), '.xml') else ()
return
if ($data) then
map{
"data": $data,
"href": $href
}
else ()
};
declare function fhh:get-next-doc($model) {
let $div := $model?data/ancestor-or-self::tei:TEI
let $documents := collection($fhh:FRUS_HISTORY_DOCUMENTS_COL)/tei:TEI
Expand Down Expand Up @@ -339,41 +385,46 @@ declare function fhh:article-list-sidebar($node, $model, $article-id) {
}</ul>
};

declare function fhh:article-breadcrumb($node, $model, $article-id) {
let $article := doc($fhh:FRUS_HISTORY_ARTICLES_COL || "/" || $article-id || ".xml")
declare function fhh:article-breadcrumb($node, $model, $document-id) {
let $article := doc($fhh:FRUS_HISTORY_ARTICLES_COL || "/" || $document-id || ".xml")
let $title := $article//tei:title[@type='short']
return
<a href="$app/historicaldocuments/frus-history/research/{$article-id}">{$title/string()}</a>
};

declare function fhh:article-title($node, $model, $article-id) {
let $article := doc($fhh:FRUS_HISTORY_ARTICLES_COL || "/" || $article-id || ".xml")
declare function fhh:article-title($node, $model, $document-id) {
let $article := doc($fhh:FRUS_HISTORY_ARTICLES_COL || "/" || $document-id || ".xml")
return
pages:process-content($model?odd, $article//tei:title[@type='complete'])
};

declare function fhh:article-author($node, $model, $article-id) {
let $article := doc($fhh:FRUS_HISTORY_ARTICLES_COL || "/" || $article-id || ".xml")
declare function fhh:article-author($node, $model, $document-id) {
let $article := doc($fhh:FRUS_HISTORY_ARTICLES_COL || "/" || $document-id || ".xml")
let $author := $article//tei:author/text()
let $affiliation := $article//tei:sponsor/text()
let $date := $article//tei:publicationStmt/tei:date/text()
return
(
<h3>By <span itemprop="author">{$author}</span><br/>
<span itemprop="sourceOrganization">{$affiliation}</span></h3>,
if ($author) then
<h3>By
<span itemprop="author">{$author}</span><br/>
<span itemprop="sourceOrganization">{$affiliation}</span>
</h3>
else
(),
<h4>Released <span itemprop="datePublished">{$date}</span></h4>
)
};

declare function fhh:article-description($node, $model, $article-id) {
let $article := doc($fhh:FRUS_HISTORY_ARTICLES_COL || "/" || $article-id || ".xml")
declare function fhh:article-description($node, $model, $document-id) {
let $article := doc($fhh:FRUS_HISTORY_ARTICLES_COL || "/" || $document-id || ".xml")
let $publication-statement := $article//tei:sourceDesc/tei:p
return
pages:process-content($model?odd, $publication-statement)
};

declare function fhh:article($node, $model, $article-id) {
let $article := doc($fhh:FRUS_HISTORY_ARTICLES_COL || "/" || $article-id || ".xml")
declare function fhh:article($node, $model, $document-id) {
let $article := doc($fhh:FRUS_HISTORY_ARTICLES_COL || "/" || $document-id || ".xml")
return
pages:process-content($model?odd, $article//tei:text/*, map { "base-uri": "frus150" })
};
Expand Down
4 changes: 3 additions & 1 deletion modules/search.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ declare variable $search:SECTIONS := map {
"retired": ("milestones", "education"),
"countries": ("countries-articles", "archives"),
"conferences": "conferences",
"frus-history": "frus-history-monograph",
"frus-history": ("frus-history-articles", "frus-history-documents", "frus-history-monograph"),
"about": ("hac", "faq")
};

Expand Down Expand Up @@ -816,6 +816,8 @@ declare function search:query-sections($sections as xs:string*, $query-configura
collection("/db/apps/conferences/data")//tei:div[ft:query(., $query-string, $query-options)],
collection("/db/apps/hac")//tei:div[ft:query(., $query-string, $query-options)],
collection("/db/apps/frus/volumes")//tei:div[ft:query(., $query-string, $frus-query-options)],
collection("/db/apps/frus-history/articles")//tei:body[ft:query(., $query-string, $query-options)],
collection("/db/apps/frus-history/documents")//tei:body[ft:query(., $query-string, $query-options)],
collection("/db/apps/frus-history/monograph")//tei:div[ft:query(., $query-string, $query-options)],
collection("/db/apps/rdcr/articles")//tei:body[ft:query(., $query-string, $query-options)],
collection("/db/apps/wwdai/articles")//tei:body[ft:query(., $query-string, $query-options)],
Expand Down
8 changes: 4 additions & 4 deletions urls.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
<step key="doc-id">
<page-template
href="pages/historicaldocuments/frus-history/documents/document.xml">
<with-param keyval="doc-id" name="document-id"/>
<with-param name="publication-id" value="frus-history-documents"/>
<with-param keyval="document-id" name="document-id"/>
</page-template>
<config>
<src collection="/db/apps/frus-history/documents"/>
Expand All @@ -55,11 +55,11 @@
<page-template href="pages/historicaldocuments/frus-history/events/index.xml"/>
</step>
<step value="research">
<step key="article-id">
<step key="document-id">
<page-template
href="pages/historicaldocuments/frus-history/research/article.xml">
<with-param name="publication-id" value="articles"/>
<with-param keyval="article-id" name="article-id"/>
<with-param name="publication-id" value="frus-history-articles"/>
<with-param keyval="document-id" name="document-id"/>
</page-template>
<config>
<src collection="/db/apps/frus-history/articles"/>
Expand Down

0 comments on commit 0a4e470

Please sign in to comment.