From ddb1adc26c0a038c3c17a79cff16b00126600424 Mon Sep 17 00:00:00 2001 From: Joe Wicentowski Date: Fri, 28 Jun 2024 12:17:04 -0400 Subject: [PATCH] fix: adopt community convention for XQuery modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … for all but those modules generated by tei-publisher-lib, which hardcodes the “xql” file extension --- controller.xql => controller.xq | 30 +++++++++---------- modules/{ext-fo.xql => ext-fo.xqm} | 0 modules/{ext-html.xql => ext-html.xqm} | 0 modules/{fo.xql => fo.xq} | 0 modules/{frus-ajax.xql => frus-ajax.xq} | 0 modules/frus-toc-html.xqm | 2 +- modules/lib/{epub.xql => epub.xqm} | 8 ++--- modules/lib/{get-epub.xql => get-epub.xq} | 4 +-- modules/lib/{regenerate.xql => regenerate.xq} | 0 modules/lib/{transform.xql => transform.xq} | 6 ++-- modules/lib/{util.xql => util.xqm} | 2 +- modules/{navigation.xql => navigation.xqm} | 0 modules/{opds-catalog.xql => opds-catalog.xq} | 2 +- modules/{open.xql => open.xq} | 4 +-- modules/pages.xqm | 2 +- modules/{pm-config.xql => pm-config.xqm} | 0 modules/{rebuild.xql => rebuild.xq} | 0 modules/sitemap-config.xqm | 4 +-- modules/{view.xql => view.xq} | 4 +-- modules/{volume-ids.xql => volume-ids.xq} | 0 .../{volume-images.xql => volume-images.xq} | 0 post-install.xql => post-install.xq | 10 +++---- pre-install.xql => pre-install.xq | 0 repo.xml.tmpl | 4 +-- 24 files changed, 41 insertions(+), 41 deletions(-) rename controller.xql => controller.xq (97%) rename modules/{ext-fo.xql => ext-fo.xqm} (100%) rename modules/{ext-html.xql => ext-html.xqm} (100%) rename modules/{fo.xql => fo.xq} (100%) rename modules/{frus-ajax.xql => frus-ajax.xq} (100%) rename modules/lib/{epub.xql => epub.xqm} (99%) rename modules/lib/{get-epub.xql => get-epub.xq} (97%) rename modules/lib/{regenerate.xql => regenerate.xq} (100%) rename modules/lib/{transform.xql => transform.xq} (96%) rename modules/lib/{util.xql => util.xqm} (98%) rename modules/{navigation.xql => navigation.xqm} (100%) rename modules/{opds-catalog.xql => opds-catalog.xq} (99%) rename modules/{open.xql => open.xq} (98%) rename modules/{pm-config.xql => pm-config.xqm} (100%) rename modules/{rebuild.xql => rebuild.xq} (100%) rename modules/{view.xql => view.xq} (99%) rename modules/{volume-ids.xql => volume-ids.xq} (100%) rename modules/{volume-images.xql => volume-images.xq} (100%) rename post-install.xql => post-install.xq (83%) rename pre-install.xql => pre-install.xq (100%) diff --git a/controller.xql b/controller.xq similarity index 97% rename from controller.xql rename to controller.xq index 3d7ed9477..b495d8940 100644 --- a/controller.xql +++ b/controller.xq @@ -41,7 +41,7 @@ declare function local:serve-not-found-page() as element() { local:render-page("error-page-404.xml") }; -declare variable $local:view-module-url := $exist:controller || "/modules/view.xql"; +declare variable $local:view-module-url := $exist:controller || "/modules/view.xq"; declare function local:render-page($page-template as xs:string, $parameters as map(*)) as element() { @@ -102,16 +102,16 @@ else if (ends-with($exist:path, "validate-results-of-twitter-jobs.xq")) then - + - + (: ignore direct requests to main modules :) -else if (ends-with($exist:resource, ".xql")) then +else if (ends-with($exist:resource, ".xq")) then @@ -123,7 +123,7 @@ else if (starts-with($exist:path, "/sitemap")) then (: reject ANY request with more than 4 path parts -> /a/b/c/d/e :) else if (count($path-parts) gt 4) then ( - util:log("info", ("hsg-shell controller.xql received >4 path parts: ", string-join($path-parts, ":"))), + util:log("info", ("hsg-shell controller.xq received >4 path parts: ", string-join($path-parts, ":"))), local:serve-not-found-page() ) @@ -237,7 +237,7 @@ else switch($path-parts[1]) default return (: return 404 for requests with unreasonable numbers of path path-parts :) if (count($path-parts) gt 3) then ( - util:log("info", ("hsg-shell controller.xql received >2 path-parts: ", string-join($path-parts, "/"))), + util:log("info", ("hsg-shell controller.xq received >2 path-parts: ", string-join($path-parts, "/"))), local:serve-not-found-page() ) else if (starts-with($path-parts[2], "frus")) then @@ -581,16 +581,16 @@ else switch($path-parts[1]) case "frus-latest.xml" return - - - + + + case "frus-metadata.xml" return - - - + + + default return @@ -666,8 +666,8 @@ else switch($path-parts[1]) case 'api' return if ($path-parts[2] eq 'v1') then - - + + @@ -680,7 +680,7 @@ else switch($path-parts[1]) case 'volume-ids' case 'volume-images' return - + default return diff --git a/modules/ext-fo.xql b/modules/ext-fo.xqm similarity index 100% rename from modules/ext-fo.xql rename to modules/ext-fo.xqm diff --git a/modules/ext-html.xql b/modules/ext-html.xqm similarity index 100% rename from modules/ext-html.xql rename to modules/ext-html.xqm diff --git a/modules/fo.xql b/modules/fo.xq similarity index 100% rename from modules/fo.xql rename to modules/fo.xq diff --git a/modules/frus-ajax.xql b/modules/frus-ajax.xq similarity index 100% rename from modules/frus-ajax.xql rename to modules/frus-ajax.xq diff --git a/modules/frus-toc-html.xqm b/modules/frus-toc-html.xqm index cdb546c86..1e7253a1e 100644 --- a/modules/frus-toc-html.xqm +++ b/modules/frus-toc-html.xqm @@ -307,7 +307,7 @@ declare function toc:paginate($child-document-count as xs:int, $start as xs:int) }; (: - TODO: Add processing this function to post-install.xql with the according permissions, + TODO: Add processing this function to post-install.xq with the according permissions, check for target collection and create a new, empty one, if necessary :) declare function toc:generate-frus-tocs() { diff --git a/modules/lib/epub.xql b/modules/lib/epub.xqm similarity index 99% rename from modules/lib/epub.xql rename to modules/lib/epub.xqm index 4f60b5449..b5d4ae56a 100644 --- a/modules/lib/epub.xql +++ b/modules/lib/epub.xqm @@ -15,10 +15,10 @@ xquery version "3.1"; module namespace epub = "http://exist-db.org/xquery/epub"; import module namespace config="http://history.state.gov/ns/site/hsg/config" at "../config.xqm"; -import module namespace pm-config="http://www.tei-c.org/tei-simple/pm-config" at "../pm-config.xql"; -import module namespace pages="http://www.tei-c.org/tei-simple/pages" at "pages.xql"; -import module namespace tpu="http://www.tei-c.org/tei-publisher/util" at "lib/util.xql"; -import module namespace nav="http://www.tei-c.org/tei-simple/navigation" at "../navigation.xql"; +import module namespace pm-config="http://www.tei-c.org/tei-simple/pm-config" at "../pm-config.xqm"; +import module namespace pages="http://www.tei-c.org/tei-simple/pages" at "pages.xqm"; +import module namespace tpu="http://www.tei-c.org/tei-publisher/util" at "lib/util.xqm"; +import module namespace nav="http://www.tei-c.org/tei-simple/navigation" at "../navigation.xqm"; declare namespace tei="http://www.tei-c.org/ns/1.0"; diff --git a/modules/lib/get-epub.xql b/modules/lib/get-epub.xq similarity index 97% rename from modules/lib/get-epub.xql rename to modules/lib/get-epub.xq index f1e642a74..5496d4edb 100644 --- a/modules/lib/get-epub.xql +++ b/modules/lib/get-epub.xq @@ -1,8 +1,8 @@ xquery version "3.1"; import module namespace config="http://history.state.gov/ns/site/hsg/config" at "../config.xqm"; -import module namespace epub="http://exist-db.org/xquery/epub" at "epub.xql"; -import module namespace pages="http://www.tei-c.org/tei-simple/pages" at "pages.xql"; +import module namespace epub="http://exist-db.org/xquery/epub" at "epub.xqm"; +import module namespace pages="http://www.tei-c.org/tei-simple/pages" at "pages.xqm"; declare namespace tei="http://www.tei-c.org/ns/1.0"; diff --git a/modules/lib/regenerate.xql b/modules/lib/regenerate.xq similarity index 100% rename from modules/lib/regenerate.xql rename to modules/lib/regenerate.xq diff --git a/modules/lib/transform.xql b/modules/lib/transform.xq similarity index 96% rename from modules/lib/transform.xql rename to modules/lib/transform.xq index c4d148853..c24f1a372 100644 --- a/modules/lib/transform.xql +++ b/modules/lib/transform.xq @@ -10,9 +10,9 @@ declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization"; declare namespace tei="http://www.tei-c.org/ns/1.0"; import module namespace config="http://history.state.gov/ns/site/hsg/config" at "../config.xqm"; -import module namespace pm-config="http://www.tei-c.org/tei-simple/pm-config" at "../pm-config.xql"; -import module namespace pages="http://www.tei-c.org/tei-simple/pages" at "pages.xql"; -import module namespace tpu="http://www.tei-c.org/tei-publisher/util" at "util.xql"; +import module namespace pm-config="http://www.tei-c.org/tei-simple/pm-config" at "../pm-config.xqm"; +import module namespace pages="http://www.tei-c.org/tei-simple/pages" at "pages.xqm"; +import module namespace tpu="http://www.tei-c.org/tei-publisher/util" at "util.xqm"; declare option output:method "html"; declare option output:html-version "5.0"; diff --git a/modules/lib/util.xql b/modules/lib/util.xqm similarity index 98% rename from modules/lib/util.xql rename to modules/lib/util.xqm index a1e0ebddc..d45a3b90f 100644 --- a/modules/lib/util.xql +++ b/modules/lib/util.xqm @@ -21,7 +21,7 @@ module namespace tpu="http://www.tei-c.org/tei-publisher/util"; import module namespace config="http://history.state.gov/ns/site/hsg/config" at "../config.xqm"; -import module namespace nav="http://www.tei-c.org/tei-simple/navigation" at "../navigation.xql"; +import module namespace nav="http://www.tei-c.org/tei-simple/navigation" at "../navigation.xqm"; declare function tpu:parse-pi($doc as document-node(), $view as xs:string?) { tpu:parse-pi($doc, $view, request:get-parameter("odd", ())) diff --git a/modules/navigation.xql b/modules/navigation.xqm similarity index 100% rename from modules/navigation.xql rename to modules/navigation.xqm diff --git a/modules/opds-catalog.xql b/modules/opds-catalog.xq similarity index 99% rename from modules/opds-catalog.xql rename to modules/opds-catalog.xq index 94be7c6b7..aa653c752 100644 --- a/modules/opds-catalog.xql +++ b/modules/opds-catalog.xq @@ -16,7 +16,7 @@ import module namespace tags="http://history.state.gov/ns/site/hsg/tags-html" at declare option output:method "xml"; declare variable $opds:opds-path := 'api/v1/catalog'; -declare variable $opds:server-url := substring-before(request:get-parameter('xql-application-url', ''), $opds:opds-path); +declare variable $opds:server-url := substring-before(request:get-parameter('xq-application-url', ''), $opds:opds-path); declare variable $opds:opds-base-url := $opds:server-url || $opds:opds-path; declare variable $opds:feed-author-name {'Office of the Historian'}; declare variable $opds:opds-search-url {concat($opds:server-url, 'opensearch.xml')}; diff --git a/modules/open.xql b/modules/open.xq similarity index 98% rename from modules/open.xql rename to modules/open.xq index 3c1f5f0a3..065ae358d 100644 --- a/modules/open.xql +++ b/modules/open.xq @@ -14,7 +14,7 @@ import module namespace app="http://history.state.gov/ns/site/hsg/templates" at declare option output:method "xml"; -declare variable $application-url := request:get-parameter('xql-application-url', ''); +declare variable $application-url := request:get-parameter('xq-application-url', ''); declare function open:frus-latest() { @@ -227,7 +227,7 @@ declare function open:frus-metadata() { }; -switch(request:get-parameter('xql-feed', '')) +switch(request:get-parameter('xq-feed', '')) case 'latest' return open:frus-latest() case 'metadata' return open:frus-metadata() default return diff --git a/modules/pages.xqm b/modules/pages.xqm index 325d4d303..08acdfc46 100755 --- a/modules/pages.xqm +++ b/modules/pages.xqm @@ -77,7 +77,7 @@ function pages:load($node as node(), $model as map(*), $publication-id as xs:str () let $created := if (exists($publication-id) and exists($document-id)) then - (: No need to truncate creation date; it'll be serialized in view.xql :) + (: No need to truncate creation date; it'll be serialized in view.xq :) pages:created($publication-id, $document-id, $section-id) else () diff --git a/modules/pm-config.xql b/modules/pm-config.xqm similarity index 100% rename from modules/pm-config.xql rename to modules/pm-config.xqm diff --git a/modules/rebuild.xql b/modules/rebuild.xq similarity index 100% rename from modules/rebuild.xql rename to modules/rebuild.xq diff --git a/modules/sitemap-config.xqm b/modules/sitemap-config.xqm index 46d748a3d..dc972ddd0 100755 --- a/modules/sitemap-config.xqm +++ b/modules/sitemap-config.xqm @@ -827,7 +827,7 @@ function site:cwpfus-with-param-select($select as attribute(select), $state as m }; declare function site:get-url() { - (: imported from old controller.xql :) + (: imported from old controller.xq :) concat( request:get-scheme(), '://', @@ -843,7 +843,7 @@ declare function site:get-url() { }; declare function site:get-uri() { - (: imported from old controller.xql :) + (: imported from old controller.xq :) let $uri := (request:get-header("nginx-request-uri"), request:get-uri())[1] return if (contains($uri, "?")) then diff --git a/modules/view.xql b/modules/view.xq similarity index 99% rename from modules/view.xql rename to modules/view.xq index dcb011c3e..9110050a1 100755 --- a/modules/view.xql +++ b/modules/view.xq @@ -1,11 +1,11 @@ (:~ - : This is the main XQuery which will (by default) be called by controller.xql + : This is the main XQuery which will (by default) be called by controller.xq : to process any URI ending with ".html". It receives the HTML from : the controller and passes it to the templating system. :) xquery version "3.0"; -import module namespace templates="http://exist-db.org/xquery/html-templating" ; +import module namespace templates="http://exist-db.org/xquery/html-templating"; (: : The following modules provide functions which will be called by the diff --git a/modules/volume-ids.xql b/modules/volume-ids.xq similarity index 100% rename from modules/volume-ids.xql rename to modules/volume-ids.xq diff --git a/modules/volume-images.xql b/modules/volume-images.xq similarity index 100% rename from modules/volume-images.xql rename to modules/volume-images.xq diff --git a/post-install.xql b/post-install.xq similarity index 83% rename from post-install.xql rename to post-install.xq index 212506ac0..ee4312345 100644 --- a/post-install.xql +++ b/post-install.xq @@ -43,11 +43,11 @@ declare function local:generate-code($collection as xs:string) { ) }; -sm:chmod(xs:anyURI($target || "/modules/view.xql"), "rwsr-xr-x"), -sm:chmod(xs:anyURI($target || "/modules/frus-ajax.xql"), "rwsr-xr-x"), -sm:chmod(xs:anyURI($target || "/modules/fo.xql"), "rwsr-xr-x"), -sm:chmod(xs:anyURI($target || "/modules/lib/regenerate.xql"), "rwsr-xr-x"), +sm:chmod(xs:anyURI($target || "/modules/view.xq"), "rwsr-xr-x"), +sm:chmod(xs:anyURI($target || "/modules/frus-ajax.xq"), "rwsr-xr-x"), +sm:chmod(xs:anyURI($target || "/modules/fo.xq"), "rwsr-xr-x"), +sm:chmod(xs:anyURI($target || "/modules/lib/regenerate.xq"), "rwsr-xr-x"), (:sm:chmod(xs:anyURI($target || "/tests/xquery/validate-results-of-twitter-jobs.xq"), "rwsr-xr-x"),:) -util:eval(xs:anyURI($target || "/modules/lib/regenerate.xql")), +util:eval(xs:anyURI($target || "/modules/lib/regenerate.xq")), local:generate-code($target) diff --git a/pre-install.xql b/pre-install.xq similarity index 100% rename from pre-install.xql rename to pre-install.xq diff --git a/repo.xml.tmpl b/repo.xml.tmpl index a76c39bfc..f0227fd0b 100644 --- a/repo.xml.tmpl +++ b/repo.xml.tmpl @@ -8,8 +8,8 @@ true application hsg-shell - pre-install.xql - post-install.xql + pre-install.xq + post-install.xq