Skip to content

Commit 9de8c83

Browse files
authored
Merge pull request #643 from pllim/fix-console-error
Only parse roles.json on Team page + other fixes
2 parents dfd423e + 5186607 commit 9de8c83

File tree

5 files changed

+122
-155
lines changed

5 files changed

+122
-155
lines changed

affiliated/index.html

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,9 @@ <h1 id="affiliated-package-list">Affiliated Packages Registry<a class="paralink"
190190
</tr>
191191
</thead>
192192
<tbody valign="top">
193-
<tr class="row-even"><td rowspan="1">Loading...</td>
194-
<td rowspan="1">&nbsp;</td>
195-
<td rowspan="1">&nbsp;</td>
196-
<td rowspan="1">&nbsp;</td>
197-
<td rowspan="1">&nbsp;</td>
193+
<tr class="row-even">
194+
<td colspan="1">&nbsp;</td>
195+
<td colspan="3">&nbsp;</td>
198196
</tr>
199197
<tr class="row-odd">
200198
<td colspan="1">&nbsp;</td>
@@ -403,9 +401,7 @@ <h2 id="new-affil-reviewer">I am a new reviewer<a class="paralink" href="#new-af
403401
var parsed = yaml.parse(yamlString);
404402
var i = 0;
405403

406-
// We have to delete the "Loading..." row
407404
var tab = document.getElementById("pyos-package-table");
408-
tab.deleteRow(1);
409405

