mirror of
https://github.com/seejohnrun/haste-client.git
synced 2025-12-17 09:11:29 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5aa8fbacc | ||
|
|
1f3318adeb | ||
|
|
4c0e5f311d | ||
|
|
dab2d08f42 | ||
|
|
0ea5e5c61c |
@@ -10,7 +10,7 @@ And once the output makes it to the server, it will print the URL to STDOUT.
|
|||||||
|
|
||||||
This can be really really cool in combination with `pbcopy`, like:
|
This can be really really cool in combination with `pbcopy`, like:
|
||||||
|
|
||||||
* mac osx: `cat file | haste | pbcopy`
|
* mac osx: `cat file | haste | pbcopy`
|
||||||
* linux: `cat file | haste | xsel`
|
* linux: `cat file | haste | xsel`
|
||||||
|
|
||||||
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.
|
||||||
@@ -42,10 +42,10 @@ haste file --raw
|
|||||||
|
|
||||||
## Changing the location of your haste server
|
## Changing the location of your haste server
|
||||||
|
|
||||||
By default, haste will point at `http://hastebin.com`. You can change this by setting the value of `ENV['HASTE_SERVER']` to the URL of your haste server. You can also use `alias` to make easy shortcuts if you commonly use a few hastes intermingled with each other. To do that, you'd put something like this into ~.bash_profile:
|
By default, haste will point at `https://hastebin.com`. You can change this by setting the value of `ENV['HASTE_SERVER']` to the URL of your haste server. You can also use `alias` to make easy shortcuts if you commonly use a few hastes intermingled with each other. To do that, you'd put something like this into ~.bash_profile:
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
alias work_haste="HASTE_SERVER=http://something.com haste"
|
alias work_haste="HASTE_SERVER=https://something.com haste"
|
||||||
```
|
```
|
||||||
|
|
||||||
After which you can use `work_haste` to send hastes to that server instead.
|
After which you can use `work_haste` to send hastes to that server instead.
|
||||||
@@ -70,7 +70,7 @@ If you'd like an alternative on Windows that supports functionality similar to `
|
|||||||
Han Boetes and @nickthename have contributed a simple shell-script alternative for those not interested in installing a RubyGem:
|
Han Boetes and @nickthename have contributed a simple shell-script alternative for those not interested in installing a RubyGem:
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
haste() { a=$(cat); curl -X POST -s -d "$a" http://hastebin.com/documents | awk -F '"' '{print "http://hastebin.com/"$4}'; }
|
haste() { a=$(cat); curl -X POST -s -d "$a" https://hastebin.com/documents | awk -F '"' '{print "https://hastebin.com/"$4}'; }
|
||||||
```
|
```
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
require 'json'
|
require 'json'
|
||||||
require 'faraday'
|
require 'faraday'
|
||||||
|
require 'uri'
|
||||||
|
|
||||||
module Haste
|
module Haste
|
||||||
|
|
||||||
@@ -40,8 +41,13 @@ module Haste
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def post_path
|
||||||
|
parsed_uri = URI.parse(server_url)
|
||||||
|
"#{parsed_uri.path}/documents"
|
||||||
|
end
|
||||||
|
|
||||||
def do_post(data)
|
def do_post(data)
|
||||||
connection.post('/documents', data)
|
connection.post(post_path, data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def connection
|
def connection
|
||||||
|
|||||||
@@ -126,6 +126,42 @@ describe Haste::Uploader do
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe :post_path do
|
||||||
|
|
||||||
|
let(:post_path) { uploader.send(:post_path) }
|
||||||
|
|
||||||
|
context "when the server URL doesn't have a path" do
|
||||||
|
|
||||||
|
let(:base) { 'http://example.com/' }
|
||||||
|
|
||||||
|
it 'should return /documents' do
|
||||||
|
expect(post_path).to eq('/documents')
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when the server URL has a path" do
|
||||||
|
|
||||||
|
let(:base) { 'http://example.com/friend' }
|
||||||
|
|
||||||
|
it 'should return /documents' do
|
||||||
|
expect(post_path).to eq('/friend/documents')
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when the server URL has a path that ends with slash" do
|
||||||
|
|
||||||
|
let(:base) { 'http://example.com/friend/' }
|
||||||
|
|
||||||
|
it 'should return /documents appended to the path without a duplicate slash' do
|
||||||
|
expect(post_path).to eq('/friend/documents')
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
describe :server_url do
|
describe :server_url do
|
||||||
|
|
||||||
let(:server_url) { uploader.server_url }
|
let(:server_url) { uploader.server_url }
|
||||||
|
|||||||
Reference in New Issue
Block a user