2012-04-13 11:24:57 +02:00
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8" />
|
|
|
|
<!-- Always force latest IE rendering engine (even in intranet) and Chrome Frame -->
|
|
|
|
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible" />
|
|
|
|
<title>{{ apiName }}</title>
|
|
|
|
<link href="http://fonts.googleapis.com/css?family=Droid+Sans:400,700" rel="stylesheet" type="text/css" />
|
2012-05-24 01:22:45 +02:00
|
|
|
<link href="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css" rel="stylesheet" type="text/css"></script>
|
2012-04-13 11:24:57 +02:00
|
|
|
<style type="text/css">
|
|
|
|
{{ css|raw }}
|
|
|
|
</style>
|
|
|
|
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
|
2012-05-24 01:22:45 +02:00
|
|
|
<script src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js" type="text/javascript"></script>
|
2012-04-13 11:24:57 +02:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="header">
|
2012-04-13 12:23:46 +02:00
|
|
|
<a href=""><h1>{{ apiName }}</h1></a>
|
2012-04-13 11:24:57 +02:00
|
|
|
</div>
|
|
|
|
<div class="container" id="resources_container">
|
|
|
|
<ul id="resources">
|
|
|
|
{% block content %}{% endblock %}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<p id="colophon">
|
|
|
|
Documentation auto-generated on {{ date }}
|
|
|
|
</p>
|
|
|
|
<script type="text/javascript">
|
|
|
|
$('.toggler').click(function() {
|
|
|
|
$(this).next().slideToggle('slow');
|
|
|
|
});
|
2012-05-24 01:22:45 +02:00
|
|
|
|
2012-06-28 10:37:35 +02:00
|
|
|
var toggleButtonText = function ($btn) {
|
|
|
|
if ($btn.text() === 'Default') {
|
|
|
|
$btn.text('Raw');
|
|
|
|
} else {
|
|
|
|
$btn.text('Default');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var renderRawBody = function ($container) {
|
|
|
|
var rawData, $btn;
|
|
|
|
|
|
|
|
rawData = $container.data('raw-response');
|
|
|
|
$btn = $container.parents('.pane').find('.to-raw');
|
|
|
|
|
|
|
|
$container.addClass('prettyprinted');
|
|
|
|
$container.html(rawData);
|
|
|
|
|
|
|
|
$btn.removeClass('to-raw');
|
|
|
|
$btn.addClass('to-prettify');
|
|
|
|
|
|
|
|
toggleButtonText($btn);
|
|
|
|
};
|
|
|
|
|
|
|
|
var renderPrettifiedBody = function ($container) {
|
|
|
|
var rawData, $btn;
|
|
|
|
|
|
|
|
rawData = $container.data('raw-response');
|
|
|
|
$btn = $container.parents('.pane').find('.to-prettify');
|
|
|
|
|
|
|
|
$container.removeClass('prettyprinted');
|
|
|
|
$container.html(prettifyResponse(rawData));
|
|
|
|
prettyPrint && prettyPrint();
|
|
|
|
|
|
|
|
$btn.removeClass('to-prettify');
|
|
|
|
$btn.addClass('to-raw');
|
|
|
|
|
|
|
|
toggleButtonText($btn);
|
|
|
|
};
|
|
|
|
|
2012-05-24 01:22:45 +02:00
|
|
|
$('.tabs li').click(function() {
|
|
|
|
var contentGroup = $(this).parents('.content');
|
|
|
|
|
|
|
|
$('.pane.selected', contentGroup).removeClass('selected');
|
|
|
|
$('.pane.' + $(this).data('pane'), contentGroup).addClass('selected');
|
|
|
|
|
|
|
|
$('li', $(this).parent()).removeClass('selected');
|
|
|
|
$(this).addClass('selected');
|
|
|
|
});
|
|
|
|
|
|
|
|
var prettifyResponse = function(text) {
|
|
|
|
try {
|
|
|
|
var data = typeof text === 'string' ? JSON.parse(text) : text;
|
|
|
|
text = JSON.stringify(data, undefined, ' ');
|
|
|
|
} catch (err) {
|
|
|
|
}
|
|
|
|
|
|
|
|
// HTML encode the result
|
|
|
|
return $('<div>').text(text).html();
|
|
|
|
};
|
|
|
|
|
|
|
|
var displayFinalUrl = function(xhr, method, url, container) {
|
|
|
|
container.html(method + ' ' + url);
|
|
|
|
};
|
|
|
|
|
|
|
|
var displayResponseData = function(xhr, container) {
|
2012-06-28 10:37:35 +02:00
|
|
|
var data = xhr.responseText;
|
|
|
|
|
|
|
|
container.data('raw-response', data);
|
|
|
|
|
|
|
|
if ('<' === data[0]) {
|
|
|
|
renderRawBody(container);
|
|
|
|
} else {
|
|
|
|
renderPrettifiedBody(container);
|
|
|
|
}
|
2012-05-24 01:22:45 +02:00
|
|
|
|
2012-06-28 10:37:35 +02:00
|
|
|
container.parents('.pane').find('.to-prettify').text('Raw');
|
|
|
|
container.parents('.pane').find('.to-raw').text('Raw');
|
2012-05-24 01:22:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
var displayResponseHeaders = function(xhr, container) {
|
|
|
|
var text = xhr.status + ' ' + xhr.statusText + "\n\n";
|
|
|
|
text += xhr.getAllResponseHeaders();
|
|
|
|
|
|
|
|
container.html(text);
|
|
|
|
};
|
|
|
|
|
|
|
|
var displayResponse = function(xhr, method, url, result_container) {
|
|
|
|
displayFinalUrl(xhr, method, url, $('.url', result_container));
|
|
|
|
displayResponseData(xhr, $('.response', result_container));
|
|
|
|
displayResponseHeaders(xhr, $('.headers', result_container));
|
|
|
|
|
|
|
|
result_container.show();
|
|
|
|
};
|
|
|
|
|
|
|
|
$('.pane.sandbox form').submit(function() {
|
|
|
|
var url = $(this).attr('action'),
|
|
|
|
method = $(this).attr('method'),
|
|
|
|
self = this,
|
|
|
|
params = {
|
|
|
|
_format: 'json' // default format if not overriden in the form
|
|
|
|
},
|
|
|
|
headers = {},
|
|
|
|
result_container = $('.result', $(this).parent());
|
|
|
|
|
|
|
|
// retrieve all the parameters to send
|
|
|
|
$('.parameters .tuple', $(this)).each(function() {
|
|
|
|
var key, value;
|
|
|
|
|
|
|
|
key = $('.key', $(this)).val();
|
|
|
|
value = $('.value', $(this)).val();
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
params[key] = value;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// retrieve the additional headers to send
|
|
|
|
$('.headers .tuple', $(this)).each(function() {
|
|
|
|
var key, value;
|
|
|
|
|
|
|
|
key = $('.key', $(this)).val();
|
|
|
|
value = $('.value', $(this)).val();
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
headers[key] = value;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// fix parameters in URL
|
|
|
|
for (var key in $.extend({}, params)) {
|
|
|
|
if (url.indexOf('{' + key + '}') !== -1) {
|
|
|
|
url = url.replace('{' + key + '}', params[key]);
|
|
|
|
delete params[key];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// disable all the fiels and buttons
|
|
|
|
$('input, button', $(this)).attr('disabled', 'disabled');
|
|
|
|
|
|
|
|
// and trigger the API call
|
|
|
|
$.ajax({
|
|
|
|
url: '{{ sandboxTarget }}' + url,
|
|
|
|
type: method,
|
|
|
|
data: params,
|
|
|
|
headers: headers,
|
|
|
|
complete: function(xhr) {
|
|
|
|
displayResponse(xhr, method, url, result_container);
|
|
|
|
|
|
|
|
// and enable them back
|
|
|
|
$('input, button', $(self)).removeAttr('disabled');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2012-06-28 10:37:35 +02:00
|
|
|
$('.pane.sandbox').delegate('.to-raw', 'click', function(e) {
|
|
|
|
renderRawBody($(this).parents('.pane').find('.response'));
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.pane.sandbox').delegate('.to-prettify', 'click', function(e) {
|
|
|
|
renderPrettifiedBody($(this).parents('.pane').find('.response'));
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
|
2012-07-04 16:31:06 +02:00
|
|
|
$('.pane.sandbox').delegate('.to-expand, .to-shrink', 'click', function(e) {
|
|
|
|
var $headers = $(this).parents('.result').find('.headers');
|
|
|
|
var $label = $(this).parents('.result').find('a.to-expand');
|
|
|
|
|
|
|
|
if ($headers.hasClass('to-expand')) {
|
2012-07-04 22:36:55 +02:00
|
|
|
$headers.removeClass('to-expand');
|
|
|
|
$headers.addClass('to-shrink');
|
|
|
|
$label.text('Shrink');
|
2012-07-04 16:31:06 +02:00
|
|
|
} else {
|
2012-07-04 22:36:55 +02:00
|
|
|
$headers.removeClass('to-shrink');
|
|
|
|
$headers.addClass('to-expand');
|
|
|
|
$label.text('Expand');
|
2012-07-04 16:31:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
|
2012-05-24 01:22:45 +02:00
|
|
|
$('.pane.sandbox').on('click', '.add', function() {
|
|
|
|
var html = $(this).parents('.pane').find('.tuple_template').html();
|
|
|
|
|
|
|
|
$(this).before(html);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.pane.sandbox').on('click', '.remove', function() {
|
|
|
|
$(this).parent().remove();
|
|
|
|
});
|
2012-04-13 11:24:57 +02:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|