cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject git commit: updating push script and stats page
Date Wed, 06 Nov 2013 22:27:44 GMT
Updated Branches:
  refs/heads/master f3194f689 -> 697102ef7


updating push script and stats page


Project: http://git-wip-us.apache.org/repos/asf/cordova-registry-web/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-registry-web/commit/697102ef
Tree: http://git-wip-us.apache.org/repos/asf/cordova-registry-web/tree/697102ef
Diff: http://git-wip-us.apache.org/repos/asf/cordova-registry-web/diff/697102ef

Branch: refs/heads/master
Commit: 697102ef72b8e66b481e14442bbae6390f285941
Parents: f3194f6
Author: Anis Kadri <anis@apache.org>
Authored: Wed Nov 6 14:27:40 2013 -0800
Committer: Anis Kadri <anis@apache.org>
Committed: Wed Nov 6 14:27:40 2013 -0800

----------------------------------------------------------------------
 attachments/more.html  |  3 +-
 attachments/site.js    | 10 +++++++
 attachments/stats.html | 71 ++++++++++++++++++++++++++-------------------
 package.json           | 16 ++++++++++
 push.sh                | 31 ++++++++++++++++++++
 5 files changed, 100 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/697102ef/attachments/more.html
----------------------------------------------------------------------
diff --git a/attachments/more.html b/attachments/more.html
index c6fa383..5fa96fc 100644
--- a/attachments/more.html
+++ b/attachments/more.html
@@ -1,3 +1,4 @@
 <h2>Goodies</h2>
 
-<h3><a href="/#/_analytics">Analytics</a></div>
\ No newline at end of file
+<h3><a href="/#/_analytics">Analytics</a></div>
+<h3><a href="/#/_stats">Stats</a></div>

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/697102ef/attachments/site.js
----------------------------------------------------------------------
diff --git a/attachments/site.js b/attachments/site.js
index c8ef8ac..6e0a529 100644
--- a/attachments/site.js
+++ b/attachments/site.js
@@ -786,6 +786,15 @@ app.author = function () {
     })
   })
 }
