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/17 08:40:15 UTC
git commit: CB-6285: fixed search, switched to searcher view
Repository: cordova-registry-web
Updated Branches:
refs/heads/master cf9fcdd7b -> 34007dc62
CB-6285: fixed search, switched to searcher view
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/34007dc6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-registry-web/tree/34007dc6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-registry-web/diff/34007dc6
Branch: refs/heads/master
Commit: 34007dc62e19068838b37b2d2721b24ac9228e26
Parents: cf9fcdd
Author: Steven Gill <st...@gmail.com>
Authored: Wed Apr 16 23:40:07 2014 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Wed Apr 16 23:40:07 2014 -0700
----------------------------------------------------------------------
app.js | 92 ++++++++++++--------
attachments/js/controllers/home.js | 2 -
attachments/js/controllers/viewAll.js | 4 +-
attachments/partials/directives/pluginlist.html | 4 +-
4 files changed, 62 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/34007dc6/app.js
----------------------------------------------------------------------
diff --git a/app.js b/app.js
index 3865714..b6ffeba 100644
--- a/app.js
+++ b/app.js
@@ -15,6 +15,27 @@ ddoc =
, lists : {}
}
+function searcher(doc) {
+
+//if(word) ? id = word : id=doc._id;
+
+ if (doc['dist-tags'] && doc['dist-tags'].latest) {
+ var dist = doc.versions[doc['dist-tags'].latest];
+ //We have latest version, now get the platforms available.
+ var version = doc['dist-tags'].latest;
+ var engines = dist && dist.engines ? dist.engines : '';
+ var platforms = dist && dist.platforms ? dist.platforms : '';
+ var obj = {
+ name: doc.name
+ , description: doc.description
+ , version: version
+ , platforms: platforms
+ , engines: engines
+ };
+ log('emit ' + doc._id);
+ emit(doc._id, obj);
+ }
+}
function packageSearch (doc) {
var descriptionBlacklist =
@@ -32,25 +53,51 @@ function packageSearch (doc) {
, "as"
]
+ if (doc['dist-tags'] && doc['dist-tags'].latest) {
+ var dist = doc.versions[doc['dist-tags'].latest];
+ //We have latest version, now get the platforms available.
+ var version = doc['dist-tags'].latest;
+ var engines = dist && dist.engines ? dist.engines : '';
+ var platforms = dist && dist.platforms ? dist.platforms : '';
+ var obj = {
+ name: doc.name
+ , description: doc.description
+ , version: version
+ , platforms: platforms
+ , engines: engines
+ };
+ log('packagesearch ' + doc._id);
+ }
+
if (doc.name) { // There aren't any better attributes for check if isPackage()
if (doc.name) {
var names = [doc.name];
if (doc.name.indexOf('-') !== -1) doc.name.split('-').forEach(function (n) {names.push(n)});
if (doc.name.indexOf('_') !== -1) doc.name.split('_').forEach(function (n) {names.push(n)});
names.forEach(function (n) {
- if (n.length > 1) emit(n.toLowerCase(), doc);
+ if (n.length > 1) emit(n.toLowerCase(), obj);
+ });
+ }
+ if (doc._id) {
+ //log(doc._id);
+ var ids = [doc._id];
+ if (doc._id.indexOf('.') !== -1) doc._id.split('.').forEach(function (n) {ids.push(n)});
+ //if (doc.name.indexOf('.') !== -1) doc.name.split('_').forEach(function (n) {names.push(n)});
+ ids.forEach(function (id) {
+ if (id.length > 1) emit(id.toLowerCase(), obj);
});
}
+
if (doc['dist-tags'] && doc['dist-tags'].latest && (
- doc.versions[doc['dist-tags'].latest].keywords || doc.versions[doc['dist-tags'].latest].tags
- )) {
- var tags = (doc.versions[doc['dist-tags'].latest].keywords || doc.versions[doc['dist-tags'].latest].tags)
- tags.forEach(function (tag) {
- tag.split(' ').forEach(function (t) {
- if (t.length > 0) emit(t.toLowerCase(), doc);
+ doc.versions[doc['dist-tags'].latest].keywords)) {
+ var keywords = (doc.versions[doc['dist-tags'].latest].keywords)
+ keywords.forEach(function (keyword) {
+ keyword.split(' ').forEach(function (k) {
+ if (k.length > 0) emit(k.toLowerCase(), obj);
});
})
}
+
if (doc.description) {
doc.description.split(' ').forEach(function (d) {
d = d.toLowerCase();
@@ -71,7 +118,7 @@ function packageSearch (doc) {
while (d.indexOf('%') !== -1) d = d.replace('%', '');
while (d.indexOf('+') !== -1) d = d.replace('+', '');
if (descriptionBlacklist.indexOf(d) !== -1) d = '';
- if (d.length > 1) emit(d, doc);
+ if (d.length > 1) emit(d, obj);
})
}
}
@@ -86,42 +133,17 @@ function dependencies (doc) {
}
}
-function searcher(doc) {
- if (doc['dist-tags'] && doc['dist-tags'].latest) {
- var dist = doc.versions[doc['dist-tags'].latest];
- //We have latest version, now get the platforms available.
- var engines = dist && dist.engines ? dist.engines : '';
- var platforms = dist && dist.platforms ? dist.platforms : '';
- var downloads = 0;
- var obj = {
- name: doc.name
- , description: doc.description
- , version: doc.dist
- , downloads: downloads
- , platforms: platforms
- , engines: engines
- };
- emit(doc._id, obj);
- }
-}
+
ddoc.views =
{ search: { map: packageSearch }
- , searcher: { map: searcher }
+ , searcher: { map: searcher}
, dependencies: {map: dependencies, reduce:"_count"}
, updated: {map: function (doc) {
var l = doc["dist-tags"].latest
, t = doc.time && doc.time[l]
if (t) emit(t, 1)
}}
- , tags:
- { map: function (doc) {
- if (doc['dist-tags'] && doc['dist-tags'].latest) {
- doc.versions[doc['dist-tags'].latest].tags.forEach(function (t) {emit(t, 1)})
- }
- }
- , reduce: "_sum"
- }
, author:
{ map: function (doc) {
if (doc.author && doc.author.name) {
http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/34007dc6/attachments/js/controllers/home.js
----------------------------------------------------------------------
diff --git a/attachments/js/controllers/home.js b/attachments/js/controllers/home.js
index 94b2ea9..bac570e 100644
--- a/attachments/js/controllers/home.js
+++ b/attachments/js/controllers/home.js
@@ -5,8 +5,6 @@ angular.module('registry.controllers').controller('HomeController', ['$rootScope
$scope.mostDownloaded = [];
$scope.lastUpdated = [];
-
-
$scope.getMostDownloaded = function() {
Downloads.getDownloads().then(function(obj){
$scope.mostDownloaded = obj.arrData.slice(0, 9);
http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/34007dc6/attachments/js/controllers/viewAll.js
----------------------------------------------------------------------
diff --git a/attachments/js/controllers/viewAll.js b/attachments/js/controllers/viewAll.js
index 827854d..4e67a09 100644
--- a/attachments/js/controllers/viewAll.js
+++ b/attachments/js/controllers/viewAll.js
@@ -3,10 +3,11 @@ angular.module('registry.controllers').controller('ViewAllController', ['$rootSc
$scope.loading = true;
$scope.getPlugins = function(){
- $http({method: 'GET', url:('/api/_all_docs?include_docs=true&skip=3')}).
+ $http.get('/_view/searcher/').
success(function(data, status, headers, config) {
$scope.plugins = data.rows;
$scope.loading = false;
+ //hacky way to assign download counts to plugin
$scope.plugins.forEach(function(element, index, array){
if(!($scope.downloads[element.id])){
array[index].downloads = 0;
@@ -14,6 +15,7 @@ angular.module('registry.controllers').controller('ViewAllController', ['$rootSc
array[index].downloads = $scope.downloads[element.id];
}
});
+ console.log($scope.plugins);
}).
error(function(data, status){
if (status === 404){
http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/34007dc6/attachments/partials/directives/pluginlist.html
----------------------------------------------------------------------
diff --git a/attachments/partials/directives/pluginlist.html b/attachments/partials/directives/pluginlist.html
index c45394c..2050fba 100644
--- a/attachments/partials/directives/pluginlist.html
+++ b/attachments/partials/directives/pluginlist.html
@@ -16,10 +16,10 @@
<div ng-repeat="plugin in plugins | platformFilter: selectedPlatforms() | orderBy:orderValue:reverse" class="row pluginItem">
<div class="column-9--hand column-8--lap">
<div><a ng-href="#/package/{{plugin.key}}">{{plugin.key}}</a></div>
- <div class="pluginItemDescription">{{((plugin.value.description)||(plugin.doc.description))}}</div>
+ <div class="pluginItemDescription">{{plugin.value.description}}</div>
</div>
<div class="column-3--hand column-2--lap center">
- <div class="pluginItemVersion">{{((plugin.value['dist-tags'].latest)||(plugin.doc['dist-tags'].latest))}}</div>
+ <div class="pluginItemVersion">{{plugin.value.version}}</div>
</div>
<div class="column-2--hand invisible--hand visible--lap center">
<div class="pluginItemDownloads">{{plugin.downloads}}</div>