diff --git a/lib/GUI/index.handlebars b/lib/GUI/index.handlebars
index 658b9f740..97afde139 100644
--- a/lib/GUI/index.handlebars
+++ b/lib/GUI/index.handlebars
@@ -18,6 +18,7 @@
npm adduser --registry {{ baseUrl }}
+
Packages:
{{#each packages}}
{{ name }} v{{ version }}
diff --git a/lib/index.js b/lib/index.js
index 7183affac..c2bf39b43 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -122,14 +122,14 @@ module.exports = function(config_hash) {
console.log(d)
})
})*/
-
+
var template = Handlebars.compile(fs.readFileSync(require.resolve('./GUI/index.handlebars'), 'utf8'));
app.get('/', can('access'), function(req, res, next) {
res.setHeader('Content-Type', 'text/html');
storage.get_local(function(err, packages) {
res.send(template({
- name: "Sinopia",
+ name: config.title || "Sinopia",
packages: packages,
baseUrl: req.protocol + '://' + req.get('host') + '/'
}));
diff --git a/lib/search.js b/lib/search.js
new file mode 100644
index 000000000..5c59b4d87
--- /dev/null
+++ b/lib/search.js
@@ -0,0 +1,35 @@
+var lunr = require('lunr')
+ , localList = require('./local-list');
+
+var Search = function() {
+ this.index = lunr(function () {
+ this.field('name', {boost: 10});
+ this.field('description');
+ this.field('author');
+ });
+
+ this.id = 0;
+
+ var packages = storage.get_local()
+ , i = packages.length;
+
+ while(i--) {
+ this.index(packages[i]);
+ }
+};
+
+Search.prototype = {
+ query: function(q) {
+ return index.search(q);
+ },
+ index: function(package) {
+ this.index.add({
+ id: ++this.id,
+ title: package.name,
+ description: package.description,
+ author: package._npmUser.name
+ });
+ }
+};
+
+module.exports = new Search();
\ No newline at end of file