[build][s]: build again.

This commit is contained in:
Rufus Pollock
2013-02-08 13:31:49 +00:00
parent 723d128d13
commit 72bcedf419
2 changed files with 45 additions and 18 deletions

View File

@@ -4,6 +4,7 @@ this.recline.Model = this.recline.Model || {};
(function(my) { (function(my) {
// use either jQuery or Underscore Deferred depending on what is available
var Deferred = _.isUndefined(this.jQuery) ? _.Deferred : jQuery.Deferred; var Deferred = _.isUndefined(this.jQuery) ? _.Deferred : jQuery.Deferred;
// ## <a id="dataset">Dataset</a> // ## <a id="dataset">Dataset</a>
@@ -596,6 +597,9 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
(function(my) { (function(my) {
my.__type__ = 'memory'; my.__type__ = 'memory';
// private data - use either jQuery or Underscore Deferred depending on what is available
var Deferred = _.isUndefined(this.jQuery) ? _.Deferred : jQuery.Deferred;
// ## Data Wrapper // ## Data Wrapper
// //
// Turn a simple array of JS objects into a mini data-store with // Turn a simple array of JS objects into a mini data-store with
@@ -639,7 +643,7 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
this.save = function(changes, dataset) { this.save = function(changes, dataset) {
var self = this; var self = this;
var dfd = new _.Deferred(); var dfd = new Deferred();
// TODO _.each(changes.creates) { ... } // TODO _.each(changes.creates) { ... }
_.each(changes.updates, function(record) { _.each(changes.updates, function(record) {
self.update(record); self.update(record);
@@ -652,7 +656,7 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
}, },
this.query = function(queryObj) { this.query = function(queryObj) {
var dfd = new _.Deferred(); var dfd = new Deferred();
var numRows = queryObj.size || this.records.length; var numRows = queryObj.size || this.records.length;
var start = queryObj.from || 0; var start = queryObj.from || 0;
var results = this.records; var results = this.records;
@@ -820,7 +824,7 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
}; };
this.transform = function(editFunc) { this.transform = function(editFunc) {
var dfd = new _.Deferred(); var dfd = new Deferred();
// TODO: should we clone before mapping? Do not see the point atm. // TODO: should we clone before mapping? Do not see the point atm.
self.records = _.map(self.records, editFunc); self.records = _.map(self.records, editFunc);
// now deal with deletes (i.e. nulls) // now deal with deletes (i.e. nulls)

53
dist/recline.js vendored
View File

@@ -27,6 +27,9 @@ this.recline.Backend.Ckan = this.recline.Backend.Ckan || {};
my.__type__ = 'ckan'; my.__type__ = 'ckan';
// private - use either jQuery or Underscore Deferred depending on what is available
var Deferred = _.isUndefined(this.jQuery) ? _.Deferred : jQuery.Deferred;
// Default CKAN API endpoint used for requests (you can change this but it will affect every request!) // Default CKAN API endpoint used for requests (you can change this but it will affect every request!)
// //
// DEPRECATION: this will be removed in v0.7. Please set endpoint attribute on dataset instead // DEPRECATION: this will be removed in v0.7. Please set endpoint attribute on dataset instead
@@ -41,7 +44,7 @@ this.recline.Backend.Ckan = this.recline.Backend.Ckan || {};
dataset.id = out.resource_id; dataset.id = out.resource_id;
var wrapper = my.DataStore(out.endpoint); var wrapper = my.DataStore(out.endpoint);
} }
var dfd = new _.Deferred(); var dfd = new Deferred();
var jqxhr = wrapper.search({resource_id: dataset.id, limit: 0}); var jqxhr = wrapper.search({resource_id: dataset.id, limit: 0});
jqxhr.done(function(results) { jqxhr.done(function(results) {
// map ckan types to our usual types ... // map ckan types to our usual types ...
@@ -84,7 +87,7 @@ this.recline.Backend.Ckan = this.recline.Backend.Ckan || {};
var wrapper = my.DataStore(out.endpoint); var wrapper = my.DataStore(out.endpoint);
} }
var actualQuery = my._normalizeQuery(queryObj, dataset); var actualQuery = my._normalizeQuery(queryObj, dataset);
var dfd = new _.Deferred(); var dfd = new Deferred();
var jqxhr = wrapper.search(actualQuery); var jqxhr = wrapper.search(actualQuery);
jqxhr.done(function(results) { jqxhr.done(function(results) {
var out = { var out = {
@@ -145,6 +148,9 @@ this.recline.Backend.CSV = this.recline.Backend.CSV || {};
(function(my) { (function(my) {
my.__type__ = 'csv'; my.__type__ = 'csv';
// use either jQuery or Underscore Deferred depending on what is available
var Deferred = _.isUndefined(this.jQuery) ? _.Deferred : jQuery.Deferred;
// ## fetch // ## fetch
// //
// fetch supports 3 options depending on the attribute provided on the dataset argument // fetch supports 3 options depending on the attribute provided on the dataset argument
@@ -163,7 +169,7 @@ this.recline.Backend.CSV = this.recline.Backend.CSV || {};
// } // }
// </pre> // </pre>
my.fetch = function(dataset) { my.fetch = function(dataset) {
var dfd = new _.Deferred(); var dfd = new Deferred();
if (dataset.file) { if (dataset.file) {
var reader = new FileReader(); var reader = new FileReader();
var encoding = dataset.encoding || 'UTF-8'; var encoding = dataset.encoding || 'UTF-8';
@@ -438,6 +444,10 @@ this.recline.Backend.DataProxy = this.recline.Backend.DataProxy || {};
// Needed because use JSONP so do not receive e.g. 500 errors // Needed because use JSONP so do not receive e.g. 500 errors
my.timeout = 5000; my.timeout = 5000;
// use either jQuery or Underscore Deferred depending on what is available
var Deferred = _.isUndefined(this.jQuery) ? _.Deferred : jQuery.Deferred;
// ## load // ## load
// //
// Load data from a URL via the [DataProxy](http://github.com/okfn/dataproxy). // Load data from a URL via the [DataProxy](http://github.com/okfn/dataproxy).
@@ -454,7 +464,7 @@ this.recline.Backend.DataProxy = this.recline.Backend.DataProxy || {};
data: data, data: data,
dataType: 'jsonp' dataType: 'jsonp'
}); });
var dfd = new _.Deferred(); var dfd = new Deferred();
_wrapInTimeout(jqxhr).done(function(results) { _wrapInTimeout(jqxhr).done(function(results) {
if (results.error) { if (results.error) {
dfd.reject(results.error); dfd.reject(results.error);
@@ -478,7 +488,7 @@ this.recline.Backend.DataProxy = this.recline.Backend.DataProxy || {};
// Many of backends use JSONP and so will not get error messages and this is // Many of backends use JSONP and so will not get error messages and this is
// a crude way to catch those errors. // a crude way to catch those errors.
var _wrapInTimeout = function(ourFunction) { var _wrapInTimeout = function(ourFunction) {
var dfd = new _.Deferred(); var dfd = new Deferred();
var timer = setTimeout(function() { var timer = setTimeout(function() {
dfd.reject({ dfd.reject({
message: 'Request Error: Backend did not respond after ' + (my.timeout / 1000) + ' seconds' message: 'Request Error: Backend did not respond after ' + (my.timeout / 1000) + ' seconds'
@@ -504,6 +514,9 @@ this.recline.Backend.ElasticSearch = this.recline.Backend.ElasticSearch || {};
(function($, my) { (function($, my) {
my.__type__ = 'elasticsearch'; my.__type__ = 'elasticsearch';
// use either jQuery or Underscore Deferred depending on what is available
var Deferred = _.isUndefined(this.jQuery) ? _.Deferred : jQuery.Deferred;
// ## ElasticSearch Wrapper // ## ElasticSearch Wrapper
// //
// A simple JS wrapper around an [ElasticSearch](http://www.elasticsearch.org/) endpoints. // A simple JS wrapper around an [ElasticSearch](http://www.elasticsearch.org/) endpoints.
@@ -678,7 +691,7 @@ this.recline.Backend.ElasticSearch = this.recline.Backend.ElasticSearch || {};
// ### fetch // ### fetch
my.fetch = function(dataset) { my.fetch = function(dataset) {
var es = new my.Wrapper(dataset.url, my.esOptions); var es = new my.Wrapper(dataset.url, my.esOptions);
var dfd = new _.Deferred(); var dfd = new Deferred();
es.mapping().done(function(schema) { es.mapping().done(function(schema) {
if (!schema){ if (!schema){
@@ -706,7 +719,7 @@ this.recline.Backend.ElasticSearch = this.recline.Backend.ElasticSearch || {};
my.save = function(changes, dataset) { my.save = function(changes, dataset) {
var es = new my.Wrapper(dataset.url, my.esOptions); var es = new my.Wrapper(dataset.url, my.esOptions);
if (changes.creates.length + changes.updates.length + changes.deletes.length > 1) { if (changes.creates.length + changes.updates.length + changes.deletes.length > 1) {
var dfd = new _.Deferred(); var dfd = new Deferred();
msg = 'Saving more than one item at a time not yet supported'; msg = 'Saving more than one item at a time not yet supported';
alert(msg); alert(msg);
dfd.reject(msg); dfd.reject(msg);
@@ -724,7 +737,7 @@ this.recline.Backend.ElasticSearch = this.recline.Backend.ElasticSearch || {};
// ### query // ### query
my.query = function(queryObj, dataset) { my.query = function(queryObj, dataset) {
var dfd = new _.Deferred(); var dfd = new Deferred();
var es = new my.Wrapper(dataset.url, my.esOptions); var es = new my.Wrapper(dataset.url, my.esOptions);
var jqxhr = es.query(queryObj); var jqxhr = es.query(queryObj);
jqxhr.done(function(results) { jqxhr.done(function(results) {
@@ -786,6 +799,9 @@ this.recline.Backend.GDocs = this.recline.Backend.GDocs || {};
(function(my) { (function(my) {
my.__type__ = 'gdocs'; my.__type__ = 'gdocs';
// use either jQuery or Underscore Deferred depending on what is available
var Deferred = _.isUndefined(this.jQuery) ? _.Deferred : jQuery.Deferred;
// ## Google spreadsheet backend // ## Google spreadsheet backend
// //
// Fetch data from a Google Docs spreadsheet. // Fetch data from a Google Docs spreadsheet.
@@ -810,13 +826,13 @@ this.recline.Backend.GDocs = this.recline.Backend.GDocs || {};
// * fields: array of Field objects // * fields: array of Field objects
// * records: array of objects for each row // * records: array of objects for each row
my.fetch = function(dataset) { my.fetch = function(dataset) {
var dfd = new _.Deferred(); var dfd = new Deferred();
var urls = my.getGDocsAPIUrls(dataset.url); var urls = my.getGDocsAPIUrls(dataset.url);
// TODO cover it with tests // TODO cover it with tests
// get the spreadsheet title // get the spreadsheet title
(function () { (function () {
var titleDfd = new _.Deferred(); var titleDfd = new Deferred();
jQuery.getJSON(urls.spreadsheet, function (d) { jQuery.getJSON(urls.spreadsheet, function (d) {
titleDfd.resolve({ titleDfd.resolve({
@@ -950,6 +966,9 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
(function(my) { (function(my) {
my.__type__ = 'memory'; my.__type__ = 'memory';
// private data - use either jQuery or Underscore Deferred depending on what is available
var Deferred = _.isUndefined(this.jQuery) ? _.Deferred : jQuery.Deferred;
// ## Data Wrapper // ## Data Wrapper
// //
// Turn a simple array of JS objects into a mini data-store with // Turn a simple array of JS objects into a mini data-store with
@@ -993,7 +1012,7 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
this.save = function(changes, dataset) { this.save = function(changes, dataset) {
var self = this; var self = this;
var dfd = new _.Deferred(); var dfd = new Deferred();
// TODO _.each(changes.creates) { ... } // TODO _.each(changes.creates) { ... }
_.each(changes.updates, function(record) { _.each(changes.updates, function(record) {
self.update(record); self.update(record);
@@ -1006,7 +1025,7 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
}, },
this.query = function(queryObj) { this.query = function(queryObj) {
var dfd = new _.Deferred(); var dfd = new Deferred();
var numRows = queryObj.size || this.records.length; var numRows = queryObj.size || this.records.length;
var start = queryObj.from || 0; var start = queryObj.from || 0;
var results = this.records; var results = this.records;
@@ -1174,7 +1193,7 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
}; };
this.transform = function(editFunc) { this.transform = function(editFunc) {
var dfd = new _.Deferred(); var dfd = new Deferred();
// TODO: should we clone before mapping? Do not see the point atm. // TODO: should we clone before mapping? Do not see the point atm.
self.records = _.map(self.records, editFunc); self.records = _.map(self.records, editFunc);
// now deal with deletes (i.e. nulls) // now deal with deletes (i.e. nulls)
@@ -1194,6 +1213,9 @@ this.recline.Backend.Solr = this.recline.Backend.Solr || {};
(function($, my) { (function($, my) {
my.__type__ = 'solr'; my.__type__ = 'solr';
// use either jQuery or Underscore Deferred depending on what is available
var Deferred = _.isUndefined(this.jQuery) ? _.Deferred : jQuery.Deferred;
// ### fetch // ### fetch
// //
// dataset must have a solr or url attribute pointing to solr endpoint // dataset must have a solr or url attribute pointing to solr endpoint
@@ -1207,7 +1229,7 @@ this.recline.Backend.Solr = this.recline.Backend.Solr || {};
dataType: 'jsonp', dataType: 'jsonp',
jsonp: 'json.wrf' jsonp: 'json.wrf'
}); });
var dfd = new _.Deferred(); var dfd = new Deferred();
jqxhr.done(function(results) { jqxhr.done(function(results) {
// if we get 0 results we cannot get fields // if we get 0 results we cannot get fields
var fields = [] var fields = []
@@ -1240,7 +1262,7 @@ this.recline.Backend.Solr = this.recline.Backend.Solr || {};
dataType: 'jsonp', dataType: 'jsonp',
jsonp: 'json.wrf' jsonp: 'json.wrf'
}); });
var dfd = new _.Deferred(); var dfd = new Deferred();
jqxhr.done(function(results) { jqxhr.done(function(results) {
var out = { var out = {
total: results.response.numFound, total: results.response.numFound,
@@ -1391,6 +1413,7 @@ this.recline.Model = this.recline.Model || {};
(function(my) { (function(my) {
// use either jQuery or Underscore Deferred depending on what is available
var Deferred = _.isUndefined(this.jQuery) ? _.Deferred : jQuery.Deferred; var Deferred = _.isUndefined(this.jQuery) ? _.Deferred : jQuery.Deferred;
// ## <a id="dataset">Dataset</a> // ## <a id="dataset">Dataset</a>