1
0
mirror of https://github.com/seejohnrun/haste-client.git synced 2025-12-18 09:31:29 +00:00

1 Commits

Author SHA1 Message Date
Konstantin Rybakov
5a4953dc93 feat: update light weight alternative 2022-01-12 15:29:01 +03:00
5 changed files with 12 additions and 91 deletions

1
.github/CODEOWNERS vendored
View File

@@ -1 +0,0 @@
* @toptal/site-acquisition-eng

View File

@@ -1,30 +0,0 @@
name: Close inactive issues and PRs
on:
workflow_dispatch:
schedule:
- cron: "30 1 * * *"
jobs:
close-stale:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v3
with:
days-before-stale: 30
days-before-close: 14
stale-issue-label: "stale"
stale-pr-label: "stale"
exempt-issue-labels: backlog,triage,nostale
exempt-pr-labels: backlog,triage,nostale
stale-pr-message: "This PR is stale because it has been open for 30 days with no activity."
close-pr-message: "This PR was closed because it has been inactive for 14 days since being marked as stale."
stale-issue-message: "This issue is stale because it has been open for 30 days with no activity."
close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale."
repo-token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -50,22 +50,6 @@ 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.
### Authentication
If your haste installation requires http authentication,
add the following to your ~.bash_profile:
```bash
export HASTE_USER="myusername"
export HASTE_PASS="mypassword"
```
if you are using SSL, you will need to supply your certs path
```bash
export HASTE_SSL_CERTS="/System/Library/OpenSSL/certs"
```
## Use as a library ## Use as a library
You can also use `Haste` as a library to upload hastes: You can also use `Haste` as a library to upload hastes:
@@ -86,22 +70,18 @@ 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() { haste() { curl -X POST -s -d "$(cat $1)" https://hastebin.com/documents | awk -F '"' '{print "https://hastebin.com/"$4}'; }
local S="https" H="hastebin.com" P="" L="$1"
local SHP="${S}://${H}${P}/"
curl -X POST -s --data-binary @- "${SHP}documents" \
| awk -F '"' 'b{ b="."b }; {print a$4b}' a="${SHP}" b="${L}"
}
``` ```
Where `S` is the scheme, `H` is the host, `P` is the port, and `L` is the language. Requires `curl`
Usage: Usage:
``` bash ``` bash
cat file.txt | haste # cat file into hate, output url cat file.txt | haste
haste sh < script.sh # Same as above, but ensure shell syntax highlighting ```
xsel -b | haste txt # Output clipboard buffer into haste, ensure no highlighting or:
```bash
haste file.txt
``` ```
And a more expansive BASH option by @diethnis can be found at: And a more expansive BASH option by @diethnis can be found at:

View File

@@ -4,11 +4,7 @@ module Haste
# Create a new uploader # Create a new uploader
def initialize def initialize
@uploader = Uploader.new( @uploader = Uploader.new ENV['HASTE_SERVER']
ENV['HASTE_SERVER'],
ENV['HASTE_USER'],
ENV['HASTE_PASS'],
ENV['HASTE_SSL_CERTS'])
end end
# And then handle the basic usage # And then handle the basic usage

View File

@@ -8,16 +8,12 @@ module Haste
class Uploader class Uploader
attr_reader :server_url, :server_user, :server_pass, :ssl_certs attr_reader :server_url
def initialize(server_url = nil, server_user = nil, server_pass = nil, ssl_certs = nil) def initialize(server_url = nil)
@server_url = server_url || Haste::DEFAULT_URL @server_url = server_url || Haste::DEFAULT_URL
@server_url = @server_url.dup @server_url = @server_url.dup
@server_url = @server_url.chop if @server_url.end_with?('/') @server_url = @server_url.chop if @server_url.end_with?('/')
@server_user = server_user
@server_pass = server_pass
@ssl_certs = ssl_certs
end end
# Take in a path and return a key # Take in a path and return a key
@@ -55,31 +51,11 @@ module Haste
end end
def connection def connection
@connection ||= connection_set @connection ||= Faraday.new(:url => server_url) do |c|
end c.adapter Faraday.default_adapter
def connection_set
return connection_https if @ssl_certs
connection_http
end
def connection_http
Faraday.new(:url => server_url) do |c|
connection_config(c)
end end
end end
def connection_https
Faraday.new(:url => server_url, :ssl => { :ca_path => @ssl_certs }) do |c|
connection_config(c)
end
end
def connection_config(config)
config.basic_auth(@server_user, @server_pass) if @server_user
config.adapter Faraday.default_adapter
end
def fail_with(msg) def fail_with(msg)
raise Exception.new(msg) raise Exception.new(msg)
end end