144 lines
4.6 KiB
HTML
144 lines
4.6 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>CouchDB Data Import/Export</title>
|
|
<link rel="stylesheet" href="style/reset.css" media="screen">
|
|
<link rel="stylesheet" href="style/demo.css" media="screen">
|
|
<link rel="stylesheet" href="style/css3buttons.css" media="screen">
|
|
<script type="text/javascript" src="script/jquery-1.5.min.js"></script>
|
|
<script type="text/javascript" src="script/jquery.mustache.js"></script>
|
|
<script type="text/javascript">
|
|
$(function() {
|
|
|
|
|
|
var baseURL = "_rewrite/",
|
|
vhost = false;
|
|
|
|
var path = document.location.pathname;
|
|
if ( path.indexOf( "_design" ) == -1 ) {
|
|
// in a vhost
|
|
vhost = true;
|
|
baseURL = "";
|
|
} else if ( path.substr(path.length - 1, path.length) == "/" ) {
|
|
baseURL = "";
|
|
}
|
|
|
|
/** uses $.mustache to render a template out to a target DOM
|
|
* template == camelcase ID (minus the word Template) of the DOM object containg your mustache template
|
|
* target == ID of the DOM node you wish to render the template into
|
|
* data == data object to pass into the mustache template when rendering
|
|
*/
|
|
function render( template, target, data ) {
|
|
if ( !data ) var data = {};
|
|
$( "#" + target ).html( $.mustache( $( "#" + template + "Template" ).text(), data ) );
|
|
}
|
|
|
|
function formatDiskSize(bytes) {
|
|
return (parseFloat(bytes)/1024/1024).toString().substr(0,4) + "MB"
|
|
}
|
|
|
|
function gotDb( dbInfo ) {
|
|
|
|
$.extend(dbInfo, {
|
|
"host": window.location.host,
|
|
"disk_size": formatDiskSize(dbInfo.disk_size)
|
|
});
|
|
|
|
if( vhost ) dbInfo.db_name = 'db';
|
|
|
|
render( 'db', 'stats', dbInfo );
|
|
render( 'actions', 'actions', dbInfo );
|
|
render( 'bulk', 'bulk', dbInfo );
|
|
|
|
}
|
|
|
|
$.getJSON( baseURL + 'db', gotDb );
|
|
|
|
$( '.csv' ).live('click', ( function( e ) {
|
|
|
|
$(this).html("<span class='loading icon'></span>Generating CSV...");
|
|
|
|
function gotHeaders( headers ) {
|
|
$('.csv').html("<span class='downarrow icon'></span>Download CSV");
|
|
window.location.href = baseURL + 'csv?headers=' + headers;
|
|
}
|
|
|
|
$.get( baseURL + 'headers', gotHeaders );
|
|
|
|
e.preventDefault();
|
|
|
|
}))
|
|
|
|
})
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<header>
|
|
<h1 id="title">CouchDB Data Import/Export</h1>
|
|
</header>
|
|
|
|
<div id="main">
|
|
<section class="odd">
|
|
|
|
<div id="actions"></div>
|
|
|
|
<p>
|
|
<div id="stats"></div>
|
|
</p>
|
|
|
|
<h3>Uploading</h3>
|
|
<p>You can bulk upload an array of JSON documents to a Couch via HTTP POST. Make sure that they are formatted one document per line:</p>
|
|
<p>
|
|
<pre><code> {
|
|
"docs": [
|
|
{"name": "barry", "type": "human"},
|
|
{"name": "carl", "type": "human"},
|
|
{"name": "ethel", "type": "robot"}
|
|
]
|
|
}</code></pre>
|
|
</p>
|
|
<p>POST to the this URL:</p>
|
|
<pre class="code" id="bulk"></pre>
|
|
</section>
|
|
</div>
|
|
|
|
<footer>
|
|
<a href='https://github.com/maxogden/removalist'>Fork this project on Github</a>. The <a href="http://github.com/michenriksen/css3buttons">pretty CSS3 Buttons</a> were created by <a href="http://michaelhenriksen.dk" title="Website of Michael Henriksen">Michael Henriksen</a>
|
|
</footer>
|
|
</div>
|
|
|
|
<script type='text/mustache' id="dbTemplate">
|
|
<div id="database" class="single_database">
|
|
<div class="group" id="current-head-database">
|
|
<table width="100%" cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr class="database_oneline action">
|
|
<td class="date">
|
|
<nobr>db</nobr>
|
|
</td>
|
|
<td class="message">
|
|
<code><a href="http://{{host}}/{{db_name}}">http://{{host}}/<strong>{{db_name}}</strong></a> </code>
|
|
</td>
|
|
<td class="database">
|
|
size {{disk_size}}
|
|
</td>
|
|
<td class="tree">
|
|
docs <a href="http://{{host}}/{{db_name}}/_all_docs?include_docs=true" hotkey="t">{{doc_count}}</a>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</script>
|
|
|
|
<script type='text/mustache' id="actionsTemplate">
|
|
<a href="javascript:void(false)" class="primary button csv"><span class="downarrow icon"></span>Download CSV</a>
|
|
</script>
|
|
|
|
<script type='text/mustache' id="bulkTemplate"> http://{{host}}/{{db_name}}/_bulk_docs</script>
|
|
|
|
</body>
|
|
</html> |