5 Commits

Author SHA1 Message Date
John Crepezzi
467f9a53b2 Added jsonp support
Closes #47
2013-12-04 12:13:17 -05:00
John Crepezzi
7a08960414 Merge branch 'master' of github.com:seejohnrun/haste-server 2013-11-24 11:54:34 -05:00
John Crepezzi
89909747f1 Don't depend on err.message for redis errors [#49] 2013-11-24 11:54:01 -05:00
John Crepezzi
202e695e07 Remove GA from index.html on Master 2013-10-31 08:44:33 -04:00
John Crepezzi
48e8e79659 Remove support from README 2013-08-13 13:06:37 -04:00
7 changed files with 18 additions and 29 deletions

View File

@@ -20,14 +20,6 @@ to do things like:
which will output a URL to share containing the contents of `cat something`'s
STDOUT. Check the README there for more details and usages.
## Support
Please consider paying what you feel this project is worth:
<a href="https://www.stripeme.com/pay/1r2f">
<img alt="Pay" src="https://www.stripeme.com/pay.jpg" />
</a>
## Tested Browsers
* Firefox 8

View File

@@ -15,12 +15,23 @@ var DocumentHandler = function(options) {
DocumentHandler.defaultKeyLength = 10;
// Handle retrieving a document
DocumentHandler.prototype.handleGet = function(key, response, skipExpire) {
DocumentHandler.prototype.handleGet = function(key, callback, response, skipExpire) {
this.store.get(key, function(ret) {
if (ret) {
winston.verbose('retrieved document', { key: key });
response.writeHead(200, { 'content-type': 'application/json' });
response.end(JSON.stringify({ data: ret, key: key }));
var responseData = JSON.stringify({ data: ret, key: key });
if (callback) {
if (callback.match(/^[a-z0-9]+$/i)) {
response.writeHead(200, { 'content-type': 'application/javascript' });
response.end(callback + '(' + responseData + ');');
} else {
response.writeHead(400, { 'content-type': 'application/json' });
response.end(JSON.stringify({ message: 'invalid callback function name' }));
}
} else {
response.writeHead(200, { 'content-type': 'application/json' });
response.end(responseData);
}
}
else {
winston.warn('document not found', { key: key });

View File

@@ -29,7 +29,7 @@ RedisDocumentStore.connect = function(options) {
if (err) {
winston.error(
'error connecting to redis index ' + index,
{ error: err.message }
{ error: err }
);
process.exit(1);
}

View File

@@ -116,8 +116,10 @@ connect.createServer(
// get documents
app.get('/documents/:id', function(request, response, next) {
var skipExpire = !!config.documents[request.params.id];
var parsedUrl = url.parse(request.url, true);
return documentHandler.handleGet(
request.params.id,
parsedUrl.query.callback,
response,
skipExpire
);

View File

@@ -362,11 +362,6 @@ haste.prototype.configureShortcuts = function() {
///// Tab behavior in the textarea - 2 spaces per tab
$(function() {
var $key = $('#key');
$(document).click(function () {
$key.fadeToggle();
});
$('textarea').keydown(function(evt) {
if (evt.keyCode === 9) {
evt.preventDefault();

File diff suppressed because one or more lines are too long

View File

@@ -63,17 +63,6 @@
<pre id="box" style="display:none;" tabindex="0"><code></code></pre>
<textarea spellcheck="false" style="display:none;"></textarea>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-27329119-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>