Skip to content

Commit bace9aa

Browse files
committed
Only parse roles.json on Team page
1 parent dfd423e commit bace9aa

File tree

3 files changed

+118
-118
lines changed

3 files changed

+118
-118
lines changed

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):

js/functions.js

Lines changed: 112 additions & 117 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,6 +394,7 @@ var review_color_map = {'Unmaintained': "red",
401394
"Needs work": "red"
402395
};
403396

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

@@ -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)