Merge branch 'master' into gh-pages

This commit is contained in:
Rufus Pollock 2012-05-07 03:59:06 +01:00
commit 0b0cd75da9
8 changed files with 294 additions and 314 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.DS_Store
sandbox/*
.*.swp
_site/*

77
_layouts/default.html Normal file
View File

@ -0,0 +1,77 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>{{ page.title }} - Recline Data Explorer and Library</title>
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link rel="stylesheet" href="vendor/bootstrap/2.0.2/css/bootstrap.css" />
<link href="css/site.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="#"><strong>Recline</strong> Data Explorer and Data Library</a>
<ul class="nav pull-right">
<li><a href="app/">Data Explorer</a></li>
<li><a href="library.html">Data Library</a></li>
<li><a href="http://github.com/okfn/recline/">Code on GitHub</a></li>
</ul>
</div>
</div>
</div>
{{content}}
<section class="footer">
<div class="container">
<div class="row">
<div class="span3">
<h5>Use the Explorer</h5>
<p class="getit-btn"><a href="app/" class="btn primary">Visit the Data Explorer &raquo;</a></p>
<h5>Get the Library</h5>
<p class="getit-btn"><a href="recline.js" class="btn primary">Development Version<br />v0.3 (67k)</a></p>
</div>
<div class="span3">
<h5>Dependencies</h5>
<ul class="deps">
<li>JQuery &gt;= 1.6</li>
<li><a href="http://backbonejs.org/">Backbone</a> &gt;= 0.5.1</li>
<li>Underscore &gt;= 1.0</li>
<li>JQuery Mustache</li>
<li><a href="http://code.google.com/p/flot/">JQuery Flot &gt;= 0.7</a>: (Optional) for graphing</li>
<li><a href="http://leaflet.cloudmade.com/">Leaflet &gt;= 0.3.1</a>: (Optional) for mapping</li>
<li><a href="http://twitter.github.com/bootstrap/">Bootstrap</a> &gt;= v2.0: (Optional) for CSS/JS</li>
</ul>
</div>
<div class="span3">
<h5>Documentation</h5>
<ul>
<li><a href="#docs-using">Using it</a></li>
<li><a href="#docs-concepts">Concepts and Structure</a></li>
<li><a href="#docs-source">Source Docs (Docco)</a></li>
</ul>
</div>
<div class="span3">
<h5>Contacts</h5>
<ul>
<li><a href="http://twitter.com/maxogden">@maxogden</a></li>
<li><a href="http://twitter.com/rufuspollock">@rufuspollock</a></li>
</ul>
<a class="nav-logo" href="http://okfn.org/" title="An Open Knowledge Foundation Project">
<img src="http://assets.okfn.org/p/okfn/img/logo_28x30.png" alt="Open Knowledge Foundation logo" />
</a>
</div>
</div>
</div>
</section>
</body>
</html>

View File

@ -98,8 +98,8 @@
<div class="page-home backbone-page">
<div class="hero-unit">
<h1>Welcome to the Recline Data Explorer</h1>
<p>The Data Explorer is an application for exploring
and working with data built in pure javascript and html. In basic operation it's much like a spreadsheet - though it's
<p>Recline allows you to explore and work with data in your browser and then share with others</p>
In basic operation it's much like a spreadsheet - though it's
feature set is a little different. In particular, the Data
Explorer provides:
<ul>
@ -153,9 +153,10 @@
<label class="control-label">Type of data</label>
<div class="controls">
<select name="backend_type">
<option value="elasticsearch">ElasticSearch</option>
<option value="dataproxy">CSV or Excel</option>
<option value="csv">CSV</option>
<option vlaue="excel">Excel</option>
<option value="gdocs">Google Spreadsheet</option>
<option value="elasticsearch">ElasticSearch</option>
</select>
</div>
</div>

View File

@ -128,14 +128,17 @@ var ExplorerApp = Backbone.View.extend({
$('.modal.js-import-dialog-url').modal('hide');
var $form = $(e.target);
var source = $form.find('input[name="source"]').val();
var datasetInfo = {
id: 'my-dataset',
url: source,
webstore_url: source
};
var type = $form.find('select[name="backend_type"]').val();
var dataset = new recline.Model.Dataset({
id: 'my-dataset',
url: source,
webstore_url: source
},
type
);
if (type === 'csv' || type === 'excel') {
datasetInfo.format = type;
type = 'dataproxy';
}
var dataset = new recline.Model.Dataset(datasetInfo, type);
this.createExplorer(dataset);
},

View File

@ -110,28 +110,10 @@ a.dotted:hover {
background-color: #bc130e \9;
}
a.btn-large.showtitle[title] {
position:relative;
margin-bottom:26px;
min-width:117px;
}
a.btn-large.showtitle[title]:after {
content: attr(title);
position:absolute;
bottom:-26px;
left:0px;
font-size:12px;
height:26px;
line-height:26px;
min-width:145px;
text-align:center;
}
.btn-large .icon-large {
height:25px;
width:25px;
margin-top:-2px;
margin-left:-25px;
margin-top:-4px;
margin-right:7px;
}
.btn-large .icon-white.icon-large {
@ -177,12 +159,16 @@ a.btn-large.showtitle[title]:after {
box-shadow: none;
}
body {
padding-top: 60px;
}
section {
padding-top:20px;
}
.page-header {
margin-top:50px;
.home-page.page-header {
margin-top:-10px;
background: #2d2d2d; /* Old browsers */
background: -moz-linear-gradient(top, #2d2d2d 0%, #040404 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#2d2d2d), color-stop(100%,#040404)); /* Chrome,Safari4+ */
@ -197,31 +183,31 @@ section {
border:none;
font-family:'Open Sans', Helvetica, Arial, sans-serif;
}
.page-header a {
.home-page.page-header a {
color:#FFF;
}
.page-header a.dotted {
.home-page.page-header a.dotted {
border-color:#FFF;
}
.page-header .container {
.home-page.page-header .container {
background-image: url(images/header-screen.png);
background-repeat: no-repeat;
background-position: -3px 0px;
}
.page-header .inner {
.home-page.page-header .inner {
padding:0px 0px 30px 40px;
font-size:16px;
}
.page-header .inner ol {
.home-page.page-header .inner ol {
list-style-type:upper-latin;
font-size:20px;
font-style:italic;
}
.page-header .inner .header-button {
.home-page.page-header .inner .header-button {
display:inline-block;
}
.page-header:after {
.home-page.page-header:after {
margin-top:-14px;
}
@ -229,15 +215,6 @@ section.grey {
background-color:#f5f5f5;
}
section:after {
content: " ";
height:14px;
display:block;
background-image: url(images/zigzags.png);
background-repeat: repeat-x;
background-position: center 1px;
}
section.grey:after {
background-position: center -50px;
}
@ -245,6 +222,7 @@ section.grey:after {
.footer {
background-color:#040404;
color:#CCC;
margin-top: 30px;
}
.footer:before {
content: " ";

View File

@ -1,34 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Recline Data Explorer and Library</title>
---
layout: default
title: Home
---
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link rel="stylesheet" href="vendor/bootstrap/2.0.2/css/bootstrap.css" />
<link href="css/site.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="#"><strong>Recline</strong> Data Explorer and Library</a>
<ul class="nav pull-right">
<li><a href="app/">Data Explorer</a></li>
<li><a href="#docs">Docs</a></li>
<li><a href="http://github.com/okfn/recline/">Code on GitHub</a></li>
</ul>
</div>
</div>
</div>
<section class="page-header">
<section class="home-page page-header">
<div class="container">
<div class="row">
<div class="span8 offset4">
@ -38,13 +13,13 @@
<div class="inner">
<ol style="list-style-type:upper-latin;">
<li>Powerful data explorer built in pure javascript and html</li>
<li>Suite of data components - grid, graphing and data connectors</li>
<li>A library of data components - grid, graphing and data connectors</li>
</ol>
&mdash; All built with <a href="http://backbonejs.org/" class="dotted">Backbone</a>
</div>
<div class="inner">
<a class="btn btn-large btn-info showtitle" href="app/" title="the data explorer"><i class="icon-graph icon-white icon-large"></i>Use It</a>
<a class="btn btn-large btn-primary showtitle" href="http://github.com/okfn/recline/" title="code on GitHub"><i class="icon-arrow-down icon-white icon-large"></i>Get It</a>
<a class="btn btn-large btn-info showtitle" href="app/" title="the data explorer"><i class="icon-graph icon-white icon-large"></i>Use the Explorer</a>
<a class="btn btn-large btn-primary showtitle" href="library.html" title="the data library"><i class="icon-arrow-down icon-white icon-large"></i>Use the Library</a>
</div>
</div>
</div>
@ -99,195 +74,8 @@
</div>
</section>
<section id="docs">
<section>
<div class="container">
<div class="row">
<div class="span12">
<h2>Data Explorer Documentation</h2>
</div>
</div>
<div class="row">
<div class="span6">
<p>Usage instructions are built into the <a href="app/">Data Explorer</a>
itself so no specific additional documentation is provided on usage.</p>
<p>To embed the data explorer in another site you can use a simple iframe in
your web page:</p>
</div>
<div class="span6">
<textarea class="span6">&lt;iframe src="http://okfnlabs.org/recline/app/" width="100%"&gt;&lt;/iframe&gt;</textarea>
</div>
</div>
<div class="row">
<div class="span12">
<p>Alternatively, you can initialize the explorer yourself from javascript. To
see how to do this just take at look at the Explorer's initialization
javascript in: <a href="app/js/app.js">app.js</a>.</p>
</div>
</div>
<div class="row">
<div class="span12">
<h2>Library Documentation</h2>
<h3 id="docs-using">Examples</h3>
<p><strong>Note:</strong> A quick read through of the Concepts section will
likely be useful in understanding the details of the examples.</p>
<p><strong>Note</strong>: for all the following examples you should have
included relevant Recline dependencies.</p>
<h4>Simple in-memory dataset.</h4>
<pre>
// Some data you have
// Your data must be in the form of list of documents / rows
// Each document/row is an Object with keys and values
var data = [
{id: 0, x: 1, y: 2, z: 3, country: 'UK', label: 'first'}
, {id: 1, x: 2, y: 4, z: 6, country: 'UK', label: 'second'}
, {id: 2, x: 3, y: 6, z: 9, country: 'US', label: 'third'}
];
// Create a Dataset object from local in-memory data
// Dataset object is a Backbone model - more info on attributes in model docs below
var dataset = recline.Backend.createDataset(data);
// Now create the main explorer view (it will create other views as needed)
// DataExplorer is a Backbone View
var explorer = recline.View.DataExplorer({
model: dataset,
// you can specify any element to bind to in the dom
el: $('.data-explorer-here')
});
// Start Backbone routing (if you want routing support)
Backbone.history.start();
</pre>
<h4>Creating a Dataset Explicitly with a Backend</h4>
<pre>
// Connect to ElasticSearch index/type as our data source
// There are many other backends you can use (and you can write your own)
var backend = new recline.Backend.ElasticSearch();
// Dataset is a Backbone model so the first hash become model attributes
var dataset = recline.Model.Dataset({
id: 'my-id',
// url for source of this dataset - will be used by backend
url: 'http://localhost:9200/my-index/my-type',
// any other metadata e.g.
title: 'My Dataset Title'
},
backend
);
</pre>
</div>
</div>
<div class="row">
<div class="span12">
<h3 id="docs-concepts">Concepts and Structure</h3>
</div>
</div>
<div class="row">
<div class="span6">
<p>Recline has a simple structure layered on top of the basic Model/View
distinction inherent in Backbone.</p>
<h4>Models</h4>
<p>There are two main model objects:</p>
<ul>
<li><a href="docs/model.html#dataset">Dataset</a>: represents the dataset.
Holds dataset info and a pointer to list of data items (Documents in our
terminology) which it can load from the relevant Backend.</li>
<li><a href="docs/model.html#document">Document</a>: an individual data item
(e.g. a row from a relational database or a spreadsheet, a document from from
a document DB like CouchDB or MongoDB).</li>
</ul>
<p>Additional, related models:</p>
<ul>
<li><a href="docs/model.html#field">Field</a>: a field/column on a
dataset.</li>
<li><a href="docs/model.html#query">Query</a>: an object to encapsulate a
query to the backend (useful both for creating queries and for storing and
manipulating query state - e.g. from a query editor).</li>
<li><a href="docs/model.html#facte">Facet</a>: Object to store Facet
information, that is summary information (e.g. values and counts) about a
field obtained by some faceting method on the backend.</li>
</ul>
<p>More detail of how these work can be found in the <a
href="docs/model.html">Model source docs</a>.</p>
</div>
<div class="span6">
<h4>Backends</h4>
<p>Backends connect Dataset and Documents to data from a
specific 'Backend' data source. They provide methods for loading and saving
Datasets and individuals Documents as well as for bulk loading via a query API
and doing bulk transforms on the backend.</p>
<p>A template Base class can be found <a href="docs/backend/base.html">in the
Backend base module of the source docs</a>. It documents both the relevant
methods a Backend must have and (optionally) provides a base 'class' for
inheritance. You can also find detailed examples of backend implementations in
the source documentation below.</p>
<h4>Views</h4>
<p>Complementing the model are various Views (you can
also easily write your own). Each view holds a pointer to a Dataset:</p>
<ul>
<li>DataExplorer: the parent view which manages the overall app and sets up
sub views.</li>
<li>Grid: the data grid view.</li>
<li>Graph: a simple graphing view using <a
href="http://code.google.com/p/flot/">Flot</a>.</li>
<li>Map: a map view using <a href="http://leaflet.cloudmade.com/">Leaflet</a>.</li>
</ul>
<p>There are additional views which do not display a whole dataset but which
are useful:</p>
<ul>
<li>QueryEditor: a query editor view</li>
<li>FacetViewer: display facets</li>
</ul>
</div>
</div>
<div class="row">
<div class="span12">
<h3 id="docs-source">Source Docs (via Docco)</h3>
</div>
</div>
<div class="row">
<div class="span6">
<h4>Models and Views (Widgets)</h4>
<ul>
<li><a href="docs/model.html">Models</a></li>
<li><a href="docs/view.html">DataExplorer View (plus common view code)</a></li>
<li><a href="docs/view-grid.html">(Data) Grid View</a></li>
<li><a href="docs/view-graph.html">Graph View (based on Flot)</a></li>
<li><a href="docs/view-map.html">Map View (based on Leaflet)</a></li>
</ul>
</div>
<div class="span6">
<h4>Backends</h4>
<ul>
<li><a href="docs/backend/base.html">Backend: Base (base class providing a template for backends)</a></li>
<li><a href="docs/backend/memory.html">Backend: Memory (local data)</a></li>
<li><a href="docs/backend/elasticsearch.html">Backend: ElasticSearch</a></li>
<li><a href="docs/backend/dataproxy.html">Backend: DataProxy (CSV and XLS on the Web)</a></li>
<li><a href="docs/backend/gdocs.html">Backend: Google Docs (Spreadsheet)</a></li>
<li><a href="docs/backend/localcsv.html">Backend: Local CSV file</a></li>
</ul>
</div>
</div>
<div class="row">
<div class="span6">
<h2 id="tests">Tests</h2>
<p><a href="test/index.html">Run the tests online</a>.</p>
</div>
</div>
<div class="row">
<div class="span12">
<h2 id="history">History</h2>
@ -318,48 +106,3 @@
</div>
</section>
<section class="footer">
<div class="container">
<div class="row">
<div class="span3">
<h5>Use the Explorer</h5>
<p class="getit-btn"><a href="app/" class="btn primary">Visit the Data Explorer &raquo;</a></p>
<h5>Get the Library</h5>
<p class="getit-btn"><a href="recline.js" class="btn primary">Development Version<br />v0.3 (67k)</a></p>
</div>
<div class="span3">
<h5>Dependencies</h5>
<ul class="deps">
<li>JQuery &gt;= 1.6</li>
<li><a href="http://backbonejs.org/">Backbone</a> &gt;= 0.5.1</li>
<li>Underscore &gt;= 1.0</li>
<li>JQuery Mustache</li>
<li><a href="http://code.google.com/p/flot/">JQuery Flot &gt;= 0.7</a>: (Optional) for graphing</li>
<li><a href="http://leaflet.cloudmade.com/">Leaflet &gt;= 0.3.1</a>: (Optional) for mapping</li>
<li><a href="http://twitter.github.com/bootstrap/">Bootstrap</a> &gt;= v2.0: (Optional) for CSS/JS</li>
</ul>
</div>
<div class="span3">
<h5>Documentation</h5>
<ul>
<li><a href="#docs-using">Using it</a></li>
<li><a href="#docs-concepts">Concepts and Structure</a></li>
<li><a href="#docs-source">Source Docs (Docco)</a></li>
</ul>
</div>
<div class="span3">
<h5>Contacts</h5>
<ul>
<li><a href="http://twitter.com/maxogden">@maxogden</a></li>
<li><a href="http://twitter.com/rufuspollock">@rufuspollock</a></li>
</ul>
<a class="nav-logo" href="http://okfn.org/" title="An Open Knowledge Foundation Project">
<img src="http://assets.okfn.org/p/okfn/img/logo_28x30.png" alt="Open Knowledge Foundation logo" />
</a>
</div>
</div>
</div>
</section>
</body>
</html>

171
library.html Normal file
View File

@ -0,0 +1,171 @@
---
layout: default
title: Library - Home
---
<div class="container">
<div class="page-header">
<h1>
The Data Library
</h1>
</div>
<div class="row">
<div class="span12">
<h2 id="docs-using">Examples</h2>
<p><strong>Note:</strong> A quick read through of the Concepts section will
likely be useful in understanding the details of the examples.</p>
<p><strong>Note</strong>: for all the following examples you should have
included relevant Recline dependencies.</p>
<h4>Simple in-memory dataset.</h4>
<pre>
// Some data you have
// Your data must be in the form of list of documents / rows
// Each document/row is an Object with keys and values
var data = [
{id: 0, x: 1, y: 2, z: 3, country: 'UK', label: 'first'}
, {id: 1, x: 2, y: 4, z: 6, country: 'UK', label: 'second'}
, {id: 2, x: 3, y: 6, z: 9, country: 'US', label: 'third'}
];
// Create a Dataset object from local in-memory data
// Dataset object is a Backbone model - more info on attributes in model docs below
var dataset = recline.Backend.createDataset(data);
// Now create the main explorer view (it will create other views as needed)
// DataExplorer is a Backbone View
var explorer = recline.View.DataExplorer({
model: dataset,
// you can specify any element to bind to in the dom
el: $('.data-explorer-here')
});
// Start Backbone routing (if you want routing support)
Backbone.history.start();
</pre>
<h4>Creating a Dataset Explicitly with a Backend</h4>
<pre>
// Connect to ElasticSearch index/type as our data source
// There are many other backends you can use (and you can write your own)
var backend = new recline.Backend.ElasticSearch();
// Dataset is a Backbone model so the first hash become model attributes
var dataset = recline.Model.Dataset({
id: 'my-id',
// url for source of this dataset - will be used by backend
url: 'http://localhost:9200/my-index/my-type',
// any other metadata e.g.
title: 'My Dataset Title'
},
backend
);
</pre>
</div>
</div>
<div class="row">
<div class="span12">
<h2 id="docs-concepts">Concepts and Structure</h2>
</div>
</div>
<div class="row">
<div class="span6">
<p>Recline has a simple structure layered on top of the basic Model/View
distinction inherent in Backbone.</p>
<h4>Models</h4>
<p>There are two main model objects:</p>
<ul>
<li><a href="docs/model.html#dataset">Dataset</a>: represents the dataset.
Holds dataset info and a pointer to list of data items (Documents in our
terminology) which it can load from the relevant Backend.</li>
<li><a href="docs/model.html#document">Document</a>: an individual data item
(e.g. a row from a relational database or a spreadsheet, a document from from
a document DB like CouchDB or MongoDB).</li>
</ul>
<p>Additional, related models:</p>
<ul>
<li><a href="docs/model.html#field">Field</a>: a field/column on a
dataset.</li>
<li><a href="docs/model.html#query">Query</a>: an object to encapsulate a
query to the backend (useful both for creating queries and for storing and
manipulating query state - e.g. from a query editor).</li>
<li><a href="docs/model.html#facte">Facet</a>: Object to store Facet
information, that is summary information (e.g. values and counts) about a
field obtained by some faceting method on the backend.</li>
</ul>
<p>More detail of how these work can be found in the <a
href="docs/model.html">Model source docs</a>.</p>
</div>
<div class="span6">
<h4>Backends</h4>
<p>Backends connect Dataset and Documents to data from a
specific 'Backend' data source. They provide methods for loading and saving
Datasets and individuals Documents as well as for bulk loading via a query API
and doing bulk transforms on the backend.</p>
<p>A template Base class can be found <a href="docs/backend/base.html">in the
Backend base module of the source docs</a>. It documents both the relevant
methods a Backend must have and (optionally) provides a base 'class' for
inheritance. You can also find detailed examples of backend implementations in
the source documentation below.</p>
<h4>Views</h4>
<p>Complementing the model are various Views (you can
also easily write your own). Each view holds a pointer to a Dataset:</p>
<ul>
<li>DataExplorer: the parent view which manages the overall app and sets up
sub views.</li>
<li>Grid: the data grid view.</li>
<li>Graph: a simple graphing view using <a
href="http://code.google.com/p/flot/">Flot</a>.</li>
<li>Map: a map view using <a href="http://leaflet.cloudmade.com/">Leaflet</a>.</li>
</ul>
<p>There are additional views which do not display a whole dataset but which
are useful:</p>
<ul>
<li>QueryEditor: a query editor view</li>
<li>FacetViewer: display facets</li>
</ul>
</div>
</div>
<div class="row">
<div class="span12">
<h2 id="docs-source">Source Docs (via Docco)</h2>
</div>
</div>
<div class="row">
<div class="span6">
<h4>Models and Views (Widgets)</h4>
<ul>
<li><a href="docs/model.html">Models</a></li>
<li><a href="docs/view.html">DataExplorer View (plus common view code)</a></li>
<li><a href="docs/view-grid.html">(Data) Grid View</a></li>
<li><a href="docs/view-graph.html">Graph View (based on Flot)</a></li>
<li><a href="docs/view-map.html">Map View (based on Leaflet)</a></li>
</ul>
</div>
<div class="span6">
<h4>Backends</h4>
<ul>
<li><a href="docs/backend/base.html">Backend: Base (base class providing a template for backends)</a></li>
<li><a href="docs/backend/memory.html">Backend: Memory (local data)</a></li>
<li><a href="docs/backend/elasticsearch.html">Backend: ElasticSearch</a></li>
<li><a href="docs/backend/dataproxy.html">Backend: DataProxy (CSV and XLS on the Web)</a></li>
<li><a href="docs/backend/gdocs.html">Backend: Google Docs (Spreadsheet)</a></li>
<li><a href="docs/backend/localcsv.html">Backend: Local CSV file</a></li>
</ul>
</div>
</div>
</div>
</div> <!-- / container -->

View File

@ -301,6 +301,12 @@ my.Graph = Backbone.View.extend({
$("#flot-tooltip").remove();
var x = item.datapoint[0];
var y = item.datapoint[1];
// it's horizontal so we have to flip
if (self.state.attributes.graphType === 'bars') {
var _tmp = x;
x = y;
y = _tmp;
}
// convert back from 'index' value on x-axis (e.g. in cases where non-number values)
if (self.model.currentDocuments.models[x]) {
x = self.model.currentDocuments.models[x].get(self.state.attributes.group);