cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mura...@apache.org
Subject cordova-registry-web git commit: CB-9152, 9153, 9154 Minor refactor and small fixes
Date Fri, 12 Jun 2015 00:28:57 GMT
Repository: cordova-registry-web
Updated Branches:
  refs/heads/master 6669015a8 -> 1d7f7c03a


CB-9152,9153,9154 Minor refactor and small fixes


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

Branch: refs/heads/master
Commit: 1d7f7c03a071ccbb81bb816194c9bfa524609b5d
Parents: 6669015
Author: Murat Sutunc <sutunc@gmail.com>
Authored: Thu Jun 11 15:21:07 2015 -0700
Committer: Murat Sutunc <sutunc@gmail.com>
Committed: Thu Jun 11 17:17:03 2015 -0700

----------------------------------------------------------------------
 npm-search/Gulpfile.js         | 22 +++--------
 npm-search/assets/css/base.css | 11 +++---
 npm-search/assets/js/app.js    | 73 ++++++++++++++++++++++++-------------
 npm-search/package.json        |  2 -
 4 files changed, 59 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/1d7f7c03/npm-search/Gulpfile.js
----------------------------------------------------------------------
diff --git a/npm-search/Gulpfile.js b/npm-search/Gulpfile.js
index cd520b0..cdfc176 100644
--- a/npm-search/Gulpfile.js
+++ b/npm-search/Gulpfile.js
@@ -1,8 +1,6 @@
 var gulp       = require('gulp'),
     concat     = require('gulp-concat'),
     imagemin   = require('gulp-imagemin'),
-    sourcemaps = require('gulp-sourcemaps'),
-    uglify     = require('gulp-uglify'),
     gutil      = require('gulp-util'),
     buffer     = require('vinyl-buffer'),
     source     = require('vinyl-source-stream'),
@@ -17,23 +15,15 @@ gulp.task('styles', function () {
 });
 
 gulp.task('scripts', function () {
-    var b = browserify({
-        entries: './assets/js/app.js',
-        debug: true,
-        transform: [ reactify ]
-    });
-
-    return b.bundle()
+    browserify('./assets/js/app.js', { debug: true })
+        .transform(reactify)
+        .bundle()
+        .on('error', gutil.log)
         .pipe(source('app.js'))
         .pipe(buffer())
-        .pipe(sourcemaps.init({loadMaps: true}))
-            // Add transformation tasks to the pipeline here.
-            .pipe(uglify())
-            .on('error', gutil.log)
-        .pipe(sourcemaps.write('./'))
         .pipe(gulp.dest('./build/'));
 });
