Added haste to version control
This commit is contained in:
		
							
								
								
									
										25
									
								
								haste
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										25
									
								
								haste
									
									
									
									
									
										Executable file
									
								
							@@ -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']}"
 | 
				
			||||||
@@ -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
 | 
					// build the store from the config on-demand - so that we don't load it
 | 
				
			||||||
// for statics
 | 
					// for statics
 | 
				
			||||||
var preferredStore = function() {
 | 
					var preferredStore = function() {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user