410406
var info = "";
411407
for (var p=0; p<parsed.length; p++) {

getteam.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
Note that this first looks for the ``ASTROPY_REPO_PATH`` environment
66
variable to try to find a local copy of the astropy repo.
77
"""
8-
from __future__ import print_function
98

109

1110
def get_astropy_credits(warner=print):

history.html

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,6 @@
1616
<!-- Google analytics -->
1717
<script src="js/analytics.js"></script>
1818

19-
<!-- Meow woof -->
20-
<script>
21-
window.onload = function() {
22-
23-
$.getJSON('https://pypi.org/pypi/astropy/json', function(data) {
24-
document.getElementById('core-package-version').innerHTML = 'Current Version: ' + data.info.version;
25-
});
26-
27-
28-
var today = new Date();
29-
var month = today.getMonth() + 1;
30-
var date = today.getDate();
31-
32-
if (month == 4 && date == 1) {
33-
$('#hero img').attr('src', 'images/astropy_meow.png');
34-
$('#hero img').attr('onerror', 'this.src=\x27images/astropy_meow.png\x27; this.onerror=null;');
35-
36-
var dogeContainer = document.getElementById("prenew");
37-
var dogeImg = document.createElement("img");
38-
dogeImg.onload=function() {
39-
dogeContainer.appendChild(dogeImg);
40-
}
41-
dogeImg.src = 'images/astropy_doge.png';
42-
dogeImg.alt = 'wow so open very python';
43-
}
44-
45-
};
46-
</script>
47-
4819
</head>
4920

5021
<body>

js/functions.js

Lines changed: 113 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -22,123 +22,6 @@ $( document ).ready(function(){
2222
$(this).removeClass("subhover"); //On hover out, remove class "subhover"
2323
});
2424

25-
//creating Astropy roles table & roles lists using roles.json
26-
var request = new XMLHttpRequest();
27-
var dataURL = "roles.json";
28-
request.open('GET', dataURL);
29-
request.responseType = 'json';
30-
request.send();
31-
32-
//log error when request gets failed
33-
request.onerror = function () {
34-
console.log("XHR error");
35-
};
36-
37-
request.onload = function () {
38-
//received json data via XHR
39-
var data = request.response;
40-
//creating roles table from json data
41-
createRolesTable(data);
42-
//creating roles lists from json data
43-
createRolesDescription(data);
44-
};
45-
46-
function createRolesTable(roles) {
47-
//roles is an array of objects called "role"
48-
var rows = '';
49-
roles.forEach(function (role) {
50-
//role is an object containing information about each team role
51-
//index marks current people
52-
var index = 0;
53-
54-
// for roles where there are no sub-roles, the people are defined
55-
// at the top-level of the JSON role dict - for convenience below we create
56-
// a virtual sub-role with no heading
57-
if (!('sub-roles' in role)) {
58-
role['sub-roles'] = [{'role': '',
59-
'people': role['people']}];
60-
}
61-
62-
//creating each row by iterating over each person in a role
63-
role["sub-roles"].forEach(function (subrole) {
64-
//rowRole is displayed once for each role
65-
rowRole = index == 0 ? '<a href="#' + role["url"] + '">' + role["role"] + '</a>' : "";
66-
67-
var rowSubRole = subrole['role'];
68-
69-
if (subrole['people'][0] == "Unfilled") {
70-
rowPeople = '<a href="mailto:[email protected]"><span style="font-style: italic;">Unfilled</span></a>';
71-
} else {
72-
rowPeople = subrole['people'].join(', ');
73-
}
74-
75-
//generating rows
76-
if (index == 0) {
77-
rows += '<tr class="border-top">';
78-
} else {
79-
rows += '<tr>';
80-
}
81-
82-
rows += '<td>' + rowRole + '</td>' +
83-
'<td>' + rowSubRole + '</td>' +
84-
'<td>' + rowPeople + '</td>' +
85-
'</tr>';
86-
index++;
87-
});
88-
});
89-
90-
$("#roles-table").append(rows);
91-
}
92-
93-
function createRolesDescription(roles) {
94-
//roles is an array of objects called "role"
95-
var blocks = "";
96-
roles.forEach(function (role) {
97-
//role is an object containing information about each team role
98-
var list = "";
99-
//checking if role["description"] array isn't empty
100-
if (role["responsibilities"] != null) {
101-
102-
// If responsibilities is a dict, wrap inside a list so that all entries have a list
103-
// dicts
104-
if (role['responsibilities'].constructor == Object) {
105-
role['responsibilities'] = [role['responsibilities']];
106-
}
107-
108-
console.log(role['responsibilities']);
109-
110-
blocks += '<br/>' +
111-
'<h3 id="' + role["url"] + '">' + role["role-head"] + '</h3>';
112-
113-
index = 0;
114-
115-
role['responsibilities'].forEach(function (resp) {
116-
117-
console.log(resp);
118-
119-
detail_list = '';
120-
resp["details"].forEach(function (detail) {
121-
detail_list += '<li>' + detail + '</li>';
122-
});
123-
124-
if ('subrole-head' in resp) {
125-
if (index > 0) {
126-
blocks += '<br>';
127-
}
128-
blocks += '<em>' + resp["subrole-head"] + '</em>';
129-
}
130-
blocks += '<p>' + resp["description"] + '</p>' +
131-
'<ul>' + detail_list + '</ul>';
132-
133-
index += 1;
134-
135-
})
136-
137-
}
138-
});
139-
$("#roles-description").append(blocks);
140-
}
141-
14225
$('#os-selector ul').each(function(){
14326
// For each set of tabs, we want to keep track of
14427
// which tab is active and it's associated content
@@ -255,6 +138,7 @@ function pypi_translator(pypiname) {
255138
}
256139
}
257140

141+
258142
function bool_translator(stable) {
259143
if (stable) {
260144
return 'Yes';
@@ -263,6 +147,7 @@ function bool_translator(stable) {
263147
}
264148
}
265149

150+
266151
function ghuser_translator(fullname, ghname) {
267152
if (fullname === undefined || ghname === undefined) {
268153
return 'None';
@@ -272,6 +157,7 @@ function ghuser_translator(fullname, ghname) {
272157
}
273158
}
274159

160+
275161
var _email_regex_str = '[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}';
276162
var _email_regex = new RegExp(_email_regex_str, 'i');
277163
var _email_with_name_regex = new RegExp('(.+)<(' + _email_regex_str + ')>', 'i');
@@ -292,11 +178,118 @@ function maintainer_translator(maint, pkgnm) {
292178
}
293179

294180

181+
function createRolesTable(roles) {
182+
//roles is an array of objects called "role"
183+
var rows = '';
184+
roles.forEach(function (role) {
185+
//role is an object containing information about each team role
186+
//index marks current people
187+
var index = 0;
188+
189+
// for roles where there are no sub-roles, the people are defined
190+
// at the top-level of the JSON role dict - for convenience below we create
191+
// a virtual sub-role with no heading
192+
if (!('sub-roles' in role)) {
193+
role['sub-roles'] = [{'role': '',
194+
'people': role['people']}];
195+
}
196+
197+
//creating each row by iterating over each person in a role
198+
role["sub-roles"].forEach(function (subrole) {
199+
//rowRole is displayed once for each role
200+
rowRole = index == 0 ? '<a href="#' + role["url"] + '">' + role["role"] + '</a>' : "";
201+
202+
var rowSubRole = subrole['role'];
203+
204+
if (subrole['people'][0] == "Unfilled") {
205+
rowPeople = '<a href="mailto:[email protected]"><span style="font-style: italic;">Unfilled</span></a>';
206+
} else {
207+
rowPeople = subrole['people'].join(', ');
208+
}
209+
210+
//generating rows
211+
if (index == 0) {
212+
rows += '<tr class="border-top">';
213+
} else {
214+
rows += '<tr>';
215+
}
216+
217+
rows += '<td>' + rowRole + '</td>' +
218+
'<td>' + rowSubRole + '</td>' +
219+
'<td>' + rowPeople + '</td>' +
220+
'</tr>';
221+
index++;
222+
});
223+
});
224+
225+
$("#roles-table").append(rows);
226+
}
227+
228+
229+
function createRolesDescription(roles) {
230+
//roles is an array of objects called "role"
231+
var blocks = "";
232+
roles.forEach(function (role) {
233+
//role is an object containing information about each team role
234+
var list = "";
235+
//checking if role["description"] array isn't empty
236+
if (role["responsibilities"] != null) {
237+
238+
// If responsibilities is a dict, wrap inside a list so that all entries have a list
239+
// dicts
240+
if (role['responsibilities'].constructor == Object) {
241+
role['responsibilities'] = [role['responsibilities']];
242+
}
243+
244+
//console.log(role['responsibilities']);
245+
246+
blocks += '<br/>' +
247+
'<h3 id="' + role["url"] + '">' + role["role-head"] + '</h3>';
248+
249+
index = 0;
250+
251+
role['responsibilities'].forEach(function (resp) {
252+
253+
//console.log(resp);
254+
255+
detail_list = '';
256+
resp["details"].forEach(function (detail) {
257+
detail_list += '<li>' + detail + '</li>';
258+
});
259+
260+
if ('subrole-head' in resp) {
261+
if (index > 0) {
262+
blocks += '<br>';
263+
}
264+
blocks += '<em>' + resp["subrole-head"] + '</em>';
265+
}
266+
blocks += '<p>' + resp["description"] + '</p>' +
267+
'<ul>' + detail_list + '</ul>';
268+
269+
index += 1;
270+
271+
})
272+
273+
}
274+
});
275+
$("#roles-description").append(blocks);
276+
}
277+
278+
279+
function populateRoles(data, tstat, xhr) {
280+
//creating roles table from json data
281+
createRolesTable(data);
282+
//creating roles lists from json data
283+
createRolesDescription(data);
284+
}
285+
286+
295287
function populateTables(data, tstat, xhr) {
296288
populatePackageTable('coordinated', filter_pkg_data(data, "coordinated", true));
297289
populatePackageTable('affiliated', filter_pkg_data(data, "coordinated", false));
298290
}
299291

292+
300293
function filter_pkg_data(data, field, value) {
301294
if (data === null) {
302295
return null;
@@ -401,13 +394,14 @@ var review_color_map = {'Unmaintained': "red",
401394
"Needs work": "red"
402395
};
403396

397+
404398
function makeShields(pkg) {
405399
var shield_string = "";
406400

407401
var key, shield_name, pkgvalue, color, url;
408402

409403
for (key in review_name_map) {
410-
console.log("K"+key);
404+
//console.log("K"+key);
411405
if (review_name_map.hasOwnProperty(key)) {
412406
shield_name = review_name_map[key];
413407
if ("review" in pkg && key in pkg.review ) {
@@ -426,6 +420,7 @@ function makeShields(pkg) {
426420
return shield_string
427421
}
428422

423+
429424
function guess_os() {
430425
var OSName="source";
431426
if (navigator.appVersion.indexOf("Win")!=-1) OSName="windows";

team.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,12 @@ <h3 id="other-credits">Other Credits<a class="paralink" href="#other-credits" ti
750750
<script src="js/jquery.sidr.min.js"></script>
751751
<script src="js/functions.js"></script>
752752

753+
<script type="text/javascript">
754+
$(document).ready(function() {
755+
$.getJSON("roles.json", populateRoles);
756+
});
757+
</script>
758+
753759
<hr>
754760
<p>
755761
<img style="vertical-align:middle" src="images/astropy_brandmark.png" height=20><span style="vertical-align:middle">

0 commit comments

Comments
 (0)