From a95a7a4cb45b4bf1b24f4dc4acba6fecde1dd80b Mon Sep 17 00:00:00 2001 From: Paweł Zuzelski Date: Tue, 23 Mar 2010 22:06:43 +0100 Subject: add my e-mail to AUTHORS file --- AUTHORS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index aa56e17..ca484f6 100644 --- a/AUTHORS +++ b/AUTHORS @@ -54,7 +54,7 @@ In alphabetical order: Nicolas Pouillard - refactored scroll command Olivier Schwander - auto file:// prepend Paul Tomak - eFormFiller - Paweł Zuzelski (pawelz) - http auth handler, misc patches + Paweł Zuzelski (pawelz) - http auth handler, misc patches Peter Suschlik - backwards searching Přemysl Hrubý (anydot) - several C contributions and cleanups Robert Manea (robm) - C code all over the place -- cgit v1.2.3 From 1dc6b9e5646542180490ae2e92eff304564fc8fc Mon Sep 17 00:00:00 2001 From: Pawel Tomak Date: Fri, 26 Mar 2010 17:52:36 +0100 Subject: checkbox support in 'once' action --- examples/data/scripts/formfiller.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 1408006..5dc6345 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -101,7 +101,7 @@ then sed 's/]\+>\).*/\1/;/type="\(password\|text\)"/Ip' | \ + sed -n 's/.*\(]\+>\).*/\1/;/type="\(password\|text\|checkbox\)"/Ip' | \ sed 's/\(.*\)\(type="[^"]\+"\)\(.*\)\(name="[^"]\+"\)\(.*\)/\1\4\3\2\5/I' | \ sed 's/.*name="\([^"]\+\)".*type="\([^"]\+\)".*/\1(\2):/I' >> $tmpfile echo "${html}" | \ @@ -111,7 +111,11 @@ then [ -e $tmpfile ] || exit 2 cat $tmpfile | \ - sed -n -e 's/\([^(]\+\)([^)]\+):[ ]*\(.\+\)/js if(window.frames.length > 0) { for(i=0;i 0) { e[0].value="\2" } } catch(err) { } } }; document.getElementsByName("\1")[0].value="\2"/p' | \ + sed -n -e 's/\([^(]\+\)(\(password\|text\|textarea\)\+):[ ]*\(.\+\)/js if(window.frames.length > 0) { for(i=0;i 0) { e[0].value="\3" } } catch(err) { } } }; document.getElementsByName("\1")[0].value="\3"/p' | \ + sed -e 's/@/\\@/g' >> $fifo + sed 's/\([^(]\+\)(\(checkbox\)):[ ]*\(.\+\)/\1(\2):1/;s/\([^(]\+\)(\(checkbox\)):$/\1(\2):0/' -i $tmpfile + cat $tmpfile | \ + sed -n -e 's/\([^(]\+\)(\(checkbox\)):[ ]*\(.\+\)/js if(window.frames.length > 0) { for(i=0;i 0) { e[0].checked=\3 } } catch(err) { } } }; document.getElementsByName("\1")[0].checked=\3/p' | \ sed -e 's/@/\\@/g' >> $fifo rm -f $tmpfile else -- cgit v1.2.3 From f18b80263ad72f432d9127f3025ea85bf89e87c7 Mon Sep 17 00:00:00 2001 From: Pawel Tomak Date: Fri, 26 Mar 2010 20:05:48 +0100 Subject: Speed up for forms output to the file Moved dumping javascript code to the function dump() outerHTML is now being used only on forms, not entire documents --- examples/data/scripts/formfiller.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 5dc6345..4b62ea1 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -74,6 +74,8 @@ then action="new" fi +dumpFunction='function dump() { var output = ""; var allFrames = new Array(window); for(f=0;f 0) { for(k=0;k 0) { for(j=0;j 0) { for(i=0;i Date: Sat, 27 Mar 2010 01:08:52 +0100 Subject: updated formfiller.sh comments --- examples/data/scripts/formfiller.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 4b62ea1..20d1d52 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -6,13 +6,14 @@ # files contain lines like: !profile= # (fieldtype): # profile_name should be replaced with a name that will tell sth about that profile -# fieldtype can be text or password - only for information pupropse (auto-generated) - don't change that +# fieldtype can be checkbox, text or password - only for information pupropse (auto-generated) - don't change that # # user arg 1: # edit: force editing the file (falls back to new if not found) # new: start with a new file. # load: try to load from file into form # add: try to add another profile to an existing file +# once: edit form using external editor # # something else (or empty): if file not available: new, otherwise load. -- cgit v1.2.3 From 32a4061abdd5f30e4a25c982fb52b09c08b39fb5 Mon Sep 17 00:00:00 2001 From: Paweł Zuzelski Date: Sat, 27 Mar 2010 01:14:34 +0100 Subject: quote ${editor} and ${VISUAL} These variables must be quoted. Otherwise script fails for VISUAL="xterm -name xvim -e vim" --- examples/data/scripts/formfiller.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 20d1d52..6f6dc34 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -37,9 +37,9 @@ keydir=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/dforms [ -d "`dirname $keydir`" ] || exit 1 [ -d "$keydir" ] || mkdir "$keydir" -editor=${VISUAL} -if [ -z ${editor} ]; then - if [ -z ${EDITOR} ]; then +editor="${VISUAL}" +if [ -z "${editor}" ]; then + if [ -z "${EDITOR}" ]; then editor='xterm -e vim' else editor="xterm -e ${EDITOR}" -- cgit v1.2.3 From fc50da64fe96da436896aa077ee8a8f807969220 Mon Sep 17 00:00:00 2001 From: Paweł Zuzelski Date: Sat, 27 Mar 2010 01:37:42 +0100 Subject: Use javascript and XPath to find input fields. Initialize field values. --- examples/data/scripts/formfiller-helper.js | 32 ++++++++++++++++++++++++++++++ examples/data/scripts/formfiller.sh | 17 ++-------------- 2 files changed, 34 insertions(+), 15 deletions(-) create mode 100644 examples/data/scripts/formfiller-helper.js diff --git a/examples/data/scripts/formfiller-helper.js b/examples/data/scripts/formfiller-helper.js new file mode 100644 index 0000000..999d860 --- /dev/null +++ b/examples/data/scripts/formfiller-helper.js @@ -0,0 +1,32 @@ +/* This script finds all editable input elemnts and generate file for + * formfiller script. It must be invoked from formfiller.sh */ + +(function () { + /* evaluate XPath query */ + var xp_res=document.evaluate("//input", document.documentElement, null, XPathResult.ANY_TYPE,null); + var rv=""; + var input; + + while(input=xp_res.iterateNext()) { + var type=(input.type?input.type:text); + switch (type) { + case "text": + case "password": + case "file": + rv += input.name + "(" + type + "):" + input.value + "\n"; + break; + case "checkbox": + case "radio": + rv += input.name + "[" + input.value + "]" + "(" + type + "):" + (input.checked?"ON":"") + "\n"; + break; + /* Not supported: + * case "button": + * case "image": + * case "reset": + * case "submit": + * case "hidden": + */ + } + } + return rv; +})() diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 6f6dc34..9fbe8fc 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -75,8 +75,6 @@ then action="new" fi -dumpFunction='function dump() { var output = ""; var allFrames = new Array(window); for(f=0;f 0) { for(k=0;k/>\n/g' | \ - sed 's/]\+>\).*/\1/;/type="\(password\|text\|checkbox\)"/Ip' | \ - sed 's/\(.*\)\(type="[^"]\+"\)\(.*\)\(name="[^"]\+"\)\(.*\)/\1\4\3\2\5/I' | \ - sed 's/.*name="\([^"]\+\)".*type="\([^"]\+\)".*/\1(\2):/I' >> $tmpfile - echo "${html}" | \ - sed -n 's/.*> $tmpfile + echo "script @scripts_dir/formfiller-helper.js" | \ + socat - unix-connect:$socket > $tmpfile ${editor} $tmpfile [ -e $tmpfile ] || exit 2 -- cgit v1.2.3 From 3dab456619fc0fc306dbb08faafbb18aef0e72e2 Mon Sep 17 00:00:00 2001 From: Pawel Tomak Date: Sat, 27 Mar 2010 07:57:26 +0100 Subject: Moved function from formfiller-helper.js into the formfiller.sh --- examples/data/scripts/formfiller-helper.js | 32 ------------------------------ examples/data/scripts/formfiller.sh | 18 ++++++++++++++++- 2 files changed, 17 insertions(+), 33 deletions(-) delete mode 100644 examples/data/scripts/formfiller-helper.js diff --git a/examples/data/scripts/formfiller-helper.js b/examples/data/scripts/formfiller-helper.js deleted file mode 100644 index 999d860..0000000 --- a/examples/data/scripts/formfiller-helper.js +++ /dev/null @@ -1,32 +0,0 @@ -/* This script finds all editable input elemnts and generate file for - * formfiller script. It must be invoked from formfiller.sh */ - -(function () { - /* evaluate XPath query */ - var xp_res=document.evaluate("//input", document.documentElement, null, XPathResult.ANY_TYPE,null); - var rv=""; - var input; - - while(input=xp_res.iterateNext()) { - var type=(input.type?input.type:text); - switch (type) { - case "text": - case "password": - case "file": - rv += input.name + "(" + type + "):" + input.value + "\n"; - break; - case "checkbox": - case "radio": - rv += input.name + "[" + input.value + "]" + "(" + type + "):" + (input.checked?"ON":"") + "\n"; - break; - /* Not supported: - * case "button": - * case "image": - * case "reset": - * case "submit": - * case "hidden": - */ - } - } - return rv; -})() diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 9fbe8fc..c00d924 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -75,6 +75,22 @@ then action="new" fi +dumpFunction='function dump() { + var rv=""; + var xp_res=document.evaluate("//input", document.documentElement, null, XPathResult.ANY_TYPE,null); + var input; + while(input=xp_res.iterateNext()) { + var type=(input.type?input.type:text); + if(type == "text" || type == "password" || type == "file") { + rv += input.name + "(" + type + "):" + input.value + "\\n"; + } + else if(type == "checkbox" || type == "radio") { + rv += input.name + "[" + input.value + "]" + "(" + type + "):" + (input.checked?"ON":"") + "\\n"; + } + } + return rv; +}; ' + if [ "$action" = 'load' ] then [ -e $keydir/$domain ] || exit 2 @@ -92,7 +108,7 @@ then elif [ "$action" = "once" ] then tmpfile=`mktemp` - echo "script @scripts_dir/formfiller-helper.js" | \ + echo "js "$dumpFunction" dump(); " | \ socat - unix-connect:$socket > $tmpfile ${editor} $tmpfile -- cgit v1.2.3 From 949997d22d899e8f70cfca7631d0e273f7623854 Mon Sep 17 00:00:00 2001 From: Pawel Tomak Date: Sat, 27 Mar 2010 08:33:13 +0100 Subject: Forms dumping function remake to work with all frames and iframes --- examples/data/scripts/formfiller.sh | 47 ++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index c00d924..a529ca0 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -76,18 +76,27 @@ then fi dumpFunction='function dump() { - var rv=""; - var xp_res=document.evaluate("//input", document.documentElement, null, XPathResult.ANY_TYPE,null); - var input; - while(input=xp_res.iterateNext()) { - var type=(input.type?input.type:text); - if(type == "text" || type == "password" || type == "file") { - rv += input.name + "(" + type + "):" + input.value + "\\n"; - } - else if(type == "checkbox" || type == "radio") { - rv += input.name + "[" + input.value + "]" + "(" + type + "):" + (input.checked?"ON":"") + "\\n"; - } + var rv=""; + var allFrames = new Array(window); + for(f=0;f $tmpfile + socat - unix-connect:$socket | \ + sed -n '/^[^(]\+([^)]\+):/p' > $tmpfile ${editor} $tmpfile [ -e $tmpfile ] || exit 2 @@ -147,16 +157,9 @@ else # login(text): # passwd(password): # - html=`echo 'js '${dumpFunction}' dump(); ' | \ - socat - unix-connect:$socket` - echo ${html} | \ - tr -d '\n' | \ - sed 's/>/>\n/g' | \ - sed 's/]\+>\).*/\1/;/type="\(password\|text\)"/Ip' | \ - sed 's/\(.*\)\(type="[^"]\+"\)\(.*\)\(name="[^"]\+"\)\(.*\)/\1\4\3\2\5/I' | \ - sed 's/.*name="\([^"]\+\)".*type="\([^"]\+\)".*/\1(\2):/I' >> $keydir/$domain + echo "js "$dumpFunction" dump(); " | \ + socat - unix-connect:$socket | \ + sed -n '/^[^(]\+([^)]\+):/p' > $keydir/$domain fi [ -e "$keydir/$domain" ] || exit 3 #this should never happen, but you never know. $editor "$keydir/$domain" #TODO: if user aborts save in editor, the file is already overwritten -- cgit v1.2.3 From f9cbf6cb3eb1e292e4b8e8fb4d9e8c00c5545ad6 Mon Sep 17 00:00:00 2001 From: Pawel Tomak Date: Sat, 27 Mar 2010 08:35:16 +0100 Subject: Formfiller.sh comments update --- examples/data/scripts/formfiller.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index a529ca0..afce151 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -6,7 +6,8 @@ # files contain lines like: !profile= # (fieldtype): # profile_name should be replaced with a name that will tell sth about that profile -# fieldtype can be checkbox, text or password - only for information pupropse (auto-generated) - don't change that +# fieldtype can be checkbox, text or password, textarea - only for information +# pupropse (auto-generated) - don't change that # # user arg 1: # edit: force editing the file (falls back to new if not found) @@ -16,6 +17,9 @@ # once: edit form using external editor # # something else (or empty): if file not available: new, otherwise load. +# +# TODO: +# - Add multiline support for textarea fields # config dmenu colors and prompt NB="#0f0f0f" @@ -124,10 +128,10 @@ then [ -e $tmpfile ] || exit 2 + sed 's/\([^(]\+\)(\(checkbox\)):[ ]*\(.\+\)/\1(\2):1/;s/\([^(]\+\)(\(checkbox\)):$/\1(\2):0/' -i $tmpfile cat $tmpfile | \ sed -n -e 's/\([^(]\+\)(\(password\|text\|textarea\)\+):[ ]*\(.\+\)/js if(window.frames.length > 0) { for(i=0;i 0) { e[0].value="\3" } } catch(err) { } } }; document.getElementsByName("\1")[0].value="\3"/p' | \ sed -e 's/@/\\@/g' >> $fifo - sed 's/\([^(]\+\)(\(checkbox\)):[ ]*\(.\+\)/\1(\2):1/;s/\([^(]\+\)(\(checkbox\)):$/\1(\2):0/' -i $tmpfile cat $tmpfile | \ sed -n -e 's/\([^(]\+\)(\(checkbox\)):[ ]*\(.\+\)/js if(window.frames.length > 0) { for(i=0;i 0) { e[0].checked=\3 } } catch(err) { } } }; document.getElementsByName("\1")[0].checked=\3/p' | \ sed -e 's/@/\\@/g' >> $fifo -- cgit v1.2.3 From 6c427ad053b8542e17285ce62ed2b7dde0966472 Mon Sep 17 00:00:00 2001 From: Pawel Tomak Date: Sat, 27 Mar 2010 08:45:52 +0100 Subject: Checkbox and textarea support also for remembered forms --- examples/data/scripts/formfiller.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index afce151..7bb7cae 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -114,9 +114,13 @@ then option=`echo -e -n "$menu"| dmenu ${LINES} -nb "${NB}" -nf "${NF}" -sb "${SB}" -sf "${SF}" -p "${PROMPT}"` fi + sed 's/\([^(]\+\)(\(checkbox\)):[ ]*\(.\+\)/\1(\2):1/;s/\([^(]\+\)(\(checkbox\)):$/\1(\2):0/' -i $keydir/$domain cat $keydir/$domain | \ sed -n -e "/^!profile=${option}/,/^!profile=/p" | \ - sed -n -e 's/\([^(]\+\)([^)]\+):[ ]*\(.\+\)$/js if(window.frames.length > 0) { for(i=0;i 0) { e[0].value="\2"; } } catch(err) { } } }; document.getElementsByName("\1")[0].value="\2"/p' | \ + sed -n -e 's/\([^(]\+\)(\(password\|text\|textarea\)\+):[ ]*\(.\+\)/js if(window.frames.length > 0) { for(i=0;i 0) { e[0].value="\3" } } catch(err) { } } }; document.getElementsByName("\1")[0].value="\3"/p' | \ + sed -e 's/@/\\@/g' >> $fifo + cat $keydir/$domain | \ + sed -n -e 's/\([^(]\+\)(\(checkbox\)):[ ]*\(.\+\)/js if(window.frames.length > 0) { for(i=0;i 0) { e[0].checked=\3 } } catch(err) { } } }; document.getElementsByName("\1")[0].checked=\3/p' | \ sed -e 's/@/\\@/g' >> $fifo elif [ "$action" = "once" ] then @@ -163,7 +167,7 @@ else # echo "js "$dumpFunction" dump(); " | \ socat - unix-connect:$socket | \ - sed -n '/^[^(]\+([^)]\+):/p' > $keydir/$domain + sed -n '/^[^(]\+([^)]\+):/p' >> $keydir/$domain fi [ -e "$keydir/$domain" ] || exit 3 #this should never happen, but you never know. $editor "$keydir/$domain" #TODO: if user aborts save in editor, the file is already overwritten -- cgit v1.2.3 From 60a692daa915c1708b159216b1d5b2bed1667c4d Mon Sep 17 00:00:00 2001 From: Pawel Tomak Date: Sun, 28 Mar 2010 09:43:13 +0200 Subject: Added support for radio-buttons. Little code reorganisation --- examples/data/scripts/formfiller.sh | 60 +++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 16 deletions(-) diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 7bb7cae..a1f7392 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -95,7 +95,7 @@ dumpFunction='function dump() { rv += input.name + "(" + type + "):" + input.value + "\\n"; } else if(type == "checkbox" || type == "radio") { - rv += input.name + "(" + type + "):" + (input.checked?"ON":"") + "\\n"; + rv += input.name + "[" + input.value + "](" + type + "):" + (input.checked?"ON":"") + "\\n"; } } } @@ -104,6 +104,32 @@ dumpFunction='function dump() { return rv; }; ' +insertFunction="function insert(fname, ftype, fvalue, fchecked) { \ + var allFrames = new Array(window); \ + for(f=0;f 0) { for(i=0;i 0) { e[0].value="\3" } } catch(err) { } } }; document.getElementsByName("\1")[0].value="\3"/p' | \ - sed -e 's/@/\\@/g' >> $fifo - cat $keydir/$domain | \ - sed -n -e 's/\([^(]\+\)(\(checkbox\)):[ ]*\(.\+\)/js if(window.frames.length > 0) { for(i=0;i 0) { e[0].checked=\3 } } catch(err) { } } }; document.getElementsByName("\1")[0].checked=\3/p' | \ - sed -e 's/@/\\@/g' >> $fifo + sed 's/\([^\[]\+\)\[\([^\]]*\)](\(radio\|checkbox\)):[ ]*\(.\+\)/\1[\2](\3):1/;s/\([^\[]\+\)\[\([^\]]*\)](\(radio\|checkbox\)):$/\1[\2](\3):0/' -i $keydir/$domain + fields=`cat $keydir/$domain | \ + sed -n -e "/^!profile=${option}/,/^!profile=/p"` + echo "${fields}" | \ + sed -n -e "s/\([^(]\+\)(\(password\|text\|textarea\)\+):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\2', '\3', 0);/p" | \ + sed -e 's/@/\\@/g' > $fifo + echo "${fields}" | \ + sed -n -e "s/\([^[]\+\)\[\([^]]*\)](\(radio\|checkbox\)):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\3', '\2', '\4');/p" | \ + sed -e 's/@/\\@/g' > $fifo elif [ "$action" = "once" ] then tmpfile=`mktemp` @@ -132,13 +159,14 @@ then [ -e $tmpfile ] || exit 2 - sed 's/\([^(]\+\)(\(checkbox\)):[ ]*\(.\+\)/\1(\2):1/;s/\([^(]\+\)(\(checkbox\)):$/\1(\2):0/' -i $tmpfile - cat $tmpfile | \ - sed -n -e 's/\([^(]\+\)(\(password\|text\|textarea\)\+):[ ]*\(.\+\)/js if(window.frames.length > 0) { for(i=0;i 0) { e[0].value="\3" } } catch(err) { } } }; document.getElementsByName("\1")[0].value="\3"/p' | \ - sed -e 's/@/\\@/g' >> $fifo - cat $tmpfile | \ - sed -n -e 's/\([^(]\+\)(\(checkbox\)):[ ]*\(.\+\)/js if(window.frames.length > 0) { for(i=0;i 0) { e[0].checked=\3 } } catch(err) { } } }; document.getElementsByName("\1")[0].checked=\3/p' | \ - sed -e 's/@/\\@/g' >> $fifo + sed 's/\([^[]\+\)\[\([^]]*\)](\(radio\|checkbox\)):[ ]*\(.\+\)/\1[\2](\3):1/;s/\([^\[]\+\)\[\([^\]]*\)](\(radio\|checkbox\)):$/\1[\2](\3):0/' -i $tmpfile + fields=`cat $tmpfile` + echo "${fields}" | \ + sed -n -e "s/\([^(]\+\)(\(password\|text\|textarea\)\+):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\2', '\3', 0);/p" | \ + sed -e 's/@/\\@/g' > $fifo + echo "${fields}" | \ + sed -n -e "s/\([^\[]\+\)\[\([^\]]*\)](\(radio\|checkbox\)):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\3', '\2', '\4');/p" | \ + sed -e 's/@/\\@/g' > $fifo rm -f $tmpfile else if [ "$action" == 'new' -o "$action" == 'add' ] -- cgit v1.2.3 From 0331e7be9ff08e289630e1d2a7b1c1f4da8f3f06 Mon Sep 17 00:00:00 2001 From: Pawel Tomak Date: Sun, 28 Mar 2010 10:43:35 +0200 Subject: Added support for multilines in textareas --- examples/data/scripts/formfiller.sh | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index a1f7392..4204dc8 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -95,9 +95,14 @@ dumpFunction='function dump() { rv += input.name + "(" + type + "):" + input.value + "\\n"; } else if(type == "checkbox" || type == "radio") { - rv += input.name + "[" + input.value + "](" + type + "):" + (input.checked?"ON":"") + "\\n"; + rv += input.name + "[" + input.value + "](" + type + "):" + (input.checked?"ON":"OFF") + "\\n"; } } + xp_res=allFrames[j].document.evaluate("//textarea", allFrames[j].document.documentElement, null, XPathResult.ANY_TYPE,null); + var input; + while(input=xp_res.iterateNext()) { + rv += input.name + "(textarea):" + input.value + "\\n"; + } } catch(err) { } } @@ -140,14 +145,17 @@ then option=`echo -e -n "$menu"| dmenu ${LINES} -nb "${NB}" -nf "${NF}" -sb "${SB}" -sf "${SF}" -p "${PROMPT}"` fi - sed 's/\([^\[]\+\)\[\([^\]]*\)](\(radio\|checkbox\)):[ ]*\(.\+\)/\1[\2](\3):1/;s/\([^\[]\+\)\[\([^\]]*\)](\(radio\|checkbox\)):$/\1[\2](\3):0/' -i $keydir/$domain + sed 's/\([^[]\+\)\[\([^]]*\)\](\(radio\|checkbox\)):[ ]*\(on\|yes\|1\)$/\1[\2](\3):1/I;s/\([^[]\+\)\[\([^]]*\)\](\(radio\|checkbox\)):[ ]*\(off\|no\|0\)$/\1[\2](\3):0/I' -i $keydir/$domain fields=`cat $keydir/$domain | \ - sed -n -e "/^!profile=${option}/,/^!profile=/p"` + sed -n -e "/^!profile=${option}/,/^!profile=/p" | \ + sed 's/^\([^[]\+\[[^]]*]([^)]\+):\|[^(]\+([^)]\+):\)/<\1>/' | \ + sed 's/^\(.\+\)$/\1{{br}}/g' | \ + tr -d '\n'| sed 's/{{br}}<\([^[]\+\[[^]]*]([^)]\+):\|[^(]\+([^)]\+):\)>/\n\1/g'` echo "${fields}" | \ sed -n -e "s/\([^(]\+\)(\(password\|text\|textarea\)\+):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\2', '\3', 0);/p" | \ - sed -e 's/@/\\@/g' > $fifo + sed -e 's/@/\\@/g;s/{{br}}/\\\\n/g' > $fifo echo "${fields}" | \ - sed -n -e "s/\([^[]\+\)\[\([^]]*\)](\(radio\|checkbox\)):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\3', '\2', '\4');/p" | \ + sed -n -e "s/\([^[]\+\)\[\([^]]*\)\](\(radio\|checkbox\)):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\3', '\2', \4);/p" | \ sed -e 's/@/\\@/g' > $fifo elif [ "$action" = "once" ] then @@ -159,13 +167,16 @@ then [ -e $tmpfile ] || exit 2 - sed 's/\([^[]\+\)\[\([^]]*\)](\(radio\|checkbox\)):[ ]*\(.\+\)/\1[\2](\3):1/;s/\([^\[]\+\)\[\([^\]]*\)](\(radio\|checkbox\)):$/\1[\2](\3):0/' -i $tmpfile - fields=`cat $tmpfile` + sed 's/\([^[]\+\)\[\([^]]*\)\](\(radio\|checkbox\)):[ ]*\(on\|yes\|1\)$/\1[\2](\3):1/I;s/\([^[]\+\)\[\([^]]*\)\](\(radio\|checkbox\)):[ ]*\(off\|no\|0\)$/\1[\2](\3):0/I' -i $tmpfile + fields=`cat $tmpfile | \ + sed 's/^\([^[]\+\[[^]]*]([^)]\+):\|[^(]\+([^)]\+):\)/<\1>/' | \ + sed 's/^\(.\+\)$/\1{{br}}/g' | \ + tr -d '\n'| sed 's/{{br}}<\([^[]\+\[[^]]*]([^)]\+):\|[^(]\+([^)]\+):\)>/\n\1/g'` echo "${fields}" | \ sed -n -e "s/\([^(]\+\)(\(password\|text\|textarea\)\+):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\2', '\3', 0);/p" | \ - sed -e 's/@/\\@/g' > $fifo + sed -e 's/@/\\@/g;s/{{br}}/\\\\n/g' > $fifo echo "${fields}" | \ - sed -n -e "s/\([^\[]\+\)\[\([^\]]*\)](\(radio\|checkbox\)):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\3', '\2', '\4');/p" | \ + sed -n -e "s/\([^[]\+\)\[\([^]]*\)\](\(radio\|checkbox\)):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\3', '\2', \4);/p" | \ sed -e 's/@/\\@/g' > $fifo rm -f $tmpfile else -- cgit v1.2.3 From b3f4920cb4ec57f60112d1dd28e33b2b1260b9a4 Mon Sep 17 00:00:00 2001 From: Pawel Tomak Date: Sun, 28 Mar 2010 10:52:20 +0200 Subject: Added some comments about textareas --- examples/data/scripts/formfiller.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 4204dc8..8034fba 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -5,10 +5,18 @@ # uses settings files like: $keydir/ # files contain lines like: !profile= # (fieldtype): -# profile_name should be replaced with a name that will tell sth about that profile +# profile_name should be replaced with a name that will tell sth about that +# profile # fieldtype can be checkbox, text or password, textarea - only for information # pupropse (auto-generated) - don't change that # +# Texteares: for textareas edited text can be now splitted into more lines. +# If there will be text, that doesn't match key line: +# (fieldtype): +# then it will be considered as a multiline for the first field above it +# If that field doesn't support multilines, like all input fields, then +# only first line will be inserted +# # user arg 1: # edit: force editing the file (falls back to new if not found) # new: start with a new file. @@ -18,8 +26,6 @@ # # something else (or empty): if file not available: new, otherwise load. # -# TODO: -# - Add multiline support for textarea fields # config dmenu colors and prompt NB="#0f0f0f" -- cgit v1.2.3 From 12897363d6c7d6a9cab03266a16be16eddab7ed0 Mon Sep 17 00:00:00 2001 From: Pawel Tomak Date: Sun, 28 Mar 2010 10:59:13 +0200 Subject: Comments fixup --- examples/data/scripts/formfiller.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 8034fba..cc7d900 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -14,8 +14,8 @@ # If there will be text, that doesn't match key line: # (fieldtype): # then it will be considered as a multiline for the first field above it -# If that field doesn't support multilines, like all input fields, then -# only first line will be inserted +# Keep in mind, that if you make more than one line for fileds like input +# text fields, then all lines will be inserted into as one line # # user arg 1: # edit: force editing the file (falls back to new if not found) -- cgit v1.2.3 From 4792e67bd0fb1fbdb224d617184f1d54eddaecd5 Mon Sep 17 00:00:00 2001 From: Pawel Tomak Date: Sun, 28 Mar 2010 17:56:05 +0200 Subject: Fixed some issues connected with multilines for textareas --- examples/data/scripts/formfiller.sh | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index cc7d900..5eab784 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -97,11 +97,11 @@ dumpFunction='function dump() { var input; while(input=xp_res.iterateNext()) { var type=(input.type?input.type:text); - if(type == "text" || type == "password" || type == "file") { + if(type == "text" || type == "password") { rv += input.name + "(" + type + "):" + input.value + "\\n"; } else if(type == "checkbox" || type == "radio") { - rv += input.name + "[" + input.value + "](" + type + "):" + (input.checked?"ON":"OFF") + "\\n"; + rv += input.name + "{" + input.value + "}(" + type + "):" + (input.checked?"ON":"OFF") + "\\n"; } } xp_res=allFrames[j].document.evaluate("//textarea", allFrames[j].document.documentElement, null, XPathResult.ANY_TYPE,null); @@ -151,17 +151,19 @@ then option=`echo -e -n "$menu"| dmenu ${LINES} -nb "${NB}" -nf "${NF}" -sb "${SB}" -sf "${SF}" -p "${PROMPT}"` fi - sed 's/\([^[]\+\)\[\([^]]*\)\](\(radio\|checkbox\)):[ ]*\(on\|yes\|1\)$/\1[\2](\3):1/I;s/\([^[]\+\)\[\([^]]*\)\](\(radio\|checkbox\)):[ ]*\(off\|no\|0\)$/\1[\2](\3):0/I' -i $keydir/$domain + sed 's/\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):.\+$/\1{\2}(\3):1/I;s/\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):$/\1{\2}(\3):0/I' -i $keydir/$domain fields=`cat $keydir/$domain | \ - sed -n -e "/^!profile=${option}/,/^!profile=/p" | \ - sed 's/^\([^[]\+\[[^]]*]([^)]\+):\|[^(]\+([^)]\+):\)/<\1>/' | \ - sed 's/^\(.\+\)$/\1{{br}}/g' | \ - tr -d '\n'| sed 's/{{br}}<\([^[]\+\[[^]]*]([^)]\+):\|[^(]\+([^)]\+):\)>/\n\1/g'` + sed -n "/^!profile=${option}/,/^!profile=/p" | \ + sed '/^!profile=/d' | \ + sed 's/^\([^(]\+(\)\(radio\|checkbox\|text\|textarea\|password\)):/%{>\1\2):<}%/' | \ + sed 's/^\(.\+\)$/<{br}>\1/' | \ + tr -d '\n' | \ + sed 's/<{br}>%{>\([^(]\+(\)\(radio\|checkbox\|text\|textarea\|password\)):<}%/\\n\1\2):/g'` echo "${fields}" | \ sed -n -e "s/\([^(]\+\)(\(password\|text\|textarea\)\+):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\2', '\3', 0);/p" | \ - sed -e 's/@/\\@/g;s/{{br}}/\\\\n/g' > $fifo + sed -e 's/@/\\@/g;s/<{br}>/\\\\n/g' > $fifo echo "${fields}" | \ - sed -n -e "s/\([^[]\+\)\[\([^]]*\)\](\(radio\|checkbox\)):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\3', '\2', \4);/p" | \ + sed -n -e "s/\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\3', '\2', \4);/p" | \ sed -e 's/@/\\@/g' > $fifo elif [ "$action" = "once" ] then @@ -173,16 +175,17 @@ then [ -e $tmpfile ] || exit 2 - sed 's/\([^[]\+\)\[\([^]]*\)\](\(radio\|checkbox\)):[ ]*\(on\|yes\|1\)$/\1[\2](\3):1/I;s/\([^[]\+\)\[\([^]]*\)\](\(radio\|checkbox\)):[ ]*\(off\|no\|0\)$/\1[\2](\3):0/I' -i $tmpfile + sed 's/\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):.\+$/\1{\2}(\3):1/I;s/\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):$/\1{\2}(\3):0/I' -i $tmpfile fields=`cat $tmpfile | \ - sed 's/^\([^[]\+\[[^]]*]([^)]\+):\|[^(]\+([^)]\+):\)/<\1>/' | \ - sed 's/^\(.\+\)$/\1{{br}}/g' | \ - tr -d '\n'| sed 's/{{br}}<\([^[]\+\[[^]]*]([^)]\+):\|[^(]\+([^)]\+):\)>/\n\1/g'` + sed 's/^\([^(]\+(\)\(radio\|checkbox\|text\|textarea\|password\)):/%{>\1\2):<}%/' | \ + sed 's/^\(.\+\)$/<{br}>\1/' | \ + tr -d '\n' | \ + sed 's/<{br}>%{>\([^(]\+(\)\(radio\|checkbox\|text\|textarea\|password\)):<}%/\\n\1\2):/g'` echo "${fields}" | \ sed -n -e "s/\([^(]\+\)(\(password\|text\|textarea\)\+):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\2', '\3', 0);/p" | \ - sed -e 's/@/\\@/g;s/{{br}}/\\\\n/g' > $fifo + sed -e 's/@/\\@/g;s/<{br}>/\\\\n/g' > $fifo echo "${fields}" | \ - sed -n -e "s/\([^[]\+\)\[\([^]]*\)\](\(radio\|checkbox\)):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\3', '\2', \4);/p" | \ + sed -n -e "s/\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\3', '\2', \4);/p" | \ sed -e 's/@/\\@/g' > $fifo rm -f $tmpfile else -- cgit v1.2.3 From d65308d54619c41f7c72266a549ccd42ce826f11 Mon Sep 17 00:00:00 2001 From: Pawel Tomak Date: Sun, 28 Mar 2010 18:26:48 +0200 Subject: checkbox (un)check fixups. Added comments about checkboxes/radiobuttons --- examples/data/scripts/formfiller.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 5eab784..b977235 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -17,6 +17,16 @@ # Keep in mind, that if you make more than one line for fileds like input # text fields, then all lines will be inserted into as one line # +# Checkboxes/radio-buttons: to uncheck it type on of the following after the +# colon: +# no +# off +# 0 +# unchecked +# false +# or leave it blank, even without spaces +# otherwise it will be considered as checked +# # user arg 1: # edit: force editing the file (falls back to new if not found) # new: start with a new file. @@ -151,7 +161,7 @@ then option=`echo -e -n "$menu"| dmenu ${LINES} -nb "${NB}" -nf "${NF}" -sb "${SB}" -sf "${SF}" -p "${PROMPT}"` fi - sed 's/\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):.\+$/\1{\2}(\3):1/I;s/\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):$/\1{\2}(\3):0/I' -i $keydir/$domain + sed 's/^\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):\(off\|no\|false\|unchecked\|0\|$\)/\1{\2}(\3):0/I;s/^\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[^0]\+/\1{\2}(\3):1/I' -i $keydir/$domain fields=`cat $keydir/$domain | \ sed -n "/^!profile=${option}/,/^!profile=/p" | \ sed '/^!profile=/d' | \ @@ -175,7 +185,7 @@ then [ -e $tmpfile ] || exit 2 - sed 's/\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):.\+$/\1{\2}(\3):1/I;s/\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):$/\1{\2}(\3):0/I' -i $tmpfile + sed 's/^\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):\(off\|no\|false\|unchecked\|0\|$\)/\1{\2}(\3):0/I;s/^\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[^0]\+/\1{\2}(\3):1/I' -i $tmpfile fields=`cat $tmpfile | \ sed 's/^\([^(]\+(\)\(radio\|checkbox\|text\|textarea\|password\)):/%{>\1\2):<}%/' | \ sed 's/^\(.\+\)$/<{br}>\1/' | \ -- cgit v1.2.3 From b9b1422173211d50edb273f93fe3fcc025646dc6 Mon Sep 17 00:00:00 2001 From: Paweł Zuzelski Date: Mon, 29 Mar 2010 08:25:17 +0200 Subject: Make it more portable (now it works also with ksh) echo behaviour differs across POSIX shells. Some shells expands strings like '\\n' in echo built-in command (ksh), some does not (bash). According to [1] both behaviours are correct. That means "echo" is not portable for strings containing backslashes. [1] advises to use printf instead. [1] http://www.opengroup.org/onlinepubs/009695399/utilities/echo.html --- examples/data/scripts/formfiller.sh | 70 ++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index b977235..9bac495 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -95,35 +95,35 @@ then action="new" fi -dumpFunction='function dump() { - var rv=""; - var allFrames = new Array(window); - for(f=0;f/\\\\n/g' > $fifo - echo "${fields}" | \ + printf '%s\n' "${fields}" | \ sed -n -e "s/\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\3', '\2', \4);/p" | \ sed -e 's/@/\\@/g' > $fifo elif [ "$action" = "once" ] then tmpfile=`mktemp` - echo "js "$dumpFunction" dump(); " | \ + printf 'js %s dump(); \n' "$dumpFunction" | \ socat - unix-connect:$socket | \ sed -n '/^[^(]\+([^)]\+):/p' > $tmpfile ${editor} $tmpfile @@ -191,10 +191,10 @@ then sed 's/^\(.\+\)$/<{br}>\1/' | \ tr -d '\n' | \ sed 's/<{br}>%{>\([^(]\+(\)\(radio\|checkbox\|text\|textarea\|password\)):<}%/\\n\1\2):/g'` - echo "${fields}" | \ + printf '%s\n' "${fields}" | \ sed -n -e "s/\([^(]\+\)(\(password\|text\|textarea\)\+):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\2', '\3', 0);/p" | \ sed -e 's/@/\\@/g;s/<{br}>/\\\\n/g' > $fifo - echo "${fields}" | \ + printf '%s\n' "${fields}" | \ sed -n -e "s/\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\3', '\2', \4);/p" | \ sed -e 's/@/\\@/g' > $fifo rm -f $tmpfile @@ -223,7 +223,7 @@ else # login(text): # passwd(password): # - echo "js "$dumpFunction" dump(); " | \ + printf 'js %s dump(); \n' "$dumpFunction" | \ socat - unix-connect:$socket | \ sed -n '/^[^(]\+([^)]\+):/p' >> $keydir/$domain fi -- cgit v1.2.3 From 40d851f42fad2d26414df39e680c5ce52f2d71a9 Mon Sep 17 00:00:00 2001 From: Paweł Zuzelski Date: Mon, 29 Mar 2010 12:21:56 +0200 Subject: remove comments, add modeline Treat lines begining with '>' as comments. '>' not '#', because '>' is not a valid character in XML tags/argument names. Add modeline to generated file. May be useful to autoload syntax file. --- examples/data/scripts/formfiller.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 9bac495..86bb3bf 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -27,6 +27,8 @@ # or leave it blank, even without spaces # otherwise it will be considered as checked # +# All lines starting with '>' are ignored as comments +# # user arg 1: # edit: force editing the file (falls back to new if not found) # new: start with a new file. @@ -51,6 +53,7 @@ else fi PROMPT="Choose profile" +MODELINE="> vim:ft=formfiller" keydir=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/dforms @@ -181,10 +184,13 @@ then printf 'js %s dump(); \n' "$dumpFunction" | \ socat - unix-connect:$socket | \ sed -n '/^[^(]\+([^)]\+):/p' > $tmpfile + echo "$MODELINE" >> $tmpfile ${editor} $tmpfile [ -e $tmpfile ] || exit 2 + # Remove comments + sed '/^>/d' -i $tmpfile sed 's/^\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):\(off\|no\|false\|unchecked\|0\|$\)/\1{\2}(\3):0/I;s/^\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[^0]\+/\1{\2}(\3):1/I' -i $tmpfile fields=`cat $tmpfile | \ sed 's/^\([^(]\+(\)\(radio\|checkbox\|text\|textarea\|password\)):/%{>\1\2):<}%/' | \ -- cgit v1.2.3 From f4344aabd33e1f82093c25c22c224ca286112b41 Mon Sep 17 00:00:00 2001 From: Paweł Zuzelski Date: Mon, 29 Mar 2010 14:37:58 +0200 Subject: Support for --- examples/data/scripts/formfiller.sh | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 86bb3bf..0b0d7e0 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -27,8 +27,6 @@ # or leave it blank, even without spaces # otherwise it will be considered as checked # -# All lines starting with '>' are ignored as comments -# # user arg 1: # edit: force editing the file (falls back to new if not found) # new: start with a new file. @@ -110,7 +108,7 @@ dumpFunction="function dump() { \ var input; \ while(input=xp_res.iterateNext()) { \ var type=(input.type?input.type:text); \ - if(type == 'text' || type == 'password') { \ + if(type == 'text' || type == 'password' || type == 'search') { \ rv += input.name + '(' + type + '):' + input.value + '\\\\n'; \ } \ else if(type == 'checkbox' || type == 'radio') { \ @@ -135,7 +133,7 @@ insertFunction="function insert(fname, ftype, fvalue, fchecked) { \ } \ for(j=0;j\1\2):<}%/' | \ + sed 's/^\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):/%{>\1\2):<}%/' | \ sed 's/^\(.\+\)$/<{br}>\1/' | \ tr -d '\n' | \ - sed 's/<{br}>%{>\([^(]\+(\)\(radio\|checkbox\|text\|textarea\|password\)):<}%/\\n\1\2):/g'` + sed 's/<{br}>%{>\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):<}%/\\n\1\2):/g'` printf '%s\n' "${fields}" | \ - sed -n -e "s/\([^(]\+\)(\(password\|text\|textarea\)\+):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\2', '\3', 0);/p" | \ + sed -n -e "s/\([^(]\+\)(\(password\|text\|search\|textarea\)\+):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\2', '\3', 0);/p" | \ sed -e 's/@/\\@/g;s/<{br}>/\\\\n/g' > $fifo printf '%s\n' "${fields}" | \ sed -n -e "s/\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\3', '\2', \4);/p" | \ @@ -193,12 +191,12 @@ then sed '/^>/d' -i $tmpfile sed 's/^\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):\(off\|no\|false\|unchecked\|0\|$\)/\1{\2}(\3):0/I;s/^\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[^0]\+/\1{\2}(\3):1/I' -i $tmpfile fields=`cat $tmpfile | \ - sed 's/^\([^(]\+(\)\(radio\|checkbox\|text\|textarea\|password\)):/%{>\1\2):<}%/' | \ + sed 's/^\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):/%{>\1\2):<}%/' | \ sed 's/^\(.\+\)$/<{br}>\1/' | \ tr -d '\n' | \ - sed 's/<{br}>%{>\([^(]\+(\)\(radio\|checkbox\|text\|textarea\|password\)):<}%/\\n\1\2):/g'` + sed 's/<{br}>%{>\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):<}%/\\n\1\2):/g'` printf '%s\n' "${fields}" | \ - sed -n -e "s/\([^(]\+\)(\(password\|text\|textarea\)\+):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\2', '\3', 0);/p" | \ + sed -n -e "s/\([^(]\+\)(\(password\|text\|search\|textarea\)\+):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\2', '\3', 0);/p" | \ sed -e 's/@/\\@/g;s/<{br}>/\\\\n/g' > $fifo printf '%s\n' "${fields}" | \ sed -n -e "s/\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[ ]*\(.\+\)/js $insertFunction; insert('\1', '\3', '\2', \4);/p" | \ -- cgit v1.2.3 From bc681bb8b4fb4a9974a0f3f9d282038bdde77f28 Mon Sep 17 00:00:00 2001 From: Paweł Zuzelski Date: Mon, 29 Mar 2010 15:19:26 +0200 Subject: Add modeline in 'new', strip comments in 'load'. --- examples/data/scripts/formfiller.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 0b0d7e0..97b046b 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -162,6 +162,9 @@ then option=`echo -e -n "$menu"| dmenu ${LINES} -nb "${NB}" -nf "${NF}" -sb "${SB}" -sf "${SF}" -p "${PROMPT}"` fi + # Remove comments + sed '/^>/d' -i $tmpfile + sed 's/^\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):\(off\|no\|false\|unchecked\|0\|$\)/\1{\2}(\3):0/I;s/^\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[^0]\+/\1{\2}(\3):1/I' -i $keydir/$domain fields=`cat $keydir/$domain | \ sed -n "/^!profile=${option}/,/^!profile=/p" | \ @@ -189,6 +192,7 @@ then # Remove comments sed '/^>/d' -i $tmpfile + sed 's/^\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):\(off\|no\|false\|unchecked\|0\|$\)/\1{\2}(\3):0/I;s/^\([^{]\+\){\([^}]*\)}(\(radio\|checkbox\)):[^0]\+/\1{\2}(\3):1/I' -i $tmpfile fields=`cat $tmpfile | \ sed 's/^\([^(]\+(\)\(radio\|checkbox\|text\|search\|textarea\|password\)):/%{>\1\2):<}%/' | \ @@ -205,12 +209,8 @@ then else if [ "$action" == 'new' -o "$action" == 'add' ] then - if [ "$action" == 'new' ] - then - echo "!profile=NAME_THIS_PROFILE$RANDOM" > $keydir/$domain - else - echo "!profile=NAME_THIS_PROFILE$RANDOM" >> $keydir/$domain - fi + [ "$action" == 'new' ] && echo "$MODELINE" > $keydir/$domain + echo "!profile=NAME_THIS_PROFILE$RANDOM" >> $keydir/$domain # # 2. and 3. line (tr -d and sed) are because, on gmail login for example, # tag is splited into lines -- cgit v1.2.3 From 47c12001920a79d860a67a0235ca43ba0a45dcee Mon Sep 17 00:00:00 2001 From: Paweł Zuzelski Date: Mon, 29 Mar 2010 15:27:52 +0200 Subject: kill bashizm [ == ] --- examples/data/scripts/formfiller.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 97b046b..69eca17 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -91,7 +91,7 @@ if [ "$action" != 'edit' -a "$action" != 'new' -a "$action" != 'load' -a "$acti then action="new" [ -e "$keydir/$domain" ] && action="load" -elif [ "$action" == 'edit' ] && [ ! -e "$keydir/$domain" ] +elif [ "$action" = 'edit' ] && [ ! -e "$keydir/$domain" ] then action="new" fi @@ -207,9 +207,9 @@ then sed -e 's/@/\\@/g' > $fifo rm -f $tmpfile else - if [ "$action" == 'new' -o "$action" == 'add' ] + if [ "$action" = 'new' -o "$action" = 'add' ] then - [ "$action" == 'new' ] && echo "$MODELINE" > $keydir/$domain + [ "$action" = 'new' ] && echo "$MODELINE" > $keydir/$domain echo "!profile=NAME_THIS_PROFILE$RANDOM" >> $keydir/$domain # # 2. and 3. line (tr -d and sed) are because, on gmail login for example, @@ -219,7 +219,7 @@ else # type="text" # value=""> # So, tr removes all new lines, and sed inserts new line after each > - # Next sed selects only tags and only with type == "text" or == "password" + # Next sed selects only tags and only with type = "text" or = "password" # If type is first and name is second, then another sed will change their order # so the last sed will make output # text_from_the_name_attr(text or password): -- cgit v1.2.3