Skip to content

Commit fe0e1d8

Browse files
Overhaul of Affiliated Packages page (astropy#2)
A simple re-imagining of the Affiliated Packages page, using a design by @astrofrog and implementation by @eteq
1 parent 2e38ea7 commit fe0e1d8

File tree

4 files changed

+153
-52
lines changed

4 files changed

+153
-52
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
*.py[co]
2+
*.DS_STORE

affiliated/index.html

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1" />
77
<link rel="shortcut icon" href="../favicon.ico" />
88

9-
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400italic,400,700' rel='stylesheet' type='text/css' />
9+
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400italic,400,700" rel="stylesheet" type="text/css" />
1010
<link rel="stylesheet" type="text/css" href="../css/style.css" />
1111
<link rel="stylesheet" type="text/css" href="../css/jquery.sidr.light.css" />
1212

@@ -79,12 +79,41 @@ <h1>Installing Affiliated Packages</h1>
7979
</section>
8080

8181
<section id="affiliated-package-registry">
82-
83-
<h1>Affiliated Packages Registry</h1>
84-
85-
<p>The following tables list all currently registered affiliated packages. They are determined from the <a href="http://www.astropy.org/affiliated/registry.json">json file</a>, which is the actual authoritative registry. The Stable column indicates whether the package maintainer consider the package to be ready for use. Packages that are under heavy development and for which the user interface is likely to change significantly in the near future are marked as No.</p>
86-
87-
<h3><u>Affiliated Packages</u></h3>
82+
<h1>Affiliated Packages Registry</h1>
83+
<p>The following table lists all currently registered affiliated packages. They are determined from the <a href="http://www.astropy.org/affiliated/registry.json">json file</a>, which is the actual authoritative registry.</p>
84+
<!-- <h3><u>Affiliated Packages</u></h3>-->
85+
86+
87+
<table border="1" class="docutils" id="accepted-package-table">
88+
<colgroup>
89+
<col width="5%" />
90+
<col width="3%" />
91+
<col width="3%" />
92+
<col width="10%" />
93+
</colgroup>
94+
<thead valign="bottom">
95+
<tr class="row-odd">
96+
<th class="head"></th>
97+
<th class="head"></th>
98+
<th class="head"></th>
99+
<th class="head"></th>
100+
</tr>
101+
</thead>
102+
<tbody valign="top">
103+
<tr class="row-even"><td rowspan="1">Loading...</td>
104+
<td rowspan="1">&nbsp;</td>
105+
<td rowspan="1">&nbsp;</td>
106+
<td rowspan="1">&nbsp;</td>
107+
<td rowspan="1">&nbsp;</td>
108+
</tr>
109+
<tr class="row-odd">
110+
<td colspan="1">&nbsp;</td>
111+
<td colspan="3">&nbsp;</td>
112+
</tr>
113+
</tbody>
114+
</table>
115+
116+
<!--
88117
<table border="1" class="docutils" id="accepted-package-table">
89118
<colgroup>
90119
<col width="17%" />
@@ -95,12 +124,12 @@ <h3><u>Affiliated Packages</u></h3>
95124
<col width="14%" />
96125
</colgroup>
97126
<thead valign="bottom">
98-
<tr class="row-odd"><th class="head">Package Name</th>
99-
<th class="head">Stable</th>
100-
<th class="head">PyPI Name</th>
101-
<th class="head">Web Page</th>
102-
<th class="head">Code Repository</th>
103-
<th class="head">Maintainer</th>
127+
<tr class="row-odd"><th class="head"></th>
128+
<th class="head"></th>
129+
<th class="head"></th>
130+
<th class="head"></th>
131+
<th class="head"></th>
132+
<th class="head"></th>
104133
</tr>
105134
</thead>
106135
<tbody valign="top">
@@ -115,6 +144,7 @@ <h3><u>Affiliated Packages</u></h3>
115144
<tr class="row-odd"></tr>
116145
</tbody>
117146
</table>
147+
-->
118148

119149
<h3><u>Other astronomy packages</u></h3>
120150

css/style.css

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ time, mark, audio, video {
2323
font: inherit;
2424
vertical-align: baseline;
2525
}
26+
2627
/* HTML5 display-role reset for older browsers */
2728
article, aside, details, figcaption, figure,
2829
footer, header, hgroup, menu, nav, section {
@@ -540,18 +541,20 @@ section.install div h3{
540541
}
541542

542543
.featured img{
543-
float: left;
544+
float: left+;
544545
margin-right:10px;
545546
}
546547

547548
table{
548549
margin: 20px 0px;
549-
word-break:break-all;
550+
word-break:overflow-wrap;
550551
}
551552

553+
/*
552554
tr{
553555
border-bottom: 1px #efefef solid;
554556
}
557+
*/
555558

556559

557560
thead{
@@ -560,10 +563,20 @@ thead{
560563
border-bottom: 1px black solid;
561564
}
562565

566+
567+
563568
td{
564-
padding:5px 3px;
569+
padding:16px 5px;
570+
font-size: 140%;
571+
line-height: 1.3em;
565572
}
566573

574+
575+
td:first-child {
576+
font-weight: bold;
577+
}
578+
579+
567580
/* About */
568581

569582
p.citation{

js/functions.js

Lines changed: 93 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -225,16 +225,26 @@ function url_translator(urltext) {
225225
if (urltext === undefined) {
226226
return 'None';
227227
} else {
228-
return '<a href="' + urltext + '">' + urltext + '</a>';
228+
return '<a href="' + urltext + '">' + 'Website' + '</a>';
229229
}
230230
}
231231

232+
233+
function repo_translator(urltext) {
234+
if (urltext === undefined) {
235+
return 'None';
236+
} else {
237+
return '<a href="' + urltext + '">' + 'Repository' + '</a>';
238+
}
239+
}
240+
241+
232242
function pypi_translator(pypiname) {
233243
if (pypiname === undefined) {
234244
return 'None';
235245
} else {
236246
var urltext = 'http://pypi.python.org/pypi/' + pypiname;
237-
return '<a href="' + urltext + '">' + pypiname + '</a>';
247+
return '<a href="' + urltext + '">' + 'PyPI' + '</a>';
238248
}
239249
}
240250

@@ -250,6 +260,7 @@ var _email_regex_str = '[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}';
250260
var _email_regex = new RegExp(_email_regex_str, 'i');
251261
var _email_with_name_regex = new RegExp('(.+)<(' + _email_regex_str + ')>', 'i');
252262

263+
253264
function maintainer_translator(maint, pkgnm) {
254265
var url, match;
255266
if (_email_with_name_regex.test(maint)) {
@@ -264,34 +275,22 @@ function maintainer_translator(maint, pkgnm) {
264275
}
265276
}
266277

278+
267279
function populateTables(data, tstat, xhr) {
268-
populateTable('accepted-package-table', data, false);
269-
populateTable('provisional-package-table', data, 'only')
280+
populateTable('accepted-package-table', data);
270281
}
271282

272-
function populateTable(tableid, data, allowprovisional) {
273-
// First we use allowprovisional io decide what the checkProvisional function (used below) does
274-
var checkProvisional;
275-
if (allowprovisional === false) {
276-
checkProvisional = function(provisional_status) { return provisional_status === false; }
277-
} else if (allowprovisional == 'only') {
278-
checkProvisional = function(provisional_status) { return provisional_status; }
279-
} else if (allowprovisional === true) {
280-
checkProvisional = function(provisional_status) { return true; }
281-
} else {
282-
throw "Invalid allowprovisional value " + allowprovisional;
283-
}
284283

284+
function populateTable(tableid, data) {
285285
// Now we get the table and prepare it
286286
var tab = document.getElementById(tableid);
287287
var ncols = tab.rows[0].cells.length;
288288

289289
//we have to delete the "Loading..." row
290290
tab.deleteRow(1);
291291

292-
var pkgi, row, nmcell, stablecell, pypicell, urlcell, rpocell, maintcell;
293292
if (data === null) {
294-
row = tab.insertRow(1);
293+
var row = tab.insertRow(1);
295294
row.insertCell(0).innerHTML = 'Could not load registry file!';
296295
for (i=0;i<(ncols - 1);i++) { row.insertCell(i + 1).innerHTML = ' '; }
297296
} else {
@@ -305,32 +304,90 @@ function populateTable(tableid, data, allowprovisional) {
305304
nmarr[i] = pkgi.name.toLowerCase();
306305
sortorder[i] = i;
307306
}
308-
// This "sorts" the indecies using a compare function that actually sorts nmarr
307+
// This "sorts" the indicies using a compare function that actually sorts nmarr
309308
sortorder.sort(function (a, b) { return nmarr[a] < nmarr[b] ? -1 : nmarr[a] > nmarr[b] ? 1 : 0; });
310309

310+
var pkgi;
311+
var namerow, descrow, shieldrow, maintrow;
312+
var nmcell, pypicell, urlcell, repocell;
313+
var desccell, maintcell, shieldcell;
314+
311315
for (i=0; i<sortorder.length; i++) {
312316
pkgi = pkgs[sortorder[i]];
313-
row = tab.insertRow(i + 1);
314-
315-
if (checkProvisional(pkgi.provisional)) {
316-
nmcell = row.insertCell(0);
317-
stablecell = row.insertCell(1);
318-
pypicell = row.insertCell(2);
319-
urlcell = row.insertCell(3);
320-
repocell = row.insertCell(4);
321-
maintcell = row.insertCell(5);
322-
323-
nmcell.innerHTML = pkgi.name;
324-
stablecell.innerHTML = bool_translator(pkgi.stable);
325-
pypicell.innerHTML = pypi_translator(pkgi.pypi_name);
326-
urlcell.innerHTML = url_translator(pkgi.home_url);
327-
repocell.innerHTML = url_translator(pkgi.repo_url);
328-
maintcell.innerHTML = maintainer_translator(pkgi.maintainer, pkgi.name);
329-
}
317+
namerow = tab.insertRow(i*4 + 1);
318+
319+
nmcell = namerow.insertCell(0);
320+
urlcell = namerow.insertCell(1);
321+
repocell = namerow.insertCell(2);
322+
pypicell = namerow.insertCell(3);
323+
324+
nmcell.innerHTML = pkgi.name;
325+
urlcell.innerHTML = url_translator(pkgi.home_url);
326+
repocell.innerHTML = repo_translator(pkgi.repo_url);
327+
pypicell.innerHTML = pypi_translator(pkgi.pypi_name);
328+
329+
330+
descrow = tab.insertRow(i*4 + 2);
331+
descrow.insertCell(0).innerHTML = "";
332+
desccell = descrow.insertCell(1);
333+
desccell.colSpan = "3";
334+
desccell.innerHTML = pkgi.description;
335+
336+
maintrow = tab.insertRow(i*4 + 3);
337+
maintrow.insertCell(0).innerHTML = "";
338+
maintcell = maintrow.insertCell(1);
339+
maintcell.colSpan = "3";
340+
maintcell.innerHTML = "Maintainer(s): " + maintainer_translator(pkgi.maintainer, pkgi.name);
341+
342+
shieldrow = tab.insertRow(i*4 + 4);
343+
shieldrow.insertCell(0).innerHTML = "";
344+
shieldcell = shieldrow.insertCell(1);
345+
shieldcell.colSpan = "3";
346+
shieldcell.innerHTML = makeShields(pkgi)
347+
330348
}
331349
}
332350
}
333351

352+
var review_name_map = {"functionality": "Functionality",
353+
"ecointegration": "Astropy%20integration",
354+
"documentation": "Docs",
355+
"testing": "Tests",
356+
"devstatus": "Development",
357+
"python3": "Python 3"
358+
};
359+
360+
var review_default_color = "green";
361+
var review_color_map = {'Unmaintained': "red",
362+
"Functional but low activity": "orange",
363+
"Good": "green",
364+
"Partial": "orange",
365+
"Needs work": "red"
366+
};
367+
368+
function makeShields(pkg) {
369+
var shield_string = "";
370+
371+
var key, shield_name, pkgvalue, color, url;
372+
373+
for (key in review_name_map) {
374+
console.log("K"+key);
375+
if (review_name_map.hasOwnProperty(key)) {
376+
shield_name = review_name_map[key];
377+
pkgvalue = pkg.review[key];
378+
379+
color = review_color_map[pkgvalue];
380+
if (typeof color == 'undefined') {
381+
color = review_default_color;
382+
}
383+
384+
url = "https://img.shields.io/badge/" + shield_name + "-" + pkgvalue + "-" + color + ".svg";
385+
shield_string += "<img src=\"" + url + "\">" + " "
386+
}
387+
}
388+
return shield_string
389+
}
390+
334391
function guess_os() {
335392
var OSName="source";
336393
if (navigator.appVersion.indexOf("Win")!=-1) OSName="windows";

0 commit comments

Comments
 (0)