forked from apache/arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversionwarning.js
More file actions
134 lines (132 loc) · 7.1 KB
/
Copy pathversionwarning.js
File metadata and controls
134 lines (132 loc) · 7.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// 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}`)
}
});
}
});
}
});
}
})()