You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
calculate-overlay/app-text/wgetpaste/files/calculate_wgetpaste-25.patch

189 lines
8.2 KiB

diff -ruN wgetpaste-2.22.orig/wgetpaste wgetpaste-2.22/wgetpaste
--- wgetpaste-2.25.orig/wgetpaste 2014-01-21 11:31:59.475610453 +0400
+++ wgetpaste-2.25/wgetpaste 2014-01-21 11:41:13.858639053 +0400
@@ -6,6 +6,8 @@
VERSION="2.25"
+DEFAULT_SERVICE="calculate"
+
# don't inherit LANGUAGE from the env
unset LANGUAGE
@@ -14,7 +16,7 @@ E=$'\e'
N=$'\n'
### services
-SERVICES="bpaste ca codepad dpaste gists poundpython"
+SERVICES="bpaste ca codepad dpaste gists poundpython calculate"
# bpaste
ENGINE_bpaste=lodgeit
URL_bpaste="http://bpaste.net/"
@@ -42,6 +44,17 @@ URL_poundpython="http://paste.pound-python.org/"
ENGINE_tinyurl=tinyurl
URL_tinyurl="http://tinyurl.com/ api-create.php"
REGEX_RAW_tinyurl='s|^\(http://[^/]*/\)\([[:alnum:]]*\)$|\1\2|'
+# calculate
+ENGINE_calculate=calculate
+if [[ "$LANG" =~ 'ru_RU' ]]; then
+ URL_calculate="http://pastebin.calculate-linux.ru"
+else
+ URL_calculate="http://pastebin.calculate-linux.org"
+fi
+DEFAULT_LANGUAGE_calculate="Text"
+DEFAULT_PARENT_calculate=""
+DEFAULT_PRIVATE_calculate=0
+SIZE_calculate="25000 25%kB"
### engines
# ca
@@ -52,12 +65,12 @@ LANGUAGE_COUNT_ca=0
EXPIRATIONS_ca="Never 5%minutes 10%minutes 15%minutes 30%minutes 45%minutes 1%hour 2%hours \
4%hours 8%hours 12%hours 1%day 2%days 3%days 1%week 2%weeks 3%weeks 1%month 2%months \
3%months 4%months 5%months 6%months 1%year"
-POST_ca="s=Submit+Post name description type expiry % content"
+POST_ca="s=Submit+Post name description type expiry % % % content"
REGEX_URL_ca='s|^.*content="[0-9]*;\(http://[^/]*/[0-9]*\)".*$|\1|p'
REGEX_RAW_ca='s|^\(http://[^/]*/\)\([0-9]*\)$|\1raw/\2|'
# codepad
LANGUAGES_codepad="C C++ D Haskell Lua OCaml PHP Perl Plain%Text Python Ruby Scheme Tcl"
-POST_codepad="submit % % lang % % code"
+POST_codepad="submit % % lang % % % % code"
REGEX_URL_codepad='s|^--.*\(http://codepad.org/[^ ]\+\)|\1|p'
REGEX_RAW_codepad='s|^\(http://[^/]*/\)\([[:alnum:]]*\)$|\1\2/raw.rb|'
# dpaste
@@ -67,7 +80,7 @@ LANGUAGE_VALUES_dpaste="% Apache Bash Css Diff DjangoTemplate Haskell JScript Py
Ruby Rhtml Sql Xml"
EXPIRATIONS_dpaste="30%days 30%days%after%last%view"
EXPIRATION_VALUES_dpaste="off on"
-POST_dpaste="submit=Paste+it poster title language hold % content"
+POST_dpaste="submit=Paste+it poster title language hold % % % content"
REGEX_RAW_dpaste='s|^\(http://[^/]*/\)[^0-9]*\([0-9]*/\)$|\1\2plain/|'
# gists
LANGUAGES_gists="ActionScript Ada Apex AppleScript Arc Arduino ASP Assembly
@@ -141,8 +154,23 @@ objective-c objective-j ocaml ooc perl php text pov prolog python python3 py3tb
ragel-c ragel-cpp ragel-d ragel-java ragel-objc ragel-ruby raw rconsole rebol redcode rst rhtml rb \
rbcon splus sass scala scheme smalltalk smarty sql sqlite3 squidconf tcl tcsh tex diff vala vb.net \
vim xml xml+cheetah xml+django xml+evoque xml+mako xml+myghty xml+php xml+erb xml+smarty xslt yaml"
-POST_lodgeit="submit=Paste! % % language % % code"
+POST_lodgeit="submit=Paste! % % language % % % % code"
REGEX_RAW_lodgeit='s|^\(http://[^/]*/\)show\(/[[:alnum:]]*/\)$|\1raw\2|'
+# calculate
+LANGUAGES_calculate="Apache Bash Batch Boo C C# C++ Clojure Creole_Wiki CSS \
+CSV D Debian_control-files Django_Jinja_Templates Dylan Erlang eRuby_rhtml GAS GCC_Messages \
+Genshi_Templates Gettext_catalogs GL_Shader_language Haskell HTML INI_File Interactive_Ruby IO \
+IRC_Logs Java javac_Messages JavaScript JSP Lighttpd Literate_Haskell LLVM Lua Mako_Templates Matlab \
+Matlab_Session MiniD Multi-File Myghty_Templates MySQL Nasm Nginx Object-Pascal OCaml Perl PHP \
+PHP_(inline) Povray Python Python_Console_Sessions Python_Tracebacks reStructuredText Ruby Scala \
+Scheme Smalltalk Smarty sources.list SQL SquidConf TeX_LaTeX Text Unified_Diff Vim XML XSLT YAML"
+LANGUAGE_VALUES_calculate="apache bash bat boo c csharp cpp clojure creole css csv d control html+django \
+dylan erlang rhtml gas gcc-messages html+genshi gettext glsl haskell html ini irb io irc java \
+javac-messages js jsp lighttpd literate-haskell llvm lua html+mako matlab matlabsession minid multi \
+html+myghty mysql nasm nginx objectpascal ocaml perl html+php php povray python pycon pytb rst ruby \
+scala scheme smalltalk smarty sourceslist sql squidconf tex text diff vim xml xslt yaml"
+POST_calculate="submit=paste! % % language % parent private % text"
+REGEX_RAW_calculate='s|^\(http://[^/]*/\)show\(/[0-9]*/\)$|\1raw\2|'
### errors
die() {
@@ -340,6 +368,9 @@ Options:
-s, --service SERVICE set service to use (defaults to "$DEFAULT_SERVICE")
-e, --expiration EXPIRATION set when it should expire (defaults to "$DEFAULT_EXPIRATION")
+ -p, --parent PARENT set parent paste (defaults to "$DEFAULT_PARENT", make use id paste) (Calculate pastebin option)
+ -P, --private PRIVATE set private status (defaults to "$DEFAULT_PRIVATE") (Calculate pastebin option)
+
-S, --list-services list supported pastebin services
-L, --list-languages list languages supported by the specified service
-E, --list-expiration list expiration setting supported by the specified service
@@ -431,6 +462,18 @@ showlanguages() {
done | sort
}
+showprivate() {
+ local p priv d
+ priv=PRIVATE_$ENGINE
+ [[ -n $COMPLETIONS ]] && printlist ${!priv} | sort && exit 0
+ echo "Private supported by $(getrecipient) (case sensitive):"
+ [[ -z ${!priv} ]] && echo "$N\"$ENGINE\" has no support for setting language." >&2 && exit 1
+ for p in ${!priv}; do
+ [[ ${p//\%/ } = $DEFAULT_PRIVATE ]] && d="*" || d=" "
+ echo " $d${p//\%/ }"
+ done | sort
+}
+
showexpirations() {
local e expiration info d
expiration=EXPIRATIONS_$ENGINE
@@ -484,7 +527,7 @@ postdata() {
post=POST_$ENGINE
if [[ -n ${!post} ]]; then
nr=${!post//[^ ]}
- [[ 6 = ${#nr} ]] || die "\"${SERVICE}\" is not supported by ${FUNCNAME}()."
+ [[ 8 = ${#nr} ]] || die "\"${SERVICE}\" is not supported by ${FUNCNAME}()."
extra=${!post%% *}
[[ '%' = $extra ]] || echo -n "$extra&"
e() {
@@ -497,7 +540,7 @@ postdata() {
post=${post#$f }
done
}
- e "${!post#$extra }" NICK DESCRIPTION LANGUAGE EXPIRATION CVT_TABS INPUT
+ e "${!post#$extra }" NICK DESCRIPTION LANGUAGE EXPIRATION PARENT PRIVATE CVT_TABS INPUT
elif [[ function == $(type -t json_$ENGINE) ]]; then
json_$ENGINE "$DESCRIPTION" "$LANGUAGE" "$INPUT"
else
@@ -600,6 +643,16 @@ while [[ -n $1 ]]; do
-L | --list-languages )
LISTLANGUAGES=0
;;
+ -p | --parent )
+ requiredarg "$@"
+ PARENTSET=0
+ PARENT="$2"
+ ;;
+ -P | --private )
+ requiredarg "$@"
+ PRIVATESET=0
+ PRIVATE="$2"
+ ;;
-n | --nick )
requiredarg "$@"
NICK=$(escape "$2")
@@ -677,12 +730,16 @@ load_configs
DEFAULT_NICK=${DEFAULT_NICK:-$(whoami)} || die "whoami failed"
DEFAULT_SERVICE=${DEFAULT_SERVICE:-bpaste}
DEFAULT_LANGUAGE=${DEFAULT_LANGUAGE:-Plain Text}
+DEFAULT_PARENT=${DEFAULT_PARENT:-''}
+DEFAULT_PRIVATE=${DEFAULT_PRIVATE:-0}
DEFAULT_EXPIRATION=${DEFAULT_EXPIRATION:-1 month}
SERVICE=${SERVICE:-${DEFAULT_SERVICE}}
ENGINE=ENGINE_$SERVICE
ENGINE="${!ENGINE}"
default="DEFAULT_NICK_$SERVICE" && [[ -n ${!default} ]] && DEFAULT_NICK=${!default}
default="DEFAULT_LANGUAGE_$SERVICE" && [[ -n ${!default} ]] && DEFAULT_LANGUAGE=${!default}
+default="DEFAULT_PARENT_$SERVICE" && [[ -n ${!default} ]] && DEFAULT_PARENT=${!default}
+default="DEFAULT_PRIVATE_$SERVICE" && [[ -n ${!default} ]] && DEFAULT_PRIVATE=${!default}
default="DEFAULT_EXPIRATION_$SERVICE" && [[ -n ${!default} ]] && DEFAULT_EXPIRATION=${!default}
NICK=${NICK:-$(escape "${DEFAULT_NICK}")}
[[ -z $SOURCE ]] && SOURCE="stdin"
@@ -704,6 +761,10 @@ INFO_ARGS=${INFO_ARGS:-"--ignore-default-opts"}
LANGUAGE=${LANGUAGE:-${DEFAULT_LANGUAGE}}
verifylanguage
LANGUAGE=$(escape "$LANGUAGE")
+PARENT=${PARENT:-${DEFAULT_PARENT}}
+PARENT=$(escape "$PARENT")
+PRIVATE=${PRIVATE:-${DEFAULT_PRIVATE}}
+PRIVATE=$(escape "$PRIVATE")
EXPIRATION=${EXPIRATION:-${DEFAULT_EXPIRATION}}
verifyexpiration
EXPIRATION=$(escape "$EXPIRATION")
@@ -853,6 +914,7 @@ else
[[ -f $TMPF ]] || TMPF=$(mktemp /tmp/wgetpaste.XXXXXX)
if [[ -f $TMPF ]]; then
postdata > "$TMPF" || die "Failed to write to temporary file: \"$TMPF\"."
+ [[ $LANG =~ ru_RU ]] && enconv $TMPF
WGETARGS="--post-file=$TMPF"
else
# fall back to using --post-data if the temporary file could not be created