-;
+
 gulp.task('images', function () {
     gulp.src(['assets/img/**/*.png', 'assets/img/**/*.gif'])
         .pipe(imagemin())
@@ -51,4 +41,4 @@ gulp.task('dev', function () {
 
 });
 
-gulp.task('build', [ 'styles', 'scripts', 'images' ]);
\ No newline at end of file
+gulp.task('build', [ 'styles', 'scripts', 'images' ]);

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/1d7f7c03/npm-search/assets/css/base.css
----------------------------------------------------------------------
diff --git a/npm-search/assets/css/base.css b/npm-search/assets/css/base.css
index 8726072..98ca151 100644
--- a/npm-search/assets/css/base.css
+++ b/npm-search/assets/css/base.css
@@ -132,17 +132,16 @@ p.version {
   background-color: #71B9F9;
 }
 
-#supportedPlatforms {
-  display: flex;
-}
+#supportedPlatforms { }
 
 #supportedPlatforms div {
   margin: 12px 2px 2px 0;
   border: 1px solid #363636;
   border-radius: 8px;
   padding: .4em .5em;
-  font-size: 9px;
-  display: flex;
-  justify-content: center;
+  height: 11px;
+  font-size: 11px;
+  line-height: 11px;
+  display: inline-block;
   align-items: center;
 }

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/1d7f7c03/npm-search/assets/js/app.js
----------------------------------------------------------------------
diff --git a/npm-search/assets/js/app.js b/npm-search/assets/js/app.js
index c8476ff..99b6d65 100644
--- a/npm-search/assets/js/app.js
+++ b/npm-search/assets/js/app.js
@@ -97,7 +97,7 @@ var Plugin = React.createClass({
                     <div id="pluginInfo">
                         <div><a href={
                             'https://www.npmjs.com/package/' + this.props.plugin.name
-                        }>{this.props.plugin.name}</a> by <span className="author">{this.props.plugin.author}</span></div>
+                        }>{this.props.plugin.name}</a> by <span className="author">{this.props.plugin.author}</span>
(last updated {this.props.plugin.modified} days ago)</div>
                         <div id="pluginDesc">{this.props.plugin.description}</div>
                         <div className="row">
                             <SupportedPlatforms keywords={this.props.plugin.keywords}/>
@@ -115,9 +115,11 @@ var Plugin = React.createClass({
 
 var PluginList = React.createClass({
     render: function() {
-        var plugins = [];
+        var plugins = [],
+            filterText = this.props.filterText.toLowerCase();
+
         this.props.plugins.forEach(function(plugin) {
-            if (plugin.name[0].indexOf(this.props.filterText) > -1) {
+            if (plugin.name[0].indexOf(filterText) > -1) {
                 plugins.push(<Plugin plugin={plugin} key={plugin.author + plugin.name}/>);
             }
         }.bind(this));
@@ -148,33 +150,54 @@ var App = React.createClass({
 
     componentDidMount: function() {
         var plugins = [],
-            officialPlugins = [],
+            officialPlugins = require('./official-plugins.json').plugins,
             pluginCount = 0,
-            self = this;
+            self = this,
+            queryHost = "http://npmsearch.com/query",
+            queryFields = "fields=name,keywords,license,description,author,modified,homepage,version",
+            queryKeywords = "q=keywords:%22ecosystem:cordova%22",
+            queryInitialSize = 300;
 
-        xhrRequest("http://npmsearch.com/query?fields=name,keywords,license,description,author,modified,homepage,version&q=keywords:%22ecosystem:cordova%22&size=20&start=0",
function(xhrResult) {
+        xhrRequest(queryHost + "?" + queryFields + "&" + queryKeywords + "&size="
+ queryInitialSize + "&start=0", function(xhrResult) {
             plugins = xhrResult.results;
             pluginCount = xhrResult.total;
-            xhrRequest("http://npmsearch.com/query?fields=name,keywords,license,description,author,modified,homepage,version&q=keywords:%22ecosystem:cordova%22&size="
+ (pluginCount - 20) + "&start=20", function(xhrResult) {
-                plugins = [].concat(plugins, xhrResult.results);
-                officialPlugins = require('./official-plugins.json').plugins;
-                officialPlugins.forEach(function(plugin) {
-                    for (var i = 0; i < plugins.length; i++) {
-                        if (plugins[i].name[0] === plugin) {
-                            plugins[i].isOfficial = true;
-                            return;
-                        }
-                    };
-                })
-
-                if (this.isMounted()) {
-                    this.setState({
-                      plugins: plugins,
-                      placeHolderText: 'Search ' + pluginCount + ' plugins...'
-                    });
-                }
-            }.bind(self), function() { console.log('xhr err'); });
+            if (pluginCount <= queryInitialSize) {
+                processPlugins.bind(self, officialPlugins, plugins)();
+            } else {
+                xhrRequest(queryHost + "?" + queryFields + "&" + queryKeywords + "&size="
+ (pluginCount - queryInitialSize) + "&start=" + queryInitialSize, function(xhrResult)
{
+                        plugins = [].concat(plugins, xhrResult.results);
+                        processPlugins.bind(self, officialPlugins, plugins)();
+                }, function() { console.log('xhr err'); });
+            }
         }, function() { console.log('xhr err'); });
+
+        function processPlugins(officialPlugins, plugins) {
+            var pluginCount = plugins.length,
+                dateNow = new Date(),
+                oneDay = 1000*60*60*24;
+
+            officialPlugins.forEach(function(plugin) {
+                for (var i = 0; i < plugins.length; i++) {
+                    // Check if plugin name is in official list
+                    if (plugins[i].name[0] === plugin) {
+                        plugins[i].isOfficial = true;
+                        return;
+                    }
+                };
+            });
+
+            for (var i = 0; i < plugins.length; i++) {
+                // Calculate last time plugin is modified (in days)
+                plugins[i].modified = Math.ceil((dateNow - new Date(plugins[i].modified))
/ oneDay);
+            };
+
+            if (this.isMounted()) {
+                this.setState({
+                  plugins: plugins,
+                  placeHolderText: 'Search ' + pluginCount + ' plugins...'
+                });
+            }
+        }
     },
 
     render: function() {

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/1d7f7c03/npm-search/package.json
----------------------------------------------------------------------
diff --git a/npm-search/package.json b/npm-search/package.json
index 12b2b72..7527a49 100644
--- a/npm-search/package.json
+++ b/npm-search/package.json
@@ -21,8 +21,6 @@
     "gulp": "^3.9.0",
     "gulp-concat": "^2.5.2",
     "gulp-imagemin": "^2.2.1",
-    "gulp-sourcemaps": "^1.5.2",
-    "gulp-uglify": "^1.2.0",
     "gulp-util": "^3.0.5",
     "react": "^0.13.3",
     "react-tools": "^0.13.3",


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message