Skip to content

Commit

Permalink
read variable from ~/.gyazo.config.yml
Browse files Browse the repository at this point in the history
set debhelper compatibility level to 9.
change Build-Depends: debhelper (>= 9.0.0).
set Standards-Version: 3.9.6.
add "Depends: xclip" to copy URL.
fix lintian warning.
  • Loading branch information
Hajime MIZUNO committed Mar 16, 2016
1 parent 95eca71 commit dd76c55
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 21 deletions.
12 changes: 11 additions & 1 deletion debian/changelog
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
gyazo (1.2ubuntu1~wily1) wily; urgency=medium

* set debhelper compatibility level to 9.
* change Build-Depends: debhelper (>= 9.0.0)
* set Standards-Version: 3.9.6.
* add "Depends: xclip" to copy URL
* fix lintian warning

-- Hajime Mizuno <mizuno-as@ubuntu.com> Fri, 04 Mar 2016 17:37:58 +0900

gyazo (1.2) unstable; urgency=low

* change icon
* optional settings screenshot command from ~/.gyazo.config.yml

-- pastak <pasta0915@gmail.com> Thu, 18 Feb 2016 18:45:20 +0900
-- pastak <pasta0915@gmail.com> Thu, 18 Feb 2016 18:45:20 +0900

gyazo (1.1) unstable; urgency=low

Expand Down
2 changes: 1 addition & 1 deletion debian/compat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7
9
10 changes: 6 additions & 4 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ Source: gyazo
Section: graphics
Priority: optional
Maintainer: Keisuke Kambara <kambara@sappari.org>
Build-Depends: debhelper (>= 7.0.50~)
Standards-Version: 3.9.1
Build-Depends: debhelper (>= 9.0.0)
Standards-Version: 3.9.6
Homepage: http://gyazo.com/

Package: gyazo
Architecture: all
Depends: ruby, imagemagick, xdotool
Depends: ruby, imagemagick, xdotool, xclip
Description: Seriously Instant Screen-Grabbing
Gyazo lets you instantly grab the screen and upload the image to the web. You can easily share them on Chat, Twitter, Blog, Tumblr, etc.
Gyazo lets you instantly grab the screen and upload
the image to the web.
You can easily share them on Chat, Twitter, Blog, Tumblr, etc.
35 changes: 20 additions & 15 deletions src/gyazo.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
#!/usr/bin/env ruby

# setting
browser_cmd = 'xdg-open'
clipboard_cmd = 'xclip'

require 'net/http'
require 'open3'
require 'openssl'
require 'json'
require 'yaml'

# setting
configfile = "#{ENV['HOME']}/.gyazo.config.yml"
if File.exist?(configfile) then
config = YAML.load_file(configfile)
end

browser_cmd = config == nil ? 'xdg-open' : config['browser_cmd']
clipboard_cmd = config == nil ? 'xclip' : config['clipboard_cmd']
clipboard_opt = config == nil ? '-sel clip' : config['clipboard_opt']
host = config == nil ? 'upload.gyazo.com' : config['host']
cgi = config == nil ? '/upload.cgi' : config['cgi']
ua = config == nil ? 'Gyazo/1.2' : config['ua']
use_ssl = config == nil ? 'true' : config['use_ssl']
http_port = config == nil ? 443 : config['http_port']

# get id
idfile = ENV['HOME'] + "/.gyazo.id"

Expand All @@ -35,7 +46,6 @@
if imagefile && File.exist?(imagefile) then
system "convert '#{imagefile}' '#{tmpfile}'"
else
configfile = "#{ENV['HOME']}/.gyazo.config.yml"
command = (File.exist?(configfile) && YAML.load_file(configfile)['command']) || 'import'
system "#{command} '#{tmpfile}'"
end
Expand All @@ -56,11 +66,6 @@
# upload
boundary = '----BOUNDARYBOUNDARY----'

# endpoint https://gyazo.com/api/docs
HOST = 'upload.gyazo.com'
CGI = '/upload.cgi'
UA = 'Gyazo/1.2'

metadata = JSON.generate({
app: active_window_name,
title: active_window_name,
Expand All @@ -87,7 +92,7 @@
header ={
'Content-Length' => data.length.to_s,
'Content-type' => "multipart/form-data; boundary=#{boundary}",
'User-Agent' => UA
'User-Agent' => ua
}

env = ENV['http_proxy']
Expand All @@ -97,16 +102,16 @@
else
proxy_host, proxy_port = nil, nil
end
https = Net::HTTP::Proxy(proxy_host, proxy_port).new(HOST,443)
https.use_ssl = true
https = Net::HTTP::Proxy(proxy_host, proxy_port).new(host,http_port)
https.use_ssl = use_ssl
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
https.verify_depth = 5
https.start{
res = https.post(CGI,data,header)
res = https.post(cgi,data,header)
url = res.response.body
puts url
if system "which #{clipboard_cmd} >/dev/null 2>&1" then
system "echo -n '#{url}' | #{clipboard_cmd}"
system "echo -n '#{url}' | #{clipboard_cmd} #{clipboard_opt}"
end
system "#{browser_cmd} '#{url}'"

Expand Down

0 comments on commit dd76c55

Please sign in to comment.