diff --git a/site/layouts/partials/githubPolarisUrl.html b/site/layouts/partials/githubPolarisUrl.html new file mode 100644 index 00000000000..5bd5bcb1b60 --- /dev/null +++ b/site/layouts/partials/githubPolarisUrl.html @@ -0,0 +1,29 @@ +{{/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/}} + +{{/* +Returns a GitHub URL pointing to the given path in the apache/polaris repository, +resolved to the correct branch or tag for the current page's release version. + +Usage: {{ partial "githubPolarisUrl.html" (dict "page" . "path" "path/to/file") }} +*/}} + +{{- $gitRef := partial "polarisGitRef.html" .page -}} +{{- $url := printf "https://github.com/apache/polaris/blob/%s/%s" $gitRef.ref .path -}} +{{- return $url -}} diff --git a/site/layouts/partials/openapiUrl.html b/site/layouts/partials/incubatingSuffix.html similarity index 62% rename from site/layouts/partials/openapiUrl.html rename to site/layouts/partials/incubatingSuffix.html index 12bc686f5a7..efdc2ceac25 100644 --- a/site/layouts/partials/openapiUrl.html +++ b/site/layouts/partials/incubatingSuffix.html @@ -16,16 +16,21 @@ specific language governing permissions and limitations under the License. */}} -{{- $ver := partial "releaseVersion.html" . -}} -{{- $spec := ( .Get 0 ) -}} -{{- $url := "" -}} -{{- $incubating := "" -}} -{{- if lt $ver "1.4.0" -}} -{{- $incubating = "-incubating" -}} + +{{/* +Returns "-incubating" if the given release version predates graduation (< 1.4.0), +or "" otherwise. Pass "[unreleased]" to get "". + +Usage: {{ partial "incubatingSuffix.html" $ver }} +*/}} + +{{- $suffix := "" -}} +{{- if ne . "[unreleased]" -}} +{{- $parts := split . "." -}} +{{- $vMajor := index $parts 0 | int -}} +{{- $vMinor := index $parts 1 | int -}} +{{- if or (lt $vMajor 1) (and (eq $vMajor 1) (lt $vMinor 4)) -}} +{{- $suffix = "-incubating" -}} {{- end -}} -{{- if eq $ver "[unreleased]" -}} -{{- $url = printf "https://github.com/apache/polaris/raw/refs/heads/main/spec/%s" $spec }} -{{- else -}} -{{- $url = printf "https://github.com/apache/polaris/raw/refs/tags/apache-polaris-%s%s/spec/%s" $ver $incubating $spec }} {{- end -}} -{{- return $url -}} \ No newline at end of file +{{- return $suffix -}} diff --git a/site/layouts/partials/polarisGitRef.html b/site/layouts/partials/polarisGitRef.html new file mode 100644 index 00000000000..9024bc517d6 --- /dev/null +++ b/site/layouts/partials/polarisGitRef.html @@ -0,0 +1,35 @@ +{{/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/}} + +{{/* +Returns a dict describing the git ref for the current page's release version: + - ref: "main" for unreleased, or "apache-polaris-{ver}{incubating}" for a release + - isReleased: false for unreleased, true for a release + +Usage: {{ $gitRef := partial "polarisGitRef.html" . }} +*/}} + +{{- $ver := partial "releaseVersion.html" . -}} +{{- $result := dict "isReleased" false "ref" "main" -}} +{{- if ne $ver "[unreleased]" -}} +{{- $incubating := partial "incubatingSuffix.html" $ver -}} +{{- $ref := printf "apache-polaris-%s%s" $ver $incubating -}} +{{- $result = dict "isReleased" true "ref" $ref -}} +{{- end -}} +{{- return $result -}} diff --git a/site/layouts/partials/rawGithubPolarisUrl.html b/site/layouts/partials/rawGithubPolarisUrl.html new file mode 100644 index 00000000000..222bf2468b1 --- /dev/null +++ b/site/layouts/partials/rawGithubPolarisUrl.html @@ -0,0 +1,33 @@ +{{/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/}} + +{{/* +Returns a raw.githubusercontent.com URL pointing to the given path in the +apache/polaris repository, resolved to the correct branch or tag for the +current page's release version. + +Usage: {{ partial "rawGithubPolarisUrl.html" (dict "page" . "path" "path/to/file") }} +*/}} + +{{- $gitRef := partial "polarisGitRef.html" .page -}} +{{- $url := printf "https://raw.githubusercontent.com/apache/polaris/refs/heads/%s/%s" $gitRef.ref .path -}} +{{- if $gitRef.isReleased -}} +{{- $url = printf "https://raw.githubusercontent.com/apache/polaris/refs/tags/%s/%s" $gitRef.ref .path -}} +{{- end -}} +{{- return $url -}} diff --git a/site/layouts/shortcodes/github-polaris.html b/site/layouts/shortcodes/github-polaris.html index a155e59d517..832f187028c 100644 --- a/site/layouts/shortcodes/github-polaris.html +++ b/site/layouts/shortcodes/github-polaris.html @@ -17,11 +17,4 @@ under the License. */}} -{{- $ver := partial "releaseVersion.html" . -}} -{{- $path := ( .Get 0 ) -}} -{{- $url := "" -}} -{{- if eq $ver "[unreleased]" -}} -{{- printf "https://github.com/apache/polaris/blob/main/%s" $path }} -{{- else -}} -{{- printf "https://github.com/apache/polaris/blob/polaris-%s/%s" $path }} -{{- end -}} +{{- partial "githubPolarisUrl.html" (dict "page" . "path" (.Get 0)) -}} diff --git a/site/layouts/shortcodes/raw-github-polaris.html b/site/layouts/shortcodes/raw-github-polaris.html new file mode 100644 index 00000000000..8c9a0a8d04b --- /dev/null +++ b/site/layouts/shortcodes/raw-github-polaris.html @@ -0,0 +1,20 @@ +{{/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/}} + +{{- partial "rawGithubPolarisUrl.html" (dict "page" . "path" (.Get 0)) -}} diff --git a/site/layouts/shortcodes/redoc-polaris.html b/site/layouts/shortcodes/redoc-polaris.html index f6469305748..b7cc030a10c 100644 --- a/site/layouts/shortcodes/redoc-polaris.html +++ b/site/layouts/shortcodes/redoc-polaris.html @@ -13,20 +13,7 @@ {{- $spec := .Get 0 -}} {{- $otheroptions := .Get 1 -}} -{{- $url := "" -}} - -{{- $ver := partial "releaseVersion.html" . -}} -{{- $spec := ( .Get 0 ) -}} -{{- $url := "" -}} -{{- $incubating := "" -}} -{{- if lt $ver "1.4.0" -}} -{{- $incubating = "-incubating" -}} -{{- end -}} -{{- if eq $ver "[unreleased]" -}} -{{- $url = printf "https://raw.githubusercontent.com/apache/polaris/refs/heads/main/spec/%s" $spec }} -{{- else -}} -{{- $url = printf "https://raw.githubusercontent.com/apache/polaris/refs/tags/apache-polaris-%s%s/spec/%s" $ver $incubating $spec }} -{{- end -}} +{{- $url := partial "rawGithubPolarisUrl.html" (dict "page" . "path" (printf "spec/%s" $spec)) -}}