mirror of
https://github.com/seejohnrun/haste-client.git
synced 2025-12-17 17:21:29 +00:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6532aa100 | ||
|
|
82d191fc5e | ||
|
|
2ef8f926af | ||
|
|
6430635bfa | ||
|
|
028e7c4424 | ||
|
|
b10fa4782a | ||
|
|
d8c4be9744 | ||
|
|
7913dd521d | ||
|
|
25140d99f5 | ||
|
|
6760a64957 | ||
|
|
98e72bce43 | ||
|
|
b53350c723 | ||
|
|
be8d4bc5de | ||
|
|
42bad59634 | ||
|
|
e156c031a8 |
28
README.md
28
README.md
@@ -13,6 +13,20 @@ This can be really really cool in combination with `pbcopy`, like:
|
|||||||
|
|
||||||
after which the contents of `file` will be accessible at a URL which has been copied to your pasteboard.
|
after which the contents of `file` will be accessible at a URL which has been copied to your pasteboard.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
gem install haste
|
||||||
|
```
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
Please consider paying what you think haste-client is worth:
|
||||||
|
|
||||||
|
<a href="https://www.stripeme.com/pay/1r2f">
|
||||||
|
<img alt="Pay" src="https://www.stripeme.com/pay.jpg" />
|
||||||
|
</a>
|
||||||
|
|
||||||
## Making uploading file contents easier
|
## Making uploading file contents easier
|
||||||
|
|
||||||
If you supply a valid file path as argument #1 to the client, it will be uploaded:
|
If you supply a valid file path as argument #1 to the client, it will be uploaded:
|
||||||
@@ -37,6 +51,20 @@ After which you can use `work_haste` to send hastes to that server instead.
|
|||||||
|
|
||||||
If you'd like an alternative on Windows that supports functionality similar to `pbcopy`, check out Aidan Ryan's [WinHaste](https://github.com/ajryan/WinHaste) project.
|
If you'd like an alternative on Windows that supports functionality similar to `pbcopy`, check out Aidan Ryan's [WinHaste](https://github.com/ajryan/WinHaste) project.
|
||||||
|
|
||||||
|
## Lightweight Alternative
|
||||||
|
|
||||||
|
Han Boetes has contributed a simple shell-script alternative for those not interested in installing a RubyGem:
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
haste(){ ( echo "% $@"; eval "$@" ) | curl -F "$@=<-" http://hastebin.com/documents|awk -F '"' '{print "http://hastebin.com/"$4}'}
|
||||||
|
```
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
haste `cat index.html
|
||||||
|
```
|
||||||
|
|
||||||
## Author
|
## Author
|
||||||
|
|
||||||
John Crepezzi <john.crepezzi@gmail.com>
|
John Crepezzi <john.crepezzi@gmail.com>
|
||||||
|
|||||||
12
lib/haste.rb
12
lib/haste.rb
@@ -1,5 +1,6 @@
|
|||||||
require 'json'
|
require 'json'
|
||||||
require 'net/http'
|
require 'net/http'
|
||||||
|
require 'net/https'
|
||||||
require 'uri'
|
require 'uri'
|
||||||
|
|
||||||
module Haste
|
module Haste
|
||||||
@@ -11,8 +12,9 @@ module Haste
|
|||||||
# Pull all of the data from STDIN
|
# Pull all of the data from STDIN
|
||||||
def initialize
|
def initialize
|
||||||
if STDIN.tty?
|
if STDIN.tty?
|
||||||
abort 'No input file given' unless ARGV.length == 1
|
file = ARGV.first
|
||||||
abort "#{file}: No such path" unless File.exists?(file = ARGV[0])
|
abort 'No input file given' unless file
|
||||||
|
abort "#{file}: No such path" unless File.exists?(file)
|
||||||
@input = open(file).read
|
@input = open(file).read
|
||||||
else
|
else
|
||||||
@input = STDIN.readlines.join
|
@input = STDIN.readlines.join
|
||||||
@@ -25,6 +27,10 @@ module Haste
|
|||||||
def start
|
def start
|
||||||
uri = URI.parse server
|
uri = URI.parse server
|
||||||
http = Net::HTTP.new uri.host, uri.port
|
http = Net::HTTP.new uri.host, uri.port
|
||||||
|
if uri.scheme =~ /^https/
|
||||||
|
http.use_ssl = true
|
||||||
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||||
|
end
|
||||||
response = http.post '/documents', @input
|
response = http.post '/documents', @input
|
||||||
if response.is_a?(Net::HTTPOK)
|
if response.is_a?(Net::HTTPOK)
|
||||||
data = JSON.parse(response.body)
|
data = JSON.parse(response.body)
|
||||||
@@ -43,7 +49,7 @@ module Haste
|
|||||||
|
|
||||||
def server
|
def server
|
||||||
return @server if @server
|
return @server if @server
|
||||||
@server = ENV['HASTE_SERVER'].dup || Haste::DEFAULT_URL
|
@server = (ENV['HASTE_SERVER'] || Haste::DEFAULT_URL).dup
|
||||||
@server.chop! if server.end_with?('/')
|
@server.chop! if server.end_with?('/')
|
||||||
@server
|
@server
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
module Haste
|
module Haste
|
||||||
|
|
||||||
VERSION = '0.1.2'
|
VERSION = '0.1.6'
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user