Skip to content

Commit

Permalink
Merge pull request #447 from HistoryAtState/add-timeline-to-search
Browse files Browse the repository at this point in the history
Add Administrative Timeline, FRUS History collections to search
  • Loading branch information
joewiz authored May 3, 2024
2 parents 8cc35d9 + aaece0f commit a9fc751
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 36 deletions.
2 changes: 1 addition & 1 deletion app/templates/site.xml
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
<div class="row">
<address class="col-xs-12 col-sm-12 col-md-12">
<h4>Office of the Historian, Foreign Service Institute <br/>
<a href="http://www.state.gov">United States Department of
<a href="https://www.state.gov">United States Department of
State</a></h4>
<p>
<a href="mailto:[email protected]">[email protected]</a>
Expand Down
14 changes: 10 additions & 4 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 Expand Up @@ -310,7 +316,7 @@ else switch($path-parts[1])
local:render-page("departmenthistory/timeline/section.xml", map {
"publication-id": "timeline",
"document-id": "timeline",
"section-id": $path-parts[3]
"section-id": "chapter_" || $path-parts[3]
})
case "short-history" return
if (empty($path-parts[3])) then
Expand Down
10 changes: 6 additions & 4 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 Expand Up @@ -523,7 +525,7 @@ declare variable $config:PUBLICATIONS :=
"document-created": function($document-id) { xmldb:created($config:ADMINISTRATIVE_TIMELINE_COL, $document-id || '.xml') },
"section-created": function($document-id, $section-id) {xmldb:created($config:ADMINISTRATIVE_TIMELINE_COL, $document-id || '.xml') },
"select-document": function($document-id) { doc($config:ADMINISTRATIVE_TIMELINE_COL || '/' || $document-id || '.xml') },
"select-section": function($document-id, $section-id) { doc($config:ADMINISTRATIVE_TIMELINE_COL || '/' || $document-id || '.xml')/id('chapter_' || $section-id) },
"select-section": function($document-id, $section-id) { doc($config:ADMINISTRATIVE_TIMELINE_COL || '/' || $document-id || '.xml')/id($section-id) },
"html-href": function($document-id, $section-id) { "$app/departmenthistory/" || string-join(($document-id, substring-after($section-id, 'chapter_')), '/') },
"url-fragment": function($div) { if (starts-with($div/@xml:id, 'chapter_')) then substring-after($div/@xml:id, 'chapter_') else $div/@xml:id/string() },
"odd": "frus.odd",
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
17 changes: 9 additions & 8 deletions modules/pages.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ declare
function pages:load($node as node(), $model as map(*), $publication-id as xs:string?, $document-id as xs:string?,
$section-id as xs:string?, $view as xs:string, $ignore as xs:boolean, $open-graph-keys as xs:string?, $open-graph-keys-exclude as xs:string?, $open-graph-keys-add as xs:string?) {

let $log := util:log("info", "loading publication-id: " || $publication-id || " document-id: " || $document-id || " section-id: " || $section-id )
let $log := util:log("info", "pages:load: loading publication-id: " || $publication-id || " document-id: " || $document-id || " section-id: " || $section-id || " view: " || $view || " ignore: " || $ignore || " open-graph-keys: " || $open-graph-keys || " open-graph-keys-exclude: " || $open-graph-keys-exclude || " open-graph-keys-add: " || $open-graph-keys-add)

let $static-open-graph := map:merge((
for $meta in $node//*[@id eq 'static-open-graph']/meta
Expand Down Expand Up @@ -140,16 +140,16 @@ function pages:load($node as node(), $model as map(*), $publication-id as xs:str

declare function pages:last-modified($publication-id as xs:string, $document-id as xs:string, $section-id as xs:string?) {
if ($section-id) then
map:get($config:PUBLICATIONS, $publication-id)?section-last-modified!.($document-id, $section-id)
map:get($config:PUBLICATIONS, $publication-id)?section-last-modified($document-id, $section-id)
else
map:get($config:PUBLICATIONS, $publication-id)?document-last-modified!.($document-id)
map:get($config:PUBLICATIONS, $publication-id)?document-last-modified($document-id)
};

declare function pages:created($publication-id as xs:string, $document-id as xs:string, $section-id as xs:string?) {
if ($section-id) then
map:get($config:PUBLICATIONS, $publication-id)?section-created!.($document-id, $section-id)
map:get($config:PUBLICATIONS, $publication-id)?section-created($document-id, $section-id)
else
map:get($config:PUBLICATIONS, $publication-id)?document-created!.($document-id)
map:get($config:PUBLICATIONS, $publication-id)?document-created($document-id)
};

declare function pages:load-xml($publication-id as xs:string, $document-id as xs:string, $section-id as xs:string?, $view as xs:string) {
Expand All @@ -158,7 +158,7 @@ declare function pages:load-xml($publication-id as xs:string, $document-id as xs

declare function pages:load-xml($publication-id as xs:string, $document-id as xs:string, $section-id as xs:string?,
$view as xs:string, $ignore as xs:boolean?) {
util:log("debug", "pages:load-xml: publication: " || $publication-id || "; document: " || $document-id || "; section: " || $section-id || "; view: " || $view),
util:log("debug", "pages:load-xml: Loading publication-id: " || $publication-id || " document-id: " || $document-id || " section-id: " || $section-id || " view: " || $view || " ignore: " || $ignore),
let $block :=
if ($view = "div") then
if ($section-id) then (
Expand All @@ -171,7 +171,7 @@ declare function pages:load-xml($publication-id as xs:string, $document-id as xs
if (empty($block) and not($ignore)) then (
pages:load-fallback-page($publication-id, $document-id, $section-id)
) else (
util:log("info", "pages:load-xml: Loaded " || document-uri(root($block)) || ". Node name: " || node-name($block) || "."),
util:log("info", "pages:load-xml: Loaded document-uri: " || document-uri(root($block)) || " node-name: " || node-name($block)),
$block
)
};
Expand All @@ -183,7 +183,7 @@ declare function pages:load-fallback-page($publication-id as xs:string, $documen
if (empty($volume)) then (
request:set-attribute("hsg-shell.errcode", 404),
request:set-attribute("hsg-shell.path", string-join(($document-id, $section-id), "/")),
error(QName("http://history.state.gov/ns/site/hsg", "not-found"), "publication " || $publication-id || " document " || $document-id || " section " || $section-id || " not found")
error(QName("http://history.state.gov/ns/site/hsg", "not-found"), "publication-id: " || $publication-id || " document-id: " || $document-id || " section-id: " || $section-id || " not found")
) else
pages:volume-to-tei($volume)
};
Expand Down Expand Up @@ -516,6 +516,7 @@ declare function pages:generate-short-title($node, $model) as xs:string? {

(: Generate page breadcrumbs :)
declare function pages:breadcrumb($node, $model){
util:log("info", "pages:breadcrumb site:get-url: " || site:get-uri() || " $app:APP_ROOT: " || $app:APP_ROOT),
pages:generate-breadcrumbs(substring-after(site:get-uri(), $app:APP_ROOT))
};

Expand Down
5 changes: 4 additions & 1 deletion modules/search.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ declare variable $search:ft-query-options := map {
declare variable $search:SECTIONS := map {
"documents": "frus",
"department": (
"timeline",
"short-history",
"people",
"buildings",
Expand All @@ -42,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 @@ -815,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
14 changes: 12 additions & 2 deletions pages/historicaldocuments/frus-history/research/article.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<div data-template="pages:load">
<div data-template="templates:surround" data-template-at="content"
data-template-with="templates/site.xml">
<div class="row">
<div>
<div class="hidden" id="static-title">
<span data-template="frus-history:article-title"/> - Research - History of the
Foreign Relations Series - Historical Documents</div>
<div class="row">
<div data-template="pages:breadcrumb"/>
</div>
<div class="row hsg-main">
<div class="row">
<div class="hsg-width-two-thirds">
<div data-template="app:fix-links" id="content-inner" itemscope="itemscope"
itemtype="http://schema.org/Article">
Expand All @@ -20,6 +20,16 @@
<p data-template="frus-history:article-description"/>
<div data-template="frus-history:article"/>
</div>
<div class="row" data-template="pages:navigation">
<a class="page-nav nav-prev" data-template="pages:navigation-link"
data-template-direction="previous">
<i class="glyphicon glyphicon-chevron-left"/>
</a>
<a class="page-nav nav-next" data-template="pages:navigation-link"
data-template-direction="next">
<i class="glyphicon glyphicon-chevron-right"/>
</a>
</div>
</div>
<aside data-template="pages:asides">
<div class="hsg-panel" data-template="app:fix-links" id="sections">
Expand Down
Loading

0 comments on commit a9fc751

Please sign in to comment.