Plugin admin fixes

This commit is contained in:
Egil Moeller 2012-04-17 22:18:43 +02:00
parent 6f774bc6a5
commit 7ab7ee9f5e
3 changed files with 64 additions and 34 deletions

View file

@ -55,7 +55,7 @@ exports.install = function(plugin_name, cb) {
);
};
exports.search = function(pattern, cb) {
exports.search = function(query, cb) {
withNpm(
function (cb) {
registry.get(
@ -63,11 +63,18 @@ exports.search = function(pattern, cb) {
function (er, data) {
if (er) return cb(er);
var res = {};
var i = 0;
for (key in data) {
if (key.indexOf(plugins.prefix) == 0 && key.indexOf(pattern) != -1)
res[key] = data[key];
if (/* && key.indexOf(plugins.prefix) == 0 */
key.indexOf(query.pattern) != -1) {
i++;
if (i > query.offset
&& i <= query.offset + query.limit) {
res[key] = data[key];
}
}
}
cb(null, {results:res});
cb(null, {results:res, query: query, total:i});
}
);
},