community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From humbed...@apache.org
Subject svn commit: r1662755 - in /comdev/projects.apache.org: scripts/cronjobs/parsereleases.py site/js/projects.js site/releases.html
Date Fri, 27 Feb 2015 17:27:21 GMT
Author: humbedooh
Date: Fri Feb 27 17:27:20 2015
New Revision: 1662755

URL: http://svn.apache.org/r1662755
Log:
Add some release data tests

Added:
    comdev/projects.apache.org/scripts/cronjobs/parsereleases.py
Modified:
    comdev/projects.apache.org/site/js/projects.js
    comdev/projects.apache.org/site/releases.html

Added: comdev/projects.apache.org/scripts/cronjobs/parsereleases.py
URL: http://svn.apache.org/viewvc/comdev/projects.apache.org/scripts/cronjobs/parsereleases.py?rev=1662755&view=auto
==============================================================================
--- comdev/projects.apache.org/scripts/cronjobs/parsereleases.py (added)
+++ comdev/projects.apache.org/scripts/cronjobs/parsereleases.py Fri Feb 27 17:27:20 2015
@@ -0,0 +1,55 @@
+import re, urllib.request
+import json
+import os
+
+releases = {}
+mainurl = "http://www.apache.org/dist/"
+
+x = 0
+
+try:
+    with open("../../site/json/foundation/releases.json") as f:
+        releases = json.loads(f.read())
+        f.close()
+except Exception as err:
+    print("Could not read releases.json, assuming blank slate")
+
+def getDirList(url):
+    try:
+        data = urllib.request.urlopen(url).read().decode('utf-8')
+        for entry, xd, xdate in re.findall(r"<a href=\"([^\"/]+)(/?)\">.+</a>\s+(\d\d\d\d-\d\d-\d\d)",
data, re.MULTILINE | re.UNICODE):
+            yield(entry, xdate, xd)
+    except:
+        pass
+
+def parseDir(project, path):
+    print("Parsing %s..." % path)
+    for f, d, xd in getDirList("%s/%s" % (mainurl, path)):
+        if xd:
+            parseDir(project, "%s/%s" % (path, f))
+        elif not re.search(r"(md5|asc|sig)", f, flags=re.IGNORECASE):
+            match =  re.match(r"^(.+?)(\.(\S{1,4}))?\.(\S{1,7})$", f)
+            if match:
+                filename = match.group(1)
+                filename = re.sub(r"[-_.]*([Aa]pache|%s|src|bin|deps)[-_.]*" % project, "",
filename, count=10, flags=re.IGNORECASE|re.UNICODE)
+                releases[project][filename] = d
+    
+
+for project, d, xdir in getDirList(mainurl):
+    if project != "incubator":
+        print("Parsing %s" % project)
+        releases[project] = releases[project] if project in releases else {}
+        parseDir(project, project)
+    else:
+        for podling, d, xd in getDirList("%s/incubator/" % mainurl):
+            print("Parsing incubator-%s" % podling)
+            project = "incubator-%s" % podling
+            releases[project] = releases[project] if project in releases else {}
+            parseDir(project, "incubator/%s" % podling)
+
+print("Writing releases.json")
+with open("../../site/json/foundation/releases.json", "w") as f:
+    f.write(json.dumps(releases))
+    f.close()
+    
+print("All done!")
\ No newline at end of file

Modified: comdev/projects.apache.org/site/js/projects.js
URL: http://svn.apache.org/viewvc/comdev/projects.apache.org/site/js/projects.js?rev=1662755&r1=1662754&r2=1662755&view=diff
==============================================================================
--- comdev/projects.apache.org/site/js/projects.js (original)
+++ comdev/projects.apache.org/site/js/projects.js Fri Feb 27 17:27:20 2015
@@ -27,7 +27,7 @@ var committees_raw = {} // TLP committee
 var pmcs = {} // pmc -> project name lookups
 var evolution = {} // Podling evolution
 var accounts = {} // Account creation lookups
-
+var releases = {} // Release data
 
 // --------- Global helpers ----------- \\
 
@@ -1261,6 +1261,44 @@ function setCommittees(json, state) {
 }
 
 
+// Render releases using datatables
+function buildReleases() {
+    var arr = []
+    for (p in releases) {
+	var releasedata = releases[p]
+	
+	for (filename in releasedata) {
+	    var date = releasedata[filename]
+	    // Shove the result into a row
+	    arr.push([ p, p, date, filename])
+	}
+	
+    }
+    
+    // Construct the data table
+    $('#contents').html( '<table cellpadding="0" cellspacing="0" border="0" class="display"
id="projectlist"></table>' );
+ 
+    $('#projectlist').dataTable( {
+	"data": arr,
+	"columns": [
+	    { "title": "ID", "visible": false },
+	    { "title": "Name" },
+	    { "title": "Date" },
+	    { "title": "Release name" },
+	],
+	"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull) {
+                    jQuery(nRow).attr('id', aData[0]);
+                    jQuery(nRow).css("cursor", "pointer");
+                    return nRow;
+                }
+    } );
+    
+    $('#projectlist tbody').on('click', 'tr', function () {
+        var name = $(this).attr('id');
+        location.href = "https://www.apache.org/dist/" + name
+    } );
+}
+
 // ------------ Async data fetching ------------\\
 // This function is the starter of every page, and preloads the needed files
 // before running the final page renderer. This is roughly 1 mb of JSON, but as
@@ -1278,6 +1316,7 @@ function preloadEverything(callback) {
 	    ["/json/foundation/projects.json", weaveInProjects],
 	    ["/json/foundation/podlings.json", weaveInProjects],
 	    ["/json/foundation/committers.json", weaveInCommitters],
+	    ["/json/foundation/releases.json", function(json) { releases = json; }],
         ],
 	callback);
 }

Modified: comdev/projects.apache.org/site/releases.html
URL: http://svn.apache.org/viewvc/comdev/projects.apache.org/site/releases.html?rev=1662755&r1=1662754&r2=1662755&view=diff
==============================================================================
--- comdev/projects.apache.org/site/releases.html (original)
+++ comdev/projects.apache.org/site/releases.html Fri Feb 27 17:27:20 2015
@@ -12,7 +12,7 @@
    
    <title>Apache Projects Directory</title>
 </head>
-<body>
+<body onload="preloadEverything(buildReleases);">
 
 <div id="logo"></div>
 <div id='cssmenu'>
@@ -27,8 +27,17 @@
 </div>
 
 <div id="contents">
-   <h1>Releases</h1>
-   This is a placeholder for project releases. TBD.
+   <p style="text-align: center;">
+      Loading data, please wait...<br/>
+      <img src="/images/loader.gif"/>
+   </p>
+   <noscript>
+      <h2>Notice!</h2>
+      <p>
+         This site relies heavily on JavaScript.
+         Please enable it or get a browser that supports it.
+      </p>
+   </noscript>
 </div>
 <div id="footer">
    Copyright&copy; 2015, the Apache Software Foundation. Licensed under the Apache License
v/2.0<br/>



Mime
View raw message