community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject svn commit: r1679406 - /comdev/projects.apache.org/site/js/projects.js
Date Thu, 14 May 2015 17:11:17 GMT
Author: hboutemy
Date: Thu May 14 17:11:17 2015
New Revision: 1679406

URL: http://svn.apache.org/r1679406
Log:
reworked code for simplification and consistency

Modified:
    comdev/projects.apache.org/site/js/projects.js

Modified: comdev/projects.apache.org/site/js/projects.js
URL: http://svn.apache.org/viewvc/comdev/projects.apache.org/site/js/projects.js?rev=1679406&r1=1679405&r2=1679406&view=diff
==============================================================================
--- comdev/projects.apache.org/site/js/projects.js (original)
+++ comdev/projects.apache.org/site/js/projects.js Thu May 14 17:11:17 2015
@@ -255,43 +255,64 @@ function appendLiInnerHTML(ul,html) {
     appendElementWithInnerHTML(ul,'li',html);
 }
 
-function renderProjectPage(json, state) {
+function renderProjectPage(project, projectId) {
+    if ((!project || !project.name) && projects[projectId]) {
+        project = projects[projectId];
+    }
+    if (!project || !project.name) {
+        obj.innerHTML = "<h2>Sorry, I don't have any information available about this
project</h2>";
+        return;
+    }
+
+    var isIncubating = project.podling || project.name.match(/incubating/i);
+
+    // Rerig the unix name and tlp
+    var unixgroup = projectId.split("-")[0];
+    // special case: empire-db
+    if (unixgroup == "empire") unixgroup = "empire-db";
+    var tlpId = unixgroup;
+    if (!tlps[unixgroup]) {
+        // one TLP has a unix group that is different from TLP id: webservices (group=ws),
see parsecommittees.py#group_ids
+        for (p in tlps) {
+            if (tlps[p].group == unixgroup) {
+                tlpId = p;
+                break;
+            }
+        }
+    }
+    if (isIncubating) {
+        tlpId = 'incubator'
+        project.pmc = tlpId;
+    }
+    var tlp = tlps[tlpId];
 
     var obj = document.getElementById('contents');
     var isTLP = false;
-    var isIncubating = false;
-    if ((!json || !json.name) && projects[state]) {
-	json = projects[state];
-    }
-    if (!json || !json.name) {
-	obj.innerHTML = "<h2>Sorry, I don't have any information available about this project</h2>";
-	return;
-    }
 
     // Start by splitting the name, thus fetching the root name of the project, and not the
sub-project.
 
-    if (!json.description || json.description.length == 0) {
-	json.description = (json.shortdesc && json.shortdesc.length > 0 ) ? json.shortdesc
: "No description available"
+    if (!project.description || project.description.length == 0) {
+	project.description = (project.shortdesc && project.shortdesc.length > 0 ) ?
project.shortdesc : "No description available"
     }
 
     // Title + description
     var pt = "Top Level Project";
-    if ((!tlpsByName[json.name] && tlps[json.pmc]) || json.name.match("Incubating",
"i")) {
-	pt = (json.pmc == "attic") ? "in the Attic" : "Sub-project"
+    if (isIncubating) {
+        pt = "Incubating";
+    } else if (!tlpsByName[project.name] && tlps[project.pmc]) {
+	pt = (project.pmc == "attic") ? "in the Attic" : "Sub-project"
     } else {
 	isTLP = true
     }
-    obj.innerHTML = "<h1>" + json.name + " (" + pt + "):</h1>";
-
-    // Rerig the unix name and pmc
-    state = state.split("-")[0];
-    if (json.name.match("incubating", "i")) {
-	json.pmc = 'incubator'
+    var name = project.name;
+    if (!name.match(/incubating/i)) {
+        name +=  " (" + pt + ")";
     }
+    obj.innerHTML = "<h1>" + name + "</h1>";
 
     var p = document.createElement('p');
     p.style.fontFamily = '"Times New Roman", Times, serif';
-    p.innerHTML = json.description.replace(/([^\r\n]+)\r?\n\r?\n/g,function(a) { return "<p>"+a+"</p>"});
+    p.innerHTML = project.description.replace(/([^\r\n]+)\r?\n\r?\n/g,function(a) { return
"<p>"+a+"</p>"});
     obj.appendChild(p);
 
 
@@ -301,8 +322,8 @@ function renderProjectPage(json, state)
     var ul = document.createElement('ul');
 
     // Categories
-    if (json['category']) {
-	var arr = json['category'].split(/,\s*/);
+    if (project['category']) {
+	var arr = project['category'].split(/,\s*/);
 	var pls = "";
 	for (i in arr) {
 	    var cat = arr[i];
@@ -312,49 +333,47 @@ function renderProjectPage(json, state)
     }
 
     // Website
-    if (json.homepage) {
-	appendLiInnerHTML(ul, "<b>Website:</b> <a href='" + json.homepage + "' target='_blank'>"
+ json.homepage + "</a>");
+    if (project.homepage) {
+	appendLiInnerHTML(ul, "<b>Website:</b> <a href='" + project.homepage + "'
target='_blank'>" + project.homepage + "</a>");
     }
-    if (unixgroups[state]) {
+    if (isIncubating) {
+        appendLiInnerHTML(ul, "<b>Project status:</b> <span class='ppodling'>Incubating</span>");
+    } else if (unixgroups[unixgroup]) {
 	appendLiInnerHTML(ul, "<b>Project status:</b> <span class='pactive'>Active</span>");
     } else {
-	appendLiInnerHTML(ul, "<b>Project status:</b> <span class='pretired'>Retired(?)</span>");
-    }
-    if (json.podling || json.name.match(/incubating/i)) {
-	appendLiInnerHTML(ul, "<b>Project status:</b> <span class='ppodling'>Incubating</span>");
-	isIncubating = true;
+	appendLiInnerHTML(ul, "<b>Project status:</b> <span class='pretired'>Retired</span>");
     }
 
-    if (tlpsByName[json.name]) {
-	appendLiInnerHTML(ul, "<b>Project established:</b> " + tlpsByName[json.name].established);
+    if (tlpsByName[project.name]) {
+	appendLiInnerHTML(ul, "<b>Project established:</b> " + tlpsByName[project.name].established);
     }
 
     // TLP Owner?
-    if (json.pmc) {
-	if (json.pmc.match(/http:\/\/([a-z0-9]+)/i)) {
-	    json.pmc = json.pmc.match(/http:\/\/([a-z0-9]+)/i)[1];
+    if (project.pmc) {
+	if (project.pmc.match(/http:\/\/([a-z0-9]+)/i)) {
+	    project.pmc = project.pmc.match(/http:\/\/([a-z0-9]+)/i)[1];
 	}
     } else {
-	json.pmc = state;
+	project.pmc = tlpId;
     }
-    if (!tlpsByName[json.name] && tlps[json.pmc]) {
-	appendLiInnerHTML(ul, "<b>Sub-project of:</b> <a href='/project.html?" +
json.pmc + "'>" + tlps[json.pmc].name + "</a>");
+    if (!tlpsByName[project.name] && tlps[project.pmc]) {
+	appendLiInnerHTML(ul, "<b>Sub-project of:</b> <a href='/project.html?" +
project.pmc + "'>" + tlps[project.pmc].name + "</a>");
     }
 
     if (isTLP) {
-        var tlp = tlps[json.pmc];
+        var tlp = tlps[project.pmc];
 
 	// VP
         appendLiInnerHTML(ul, "<b>PMC Chair:</b> " + people[tlp.chair]);
 
 	// Reporting cycle
         var cycles = [ "every month", "January, April, July, October", "February, May, August,
November", "March, June, September, December" ];
-        appendLiInnerHTML(ul, "<b>Reporting cycle:</b> " + cycles[tlp.reporting]
+ ", see <a href='https://whimsy.apache.org/board/minutes/" + camelCase(json.pmc) + ".html'>minutes</a>");
+        appendLiInnerHTML(ul, "<b>Reporting cycle:</b> " + cycles[tlp.reporting]
+ ", see <a href='https://whimsy.apache.org/board/minutes/" + camelCase(project.pmc) +
".html'>minutes</a>");
 
 	// PMC
-	if (unixgroups[state+"-pmc"]) {
+	if (unixgroups[unixgroup+"-pmc"]) {
 	    var pmcl = [];
-	    var pmcgroup = unixgroups[state+"-pmc"];
+	    var pmcgroup = unixgroups[unixgroup+"-pmc"];
 	    for (i in pmcgroup) {
 		pmcl.push(linkCommitterIndex(pmcgroup[i]));
 	    }
@@ -363,9 +382,9 @@ function renderProjectPage(json, state)
     }
 
     // Committers
-    if (unixgroups[state] && (isTLP || isIncubating)) {
+    if (unixgroups[unixgroup] && (isTLP || isIncubating)) {
 	var commitl = [];
-	var commitgroup = unixgroups[state];
+	var commitgroup = unixgroups[unixgroup];
 	for (i in commitgroup) {
 	    commitl.push(linkCommitterIndex(commitgroup[i]));
 	}
@@ -373,13 +392,13 @@ function renderProjectPage(json, state)
     }
 
     // maintainer
-    if (json.maintainer && json.maintainer.Person && json.maintainer.Person.mbox)
{
-	var mt = json.maintainer.Person.mbox;
+    if (project.maintainer && project.maintainer.Person && project.maintainer.Person.mbox)
{
+	var mt = project.maintainer.Person.mbox;
 	appendLiInnerHTML(ul, "<b>Project data maintainer:</b> <a href='" + mt +
"'>" + mt.substr(mt.indexOf(":") + 1) + "</a>");
     }
     // doap/rdf
-    if (json.doap) {
-	appendLiInnerHTML(ul, "<b>Project data file:</b> <a href='" + json.doap +
"' target='_blank'>RDF Source</a>");
+    if (project.doap) {
+	appendLiInnerHTML(ul, "<b>Project data file:</b> <a href='" + project.doap
+ "' target='_blank'>RDF Source</a>");
     }
 
     obj.appendChild(ul);
@@ -388,8 +407,8 @@ function renderProjectPage(json, state)
     appendElementWithInnerHTML(obj,'h4',"Development:");
     ul = document.createElement('ul');
 
-    if (json['programming-language']) {
-	pl = json['programming-language'];
+    if (project['programming-language']) {
+	pl = project['programming-language'];
 	var arr = pl.split(/,\s*/);
 	pls = "";
 	for (i in arr) {
@@ -398,13 +417,13 @@ function renderProjectPage(json, state)
 	appendLiInnerHTML(ul, "<b>Programming language:</b> " + pls);
     }
 
-    if (json['bug-database']) {
-	var bd = json['bug-database'];
+    if (project['bug-database']) {
+	var bd = project['bug-database'];
 	appendLiInnerHTML(ul, "<b>Bug-tracking:</b> <a href='" + bd + "'>" + bd
+ "</a>");
     }
 
-    if (json['mailing-list']) {
-	bd = json['mailing-list'];
+    if (project['mailing-list']) {
+	bd = project['mailing-list'];
 	var xbd = bd;
 	// email instead of link?
 	if (bd.match(/@/)) {
@@ -418,19 +437,19 @@ function renderProjectPage(json, state)
     // repositories
     appendElementWithInnerHTML(obj,'h4',"Repositories:");
     ul = document.createElement('ul');
-    if (json.SVNRepository&& json.SVNRepository.length > 0) {
-	appendLiInnerHTML(ul, "<b>Subversion:</b> <a target=*_blank' href='" + json.SVNRepository
+ "'>" + json.SVNRepository + "</a>");
+    if (project.SVNRepository&& project.SVNRepository.length > 0) {
+	appendLiInnerHTML(ul, "<b>Subversion:</b> <a target=*_blank' href='" + project.SVNRepository
+ "'>" + project.SVNRepository + "</a>");
     }
-    if (json.GitRepository && json.GitRepository.length > 0) {
-	appendLiInnerHTML(ul, "<b>Git:</b> <a target=*_blank' href='" + json.GitRepository
+ "'>" + json.GitRepository + "</a>");
+    if (project.GitRepository && project.GitRepository.length > 0) {
+	appendLiInnerHTML(ul, "<b>Git:</b> <a target=*_blank' href='" + project.GitRepository
+ "'>" + project.GitRepository + "</a>");
     }
     obj.appendChild(ul);
 }
 
 
 function buildProjectPage() {
-    var project = document.location.search.substr(1);
-    GetAsyncJSON("/json/projects/" + project + ".json?" + Math.random(), project, renderProjectPage)
+    var projectId = document.location.search.substr(1);
+    GetAsyncJSON("/json/projects/" + projectId + ".json?" + Math.random(), projectId, renderProjectPage)
 }
 
 
@@ -450,7 +469,13 @@ function projectIcon(name) {
 
 function projectLink(id) {
     project = projects[id];
-    return "<a href='/project.html?" + id + "'>" + project.name + ( ( project.pmc ==
"attic" ) ? " (in the Attic)" : "" ) + "</a>"
+    var name = project.name;
+    if (project.pmc == "attic") {
+        name += " (in the Attic)";
+    } else if ((project.pmc == "incubator") && !name.match(/incubating/i)) {
+        name += " (Incubating)";
+    }
+    return "<a href='/project.html?" + id + "'>" + name + "</a>";
 }
 
 function isMember(id) {



Mime
View raw message