uplr 1.0.0.pre.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +5 -0
- data/Rakefile +2 -0
- data/bin/uplr +3 -0
- data/lib/uplr.rb +61 -0
- data/lib/uplr/scp_connection.rb +27 -0
- data/lib/uplr/upload_clipboard_handler.rb +26 -0
- data/lib/uplr/upload_complete_notifier.rb +27 -0
- data/lib/uplr/upload_progress.rb +34 -0
- data/lib/uplr/upload_progress_notifier.rb +28 -0
- data/lib/uplr/uploader.rb +29 -0
- data/lib/uplr/version.rb +3 -0
- data/license.txt +21 -0
- data/readme.md +78 -0
- data/uplr.gemspec +23 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: aeca571c622594d957ff8e14bce76295abacd57c
|
4
|
+
data.tar.gz: 065123c3062c20bba8436eef78a0f4516dbc2cca
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 187022429e24ea3180aad60ee34a330924f364aed88591c7fd4d2fc22bec54f087b0d1b608db5532a313b838c3af8514f20003ef4964132f555f7949810fab25
|
7
|
+
data.tar.gz: 5da3469878aaa678c33bf51ad52f4d51508819133605abf1be9442b6fe9222d7792c0ac0c68f714765b9c59594dca174fbbdf8376e86a0734bb02ac4aa08e61f
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
data/bin/uplr
ADDED
data/lib/uplr.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'terminal-notifier'
|
4
|
+
require 'micro-optparse'
|
5
|
+
|
6
|
+
require 'uplr/scp_connection'
|
7
|
+
require 'uplr/uploader'
|
8
|
+
require 'uplr/upload_progress'
|
9
|
+
require 'uplr/upload_progress_notifier'
|
10
|
+
require 'uplr/upload_complete_notifier'
|
11
|
+
require 'uplr/upload_clipboard_handler'
|
12
|
+
require 'uplr/version'
|
13
|
+
|
14
|
+
options = Parser.new do |p|
|
15
|
+
p.banner = <<-BANNER
|
16
|
+
NAME
|
17
|
+
uplr -- Upload Files via SCP
|
18
|
+
|
19
|
+
SYNOPSIS
|
20
|
+
uplr [options] file
|
21
|
+
|
22
|
+
DESCRIPTION
|
23
|
+
Uploads the specified file to the given server.
|
24
|
+
Progress is shown via system notifications (disable with --no-progress).
|
25
|
+
The final notification is clickable and opens the share URL in a web
|
26
|
+
browser. The share URL is automatically copied to the system clipboard
|
27
|
+
(disable with --no-clipboard).
|
28
|
+
|
29
|
+
OPTIONS
|
30
|
+
BANNER
|
31
|
+
p.version = Uplr::VERSION
|
32
|
+
p.option :file, "File to upload (or pass as last argument)", default: ARGV.last
|
33
|
+
p.option :host, "Connection: host", default: 'example.com'
|
34
|
+
p.option :user, "Connection: user", default: 'john'
|
35
|
+
p.option :path, "Connection: path", default: '/srv/www/example.com/public_html/u/'
|
36
|
+
p.option :base_url, "Upload URL directory", default: 'http://www.example.com/u/'
|
37
|
+
p.option :progress, "Show upload progress notifications", default: true
|
38
|
+
p.option :clipboard, "Copy final URL to clipboard", default: true
|
39
|
+
end.process!
|
40
|
+
|
41
|
+
connection = Uplr::ScpConnection.new(
|
42
|
+
host: options[:host],
|
43
|
+
user: options[:user],
|
44
|
+
path: options[:path],
|
45
|
+
base_url: options[:base_url]
|
46
|
+
)
|
47
|
+
|
48
|
+
uploader = Uplr::Uploader.new(connection)
|
49
|
+
progress = Uplr::UploadProgress.new
|
50
|
+
|
51
|
+
if options[:clipboard]
|
52
|
+
Uplr::UploadClipboardHandler.new(progress)
|
53
|
+
end
|
54
|
+
|
55
|
+
if options[:progress]
|
56
|
+
Uplr::UploadProgressNotifier.new(progress)
|
57
|
+
end
|
58
|
+
|
59
|
+
Uplr::UploadCompleteNotifier.new(progress, options[:clipboard])
|
60
|
+
|
61
|
+
uploader.upload(options[:file], progress)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'net/scp'
|
2
|
+
require "pp"
|
3
|
+
|
4
|
+
module Uplr
|
5
|
+
class ScpConnection
|
6
|
+
|
7
|
+
def initialize(args)
|
8
|
+
@host = args[:host]
|
9
|
+
@user = args[:user]
|
10
|
+
@path = args[:path]
|
11
|
+
@path << '/' unless @path.end_with?('/')
|
12
|
+
@base_url = args[:base_url]
|
13
|
+
end
|
14
|
+
|
15
|
+
def upload(local_file, filename, progress = nil)
|
16
|
+
|
17
|
+
url = @base_url + filename
|
18
|
+
|
19
|
+
Net::SCP.upload!(@host, @user, local_file, @path + filename) do |ch, name, sent, total|
|
20
|
+
progress.update(sent, total, url) if progress
|
21
|
+
end
|
22
|
+
|
23
|
+
url
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Uplr
|
2
|
+
# copy url to clipboard when upload finishes
|
3
|
+
class UploadClipboardHandler
|
4
|
+
def initialize(progress)
|
5
|
+
progress.add_observer(self)
|
6
|
+
end
|
7
|
+
|
8
|
+
def update(progress)
|
9
|
+
if progress.complete?
|
10
|
+
notify(progress.url)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def notify(url)
|
17
|
+
pbcopy(url)
|
18
|
+
end
|
19
|
+
|
20
|
+
def pbcopy(input)
|
21
|
+
str = input.to_s
|
22
|
+
IO.popen('pbcopy', 'w') { |f| f << str }
|
23
|
+
str
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Uplr
|
2
|
+
class UploadCompleteNotifier
|
3
|
+
|
4
|
+
def initialize(progress, clipboard)
|
5
|
+
@clipboard = clipboard
|
6
|
+
progress.add_observer(self)
|
7
|
+
end
|
8
|
+
|
9
|
+
def update(progress)
|
10
|
+
if progress.complete?
|
11
|
+
notify_complete(progress.url)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def notify_complete(url)
|
18
|
+
args = {title: "Upload Complete", open: url, group: url}
|
19
|
+
|
20
|
+
if @clipboard
|
21
|
+
args[:subtitle] = "URL copied to clipboard."
|
22
|
+
end
|
23
|
+
|
24
|
+
TerminalNotifier.notify url, args
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "observer"
|
2
|
+
|
3
|
+
module Uplr
|
4
|
+
class UploadProgress
|
5
|
+
include Observable
|
6
|
+
|
7
|
+
attr_reader :sent, :total, :url
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@sent = 0
|
11
|
+
@total = 0
|
12
|
+
end
|
13
|
+
|
14
|
+
def update(sent, total, url)
|
15
|
+
@sent = sent
|
16
|
+
@total = total
|
17
|
+
@url = url
|
18
|
+
changed
|
19
|
+
notify_observers(self)
|
20
|
+
end
|
21
|
+
|
22
|
+
def percent
|
23
|
+
@sent.to_f / @total * 100
|
24
|
+
end
|
25
|
+
|
26
|
+
def complete?
|
27
|
+
@sent > 0 && @sent == @total
|
28
|
+
end
|
29
|
+
|
30
|
+
def started?
|
31
|
+
@sent > 0 && @total > 0
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Uplr
|
2
|
+
class UploadProgressNotifier
|
3
|
+
|
4
|
+
def initialize(progress)
|
5
|
+
@prev_message_time = 0
|
6
|
+
progress.add_observer(self)
|
7
|
+
end
|
8
|
+
|
9
|
+
def update(progress)
|
10
|
+
if progress.started? && !progress.complete?
|
11
|
+
if current_time - @prev_message_time >= 1000
|
12
|
+
notify_progress(progress.url, progress.percent)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def notify_progress(url, percent)
|
20
|
+
TerminalNotifier.notify("%.2f%" % percent, title: "Upload…", group: url)
|
21
|
+
@prev_message_time = current_time
|
22
|
+
end
|
23
|
+
|
24
|
+
def current_time
|
25
|
+
(Time.now.to_f * 1000.0).to_i
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
3
|
+
module Uplr
|
4
|
+
class Uploader
|
5
|
+
|
6
|
+
def initialize(connection)
|
7
|
+
@connection = connection
|
8
|
+
end
|
9
|
+
|
10
|
+
def upload(local_file, progress = nil)
|
11
|
+
|
12
|
+
unless File.exists? local_file
|
13
|
+
raise "File #{local_file} does not exist."
|
14
|
+
end
|
15
|
+
|
16
|
+
file_extension = File.extname(local_file)
|
17
|
+
filename = uuid + file_extension
|
18
|
+
|
19
|
+
url = @connection.upload(local_file, filename, progress)
|
20
|
+
|
21
|
+
{ url: url }
|
22
|
+
end
|
23
|
+
|
24
|
+
private def uuid
|
25
|
+
SecureRandom.urlsafe_base64(10)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
data/lib/uplr/version.rb
ADDED
data/license.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) <year> <copyright holders>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/readme.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# FileCloud — Quickly Upload & Share Files
|
2
|
+
|
3
|
+
Uploads Files via SSH to your own server and copies the resulting URL to clipboard for easy sharing.
|
4
|
+
|
5
|
+
![demo](https://cloud.githubusercontent.com/assets/235918/6935631/1b59d21a-d87b-11e4-923e-125ffa4e66ed.gif)
|
6
|
+
|
7
|
+
## Requirements
|
8
|
+
|
9
|
+
* Ruby
|
10
|
+
* Mac OS X 10.8+
|
11
|
+
* Web Server with [SSH Private Key Authentication][2] to store files
|
12
|
+
|
13
|
+
## Setup
|
14
|
+
|
15
|
+
```
|
16
|
+
gem install uplr --pre
|
17
|
+
```
|
18
|
+
|
19
|
+
## Help
|
20
|
+
|
21
|
+
```
|
22
|
+
uplr --help
|
23
|
+
|
24
|
+
NAME
|
25
|
+
uplr -- Upload Files via SCP
|
26
|
+
|
27
|
+
SYNOPSIS
|
28
|
+
uplr [options] file
|
29
|
+
|
30
|
+
DESCRIPTION
|
31
|
+
Uploads the specified file to the given server.
|
32
|
+
Progress is shown via system notifications (disable with --no-progress).
|
33
|
+
The final notification is clickable and opens the share URL in a web
|
34
|
+
browser. The share URL is automatically copied to the system clipboard
|
35
|
+
(disable with --no-clipboard).
|
36
|
+
|
37
|
+
OPTIONS
|
38
|
+
-f, --file --help File to upload (or pass as last argument)
|
39
|
+
-h, --host example.com Connection: host
|
40
|
+
-u, --user john Connection: user
|
41
|
+
-p /srv/www/example.com/public_html/u/,
|
42
|
+
--path Connection: path
|
43
|
+
-b http://www.example.com/u/, Upload URL directory
|
44
|
+
--base-url
|
45
|
+
-r, --[no-]progress Show upload progress notifications
|
46
|
+
-c, --[no-]clipboard Copy final URL to clipboard
|
47
|
+
--help Show this message
|
48
|
+
-v, --version Print version
|
49
|
+
```
|
50
|
+
|
51
|
+
## Example
|
52
|
+
|
53
|
+
```shell
|
54
|
+
uplr --host example.com \
|
55
|
+
--user john \
|
56
|
+
--path /srv/www/example.com/public_html/u/ \
|
57
|
+
--base-url http://www.example.com/u/ \
|
58
|
+
/path/to/file.png
|
59
|
+
```
|
60
|
+
|
61
|
+
## Recommendation
|
62
|
+
|
63
|
+
To maximize joy, pair with [Hazel][1].
|
64
|
+
|
65
|
+
1. Create "Uploads" folder
|
66
|
+
2. Drag "Uploads" folder into Dock
|
67
|
+
3. Create new rule in Hazel for "Uploads" folder, choose "Run Shell Script", "embedded script", "/bin/bash" and paste/adjust the following:
|
68
|
+
|
69
|
+
```
|
70
|
+
uplr "$1"
|
71
|
+
```
|
72
|
+
|
73
|
+
Note that depending on your ruby setup it might be necessary to provide the full path to the binary, for example `~/.rbenv/shims/uplr` for rbenv.
|
74
|
+
|
75
|
+
Now you just have to drag&drop a file to the dock folder and seconds later there is a shareable link in your clipboard. Awesome!
|
76
|
+
|
77
|
+
[1]: http://www.noodlesoft.com/hazel.php
|
78
|
+
[2]: https://help.ubuntu.com/community/SSH/OpenSSH/Keys
|
data/uplr.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'uplr/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "uplr"
|
8
|
+
spec.version = Uplr::VERSION
|
9
|
+
spec.authors = ["Eric Teubert"]
|
10
|
+
spec.email = ["eric@ericteubert.de"]
|
11
|
+
spec.summary = %q{Uploads Files via SSH to your own server and copies the resulting URL to clipboard for easy sharing.}
|
12
|
+
spec.description = %q{Uploads the specified file to the given server. Progress is shown via system notifications (disable with --no-progress). The final notification is clickable and opens the share URL in a web browser. The share URL is automatically copied to the system clipboard (disable with --no-clipboard).}
|
13
|
+
spec.homepage = "https://github.com/eteubert/uplr"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
# spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: uplr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.pre.rc.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eric Teubert
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Uploads the specified file to the given server. Progress is shown via
|
42
|
+
system notifications (disable with --no-progress). The final notification is clickable
|
43
|
+
and opens the share URL in a web browser. The share URL is automatically copied
|
44
|
+
to the system clipboard (disable with --no-clipboard).
|
45
|
+
email:
|
46
|
+
- eric@ericteubert.de
|
47
|
+
executables:
|
48
|
+
- uplr
|
49
|
+
extensions: []
|
50
|
+
extra_rdoc_files: []
|
51
|
+
files:
|
52
|
+
- ".gitignore"
|
53
|
+
- Gemfile
|
54
|
+
- Gemfile.lock
|
55
|
+
- Rakefile
|
56
|
+
- bin/uplr
|
57
|
+
- lib/uplr.rb
|
58
|
+
- lib/uplr/scp_connection.rb
|
59
|
+
- lib/uplr/upload_clipboard_handler.rb
|
60
|
+
- lib/uplr/upload_complete_notifier.rb
|
61
|
+
- lib/uplr/upload_progress.rb
|
62
|
+
- lib/uplr/upload_progress_notifier.rb
|
63
|
+
- lib/uplr/uploader.rb
|
64
|
+
- lib/uplr/version.rb
|
65
|
+
- license.txt
|
66
|
+
- readme.md
|
67
|
+
- uplr.gemspec
|
68
|
+
homepage: https://github.com/eteubert/uplr
|
69
|
+
licenses:
|
70
|
+
- MIT
|
71
|
+
metadata: {}
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">"
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.3.1
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 2.4.6
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: Uploads Files via SSH to your own server and copies the resulting URL to
|
92
|
+
clipboard for easy sharing.
|
93
|
+
test_files: []
|