From 60f412b7bcafd3292995aec66c242eb5189b50d3 Mon Sep 17 00:00:00 2001 From: John Crepezzi Date: Fri, 18 Nov 2011 18:30:31 -0500 Subject: [PATCH] Added haste to version control --- haste | 25 +++++++++++++++++++++++++ server.js | 2 -- 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100755 haste diff --git a/haste b/haste new file mode 100755 index 0000000..350ab59 --- /dev/null +++ b/haste @@ -0,0 +1,25 @@ +#! /usr/bin/env ruby + +require 'restclient' +require 'json' + +# Get the data +data = STDIN.readlines.join +data.strip! + +# if there is no data, stop +if data == '' + puts 'no input given' + exit 1 +end + +# Decide on a server +server = ENV['HASTE_SERVER'] || 'http://localhost:7777' +server.chop! if server.end_with?('/') + +# Send the data up +back = RestClient.post "#{server}/documents", data +data = JSON.parse(back) + +# Output the url +puts "#{server}/#{data['key']}" diff --git a/server.js b/server.js index d52e90f..5007711 100644 --- a/server.js +++ b/server.js @@ -26,8 +26,6 @@ if (config.logging) { } } -// TODO implement command line - // build the store from the config on-demand - so that we don't load it // for statics var preferredStore = function() {