This is an automated email from the ASF dual-hosted git repository.

jorisvandenbossche pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/arrow-site.git


The following commit(s) were added to refs/heads/asf-site by this push:
     new 35e3a970e7e Update how versionwarning.js handles doc versions with 
more than one digit (#312)
35e3a970e7e is described below

commit 35e3a970e7e8905decab930ea45b8a9ce9dad7b6
Author: Alenka Frim <[email protected]>
AuthorDate: Tue Feb 14 09:00:52 2023 +0100

    Update how versionwarning.js handles doc versions with more than one digit 
(#312)
    
    This PR corrects the check for version number of the documentation when
    adding version warnings to the html files.
    See: https://github.com/apache/arrow/issues/34023
    
    Also, additional copying of the versionwarning.js file seems to happen
    with the release. Currently there are three versions of the same file:
    
    - docs/_static/versionwarning.js
    - docs/dev/_static/versionwarning.js
    - docs/10.0/_static/versionwarning.js
    
    Second and third should be redundant and are removed with this PR. I
    will create a separate issue on the apache/arrow repo to research and
    correct how the versionwarning.js file is being copied.
    
    ---------
    
    Co-authored-by: Sutou Kouhei <[email protected]>
---
 docs/10.0/_static/versionwarning.js | 117 -------------------------------
 docs/_static/versionwarning.js      |   9 +--
 docs/dev/_static/versionwarning.js  | 134 ------------------------------------
 3 files changed, 5 insertions(+), 255 deletions(-)

diff --git a/docs/10.0/_static/versionwarning.js 
b/docs/10.0/_static/versionwarning.js
deleted file mode 100644
index be7777fe9b2..00000000000
--- a/docs/10.0/_static/versionwarning.js
+++ /dev/null
@@ -1,117 +0,0 @@
-(function() {
-    // adapted 2022-11 from https://mne.tools/versionwarning.js
-    if (location.hostname == 'arrow.apache.org') {
-        $.getJSON("https://arrow.apache.org/docs/_static/versions.json";, 
function(data){
-            var latestStable = data[1].name.replace(" (stable)","");
-            // HTML tags
-            var pre = '<div class="container-fluid alert-danger devbar"><div 
class="row no-gutters"><div class="col-12 text-center">';
-            var post = '</div></div></div>';
-            var anchor = 'class="btn btn-danger font-weight-bold ml-3 my-3 
align-baseline"';
-            // Switch button message
-            var switch_dev = `Switch to unstable development release version`;
-            var switch_stable = `latest stable release (version 
${latestStable})`;
-            // Path of the page
-            var location_array = location.pathname.split('/');
-            var versionPath = location_array[2];
-            var subPath = location_array[3];
-            var filePath = location_array.slice(3).join('/');
-            // Links to stable or dev versions
-            var uri_dev = `https://arrow.apache.org/docs/dev/${filePath}`;
-            var uri_stable = `https://arrow.apache.org/docs/${filePath}`;
-
-            if (versionPath == 'developers') {
-                // developers section in the stable version
-                filePath = location_array.slice(2).join('/');
-                uri_dev = `https://arrow.apache.org/docs/dev/${filePath}`;
-                $.ajax({
-                    type: 'HEAD',
-                    url: `${uri_dev}`,
-                    error: function() {
-                        filePath = '';
-                        uri_dev = 
`https://arrow.apache.org/docs/dev/${filePath}`;
-                    },
-                    complete: function() {
-                        var showWarning = `${pre}This is documentation for the 
stable version ` +
-                                        `of Apache Arrow (version 
${latestStable}). For latest development practices: ` +
-                                        `<a ${anchor} 
href=${uri_dev}>${switch_dev}</a>${post}`
-                        $('.container-fluid').prepend(`${showWarning}`)
-                    }
-                });
-            } else if (versionPath.match(/^\d/) < "4") {
-                // old versions 1.0,. 2.0 or 3.0
-                $.ajax({
-                    type: 'HEAD',
-                    url: `${uri_stable}`,
-                    error: function() {
-                        filePath = '';
-                        uri_stable = 
`https://arrow.apache.org/docs/${filePath}`;
-                    },
-                    complete: function() {
-                        $.ajax({
-                            type: 'HEAD',
-                            url: `${uri_dev}`,
-                            error: function() {
-                                filePath = '';
-                                uri_dev = 
`https://arrow.apache.org/docs/dev/${filePath}`;
-                            },
-                            complete: function() {
-                                pre = '<p style="padding: 1em;font-size: 
1em;border: 1px solid red;background: pink;">';
-                                post = '</p>';
-                                anchor = 'class="btn btn-danger" 
style="font-weight: bold; vertical-align: baseline;' +
-                                        'margin: 0.5rem; border-style: solid; 
border-color: white;"';
-                                var showWarning = `${pre}This is documentation 
for an old release of ` +
-                                                `Apache Arrow (version 
${versionPath}). Try the` +
-                                                `<a ${anchor} 
href=${uri_stable}>${switch_stable}</a> or` +
-                                                `<a ${anchor} 
href=${uri_dev}>development (unstable) version. </a>${post}`
-                                $('.document').prepend(`${showWarning}`)
-                            }
-                        });
-                    }
-                });
-            } else if (versionPath.match(/^\d/) && subPath == 'developers') {
-                // older versions of developers section (with numbered version 
in the URL)
-                $.ajax({
-                    type: 'HEAD',
-                    url: `${uri_dev}`,
-                    error: function() {
-                        filePath = '';
-                        uri_dev = 
`https://arrow.apache.org/docs/dev/${filePath}`;
-                    },
-                    complete: function() {
-                        var showWarning = `${pre}This is documentation for an 
old release of Apache Arrow ` +
-                                        `(version ${versionPath}). For latest 
development practices: ` +
-                                        `<a ${anchor} 
href=${uri_dev}>${switch_dev} </a>${post}`
-                        $('.container-fluid').prepend(`${showWarning}`)
-                    }
-                });
-            } else if (versionPath.match(/^\d/)) {
-                // older versions (with numbered version in the URL)
-                $.ajax({
-                    type: 'HEAD',
-                    url: `${uri_stable}`,
-                    error: function() {
-                        filePath = '';
-                        uri_stable = 
`https://arrow.apache.org/docs/${filePath}`;
-                    },
-                    complete: function() {
-                        $.ajax({
-                            type: 'HEAD',
-                            url: `${uri_dev}`,
-                            error: function() {
-                                filePath = '';
-                                uri_dev = 
`https://arrow.apache.org/docs/dev/${filePath}`;
-                            },
-                            complete: function() {
-                                var showWarning = `${pre}This is documentation 
for an old release of ` +
-                                                `Apache Arrow (version 
${versionPath}). Try the` +
-                                                `<a ${anchor} 
href=${uri_stable}>${switch_stable}</a> or` +
-                                                `<a ${anchor} 
href=${uri_dev}>development (unstable) version. </a>${post}`
-                                $('.container-fluid').prepend(`${showWarning}`)
-                            }
-                        });
-                    }
-                });
-            }
-        });
-    }
-})()
diff --git a/docs/_static/versionwarning.js b/docs/_static/versionwarning.js
index a9bea99affa..f7d2a7c511b 100644
--- a/docs/_static/versionwarning.js
+++ b/docs/_static/versionwarning.js
@@ -30,6 +30,7 @@
             // Path of the page
             var location_array = location.pathname.split('/');
             var versionPath = location_array[2];
+            var versionNumber = Number(versionPath.match(/^\d+/))
             var subPath = location_array[3];
             var filePath = location_array.slice(3).join('/');
             // Links to stable or dev versions
@@ -54,8 +55,8 @@
                         $('.container-fluid').prepend(`${showWarning}`)
                     }
                 });
