From 91febc749149b4a181525e44c18e22cec3daad12 Mon Sep 17 00:00:00 2001 From: Kim Coleman Date: Tue, 18 Jul 2017 09:40:35 -0700 Subject: [PATCH] For #702, change assumptions about version format so we can host minor version updates of docs --- src/apidoc/controller/rewrite.xqm | 4 ++-- src/apidoc/model/data-access.xqy | 2 +- src/apidoc/setup/toc.xqm | 2 +- src/js/rundmc_init.js | 10 +++++----- src/model/data-access.xqy | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/apidoc/controller/rewrite.xqm b/src/apidoc/controller/rewrite.xqm index b72424fc3..020125582 100644 --- a/src/apidoc/controller/rewrite.xqm +++ b/src/apidoc/controller/rewrite.xqm @@ -52,8 +52,8 @@ declare variable $QUERY-STRING := substring-after($URL-ORIG, '?'); declare variable $QUERY-STRING-FIELDS := xdmp:get-request-field-names() ; declare variable $VERSION-SPECIFIED := ( - if (matches($PATH, '^/\d\.\d$')) then substring-after($PATH, '/') - else if (matches($PATH, '^/\d\.\d/')) then substring-before( + if (matches($PATH, '^/\d+\.\d+(-\d+)?$')) then substring-after($PATH, '/') + else if (matches($PATH, '^/\d+\.\d+(-\d+)?/')) then substring-before( substring-after($PATH, '/'), '/') else "") ; diff --git a/src/apidoc/model/data-access.xqy b/src/apidoc/model/data-access.xqy index fe11b54bc..8e08a5a1f 100755 --- a/src/apidoc/model/data-access.xqy +++ b/src/apidoc/model/data-access.xqy @@ -60,7 +60,7 @@ declare variable $TYPE-JS-PAT := '(.+[^\?\*\+])([\?\*\+])?' ; declare function api:version-dir($version as xs:string) as xs:string { - if (matches($version, '^\d+\.\d+$')) then concat("/apidoc/", $version, "/") + if (matches($version, '^\d+\.\d+(-\d+)?$')) then concat("/apidoc/", $version, "/") else error((), 'APIDOC-BADVERSION', xdmp:describe($version)) }; diff --git a/src/apidoc/setup/toc.xqm b/src/apidoc/setup/toc.xqm index 1fb4ccb47..83f0cf138 100755 --- a/src/apidoc/setup/toc.xqm +++ b/src/apidoc/setup/toc.xqm @@ -1272,7 +1272,7 @@ as element(toc:node) (: By now the JavaScript translation should already have happened. :) case $api:MODE-REST return api:reverse-translate-REST-resource-name( (: For 5.0 hide the verb. :) - if (xs:double($version) gt 5.0) then $function-name + if ($version ne "5.0") then $function-name else api:name-from-REST-fullname($function-name)) default return $function-name) let $href as xs:string := ( diff --git a/src/js/rundmc_init.js b/src/js/rundmc_init.js index 8cb53feb3..84595ac82 100644 --- a/src/js/rundmc_init.js +++ b/src/js/rundmc_init.js @@ -352,8 +352,8 @@ function versionSelectInit() { var oldQuery = window.location.search; // Handle different positioning of version strings. var newQuery = oldQuery - .replace(/\?v=\d+\.\d+/, "?v=" + version) - .replace(/&v=\d+\.\d+/, "&v=" + version); + .replace(/\?v=\d+\.\d+(?:-\d+)?/, "?v=" + version) + .replace(/&v=\d+\.\d+(?:-\d+)?/, "&v=" + version); // Handle no version string. if (newQuery == oldQuery) newQuery += "&v=" + version; @@ -365,11 +365,11 @@ function versionSelectInit() { var newPath = oldPath; if (version == defaultVersion) { LOG.debug("using default", defaultVersion); - newPath = oldPath.replace(/^\/\d+\.\d+/, ""); - } else if (oldPath.match(/^\/\d+\.\d+/)) { + newPath = oldPath.replace(/^\/\d+\.\d+(?:-\d+)?/, ""); + } else if (oldPath.match(/^\/\d+\.\d+(?:-\d+)?/)) { LOG.debug("replacing old with", version); newPath = oldPath.replace( - /^\/\d+\.\d+/, "/" + version); + /^\/\d+\.\d+(?:-\d+)?/, "/" + version); } else { LOG.debug("prepending", version); newPath = '/' + version + oldPath; diff --git a/src/model/data-access.xqy b/src/model/data-access.xqy index b6754602d..5a5f5054a 100755 --- a/src/model/data-access.xqy +++ b/src/model/data-access.xqy @@ -80,7 +80,7 @@ declare variable $server-versions-available as xs:string+ := cts:uris( (), (), cts:document-query( $server-versions ! concat('/apidoc/', ., '/index.xml'))) -! replace(., '/apidoc/(\d+\.\d+)/index.xml', '$1') ; +! replace(., '/apidoc/(\d+\.\d+(-\d+)?)/index.xml', '$1') ; declare variable $server-version-nodes-available as element()+ := ( $server-version-nodes[@number = $server-versions-available]) ; @@ -1002,7 +1002,7 @@ as xs:string? { (for $v in distinct-values($list ! normalize-space(.)) where $v = $server-versions-available - order by xs:double($v) descending + order by $v descending return $v)[1] };