Skip to content

Commit

Permalink
Merge pull request #643 from pllim/fix-console-error
Browse files Browse the repository at this point in the history
Only parse roles.json on Team page + other fixes
  • Loading branch information
hamogu authored Nov 20, 2024
2 parents dfd423e + 5186607 commit 9de8c83
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 155 deletions.
10 changes: 3 additions & 7 deletions affiliated/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,9 @@ <h1 id="affiliated-package-list">Affiliated Packages Registry<a class="paralink"
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td rowspan="1">Loading...</td>
<td rowspan="1">&nbsp;</td>
<td rowspan="1">&nbsp;</td>
<td rowspan="1">&nbsp;</td>
<td rowspan="1">&nbsp;</td>
<tr class="row-even">
<td colspan="1">&nbsp;</td>
<td colspan="3">&nbsp;</td>
</tr>
<tr class="row-odd">
<td colspan="1">&nbsp;</td>
Expand Down Expand Up @@ -403,9 +401,7 @@ <h2 id="new-affil-reviewer">I am a new reviewer<a class="paralink" href="#new-af
var parsed = yaml.parse(yamlString);
var i = 0;

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

var info = "";
for (var p=0; p<parsed.length; p++) {
Expand Down
1 change: 0 additions & 1 deletion getteam.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Note that this first looks for the ``ASTROPY_REPO_PATH`` environment
variable to try to find a local copy of the astropy repo.
"""
from __future__ import print_function


def get_astropy_credits(warner=print):
Expand Down
29 changes: 0 additions & 29 deletions history.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,6 @@
<!-- Google analytics -->
<script src="js/analytics.js"></script>

<!-- Meow woof -->
<script>
window.onload = function() {

$.getJSON('https://pypi.org/pypi/astropy/json', function(data) {
document.getElementById('core-package-version').innerHTML = 'Current Version: ' + data.info.version;
});


var today = new Date();
var month = today.getMonth() + 1;
var date = today.getDate();

if (month == 4 && date == 1) {
$('#hero img').attr('src', 'images/astropy_meow.png');
$('#hero img').attr('onerror', 'this.src=\x27images/astropy_meow.png\x27; this.onerror=null;');

var dogeContainer = document.getElementById("prenew");
var dogeImg = document.createElement("img");
dogeImg.onload=function() {
dogeContainer.appendChild(dogeImg);
}
dogeImg.src = 'images/astropy_doge.png';
dogeImg.alt = 'wow so open very python';
}

};
</script>

</head>

<body>
Expand Down
231 changes: 113 additions & 118 deletions js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,123 +22,6 @@ $( document ).ready(function(){
$(this).removeClass("subhover"); //On hover out, remove class "subhover"
});

//creating Astropy roles table & roles lists using roles.json
var request = new XMLHttpRequest();
var dataURL = "roles.json";
request.open('GET', dataURL);
request.responseType = 'json';
request.send();

//log error when request gets failed
request.onerror = function () {
console.log("XHR error");
};

request.onload = function () {
//received json data via XHR
var data = request.response;
//creating roles table from json data
createRolesTable(data);
//creating roles lists from json data
createRolesDescription(data);
};

function createRolesTable(roles) {
//roles is an array of objects called "role"
var rows = '';
roles.forEach(function (role) {
//role is an object containing information about each team role
//index marks current people
var index = 0;

// for roles where there are no sub-roles, the people are defined
// at the top-level of the JSON role dict - for convenience below we create
// a virtual sub-role with no heading
if (!('sub-roles' in role)) {
role['sub-roles'] = [{'role': '',
'people': role['people']}];
}

//creating each row by iterating over each person in a role
role["sub-roles"].forEach(function (subrole) {
//rowRole is displayed once for each role
rowRole = index == 0 ? '<a href="#' + role["url"] + '">' + role["role"] + '</a>' : "";

var rowSubRole = subrole['role'];

if (subrole['people'][0] == "Unfilled") {
rowPeople = '<a href="mailto:[email protected]"><span style="font-style: italic;">Unfilled</span></a>';
} else {
rowPeople = subrole['people'].join(', ');
}

//generating rows
if (index == 0) {
rows += '<tr class="border-top">';
} else {
rows += '<tr>';
}

rows += '<td>' + rowRole + '</td>' +
'<td>' + rowSubRole + '</td>' +
'<td>' + rowPeople + '</td>' +
'</tr>';
index++;
});
});

$("#roles-table").append(rows);
}

function createRolesDescription(roles) {
//roles is an array of objects called "role"
var blocks = "";
roles.forEach(function (role) {
//role is an object containing information about each team role
var list = "";
//checking if role["description"] array isn't empty
if (role["responsibilities"] != null) {

// If responsibilities is a dict, wrap inside a list so that all entries have a list
// dicts
if (role['responsibilities'].constructor == Object) {
role['responsibilities'] = [role['responsibilities']];
}

console.log(role['responsibilities']);

blocks += '<br/>' +
'<h3 id="' + role["url"] + '">' + role["role-head"] + '</h3>';

index = 0;

role['responsibilities'].forEach(function (resp) {

console.log(resp);

detail_list = '';
resp["details"].forEach(function (detail) {
detail_list += '<li>' + detail + '</li>';
});

if ('subrole-head' in resp) {
if (index > 0) {
blocks += '<br>';
}
blocks += '<em>' + resp["subrole-head"] + '</em>';
}
blocks += '<p>' + resp["description"] + '</p>' +
'<ul>' + detail_list + '</ul>';

index += 1;

})

}
});
$("#roles-description").append(blocks);
}

$('#os-selector ul').each(function(){
// For each set of tabs, we want to keep track of
// which tab is active and it's associated content
Expand Down Expand Up @@ -255,6 +138,7 @@ function pypi_translator(pypiname) {
}
}


function bool_translator(stable) {
if (stable) {
return 'Yes';
Expand All @@ -263,6 +147,7 @@ function bool_translator(stable) {
}
}


function ghuser_translator(fullname, ghname) {
if (fullname === undefined || ghname === undefined) {
return 'None';
Expand All @@ -272,6 +157,7 @@ function ghuser_translator(fullname, ghname) {
}
}


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


function createRolesTable(roles) {
//roles is an array of objects called "role"
var rows = '';
roles.forEach(function (role) {
//role is an object containing information about each team role
//index marks current people
var index = 0;

// for roles where there are no sub-roles, the people are defined
// at the top-level of the JSON role dict - for convenience below we create
// a virtual sub-role with no heading
if (!('sub-roles' in role)) {
role['sub-roles'] = [{'role': '',
'people': role['people']}];
}

//creating each row by iterating over each person in a role
role["sub-roles"].forEach(function (subrole) {
//rowRole is displayed once for each role
rowRole = index == 0 ? '<a href="#' + role["url"] + '">' + role["role"] + '</a>' : "";

var rowSubRole = subrole['role'];

if (subrole['people'][0] == "Unfilled") {
rowPeople = '<a href="mailto:[email protected]"><span style="font-style: italic;">Unfilled</span></a>';
} else {
rowPeople = subrole['people'].join(', ');
}

//generating rows
if (index == 0) {
rows += '<tr class="border-top">';
} else {
rows += '<tr>';
}

rows += '<td>' + rowRole + '</td>' +
'<td>' + rowSubRole + '</td>' +
'<td>' + rowPeople + '</td>' +
'</tr>';
index++;
});
});

$("#roles-table").append(rows);
}


function createRolesDescription(roles) {
//roles is an array of objects called "role"
var blocks = "";
roles.forEach(function (role) {
//role is an object containing information about each team role
var list = "";
//checking if role["description"] array isn't empty
if (role["responsibilities"] != null) {

// If responsibilities is a dict, wrap inside a list so that all entries have a list
// dicts
if (role['responsibilities'].constructor == Object) {
role['responsibilities'] = [role['responsibilities']];
}

//console.log(role['responsibilities']);

blocks += '<br/>' +
'<h3 id="' + role["url"] + '">' + role["role-head"] + '</h3>';

index = 0;

role['responsibilities'].forEach(function (resp) {

//console.log(resp);

detail_list = '';
resp["details"].forEach(function (detail) {
detail_list += '<li>' + detail + '</li>';
});

if ('subrole-head' in resp) {
if (index > 0) {
blocks += '<br>';
}
blocks += '<em>' + resp["subrole-head"] + '</em>';
}
blocks += '<p>' + resp["description"] + '</p>' +
'<ul>' + detail_list + '</ul>';

index += 1;

})

}
});
$("#roles-description").append(blocks);
}


function populateRoles(data, tstat, xhr) {
//creating roles table from json data
createRolesTable(data);
//creating roles lists from json data
createRolesDescription(data);
}


function populateTables(data, tstat, xhr) {
populatePackageTable('coordinated', filter_pkg_data(data, "coordinated", true));
populatePackageTable('affiliated', filter_pkg_data(data, "coordinated", false));
}


function filter_pkg_data(data, field, value) {
if (data === null) {
return null;
Expand Down Expand Up @@ -401,13 +394,14 @@ var review_color_map = {'Unmaintained': "red",
"Needs work": "red"
};


function makeShields(pkg) {
var shield_string = "";

var key, shield_name, pkgvalue, color, url;

for (key in review_name_map) {
console.log("K"+key);
//console.log("K"+key);
if (review_name_map.hasOwnProperty(key)) {
shield_name = review_name_map[key];
if ("review" in pkg && key in pkg.review ) {
Expand All @@ -426,6 +420,7 @@ function makeShields(pkg) {
return shield_string
}


function guess_os() {
var OSName="source";
if (navigator.appVersion.indexOf("Win")!=-1) OSName="windows";
Expand Down
6 changes: 6 additions & 0 deletions team.html
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,12 @@ <h3 id="other-credits">Other Credits<a class="paralink" href="#other-credits" ti
<script src="js/jquery.sidr.min.js"></script>
<script src="js/functions.js"></script>

<script type="text/javascript">
$(document).ready(function() {
$.getJSON("roles.json", populateRoles);
});
</script>

<hr>
<p>
<img style="vertical-align:middle" src="images/astropy_brandmark.png" height=20><span style="vertical-align:middle">
Expand Down

0 comments on commit 9de8c83

Please sign in to comment.