Skip to content

Commit

Permalink
For #702, change assumptions about version format so we can host mino…
Browse files Browse the repository at this point in the history
…r version updates of docs
  • Loading branch information
kcoleman-marklogic committed Jul 18, 2017
1 parent 6b5f7e0 commit 91febc7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/apidoc/controller/rewrite.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -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 "") ;

Expand Down
2 changes: 1 addition & 1 deletion src/apidoc/model/data-access.xqy
Original file line number Diff line number Diff line change
Expand Up @@ -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))
};

Expand Down
2 changes: 1 addition & 1 deletion src/apidoc/setup/toc.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -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 := (
Expand Down
10 changes: 5 additions & 5 deletions src/js/rundmc_init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/model/data-access.xqy
Original file line number Diff line number Diff line change
Expand Up @@ -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]) ;

Expand Down Expand Up @@ -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]
};

Expand Down

0 comments on commit 91febc7

Please sign in to comment.