-            } else if (versionPath.match(/^\d/) < "4") {
-                // old versions 1.0,. 2.0 or 3.0
+            } else if (versionNumber < 4) {
+                // old versions 1.0, 2.0 or 3.0
                 $.ajax({
                     type: 'HEAD',
                     url: `${uri_stable}`,
@@ -85,7 +86,7 @@
                         });
                     }
                 });
-            } else if (versionPath.match(/^\d/) && subPath == 'developers') {
+            } else if (versionNumber && subPath == 'developers') {
                 // older versions of developers section (with numbered version 
in the URL)
                 $.ajax({
                     type: 'HEAD',
@@ -101,7 +102,7 @@
                         $('.container-fluid').prepend(`${showWarning}`)
                     }
                 });
-            } else if (versionPath.match(/^\d/)) {
+            } else if (versionNumber) {
                 // older versions (with numbered version in the URL)
                 $.ajax({
                     type: 'HEAD',
diff --git a/docs/dev/_static/versionwarning.js 
b/docs/dev/_static/versionwarning.js
deleted file mode 100644
index a9bea99affa..00000000000
--- a/docs/dev/_static/versionwarning.js
+++ /dev/null
@@ -1,134 +0,0 @@
-// 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.
-
-(function() {
-    // adapted 2022-11 from https://mne.tools/versionwarning.js
-    if (location.hostname == 'arrow.apache.org') {
-        $.getJSON("https://arrow.apache.org/docs/_static/versions.json";, 
function(data){
-            var latestStable = data[1].name.replace(" (stable)","");
-            // HTML tags
-            var pre = '<div class="container-fluid alert-danger devbar"><div 
class="row no-gutters"><div class="col-12 text-center">';
-            var post = '</div></div></div>';
-            var anchor = 'class="btn btn-danger font-weight-bold ml-3 my-3 
align-baseline"';
-            // Switch button message
-            var switch_dev = `Switch to unstable development release version`;
-            var switch_stable = `latest stable release (version 
${latestStable})`;
-            // Path of the page
-            var location_array = location.pathname.split('/');
-            var versionPath = location_array[2];
-            var subPath = location_array[3];
-            var filePath = location_array.slice(3).join('/');
-            // Links to stable or dev versions
-            var uri_dev = `https://arrow.apache.org/docs/dev/${filePath}`;
-            var uri_stable = `https://arrow.apache.org/docs/${filePath}`;
-
-            if (versionPath == 'developers') {
-                // developers section in the stable version
-                filePath = location_array.slice(2).join('/');
-                uri_dev = `https://arrow.apache.org/docs/dev/${filePath}`;
-                $.ajax({
-                    type: 'HEAD',
-                    url: `${uri_dev}`,
-                    error: function() {
-                        filePath = '';
-                        uri_dev = 
`https://arrow.apache.org/docs/dev/${filePath}`;
-                    },
-                    complete: function() {
-                        var showWarning = `${pre}This is documentation for the 
stable version ` +
-                                        `of Apache Arrow (version 
${latestStable}). For latest development practices: ` +
-                                        `<a ${anchor} 
href=${uri_dev}>${switch_dev}</a>${post}`
-                        $('.container-fluid').prepend(`${showWarning}`)
-                    }
-                });
-            } else if (versionPath.match(/^\d/) < "4") {
-                // old versions 1.0,. 2.0 or 3.0
-                $.ajax({
-                    type: 'HEAD',
-                    url: `${uri_stable}`,
-                    error: function() {
-                        filePath = '';
-                        uri_stable = 
`https://arrow.apache.org/docs/${filePath}`;
-                    },
-                    complete: function() {
-                        $.ajax({
-                            type: 'HEAD',
-                            url: `${uri_dev}`,
-                            error: function() {
-                                filePath = '';
-                                uri_dev = 
`https://arrow.apache.org/docs/dev/${filePath}`;
-                            },
-                            complete: function() {
-                                pre = '<p style="padding: 1em;font-size: 
1em;border: 1px solid red;background: pink;">';
-                                post = '</p>';
-                                anchor = 'class="btn btn-danger" 
style="font-weight: bold; vertical-align: baseline;' +
-                                        'margin: 0.5rem; border-style: solid; 
border-color: white;"';
-                                var showWarning = `${pre}This is documentation 
for an old release of ` +
-                                                `Apache Arrow (version 
${versionPath}). Try the` +
-                                                `<a ${anchor} 
href=${uri_stable}>${switch_stable}</a> or` +
-                                                `<a ${anchor} 
href=${uri_dev}>development (unstable) version. </a>${post}`
-                                $('.document').prepend(`${showWarning}`)
-                            }
-                        });
-                    }
-                });
-            } else if (versionPath.match(/^\d/) && subPath == 'developers') {
-                // older versions of developers section (with numbered version 
in the URL)
-                $.ajax({
-                    type: 'HEAD',
-                    url: `${uri_dev}`,
-                    error: function() {
-                        filePath = '';
-                        uri_dev = 
`https://arrow.apache.org/docs/dev/${filePath}`;
-                    },
-                    complete: function() {
-                        var showWarning = `${pre}This is documentation for an 
old release of Apache Arrow ` +
-                                        `(version ${versionPath}). For latest 
development practices: ` +
-                                        `<a ${anchor} 
href=${uri_dev}>${switch_dev} </a>${post}`
-                        $('.container-fluid').prepend(`${showWarning}`)
-                    }
-                });
-            } else if (versionPath.match(/^\d/)) {
-                // older versions (with numbered version in the URL)
-                $.ajax({
-                    type: 'HEAD',
-                    url: `${uri_stable}`,
-                    error: function() {
-                        filePath = '';
-                        uri_stable = 
`https://arrow.apache.org/docs/${filePath}`;
-                    },
-                    complete: function() {
-                        $.ajax({
-                            type: 'HEAD',
-                            url: `${uri_dev}`,
-                            error: function() {
-                                filePath = '';
-                                uri_dev = 
`https://arrow.apache.org/docs/dev/${filePath}`;
-                            },
-                            complete: function() {
-                                var showWarning = `${pre}This is documentation 
for an old release of ` +
-                                                `Apache Arrow (version 
${versionPath}). Try the` +
-                                                `<a ${anchor} 
href=${uri_stable}>${switch_stable}</a> or` +
-                                                `<a ${anchor} 
href=${uri_dev}>development (unstable) version. </a>${post}`
-                                $('.container-fluid').prepend(`${showWarning}`)
-                            }
-                        });
-                    }
-                });
-            }
-        });
-    }
-})()

Reply via email to