rpms/nopaste/EL-5 import.log, NONE, 1.1 nopaste-2835, NONE, 1.1 nopaste.spec, NONE, 1.1
Simon Wesp
cassmodiah at fedoraproject.org
Thu Jan 15 19:17:10 UTC 2009
Author: cassmodiah
Update of /cvs/pkgs/rpms/nopaste/EL-5
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv31280/EL-5
Added Files:
import.log nopaste-2835 nopaste.spec
Log Message:
--- NEW FILE import.log ---
nopaste-2835-2_fc10:EL-5:nopaste-2835-2.fc10.src.rpm:1232047030
--- NEW FILE nopaste-2835 ---
#!/usr/bin/ruby -w
#
# nopaste -- quick script in the spirit of eatpaste, to generate nopaste urls.
# See http://www.rafb.net/paste/ for more information.
#
# Copyright 2005,2007 Aron Griffis <agriffis n01se.net>
# Released under the GNU General Public License v2
#
require 'cgi'
require 'net/http'
require 'optparse'
require 'ostruct'
require 'uri'
class CmdLine
def self.parse(args)
options = OpenStruct.new
options.lang = 'Plain Text'
opts = OptionParser.new do |opts|
opts.banner = "Usage: nopaste [options]"
opts.separator ""
opts.separator "Options:"
opts.on("-l", "--language LANG",
"set language (defaults to \"Plain Text\")") do |x|
options.lang = x
end
opts.on("-d", "--description DESCRIPTION",
"set description (defaults to \"stdin\" or filename)") do |x|
options.desc = x
end
opts.on("-n", "--nick NICK",
"set nick (defaults to your username)") do |x|
options.nick = x
end
opts.on("-t", "--txturl",
"return url for the plain text file") do
options.txturl = true
end
opts.on("-x", "--xcut",
"nopaste from X selection (using xclip or xcut)") do
options.xcut = true
end
opts.on("--debug",
"enable debug output") do
options.debug = true
end
opts.on_tail("--help", "show this help") do
puts opts
exit
end
opts.on_tail("--version", "show version information") do
puts "nopaste " + $version
exit
end
end
opts.parse!(args)
options
end
end
def e(s)
return $zero+" error: "+s
end
def nopaste(nick, desc, text, lang = "Plain Text")
cxn = Net::HTTP::Proxy($proxy.host, $proxy.port, $proxy_user, $proxy_pass
).start($url.host, $url.port) { |cxn|
response = cxn.request_post($url.path,
[ "cvt_tabs=No",
"lang=#{CGI::escape(lang)}",
"nick=#{CGI::escape(nick)}",
"desc=#{CGI::escape(desc)}",
"text=#{CGI::escape(text)}" ].join('&'),
{ 'Content-Type' => 'application/x-www-form-urlencoded' })
if $options.debug
STDERR.puts response.inspect
response.each_header {|k,v| STDERR.printf "%s: %s\n", k, v}
STDERR.puts response.body
end
case response
when Net::HTTPRedirection
if response['location'] =~ /toofast.html/
return e("rafb.net says you're pasting too fast. Try again in 10 seconds")
else
u = $url.merge(response['location'])
u.path = u.path.sub(/html$/, 'txt') if $options.txturl
return u
end
when Net::HTTPSuccess
# strange
return e("rafb.net sent an unexpected HTML response")
else
return e("rafb.net says #{response.code} #{response.message}")
end
}
end
$proxy = URI.parse(ENV['http_proxy'] || '')
$proxy_user, $proxy_pass = nil, nil
$proxy_user, $proxy_pass = $proxy.userinfo.split(/:/) if $proxy.userinfo
$url = URI.parse("http://www.rafb.net/paste/paste.php")
$version = '$Revision: 2835 $'.split(' ')[1]
$zero = $0.sub(/.*\//, '')
$options = CmdLine.parse(ARGV)
urls = []
if $options.desc.to_s.empty?
if $options.xcut
$options.desc = 'xcut'
elsif ARGV.empty?
$options.desc = 'stdin'
else
$options.desc = ARGV[0]
end
end
if $options.nick.to_s.empty?
$options.nick = ENV['USER'] || 'unknown'
end
begin
if $options.xcut
buf = %x{xclip -o 2>/dev/null || xcut -p 2>/dev/null}
urls << nopaste($options.nick, $options.desc, buf, $options.lang)
elsif ARGV.empty?
urls << nopaste($options.nick, $options.desc, gets(nil), $options.lang)
end
urls << nopaste($options.nick, $options.desc, gets(nil), $options.lang) until ARGV.empty?
begin
IO.popen("xclip 2>/dev/null", "w") {|p| p.print urls.map {|u| u.to_s}.join(' ') }
rescue Errno::EPIPE
begin
IO.popen("xcut 2>/dev/null", "w") {|p| p.print urls.map {|u| u.to_s}.join(' ') }
rescue Errno::EPIPE
end
end
rescue
puts urls # whatever we've accumulated already
puts e("something bad happened, stack trace follows")
raise
end
puts urls
exit 1 if urls.join("\n") =~ /^(?!http:)/
--- NEW FILE nopaste.spec ---
Name: nopaste
Version: 2835
Release: 2%{?dist}
Summary: Command-line interface to rafb.net/paste
Group: Applications/Internet
License: GPLv2
URL: http://n01se.net/agriffis/nopaste
Source0: http://agriffis.n01se.net/%{name}/%{name}-%{version}
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%description
This is a simple script to facilitate sharing text through
http://rafb.net/paste/. Like most UNIX utilities, it can take
stdin or files on the command-line. Additionally nopaste can
use the X cut buffer for input, designed to be used with a
window-manager key binding or panel launcher.
The resulting URLs are printed to stdout and additionally
placed in the X cut buffer for quick pasting.
%prep
%build
%install
rm -rf %{buildroot}
mkdir -p %{buildroot}%{_bindir}
install -pm755 %{SOURCE0} \
%{buildroot}%{_bindir}/%{name}
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
%{_bindir}/%{name}
%changelog
* Sat Jan 10 2009 Simon Wesp <cassmodiah at fedoraproject.org> - 2835-2
- Correct License to GPLv2
- Remove doc in files-section
* Sat Nov 29 2008 Philipp Baum <phil at linuxeinsteiger.net> - 2835-1
- Initial Package Release
More information about the fedora-extras-commits
mailing list