Permalink
Browse files

read variable from ~/.gyazo.config.yml

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.
1 parent 95eca71 commit dd76c5591800fc898d0decd546f7c49a75652da1 Hajime MIZUNO committed Mar 16, 2016
Showing with 38 additions and 21 deletions.
  1. +11 −1 debian/changelog
  2. +1 −1 debian/compat
  3. +6 −4 debian/control
  4. +20 −15 src/gyazo.rb
View
@@ -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
View
@@ -1 +1 @@
-7
+9
View
@@ -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.
View
@@ -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"
@@ -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
@@ -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,
@@ -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']
@@ -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}'"

0 comments on commit dd76c55

Please sign in to comment.