You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2014/04/07 23:07:02 UTC

[06/53] [abbrv] git commit: updated readme and grunt scripts

updated readme and grunt scripts


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/e9519c9f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-registry-web/tree/e9519c9f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-registry-web/diff/e9519c9f

Branch: refs/heads/master
Commit: e9519c9fff8a8964819e7695b66598f5c74aa314
Parents: 3243029
Author: Steven Gill <st...@gmail.com>
Authored: Sun Mar 16 12:46:13 2014 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Sun Mar 16 12:46:13 2014 -0700

----------------------------------------------------------------------
 .gitignore                           |   3 +-
 Gruntfile.js                         |  85 ++++++++++++++---
 README.md                            | 153 +++++++++++++++++++-----------
 attachments/css/layout.less          |   2 +-
 attachments/css/pages/home.less      |   2 +-
 attachments/css/styles.css           |   4 +-
 attachments/js/directives/topbar.js  |   2 +-
 attachments/partials/views/home.html |   4 +-
 config.json                          |  12 +++
 package.json                         |   8 +-
 10 files changed, 195 insertions(+), 80 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/e9519c9f/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 496ee2c..9daa824 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
-.DS_Store
\ No newline at end of file
+.DS_Store
+node_modules

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/e9519c9f/Gruntfile.js
----------------------------------------------------------------------
diff --git a/Gruntfile.js b/Gruntfile.js
index 336ecda..d084f35 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -1,14 +1,12 @@
 'use strict';
 module.exports = function(grunt) {
 
+  var rewriteRulesSnippet = require('grunt-connect-rewrite/lib/utils').rewriteRequest;
+  var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;
+
   grunt.initConfig({
     pkg: grunt.file.readJSON('package.json'),
-    jshint: {
-      files: ['Gruntfile.js', 'attachments/js/*.js', 'attachments/controllers/*.js'],
-      options: {
-        jshintrc: true
-      }
-    },
+    config:grunt.file.readJSON('config.json'),
     watch: {
       changeFiles: {
         files: ['attachments/*.html', 'attachments/partials/**/*.html', 'attachments/css/**/*.less', 'attachments/css/**/*.css', 'attachments/js/**/*.js'],
@@ -24,6 +22,12 @@ module.exports = function(grunt) {
       },
       reloadServer: {
         command: 'couchapp push app.js http://localhost:5984/registry'
+      },
+      cloudant: {
+        command: 'couchapp push app.js http://<%= config.cloudant.username %>:<%= config.cloudant.password %>@<%= config.cloudant.url %>/registry'
+      },
+      iriscouch: {
+        command: 'couchapp push app.js http://<%= config.iriscouch.username %>:<%= config.iriscouch.password %>@<%= config.iriscouch.url %>/registry'
       }
     },
     less: {
@@ -35,12 +39,71 @@ module.exports = function(grunt) {
           "attachments/css/styles.css": "attachments/css/styles.less"
         }
       },
+    },
+    connect: {
+        options: {
+            port: 5000,
+            hostname: 'localhost'
+        },
+        localRegistry:{    
+            proxies: [{
+                context: '/',
+                host: 'localhost',
+                port:5984,
+                https: false,
+                changeOrigin: false,
+                rewrite:{
+                    '^/(.*)$':'/registry/_design/ui/_rewrite/$1'
+                }
+            }]
+        },
+        develop: {
+            options: {
+                middleware: function (connect, options) {
+                    if (!Array.isArray(options.base)) {
+                        options.base = [options.base];
+                    }
+
+                    // Setup the proxy
+                    var middlewares = [require('grunt-connect-proxy/lib/utils').proxyRequest];
+
+                    // Serve static files.
+                    options.base.forEach(function(base) {
+                        middlewares.push(connect.static(base));
+                    });
+
+                    // Make directory browse-able.
+                    var directory = options.directory || options.base[options.base.length - 1];
+                    middlewares.push(connect.directory(directory));
+
+                    return middlewares;
+                },
+            }
+        }
     }
   });
-
-  // grunt.loadNpmTasks('grunt-contrib-jshint');
+  
+  //load all of the grunt tasks
   require('load-grunt-tasks')(grunt);
+  
+  grunt.registerTask('server', function (target) {
+      grunt.task.run([
+          'configureProxies:localRegistry',
+          'connect:develop',
+          'watch'
+      ]);
+  });
 
-  grunt.registerTask('default', ['jshint']);
-
-};
\ No newline at end of file
+  grunt.registerTask('cloudant', function (target) {
+      grunt.task.run([
+          'less',
+          'shell:cloudant'   
+      ]);
+  });
+  grunt.registerTask('iriscouch', function (target) {
+      grunt.task.run([
+          'less',
+          'shell:iriscouch'   
+      ]);
+  });
+};

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/e9519c9f/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 37d8636..327df00 100644
--- a/README.md
+++ b/README.md
@@ -1,88 +1,125 @@
-# Cordova Registry UI
-This repo contains the assets for [plugins.cordova.io](http://plugins.cordova.io). Everything is located in the attachments folder. Below we go over the steps of getting setup and running locally.
+Cordova Registry UI
+===================
+This repo contains the assets for [plugins.cordova.io](http://plugins.cordova.io). The site is located in the attachments folder. Below we go over the steps of getting setup, running locally and pushing to the server. The main UI files for the site can be found in the `attachments` directory.
+
+Setup
+=====
+### Clone this repo & install dependencies
+```bash
+git clone https://git-wip-us.apache.org/repos/asf/cordova-registry-web.git
+```
+In your terminal, navigate to the cordova-registry-web directory and run `npm install`. This will install the dependencies required to deploy locally. 
 
-## Setup
+### Clone Cordova-Registry repo
+If you are interested in publishing plugins to your local repo, you will need this repo.
+```bash
+git clone https://git-wip-us.apache.org/repos/asf/cordova-registry-web.git
+```
+Navigate to the cordova-registry directory and run `npm install`.
 
-### Install COUCHDB
+### Install & Start CouchDB
+```bash
+brew install couchdb
+```
+Once installed, start CouchDB. You can do this by running 'couchdb' in your terminal. 
+Go to `http://localhost:5984` in your browser to confirm it is working.
 
-`brew install couchdb`
+### Create databases in couch
 
-You can find more documentation 
+* Registry - holds plugins, views and site ui
 
-### Create registry database in couch
+```bash
 curl -X PUT http://localhost:5984/registry
+```
 
-### npmjs
-git clone https://github.com/imhotep/npmjs.org
+* Downloads - holds download counts
 
-### cordova registry web
-git clone https://git-wip-us.apache.org/repos/asf/cordova-registry-web.git
+```bash
+curl -X PUT http://localhost:5984/downloads
+```
 
-cd npmjs
-npm install -g couchapp
-npm install couchapp
-npm install semver
+### Replicate remote databases
+If you want to see actual plugins and download counts when you are working locally, you will have to replicate the remote dbs. This could take a while as they are large. An alternative to replicating is to publish plugins locally for testing purposes.
 
-couchapp push registry/app.js http://localhost:5984/registry
-cd ../cordova-registry-web
-couchapp push app.js http://localhost:5984/registry
+Note: We are in the process of moving over form IrisCouch to Cloudant. IrisCouch seems to have better replication support.
 
-Pretty much all of the work you need to do is in cordova-registry-web
+* IrisCouch
 
-Enter this into your terminal because legacy.
-curl http://localhost:5984/registry/_design/scratch -X COPY  -H destination:'_design/app'
+```bash
+curl -X POST -d '{"source":"http://cordova.iriscouch.com/registry", "target":"http://localhost:5984/registry"}' http://localhost:5984/_replicate -H "Content-Type: application/json"
+```
 
-## Displaying on localhost
+```bash
+curl -X POST -d '{"source":"http://cordova.iriscouch.com/downloads", "target":"http://localhost:5984/downloads"}' http://localhost:5984/_replicate -H "Content-Type: application/json"
+```
 
-cd /etc/apache2/users
-sudo vim YOURCOMPUTERUSERNAME.conf (mine was stevengill.conf)
+* Cloudant
 
-Paste the following rewrite rules into it.
+```bash
+curl -X POST -d '{"source":"http://apachecordova.cloudant.com/registry", "target":"http://localhost:5984/registry"}' http://localhost:5984/_replicate -H "Content-Type: application/json"
+```
 
-<VirtualHost *:80>
-  ServerName localhost
-  RewriteEngine on
-  RewriteRule ^/((?!downloads).*)$ /registry/_design/ui/_rewrite/$1 [PT]
-  ProxyPassMatch ^/downloads/(.*)$ http://cordova.iriscouch.com/downloads/$1
-  ProxyPassMatch ^/registry/(.*)$ http://localhost:5984/registry/$1
-  RewriteLog "/var/log/apache2/plugins.cordova.io-rewrite.log"
-  RewriteLogLevel 3
-  LogLevel debug
-  ErrorLog "/var/log/apache2/plugins.cordova.io-error_log"
-  CustomLog "/var/log/apache2/plugins.cordova.io-access_log" common
-</VirtualHost>
+```bash
+curl -X POST -d '{"source":"http://apachecordova.cloudant.com/downloads", "target":"http://localhost:5984/downloads"}' http://localhost:5984/_replicate -H "Content-Type: application/json"
+```
 
-back to terminal, start apache with:
-sudo apachectl start\
+Note: A possible error may be that you don't have a local `_replicate` db. You can create one with:
+```bash
+curl -X PUT http://localhost:5984/_replicate
+```
 
-go to localhost in your browser and bam! should be working.
+Deploy Locally
+==============
 
-## Publish Plugins to your local instance
-plugman config set registry http://localhost:5984/registry/_design/app/_rewrite
+### Cordova-registy
+Navigate to cordova-registy directory in your terminal and run the following command.
+```bash
+couchapp push app.js http://localhost:5984/registry
+```
 
-##Potential Errors
-If you keep seeing `POST /_session 401` when you try to publish a plugin locally, you need to go delete your user info. In terminal type `rm -rf ~/.plugman`. Then go to the plugin you want to add and go `plugman adduser`. Enter in your username, password and email.
+### Cordova-registy-web
+Navigate to cordova-registy-web directory in your terminal and run the following command.
+```bash
+grunt server
+```
 
-##Alternative
-couchapp serve app.js http://localhost:5984/registry -p 3000 -l -d attachments/
+You show now be able to view the site at http://localhost:5000 in your browser.
+The site is setup to use livereload. As you modify & save files in the `attachments` directory, the browser will automatically reload the page.
 
-## Changes to LESS
+NOTE - The Grunt server & watch commands are set up to use livereload - this will automatically reload your browser after the server is done reloading - no more needing to click the refresh button on your browser. The livereload script is put in the HEAD of the index.html page - if you wish to not use it, you will need to comment or remove that from the index.html page.
 
-The project is now heavily using LESS using imports
+## Publish Plugins to your local instance
+```bash
+plugman config set registry http://localhost:5984/registry/_design/app/_rewrite
+```
+Now you can run commands like `plugman publish` and the plugins will install locally.
 
-To get started, take a peak into styles.less - this contains @import statements to pull in other stylesheets to help organize the styles. Compile it with your favorite less compiler or use `grunt less` if you'd wish.
+## Potential Errors
+If you keep seeing `POST /_session 401` when you try to publish a plugin locally, you need to go delete your user info. In terminal type `rm -rf ~/.plugman`. Then go to the plugin you want to add and go `plugman adduser`. Enter in your username, password and email.
 
-## Using Grunt
+Deploy Remotely
+==============
+Contact Steve or Anis to get username and passwords for remote couchdb instances. Any Cordova committers will be given the information if requested. Currently [plugins.cordova.io](http://plugins.cordova.io) is hosted on irisCouch and [stage.plugins.cordova.io](http://stage.plugins.cordova.io) is hosted on CloudAnt. The plan is to move over to cloudant when this site launches. This will require setting up the default plugman registry to cloudant.
 
-Grunt has been added to help with some mundane tasks.
+### Cordova-registy
+Navigate to cordova-registy directory in your terminal and run the following command.
+```bash
+couchapp push app.js http://username:password@apachecordova.cloudant.com/registry
+```
+or
+```bash
+couchapp push app.js http://username:password@cordova.irishcouch.com/registry
+```
 
-To get started, `npm install` this should install Grunt and its plugins.
+### Cordova-registy-web
+Navigate to cordova-registy-web directory in your terminal and run the following command.
+```bash
+grunt cloudant
+```
+or
+```bash
+grunt iriscouch
+```
 
-You can run a few commands with grunt.
 
-* View Grunt tasks available `grunt --help`
-* JSHint the javascript files `grunt jshint`
-* Compile the LESS `grunt less`
-* Watch all HTML/JS/CSS/LESS files - and if changes are made, auto compile LESS and reload the server with latest code `grunt watch`
 
-NOTE - The Grunt watch command is set up to use livereload - this will automatically reload your browser after the server is done reloading - no more needing to click the refresh button on your browser. The livereload script is put in the HEAD of the index.html page - if you wish to not use it, you will need to comment or remove that from the index.html page.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/e9519c9f/attachments/css/layout.less
----------------------------------------------------------------------
diff --git a/attachments/css/layout.less b/attachments/css/layout.less
index 9a50ef7..5c4f7b6 100644
--- a/attachments/css/layout.less
+++ b/attachments/css/layout.less
@@ -46,7 +46,7 @@ a.dep-link {
 }
 
 .pluggy-logo {
-  background: transparent url('../images/pluggy.svg') no-repeat top left;
+  background: transparent url('../img/pluggy.svg') no-repeat top left;
   background-size: contain;
 } 
 

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/e9519c9f/attachments/css/pages/home.less
----------------------------------------------------------------------
diff --git a/attachments/css/pages/home.less b/attachments/css/pages/home.less
index e3741df..7a42cf1 100644
--- a/attachments/css/pages/home.less
+++ b/attachments/css/pages/home.less
@@ -19,7 +19,7 @@
 }
 
 .cordova-grid-bg {
-    background: url(../images/grid.png);
+    background: url(../img/grid.png);
 }
 
 .discover-message {

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/e9519c9f/attachments/css/styles.css
----------------------------------------------------------------------
diff --git a/attachments/css/styles.css b/attachments/css/styles.css
index 9785de7..f08b017 100644
--- a/attachments/css/styles.css
+++ b/attachments/css/styles.css
@@ -2397,7 +2397,7 @@ a.dep-link {
   color: #fff;
 }
 .pluggy-logo {
-  background: transparent url('../images/pluggy.svg') no-repeat top left;
+  background: transparent url('../img/pluggy.svg') no-repeat top left;
   background-size: contain;
 }
 .top-logo {
@@ -2870,7 +2870,7 @@ div.left {
   background: -o-linear-gradient(top, transparent, #ededed);
 }
 .cordova-grid-bg {
-  background: url(../images/grid.png);
+  background: url(../img/grid.png);
 }
 .discover-message {
   background-color: white;

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/e9519c9f/attachments/js/directives/topbar.js
----------------------------------------------------------------------
diff --git a/attachments/js/directives/topbar.js b/attachments/js/directives/topbar.js
index 8c99dbf..249ffad 100644
--- a/attachments/js/directives/topbar.js
+++ b/attachments/js/directives/topbar.js
@@ -46,7 +46,7 @@ angular.module('registry.controllers').directive('topbar', function ($http, $loc
                 //todo: use sessionstorage or turn this into a service to cache results
                 $http({method: 'GET', url:('/api/_all_docs?limit=0')}).
                     success(function(data, status, headers, config) {
-                        $scope.totalPlugins = data.total_rows - 4;
+                        $scope.totalPlugins = data.total_rows - 2;
                     }).
                     error(function(data, status){
                         if (status === 404){

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/e9519c9f/attachments/partials/views/home.html
----------------------------------------------------------------------
diff --git a/attachments/partials/views/home.html b/attachments/partials/views/home.html
index 336c36e..4ffa7c8 100644
--- a/attachments/partials/views/home.html
+++ b/attachments/partials/views/home.html
@@ -21,7 +21,7 @@
 					<div class="call-to-action-pane-right-triangle"><div></div></div>
 					<div class="row">
 						<div class="column-12--hand">
-							<img class="call-to-action-img" title="Contrib flyer" src="/images/contribute.png" />
+							<img class="call-to-action-img" title="Contrib flyer" src="/img/contribute.png" />
 						</div>
 					</div>
 					<div class="row">
@@ -46,7 +46,7 @@
 					<div class="call-to-action-pane-right-triangle"><div></div></div>
 					<div class="row">
 						<div class="column-12--hand">
-							<img class="call-to-action-img" title="Utilize wrench" src="/images/utilize.png" />
+							<img class="call-to-action-img" title="Utilize wrench" src="/img/utilize.png" />
 						</div>
 					</div>
 					<div class="row">

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/e9519c9f/config.json
----------------------------------------------------------------------
diff --git a/config.json b/config.json
new file mode 100644
index 0000000..56ef1a1
--- /dev/null
+++ b/config.json
@@ -0,0 +1,12 @@
+{
+    "cloudant":{
+        "username":"username",
+        "password":"password",
+        "url":"apachecordova.cloudant.com"
+    },
+    "iriscouch":{
+        "username":"username",
+        "password":"password",
+        "url":"cordova.iriscouch.com"
+    }
+}

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/e9519c9f/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index d691dd3..3e43706 100644
--- a/package.json
+++ b/package.json
@@ -6,16 +6,18 @@
     "start": "./push.sh"
   },
   "dependencies": {
-    "couchapp": "~0.9",
+    "couchapp": "~0.10.0",
     "semver": "~2.0.10"
   },
   "devDependencies": {
     "jsontool": "~4.0.0",
     "grunt": "~0.4.1",
-    "grunt-contrib-jshint": "~0.7.1",
     "grunt-shell": "~0.6.2",
     "grunt-contrib-watch": "~0.5.3",
     "load-grunt-tasks": "~0.2.1",
-    "grunt-contrib-less": "~0.9.0"
+    "grunt-contrib-less": "~0.9.0",
+    "grunt-connect-proxy": "^0.1.8",
+    "grunt-contrib-connect": "^0.7.1",
+    "connect-livereload": "^0.3.2"
   }
 }