+
+app.stats = function() {
+  clearContent();
+
+  request({url:'/stats.html', dataType:'html'}, function (e, resp) {
+    $('div#content').html('<div id="main-container">'+resp+'</div>');
+  })
+}
+
 app.analytics = function () {
   clearContent();
   var view = this.params.view || "thisweek";
@@ -922,6 +931,7 @@ $(function () {
     this.get('', app.index);
     this.get("#/", app.index);
     this.get("#/_analytics", app.analytics);
+    this.get("#/_stats", app.stats);
     this.get("#/_analytics/:view", app.analytics);
     this.get("#/_browse", app.browse);
     this.get("#/_browse/:view", app.browse);

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/697102ef/attachments/stats.html
----------------------------------------------------------------------
diff --git a/attachments/stats.html b/attachments/stats.html
index bf5818f..8ee2b67 100644
--- a/attachments/stats.html
+++ b/attachments/stats.html
@@ -12,49 +12,59 @@
     <script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
     <script type='text/javascript'>
       function clientStats() {
-        var url = 'http://cordova.iriscouch.com/downloads/_design/downloads/_view/byClient?group=true'
+        var url = '/downloads/_design/downloads/_view/byClient?group=true'
         var xhr = new XMLHttpRequest();
         xhr.open('GET', url, true);
         xhr.onload = function(e) {
-          var data = JSON.parse(xhr.responseText).rows;
-          var clientStatsEm = document.getElementById('client_stats');
-          var plugman = cordova_cli = unknown = total = 0;
-          for(var i = 0 ; i < data.length ; i++) {
-            total += data[i].value;
-            if(data[i].key[1] === 'plugman') {
-              plugman += data[i].value;
-            } else if(data[i].key[1] === 'cordova-cli') {
-              cordova_cli += data[i].value;
-            } else {
-              unknown += data[i].value;
+          var res = JSON.parse(xhr.responseText);
+          if(res) {
+            var data = res.rows;
+            var clientStatsEm = document.getElementById('client_stats');
+            var plugman = cordova_cli = unknown = total = 0;
+            for(var i = 0 ; i < data.length ; i++) {
+              total += data[i].value;
+              if(data[i].key[1] === 'plugman') {
+                plugman += data[i].value;
+              } else if(data[i].key[1] === 'cordova-cli') {
+                cordova_cli += data[i].value;
+              } else {
+                unknown += data[i].value;
+              }
             }
+            var totalEm = document.getElementById('total');
+            totalEm.innerHTML = '<h1>Total Downloads: '+total+'</h1>';
+            var plugmanPerc = plugman * 100 / total;
+            var cordovaCliPerc = cordova_cli * 100 / total;
+            var unknownPerc = unknown * 100 / total;
+            var html = 'plugman '+Math.round(plugmanPerc)+'%<br/>';
+            html += 'cordova-cli '+Math.round(cordovaCliPerc)+'%<br/>';
+            html += 'unknown '+Math.round(unknownPerc)+'%<br/>';
+            clientStatsEm.innerHTML = html;
           }
-          var plugmanPerc = plugman * 100 / total;
-          var cordovaCliPerc = cordova_cli * 100 / total;
-          var unknownPerc = unknown * 100 / total;
-          var html = 'plugman '+Math.round(plugmanPerc)+'%<br/>';
-          html += 'cordova-cli '+Math.round(cordovaCliPerc)+'%<br/>';
-          html += 'unknown '+Math.round(unknownPerc)+'%<br/>';
-          clientStatsEm.innerHTML = html; 
         };
         xhr.send();
       };
       window.addEventListener('load', function load(event) {
           window.removeEventListener('load');
-          var url = 'http://cordova.iriscouch.com/downloads/_design/downloads/_view/byId?group=true';
+          var url = '/downloads/_design/downloads/_view/byId?group=true';
           var xhr = new XMLHttpRequest();
           xhr.open('GET', url, true);
           xhr.onload = function(e) {
-            var downloads = JSON.parse(xhr.responseText).rows;
-            var downloadsEm = document.getElementById('downloads');
-            downloads.sort(function(a,b) { return b.value - a.value; });
-            for(var i = 0 ; i < downloads.length ; i++) {
-              var row = document.createElement('tr');
-              var rank = i+1;
-              row.innerHTML = '<td>'+rank+'</td><td>'+downloads[i].key+'</td>'+'<td>'+downloads[i].value+'</td>';
-              downloadsEm.appendChild(row); 
-            }
-            clientStats();
+            var res = JSON.parse(xhr.responseText);
+            if(res) {
+              var downloads = res.rows;
+              var downloadsEm = document.getElementById('downloads');
+              downloads.sort(function(a,b) { return b.value - a.value; });
+              for(var i = 0 ; i < downloads.length ; i++) {
+                var row = document.createElement('tr');
+                var rank = i+1;
+                row.innerHTML = '<td>'+rank+'</td><td>'+downloads[i].key+'</td>'+'<td>'+downloads[i].value+'</td>';
+                downloadsEm.appendChild(row); 
+              }
+              clientStats();
+              } else {
+                document.getElementById('total').innerHTML = "Cannot get download data :-("
+              }
           };
           xhr.send();
       });
@@ -62,6 +72,7 @@
   </head>
 
   <body>
+    <div id="total"></div>
     <table class='table'>
       <thead>
         <tr>

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/697102ef/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..b098d1d
--- /dev/null
+++ b/package.json
@@ -0,0 +1,16 @@
+{
+  "name": "cordova-registry-web",
+    "version": "0.1.0",
+    "description": "The cordova registry ui couchapp",
+    "scripts": {
+      "start": "./push.sh"
+    },
+    "dependencies": {
+      "couchapp": "~0.9",
+      "semver": "~2.0.10"
+    },
+    "devDependencies": {
+      "jsontool": "~4.0.0"
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/697102ef/push.sh
----------------------------------------------------------------------
diff --git a/push.sh b/push.sh
new file mode 100755
index 0000000..d1d0848
--- /dev/null
+++ b/push.sh
@@ -0,0 +1,31 @@
+CREDS="admin:adobe"
+HOST="localhost:5984"
+
+if [ $# -ne 2 ] && [ $# -ne 0 ]
+then
+    echo 'Usage: drop_registry username:password http://registry_host'
+    exit 1
+fi
+
+if [[ -n $1 ]]
+then
+  CREDS=$1
+fi
+
+if [[ -n $2 ]]
+then
+  HOST=$2
+fi
+
+echo $CREDS $HOST
+
+SURL="http://$HOST"
+URL="http://$CREDS@$HOST"
+
+echo $URL
+
+#curl -u $CREDS -X DELETE $SURL/registry && \
+#curl -u $CREDS -X PUT $SURL/registry && \
+
+# pushing new registry
+couchapp push app.js "$URL/registry"


Mime
View raw message