aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/configs/sampleconfig-dev9
-rw-r--r--examples/data/forms/bbs.archlinux.org5
-rwxr-xr-xexamples/scripts/formfiller.sh60
3 files changed, 74 insertions, 0 deletions
diff --git a/examples/configs/sampleconfig-dev b/examples/configs/sampleconfig-dev
index 0edaecd..a093574 100644
--- a/examples/configs/sampleconfig-dev
+++ b/examples/configs/sampleconfig-dev
@@ -112,6 +112,12 @@ bind S = js alert("hi");
bind XS = sh 'echo "act script alert (\\"This is sent by the shell via a fifo\\")" > "$4"'
+# this script allows you to configure (per domain) values to fill in form fields (eg login information) and to fill in these values automatically
+bind za = spawn ./examples/scripts/formfiller.sh
+bind ze = spawn ./examples/scripts/formfiller.sh edit
+bind zn = spawn ./examples/scripts/formfiller.sh new
+bind zl = spawn ./examples/scripts/formfiller.sh load
+
# we ship some javascripts to do keyboard based link hinting/following. (webkit does not have C DOM bindings yet)
# this is similar to how it works in vimperator (and konqueror)
# TODO: did we resolve: "no click() event for hyperlinks so no referrer set" ?
@@ -122,5 +128,8 @@ bind fl* = script ./examples/scripts/follow_Numbers.js %s
# using strings, not polished yet:
bind fL* = script ./examples/scripts/follow_Numbers_Strings.js %s
+# you can use this to disable all plugins
+set disable_plugins = 0
+
# "home" page if you will
set uri = uzbl.org
diff --git a/examples/data/forms/bbs.archlinux.org b/examples/data/forms/bbs.archlinux.org
new file mode 100644
index 0000000..73c1539
--- /dev/null
+++ b/examples/data/forms/bbs.archlinux.org
@@ -0,0 +1,5 @@
+form_sent:
+redirect_url:
+req_username: <your username>
+req_password: <password>
+login:
diff --git a/examples/scripts/formfiller.sh b/examples/scripts/formfiller.sh
new file mode 100755
index 0000000..45cde69
--- /dev/null
+++ b/examples/scripts/formfiller.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+# simple html form (eg for logins) filler (and manager) for uzbl.
+# uses settings files like: $keydir/<domain>
+# files contain lines like: <fieldname>: <value>
+
+
+# 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
+
+# something else (or empty): if file not available: new, otherwise load.
+
+[ -d /usr/share/uzbl/examples/data/forms ] && keydir=/usr/share/uzbl/examples/data/forms # you will probably get permission denied errors here.
+[ -d $XDG_DATA_HOME/uzbl/forms ] && keydir=$XDG_DATA_HOME/uzbl/forms
+[ -d ./examples/data/forms ] && keydir=./examples/data/forms #useful when developing
+[ -z "$keydir" ] && exit 1
+
+#editor=gvim
+editor='urxvt -e vim'
+
+config=$1; shift
+pid=$1; shift
+xid=$1; shift
+fifo=$1; shift
+socket=$1; shift
+url=$1; shift
+title=$1; shift
+action=$1
+
+[ -d $keydir ] || mkdir $keydir || exit 1
+
+if [ "$action" != 'edit' -a "$action" != 'new' -a "$action" != 'load' ]
+then
+ action=new
+ [[ -e $keydir/$domain ]] && action=load
+elif [ "$action" == 'edit' ] && [[ ! -e $keydir/$domain ]]
+then
+ action=new
+fi
+domain=$(echo $url | sed -re 's|(http\|https)+://([A-Za-z0-9\.]+)/.*|\2|')
+
+
+#regex='s|.*<input.*?name="([[:graph:]]+)".*?/>.*|\1: |p' # sscj's first version, does not work on http://wiki.archlinux.org/index.php?title=Special:UserLogin&returnto=Main_Page
+ regex='s|.*<input.*?name="([^"]*)".*|\1: |p' #works on arch wiki, but not on http://lists.uzbl.org/listinfo.cgi/uzbl-dev-uzbl.org TODO: improve
+
+
+if [ "$action" = 'load' ]
+then
+ [[ -e $keydir/$domain ]] || exit 2
+ gawk -F': ' '{ print "act js document.getElementsByName(\"" $1 "\")[0].value = \"" $2 "\";"}' $keydir/$domain >> $fifo
+else
+ if [ "$action" == 'new' ]
+ then
+ curl "$url" | grep '<input' | sed -nre "$regex" > $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
+fi