Repository: cordova-registry-web Updated Branches: refs/heads/refactor 1c510b0e8 -> 074012f83
CB-5130: search is working, added styles to other pages 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/074012f8 Tree: http://git-wip-us.apache.org/repos/asf/cordova-registry-web/tree/074012f8 Diff: http://git-wip-us.apache.org/repos/asf/cordova-registry-web/diff/074012f8 Branch: refs/heads/refactor Commit: 074012f83c437737fbd94e7d5b30aea2bed25cd1 Parents: 1c510b0 Author: Steven Gill <[email protected]> Authored: Wed Mar 12 17:54:21 2014 -0700 Committer: Steven Gill <[email protected]> Committed: Wed Mar 12 17:54:21 2014 -0700 ---------------------------------------------------------------------- attachments/css/pages/packageDetails.less | 12 +++- attachments/css/pages/pluginlist.less | 9 +++ attachments/css/pages/search.less | 11 +++ attachments/css/pages/topbar.less | 2 +- attachments/css/pages/viewAll.less | 5 +- attachments/css/styles.css | 30 +++++++- attachments/css/styles.less | 1 + attachments/index.html | 3 +- attachments/js/controllers/home.js | 2 +- attachments/js/controllers/search.js | 37 +--------- attachments/js/directives/pluginlist.js | 13 ++++ attachments/js/directives/topbar.js | 46 ++++++++++-- attachments/js/services.js | 2 +- attachments/partials/directives/pluginlist.html | 25 +++++++ attachments/partials/directives/topbar.html | 4 +- attachments/partials/views/packageDetails.html | 68 +++++++++++------- attachments/partials/views/search.html | 76 +++++--------------- attachments/partials/views/viewAll.html | 27 +------ 18 files changed, 213 insertions(+), 160 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/074012f8/attachments/css/pages/packageDetails.less ---------------------------------------------------------------------- diff --git a/attachments/css/pages/packageDetails.less b/attachments/css/pages/packageDetails.less index 38d7617..ea3abdd 100644 --- a/attachments/css/pages/packageDetails.less +++ b/attachments/css/pages/packageDetails.less @@ -1 +1,11 @@ -/* Package Details styles */ \ No newline at end of file +/* Package Details styles */ + +.space { + padding-top:10px; + padding-bottom:10px; + border-bottom:solid 2px #bfb7b9; +} + +.toprow { + padding-top:10px; +} http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/074012f8/attachments/css/pages/pluginlist.less ---------------------------------------------------------------------- diff --git a/attachments/css/pages/pluginlist.less b/attachments/css/pages/pluginlist.less new file mode 100644 index 0000000..3bcc72f --- /dev/null +++ b/attachments/css/pages/pluginlist.less @@ -0,0 +1,9 @@ +.pluginHeader { + border-bottom:solid 2px black; +} + +.pluginItem { + border-bottom:solid 2px #bfb7b9; + padding-top:10px; + padding-bottom:10px; +} http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/074012f8/attachments/css/pages/search.less ---------------------------------------------------------------------- diff --git a/attachments/css/pages/search.less b/attachments/css/pages/search.less index 572843f..920e2fd 100644 --- a/attachments/css/pages/search.less +++ b/attachments/css/pages/search.less @@ -1 +1,12 @@ /* Search styles */ + +.searchContainer { + padding-left:10px; +} + +.found { + font-size:25px; + padding-top:10px; + padding-bottom:10px; + border-bottom:dotted 2px #bfb7b9 +} http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/074012f8/attachments/css/pages/topbar.less ---------------------------------------------------------------------- diff --git a/attachments/css/pages/topbar.less b/attachments/css/pages/topbar.less index d286bd8..904ab11 100644 --- a/attachments/css/pages/topbar.less +++ b/attachments/css/pages/topbar.less @@ -6,7 +6,7 @@ .topbar-search { height: 35px; - border: 2px solid #4cc2e4; + border: 1px solid #4cc2e4; } .topbar-button { http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/074012f8/attachments/css/pages/viewAll.less ---------------------------------------------------------------------- diff --git a/attachments/css/pages/viewAll.less b/attachments/css/pages/viewAll.less index 49c759b..50274bf 100644 --- a/attachments/css/pages/viewAll.less +++ b/attachments/css/pages/viewAll.less @@ -1 +1,4 @@ -/* View all page styles */ \ No newline at end of file +/* View all page styles */ +.viewContainer { + padding-left:10px; +} http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/074012f8/attachments/css/styles.css ---------------------------------------------------------------------- diff --git a/attachments/css/styles.css b/attachments/css/styles.css index 9182e9e..9785de7 100644 --- a/attachments/css/styles.css +++ b/attachments/css/styles.css @@ -2951,8 +2951,28 @@ div.left { margin-top: 20px; } /* Package Details styles */ +.space { + padding-top: 10px; + padding-bottom: 10px; + border-bottom: solid 2px #bfb7b9; +} +.toprow { + padding-top: 10px; +} /* View all page styles */ +.viewContainer { + padding-left: 10px; +} /* Search styles */ +.searchContainer { + padding-left: 10px; +} +.found { + font-size: 25px; + padding-top: 10px; + padding-bottom: 10px; + border-bottom: dotted 2px #bfb7b9; +} .topbar-row { padding-top: 5px; padding-bottom: 5px; @@ -2960,7 +2980,7 @@ div.left { } .topbar-search { height: 35px; - border: 2px solid #4cc2e4; + border: 1px solid #4cc2e4; } .topbar-button { background-color: #4cc2e4; @@ -2980,3 +3000,11 @@ div.left { font-size: 20px; padding-top: 5px; } +.pluginHeader { + border-bottom: solid 2px black; +} +.pluginItem { + border-bottom: solid 2px #bfb7b9; + padding-top: 10px; + padding-bottom: 10px; +} http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/074012f8/attachments/css/styles.less ---------------------------------------------------------------------- diff --git a/attachments/css/styles.less b/attachments/css/styles.less index dab8b76..103614b 100644 --- a/attachments/css/styles.less +++ b/attachments/css/styles.less @@ -20,3 +20,4 @@ @import "pages/viewAll.less"; @import "pages/search.less"; @import "pages/topbar.less"; +@import "pages/pluginlist.less"; http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/074012f8/attachments/index.html ---------------------------------------------------------------------- diff --git a/attachments/index.html b/attachments/index.html index 80cd27a..5d4b760 100644 --- a/attachments/index.html +++ b/attachments/index.html @@ -78,7 +78,8 @@ <script type="text/javascript" src="js/controllers/search.js"></script> <script type="text/javascript" src="js/directives/ng-enter.js"></script> <script type="text/javascript" src="js/directives/topbar.js"></script> - + <script type="text/javascript" src="js/directives/pluginlist.js"></script> + <!-- <script type="text/javascript" src="js/services/search-service.js"></script>--> http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/074012f8/attachments/js/controllers/home.js ---------------------------------------------------------------------- diff --git a/attachments/js/controllers/home.js b/attachments/js/controllers/home.js index 93a0ae2..94b2ea9 100644 --- a/attachments/js/controllers/home.js +++ b/attachments/js/controllers/home.js @@ -9,7 +9,7 @@ angular.module('registry.controllers').controller('HomeController', ['$rootScope $scope.getMostDownloaded = function() { Downloads.getDownloads().then(function(obj){ - $scope.mostDownloaded = obj.slice(0, 9); + $scope.mostDownloaded = obj.arrData.slice(0, 9); }); }; http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/074012f8/attachments/js/controllers/search.js ---------------------------------------------------------------------- diff --git a/attachments/js/controllers/search.js b/attachments/js/controllers/search.js index 7cb4fd1..87a51c4 100644 --- a/attachments/js/controllers/search.js +++ b/attachments/js/controllers/search.js @@ -1,38 +1,3 @@ -angular.module('registry.controllers').controller('SearchController', ['$rootScope', '$routeParams', '$scope', '$location', '$http', function($rootScope, $routeParams, $scope, $location, $http) { +angular.module('registry.controllers').controller('SearchController', ['$rootScope', function($rootScope) { - var results = []; - var currentSearch, currentTerms; - var searchResults = {}; - $scope.plugins = null; - $scope.searchText = ''; - - $scope.searchPlugins = function() { - //console.log($scope.searchText); - currentSearch = $scope.searchText.toLowerCase(); - currentTerms = currentSearch.trim().split(' '); - console.log(currentTerms); - - currentTerms.forEach(function(term){ - if(!searchResults[term]){ - $http.get('/_list/search/search?startkey='+JSON.stringify(term)+'&endkey='+JSON.stringify(term+'ZZZZZZZZZZZZZZ')+'&limit=25'). - success(function(data, status, headers, config){ - //console.log(data); - $scope.plugins = data.rows; - console.log($scope.plugins); - console.log($scope.plugins[0].value._id); - }). - error(function(data,status){ - console.log(data); - console.log(status); - }) - } - }) - } - - if ($routeParams.search){ - console.log($routeParams.search); - $scope.searchText = $routeParams.search; - $scope.searchPlugins(); - } - }]); http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/074012f8/attachments/js/directives/pluginlist.js ---------------------------------------------------------------------- diff --git a/attachments/js/directives/pluginlist.js b/attachments/js/directives/pluginlist.js new file mode 100644 index 0000000..85bf4dd --- /dev/null +++ b/attachments/js/directives/pluginlist.js @@ -0,0 +1,13 @@ +angular.module('registry.controllers').directive('pluginlist', function () { + return { + restrict: 'E', + templateUrl: '/partials/directives/pluginlist.html', + controller:['$scope', '$rootScope', 'Downloads', function($scope, $rootScope, Downloads){ + Downloads.getDownloads().then(function(obj){ + $scope.downloads = obj.data; + }); + }], + link: function(scope, element, attrs, controller){ + } + }; +}); http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/074012f8/attachments/js/directives/topbar.js ---------------------------------------------------------------------- diff --git a/attachments/js/directives/topbar.js b/attachments/js/directives/topbar.js index 705a550..8c99dbf 100644 --- a/attachments/js/directives/topbar.js +++ b/attachments/js/directives/topbar.js @@ -1,16 +1,47 @@ -angular.module('registry.controllers').directive('topbar', function ($http, $location, $window, $rootScope) { +angular.module('registry.controllers').directive('topbar', function ($http, $location, $window, $rootScope, $routeParams) { return { restrict: 'E', templateUrl: '/partials/directives/topbar.html', controller:['$scope', '$rootScope', function($scope, $rootScope){ - + var currentSearch, currentTerms; + var searchResults = {}; + $scope.plugins = []; + $scope.searchText = ''; + + $scope.search = function(evt) { + if($location.url().indexOf("search") != -1){ + currentSearch = $scope.searchText.toLowerCase(); + currentTerms = currentSearch.trim().split(' '); - $scope.search = function(evt){ - var currentSearch = encodeURIComponent($scope.searchText.toLowerCase()); - $window.location.href = '/#/search?search='+currentSearch; + //todo: add a short timeout to lower number of requests + currentTerms.forEach(function(term){ + if(!searchResults[term]){ + $http.get('/_list/search/search?startkey='+JSON.stringify(term)+'&endkey='+JSON.stringify(term+'ZZZZZZZZZZZZZZ')+'&limit=25'). + success(function(data, status, headers, config){ + $scope.plugins = data.rows; + //todo: save this in session storage instead of object? + searchResults[term] = data.rows; + }). + error(function(data,status){ + console.log(data); + console.log(status); + }) + }else{ + $scope.plugins = searchResults[term]; + } + }) + }else{ + //check to see if user pressed enter or hit submit button + if ((evt.keyCode === 13) || evt.type === "submit" ){ + currentSearch = encodeURIComponent($scope.searchText.toLowerCase()); + //send to search page + $window.location.href = '/#/search?search='+currentSearch; + } + } } + $scope.getTotalPlugins = function(){ //todo: use sessionstorage or turn this into a service to cache results $http({method: 'GET', url:('/api/_all_docs?limit=0')}). @@ -26,6 +57,11 @@ angular.module('registry.controllers').directive('topbar', function ($http, $loc }; $scope.getTotalPlugins(); + + if($routeParams.search){ + $scope.searchText = $routeParams.search; + $scope.search(); + } }], link: function(scope, element, attrs, controller){ } http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/074012f8/attachments/js/services.js ---------------------------------------------------------------------- diff --git a/attachments/js/services.js b/attachments/js/services.js index 2ad33f7..b7cea8c 100644 --- a/attachments/js/services.js +++ b/attachments/js/services.js @@ -30,7 +30,7 @@ service.factory('Downloads', function($http, $window, $q) { return 0; }); //$window.sessionStorage.setItem("Downloads", JSON.stringify(downloads)); - return downloads.arrData; + return downloads; }); } return promise; http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/074012f8/attachments/partials/directives/pluginlist.html ---------------------------------------------------------------------- diff --git a/attachments/partials/directives/pluginlist.html b/attachments/partials/directives/pluginlist.html new file mode 100644 index 0000000..7cfa7a0 --- /dev/null +++ b/attachments/partials/directives/pluginlist.html @@ -0,0 +1,25 @@ +<div ng-show="plugins.length > 0"> + <div class="row pluginHeader"> + <div class="column-9--hand column-8--lap"> + <h3>Plugin ID & description</h3> + </div> + <div class="column-3--hand column-2--lap center"> + <h3>Version</h3> + </div> + <div class="column-2--hand center invisible--hand visible--lap"> + <h3>Downloads</h3> + </div> + </div> + <div ng-repeat="plugin in plugins" class="row pluginItem"> + <div class="column-9--hand column-8--lap"> + <div><a ng-href="#/package/{{plugin.key}}">{{plugin.key}}</a></div> + <div>{{((plugin.value.description)||(plugin.doc.description))}}</div> + </div> + <div class="column-3--hand column-2--lap center"> + <div class="">{{((plugin.value['dist-tags'].latest)||(plugin.doc['dist-tags'].latest))}}</div> + </div> + <div class="column-2--hand invisible--hand visible--lap center"> + <div class="">{{downloads[plugin.key]}}</div> + </div> + </div> +</div> http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/074012f8/attachments/partials/directives/topbar.html ---------------------------------------------------------------------- diff --git a/attachments/partials/directives/topbar.html b/attachments/partials/directives/topbar.html index 8609d9a..ee5fa8e 100644 --- a/attachments/partials/directives/topbar.html +++ b/attachments/partials/directives/topbar.html @@ -1,8 +1,8 @@ <div class="row center topbar-row"> <div class="column-12--hand column-5--lap"> - <form ng-submit="search()"> + <form ng-submit="search($event)"> <div class="row center"> - <input id="search-text" type="search" ng-model="searchText" class="column-8--hand topbar-search" placeholder="Find a plugin..." /> + <input id="search-text" type="search" ng-model="searchText" class="column-8--hand topbar-search" placeholder="Find a plugin..." ng-keyup="search($event)"/> <input type="submit" id="submit" value="" class="column-1--hand topbar-button"/> </div> </form> http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/074012f8/attachments/partials/views/packageDetails.html ---------------------------------------------------------------------- diff --git a/attachments/partials/views/packageDetails.html b/attachments/partials/views/packageDetails.html index 36d0d57..19f97a3 100644 --- a/attachments/partials/views/packageDetails.html +++ b/attachments/partials/views/packageDetails.html @@ -1,33 +1,49 @@ -<div class="package-label">Plugin ID</div> -<div class="package-title">{{packageID}}</div> -<div class="spacer"></div> - -<div ng-show="description"> - <div class="package-label">Description</div> - <div class="package-title">{{description}}</div> - <div class="spacer"></div> -</div> +<div class="viewContainer"> + <div class="row toprow"> + <div class="package-label column-8--hand">Plugin ID</div> + <div class="column-4--hand right"> + <select ng-model="currentVersion" ng-options="key as key for (key, value) in versions"> + <option value="{{currentVersion}}">{{currentVersion}}</option> + </select> + </div> -<div> - <select ng-model="currentVersion" ng-options="key as key for (key, value) in versions"> - <option value="{{currentVersion}}">{{currentVersion}}</option> - </select> -</div> + </div> + <div class="row"> + <div class="package-title column-12--hand">{{packageID}}</div> + </div> + <div ng-show="description" class="space"> + <div class="row"> + <div class="package-label column-12--hand">Description</div> + </div> + <div class="row"> + <div class="package-title column-12--hand">{{description}}</div> + </div> + </div> -<div ng-show="repo"> - <div class="package-label">Repository</div> - <div class="package-title"><a href={{repo}}>{{repo}}</a></div> - <div class="spacer"></div> -</div> -<div ng-show="issue"> - <div class="package-label">Issue tracker</div> - <div class="package-title"><a href={{issue}}>{{issue}}</a></div> - <div class="spacer"></div> -</div> -<div ng-show="readme"> - <div class="package-readme" ng-bind-html="readme"></div> + <div ng-show="repo" class="space"> + <div class="row"> + <div class="package-label column-12--hand">Repository</div> + </div> + <div class="row"> + <div class="column-12--hand"><a href={{repo}}>{{repo}}</a></div> + </div> + </div> + + <div ng-show="issue" class="space"> + <div class="row"> + <div class="package-label column-12--hand">Issue tracker</div> + </div> + <div class="row"> + <div class="column-12--hand"><a href={{issue}}>{{issue}}</a></div> + </div> + </div> + + <div ng-show="readme" class="readme"> + <div class="package-readme">Read Me</div> + <div class="" ng-bind-html="readme"></div> + </div> </div> http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/074012f8/attachments/partials/views/search.html ---------------------------------------------------------------------- diff --git a/attachments/partials/views/search.html b/attachments/partials/views/search.html index 1f977b2..d2ba32f 100644 --- a/attachments/partials/views/search.html +++ b/attachments/partials/views/search.html @@ -1,63 +1,19 @@ -<div class=""> - <div class=""> - <div class=""> - <a href="/#/viewAll">Browse all {{totalPlugins}} plugins</a> - </div> - </div> - <div class=""> - <div class=""> - <input id="search-text" type="search" ng-model="searchText" placeholder="Find a plugin..." ng-change="searchPlugins()" /> - </div> - </div> - <div class=""> - <div class=""> - <ng-pluralize count="searchResults.length" - when="{'0': 'No plugins found.', - 'one': '1 plugin found.', - 'other': '{} plugins found.'}"> - </ng-pluralize> - </div> - </div> - <div class=""> - <div class=""> - <a href="#Filter">Filter by Platform:</a> All - </div> - </div> - <div ng-repeat="plugin in plugins"> - <div class="left"> - <div><a ng-href="#/package/{{plugin.key}}">{{plugin.key}}</a></div> - <div>{{plugin.value.description}}</div> - </div> - <div class="right"> - <div class="left">{{plugin.value['dist-tags'].latest}}</div> - <div class="right">count</div> - </div> - <div style="clear:both"></div> - <div class="lightline"></div> - </div> - <div ng-show="searchResults.length > 0"> - <div class="row"> - <div class="column-9--hand offset-1--hand"> - <h3>Plugin Name and Description</h3> - </div> - <div class="column-1--hand"> - <h3>Version</h3> - </div> - <div class="column-1--hand"> - <h3>Downloads</h3> - </div> - </div> - <div class="row" ng-repeat="result in searchResults"> - <div class="column-9--hand offset-1--hand"> - <a href="/#/package/{{result.package_id}}"><h4>{{result.name}}</h4></a> - <h5>{{result.description}}</h5> - </div> - <div class="column-1--hand"> - <h3>{{result.version}}</h3> - </div> - <div class="column-1--hand"> - <h3>{{result.downloads}}</h3> - </div> +<topbar></topbar> +<div class="searchContainer"> + <div class="row"> + <div class="column-12--hand found"> + <ng-pluralize count="plugins.length" + when="{'0': 'No plugins found', + '1': '1 plugin found', + 'other': '{{plugins.length}} plugins found'}"> + </ng-pluralize> </div> </div> + +<!--<div class="row"> + <a href="">Filter by Platform:</a> All + </div>--> + + <pluginlist></pluginlist> </div> + http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/074012f8/attachments/partials/views/viewAll.html ---------------------------------------------------------------------- diff --git a/attachments/partials/views/viewAll.html b/attachments/partials/views/viewAll.html index 6471fb3..8e7e654 100644 --- a/attachments/partials/views/viewAll.html +++ b/attachments/partials/views/viewAll.html @@ -1,25 +1,4 @@ -<div> - <div id="pluginList"> - <div id="listHeader"> - <div class="listHeaderItem left">Plugin ID and Description</div> - <div class="right"> - <div class="listHeaderItem left">Version</div> - <div class="listHeaderItem right">Downloads</div> - </div> - <div style="clear:both"></div> - </div> - <div class="darkline"></div> - <div ng-repeat="plugin in plugins"> - <div class="left"> - <div><a ng-href="#/package/{{plugin.id}}">{{plugin.id}}</a></div> - <div>{{plugin.doc.description}}</div> - </div> - <div class="right"> - <div class="left">{{plugin.doc['dist-tags'].latest}}</div> - <div class="right">{{downloads[plugin.id]}}</div> - </div> - <div style="clear:both"></div> - <div class="lightline"></div> - </div> - </div> +<topbar></topbar> +<div class="viewContainer"> + <pluginlist></pluginlist> </div>
