diff --git a/demos/search/demo.search.app.js b/demos/search/demo.search.app.js index 72b5937a..49f5f9b9 100644 --- a/demos/search/demo.search.app.js +++ b/demos/search/demo.search.app.js @@ -207,32 +207,6 @@ var templates = { data: data }); }, - 'http://openspending.org/api/search': function(record) { - record['time'] = record['time.label_facet'] - var template = '
\ -

\ - {{record.dataset}} {{record.time}} \ - – {{amount_formatted}} \ -

\ - \ -
\ - '; - var data = []; - _.each(_.keys(record), function(key) { - if (key !='_id' && key != 'id') { - data.push({ key: key, value: record[key] }); - } - }); - return Mustache.render(template, { - record: record, - amount_formatted: formatAmount(record['amount']), - data: data - }); - }, 'https://docs.google.com/spreadsheet/ccc?key=0Aon3JiuouxLUdExXSTl2Y01xZEszOTBFZjVzcGtzVVE': function(record) { var template = '
\

\ diff --git a/demos/search/index.html b/demos/search/index.html index e19ada5b..28d3bb6a 100644 --- a/demos/search/index.html +++ b/demos/search/index.html @@ -86,7 +86,7 @@ ul.facet-items {

This demo shows how Recline can be used to build a search app. It includes faceting as well as search. You can find the source javascript here (plus prettified version of source for readability) – please feel free to reuse!

-

The default setup uses local example data but you can also connect directly to any other backend supported by Recline, for example SOLR, ElasticSearch or even a google docs spreadsheet. As an example: here's an example running against the SOLR-style OpenSpending API and here's an example running against a GDocs spreadsheet (Oil spills in the Niger Delta).

+

The default setup uses local example data but you can also connect directly to any other backend supported by Recline, for example SOLR, ElasticSearch or even a google docs spreadsheet. Here's an example running against a GDocs spreadsheet (Oil spills in the Niger Delta).


diff --git a/src/backend.solr.js b/src/backend.solr.js deleted file mode 100644 index 36e465f0..00000000 --- a/src/backend.solr.js +++ /dev/null @@ -1,68 +0,0 @@ -this.recline = this.recline || {}; -this.recline.Backend = this.recline.Backend || {}; -this.recline.Backend.Solr = this.recline.Backend.Solr || {}; - -(function($, my) { - my.__type__ = 'solr'; - - // use either jQuery or Underscore Deferred depending on what is available - var Deferred = _.isUndefined(this.jQuery) ? _.Deferred : jQuery.Deferred; - - // ### fetch - // - // dataset must have a solr or url attribute pointing to solr endpoint - my.fetch = function(dataset) { - var jqxhr = $.ajax({ - url: dataset.solr || dataset.url, - data: { - rows: 1, - wt: 'json' - }, - dataType: 'jsonp', - jsonp: 'json.wrf' - }); - var dfd = new Deferred(); - jqxhr.done(function(results) { - // if we get 0 results we cannot get fields - var fields = [] - if (results.response.numFound > 0) { - fields = _.map(_.keys(results.response.docs[0]), function(fieldName) { - return { id: fieldName }; - }); - } - var out = { - fields: fields, - useMemoryStore: false - }; - dfd.resolve(out); - }); - return dfd.promise(); - } - - // TODO - much work on proper query support is needed!! - my.query = function(queryObj, dataset) { - var q = queryObj.q || '*:*'; - var data = { - q: q, - rows: queryObj.size, - start: queryObj.from, - wt: 'json' - }; - var jqxhr = $.ajax({ - url: dataset.solr || dataset.url, - data: data, - dataType: 'jsonp', - jsonp: 'json.wrf' - }); - var dfd = new Deferred(); - jqxhr.done(function(results) { - var out = { - total: results.response.numFound, - hits: results.response.docs - }; - dfd.resolve(out); - }); - return dfd.promise(); - }; - -}(jQuery, this.recline.Backend.Solr)); diff --git a/test/backend.solr.test.js b/test/backend.solr.test.js deleted file mode 100644 index 2b7ec65a..00000000 --- a/test/backend.solr.test.js +++ /dev/null @@ -1,85 +0,0 @@ -(function ($) { -module("Backend SOLR"); - -test("fetch", function() { - var dataset = new recline.Model.Dataset({ - url: 'http://openspending.org/api/search', - backend: 'solr' - }); - // stop(); - - var stub = sinon.stub($, 'ajax', function(options) { - return { - done: function(callback) { - callback(sample_data); - return this; - }, - fail: function() { - } - }; - }); - - dataset.fetch().done(function(dataset) { - var exp = [ - "_id", - "amount", - "category.label_facet", - "dataset", - "from.label_facet", - "id", - "subcategory.label_facet", - "time.label_facet", - "to.label_facet" - ]; - deepEqual( - exp, - _.pluck(dataset.fields.toJSON(), 'id') - ); - // check we've mapped types correctly - equal(dataset.fields.get('amount').get('type'), 'string'); - - // fetch does a query so we can check for records - equal(dataset.recordCount, 10342132); - equal(dataset.records.length, 2); - equal(dataset.records.at(0).get('id'), '3e3e25d7737634127b76d5ee4a7df280987013c7'); - // start(); - }); - $.ajax.restore(); -}); - -var sample_data = { - "response": { - "docs": [ - { - "_id": "south-african-national-gov-budget-2012-13::3e3e25d7737634127b76d5ee4a7df280987013c7", - "amount": 30905738200000.0, - "category.label_facet": "General public services", - "dataset": "south-african-national-gov-budget-2012-13", - "from.label_facet": "National Treasury", - "id": "3e3e25d7737634127b76d5ee4a7df280987013c7", - "subcategory.label_facet": "Transfers of a general character between different levels of government", - "time.label_facet": "01. April 2012", - "to.label_facet": "Provincial Equitable Share" - }, - { - "_id": "south-african-national-gov-budget-2012-13::738849e28e6b3c45e5b0001e142b51479b3a3e41", - "amount": 8938807300000.0, - "category.label_facet": "General public services", - "dataset": "south-african-national-gov-budget-2012-13", - "from.label_facet": "National Treasury", - "id": "738849e28e6b3c45e5b0001e142b51479b3a3e41", - "subcategory.label_facet": "Public debt transactions", - "time.label_facet": "01. April 2012", - "to.label_facet": "State Debt Costs" - } - ], - "numFound": 10342132, - "start": 0 - }, - "responseHeader": { - "QTime": 578, - "status": 0 - } -}; - -})(this.jQuery); diff --git a/test/index.html b/test/index.html index 0bf98a62..cfa1151e 100644 --- a/test/index.html +++ b/test/index.html @@ -38,7 +38,6 @@ - @@ -47,7 +46,6 @@ -