From 2e94b278d0697cd35a842faba6f74be22a76faf2 Mon Sep 17 00:00:00 2001 From: Joe Wicentowski Date: Wed, 1 May 2024 19:07:35 -0400 Subject: [PATCH 1/8] feat: add Administrative Timeline to search MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … within the Department History category --- modules/search.xqm | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/search.xqm b/modules/search.xqm index d6fed0b76..94083f43e 100644 --- a/modules/search.xqm +++ b/modules/search.xqm @@ -31,6 +31,7 @@ declare variable $search:ft-query-options := map { declare variable $search:SECTIONS := map { "documents": "frus", "department": ( + "timeline", "short-history", "people", "buildings", From a05ccde95c581a3166c41fbc939de263179cfc8f Mon Sep 17 00:00:00 2001 From: Joe Wicentowski Date: Wed, 1 May 2024 19:08:24 -0400 Subject: [PATCH 2/8] fix: correct routing to Admin Timeline entries --- controller.xql | 2 +- modules/config.xqm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/controller.xql b/controller.xql index 09c3766d1..e22e5cc60 100644 --- a/controller.xql +++ b/controller.xql @@ -310,7 +310,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 diff --git a/modules/config.xqm b/modules/config.xqm index bc608fd6f..9041ff4b1 100644 --- a/modules/config.xqm +++ b/modules/config.xqm @@ -523,7 +523,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", From e4e9cb1627e2d7e74594556c585d031205c30b33 Mon Sep 17 00:00:00 2001 From: Joe Wicentowski Date: Wed, 1 May 2024 19:10:40 -0400 Subject: [PATCH 3/8] fix: improve logging in pages:load MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … and pages:load-fallback-page --- modules/pages.xqm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/pages.xqm b/modules/pages.xqm index 313fb090e..934bc4dc0 100755 --- a/modules/pages.xqm +++ b/modules/pages.xqm @@ -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", "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 @@ -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) }; From 0a4e470e040e0842197d91c58e08f045ce953ed3 Mon Sep 17 00:00:00 2001 From: Joe Wicentowski Date: Thu, 2 May 2024 16:32:08 -0400 Subject: [PATCH 4/8] feat: add FRUS history docs & articles to search --- controller.xql | 12 ++++-- modules/config.xqm | 8 ++-- modules/frus-history-html.xqm | 75 +++++++++++++++++++++++++++++------ modules/search.xqm | 4 +- urls.xml | 8 ++-- 5 files changed, 84 insertions(+), 23 deletions(-) diff --git a/controller.xql b/controller.xql index e22e5cc60..3d7ed9477 100644 --- a/controller.xql +++ b/controller.xql @@ -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{ diff --git a/modules/config.xqm b/modules/config.xqm index 9041ff4b1..cf8c5c8dd 100644 --- a/modules/config.xqm +++ b/modules/config.xqm @@ -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 { diff --git a/modules/frus-history-html.xqm b/modules/frus-history-html.xqm index 6a541f26c..35c963072 100644 --- a/modules/frus-history-html.xqm +++ b/modules/frus-history-html.xqm @@ -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 @@ -339,41 +385,46 @@ declare function fhh:article-list-sidebar($node, $model, $article-id) { } }; -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 {$title/string()} }; -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 ( -

By
- {$affiliation}

, + if ($author) then +

By +
+ {$affiliation} +

+ else + (),

Released

) }; -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" }) }; diff --git a/modules/search.xqm b/modules/search.xqm index 94083f43e..e7cd417c4 100644 --- a/modules/search.xqm +++ b/modules/search.xqm @@ -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") }; @@ -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)], diff --git a/urls.xml b/urls.xml index edb08a475..4cc32242b 100644 --- a/urls.xml +++ b/urls.xml @@ -42,8 +42,8 @@ - + @@ -55,11 +55,11 @@ - + - - + + From 569f0e9a6c4cc82f6f8eac94adb99e50c516a54b Mon Sep 17 00:00:00 2001 From: Joe Wicentowski Date: Thu, 2 May 2024 16:33:40 -0400 Subject: [PATCH 5/8] fix: extend logging in pages module --- modules/pages.xqm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/pages.xqm b/modules/pages.xqm index 934bc4dc0..2ab4d9ff0 100755 --- a/modules/pages.xqm +++ b/modules/pages.xqm @@ -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 || " 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 $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 @@ -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 ( @@ -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 ) }; @@ -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)) }; From d1a115e8046d79609b972c7d77c3dea78a27a154 Mon Sep 17 00:00:00 2001 From: Joe Wicentowski Date: Thu, 2 May 2024 16:34:46 -0400 Subject: [PATCH 6/8] feat: add prev/next nav to FRUS history articles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … and fix CSS --- .../frus-history/research/article.xml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pages/historicaldocuments/frus-history/research/article.xml b/pages/historicaldocuments/frus-history/research/article.xml index 773a740ba..156efbc14 100644 --- a/pages/historicaldocuments/frus-history/research/article.xml +++ b/pages/historicaldocuments/frus-history/research/article.xml @@ -2,14 +2,14 @@
-
+
-
+
@@ -20,6 +20,16 @@

+