1 Commits

Author SHA1 Message Date
John Crepezzi
2c466d069b Allow key toggling by clicking 2013-05-24 14:19:18 -04:00
7 changed files with 29 additions and 18 deletions

View File

@@ -20,6 +20,14 @@ to do things like:
which will output a URL to share containing the contents of `cat something`'s which will output a URL to share containing the contents of `cat something`'s
STDOUT. Check the README there for more details and usages. 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 ## Tested Browsers
* Firefox 8 * Firefox 8

View File

@@ -15,23 +15,12 @@ var DocumentHandler = function(options) {
DocumentHandler.defaultKeyLength = 10; DocumentHandler.defaultKeyLength = 10;
// Handle retrieving a document // Handle retrieving a document
DocumentHandler.prototype.handleGet = function(key, callback, response, skipExpire) { DocumentHandler.prototype.handleGet = function(key, response, skipExpire) {
this.store.get(key, function(ret) { this.store.get(key, function(ret) {
if (ret) { if (ret) {
winston.verbose('retrieved document', { key: key }); winston.verbose('retrieved document', { 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.writeHead(200, { 'content-type': 'application/json' });
response.end(responseData); response.end(JSON.stringify({ data: ret, key: key }));
}
} }
else { else {
winston.warn('document not found', { key: key }); winston.warn('document not found', { key: key });

View File

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

View File

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

View File

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

File diff suppressed because one or more lines are too long

View File

@@ -63,6 +63,17 @@
<pre id="box" style="display:none;" tabindex="0"><code></code></pre> <pre id="box" style="display:none;" tabindex="0"><code></code></pre>
<textarea spellcheck="false" style="display:none;"></textarea> <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> </body>
</html> </html>