Merge branch 'experimental' of git://github.com/DuClare/uzbl
authorRobert Manea <gotmor@gmail.com>
Sat, 23 May 2009 12:29:42 +0000 (14:29 +0200)
committerRobert Manea <gotmor@gmail.com>
Sat, 23 May 2009 12:29:42 +0000 (14:29 +0200)
AUTHORS
Makefile
docs/COMMUNITY [new file with mode: 0644]
docs/TODO
docs/config-syntax
docs/url-editing
docs/widgets [deleted file]
examples/configs/sampleconfig-dev
examples/data/forms/bbs.archlinux.org [new file with mode: 0644]
examples/scripts/formfiller.sh [new file with mode: 0755]
uzbl.c

diff --git a/AUTHORS b/AUTHORS
index 66bd93e..ca9e102 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -4,7 +4,7 @@ Developers:
     Dusan Popovic (dusanx)
     Michael Walker (Barrucadu) <email is mike AT barrucadu.co.uk>
     Přemysl Hrubý, (anydot) <email is dfenze AT gmail.com>
-    Robert Manea (robm)
+    Robert Manea (robm) <email is rob DOT manea AT gmail DOT com>
 
 Contributors:
     (DuClare) - Various improvements
@@ -15,6 +15,7 @@ Contributors:
     Damien Leon - misc
     Peter Suschlik - backwards searching
     (salinasv) - move some variables to heap
+    Sylvester Johansson (scj) - original form filler script
 
 Originaly based on http://trac.webkit.org/browser/trunk/WebKitTools/GtkLauncher/main.c
 Which is  copyrighted:
index fe6f73a..d158a9b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-CPPFLAGS=$(shell pkg-config --cflags gtk+-2.0 webkit-1.0) -ggdb -Wall -W -DARCH="\"$(shell uname -m)\"" -DCOMMIT="\"$(shell git log | head -n1 | sed "s/.* //")\""
+CPPFLAGS=$(shell pkg-config --cflags gtk+-2.0 webkit-1.0) -ggdb -Wall -W -DARCH="\"$(shell uname -m)\"" -DG_ERRORCHECK_MUTEXES -DCOMMIT="\"$(shell git log | head -n1 | sed "s/.* //")\""
 LDFLAGS=$(shell pkg-config --libs gtk+-2.0 webkit-1.0)
 all: uzbl uzblctrl
 
diff --git a/docs/COMMUNITY b/docs/COMMUNITY
new file mode 100644 (file)
index 0000000..a20d25d
--- /dev/null
@@ -0,0 +1,33 @@
+COMMUNITY
+------
+
+### Mailing list
+
+* Address: uzbl-dev@lists.uzbl.org
+* [Page](http://lists.uzbl.org/listinfo.cgi/uzbl-dev-uzbl.org)
+* [Archives](http://lists.uzbl.org/pipermail/uzbl-dev-uzbl.org/)
+
+### IRC
+
+* `#uzbl` on irc.freenode.net
+
+### Website
+
+* http://www.uzbl.org
+
+### Bugtracker
+
+* http://www.uzbl.org/bugs/
+
+### Code repositories
+Remember: dieter/master = official stable branch.
+
+* http://github.com/Dieterbe/uzbl/
+* http://github.com/anydot/uzbl/
+* http://github.com/Barrucadu/uzbl/
+* http://github.com/dusanx/uzbl/
+* http://github.com/robm/uzbl/
+
+There are more contributors who have forks.  See:
+
+[Uzbl Network graph](http://github.com/Dieterbe/uzbl/network)
index 0b0e035..0bd238b 100644 (file)
--- a/docs/TODO
+++ b/docs/TODO
@@ -41,6 +41,7 @@ More or less in order of importance/urgency
 * regex style page searching? so you can do 'or' and 'and' things. flags like case sensitive etc.
 * check for real command name, not just the first letter.
 * let users attach handlers to the most common events/signals in uzbl.
+  great use case: automatically calling formfiller for certain sites
 * write little script to open new urls with the urxvt url thing +document.
 
 SOMEDAY:
index 30cf91f..9894401 100644 (file)
@@ -1,42 +1,5 @@
-Configuration setting at startup and changing at runtime happens through one of these:
-- stdin at startup (TODO: see if we can keep listening while running) (write command to it + "\n")
-- fifo (write command to it + "\n")
-- socket (uzblctrl -s <file> -c <comand>
-
-Lines written to the above starting with '#' or being empty, are ignored.
-
-** Command syntax:
-commands can have no, one or 2 arguments.
-
-<command>[\t<arg1>[\t<arg2>]]
-
-The 'bind' command is a special command, where argument 1 is a keyboard character (combo) and argument 2 is a command as specified above.
-You can also use a '_' in the <chars> part to denote where you pass on whatever you want, which will be replaced into the specififed command whereever %s is mentioned
-
-** commands
-Commands where one of the arguments is "parameter" expect this arugment to be a valid variable identifier (eg uzbl.behave.status_format) 
-
-set              parameter value # make sure the value complies with the datatype.
-toggle           parameter    # expects parameter to be a gboolean. (eg status, insert_mode, ..)
-get              parameter
-bind             <chars> <command>
-script           <JS code to execute>
-script_file      <filename containing JS code to execute>
-back
-forward
-scroll_vert      <int>
-scroll_horz      <int>
-reload
-reload_ign_cache
-stop
-zoom_in
-zoom_out
-spawn            <filename for process to start asynchronously>
-exit
-search           <string>
-
-The 'set' command may do more then just set the variable. eg 'set uri' commands will also cause uzbl to navigate to the uri.
-
+here: design notes
+readme: end-user instructions
 
 
 Rationale. AKA "why not config files?"
@@ -53,4 +16,6 @@ issues
    - iterate over state structs and generate appropriate commands to bring an instance in this state.
      - plaintext :)
      - user editable
-     - also useful for saving state if we need to update/shutdown/..
\ No newline at end of file
+     - also useful for saving state if we need to update/shutdown/..
+   -> all of this is overkill. for now we just decided to live with the fact we pass on '--config' flags,
+      it's up to the user to tweak his setup so it works.
index 1059fc5..d8943fb 100644 (file)
@@ -5,3 +5,5 @@ Use cases:
 * edit current url or one from history/bookmarks: dmenu-vertical is relatively good for this, though it would be better if we had:
 - minimal editing helper key shortcuts (eg to go to beginning/end of input buffer, erase search string, undo)
 - copy/paste support
+
+* Though you can obviously type new urls and edit the current ones with the appropriate statusbar stuff/binds/xclip commands, this is sometimes enough.
\ No newline at end of file
diff --git a/docs/widgets b/docs/widgets
deleted file mode 100644 (file)
index dc7127a..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-
-* statusbar? (the bar you see in pretty much every gtk program at the
-* bottom. eg firefox)
-  consumes too much space (if always visible) for the little it is used.  (+
-* you can put only 1 message in it at a time!)
-  -> option 1: no statusbar at all. when hovering over a link (or pressing
-  -> key to preview the url without changing page) -> show url in tooltip on
-  -> page.
-  -> option 2: toggle visibility of statusbar on/off when hovering over a
-  -> link. since it's at the bottom I don't think it will disturb too much.
-* viewing progress/state of pageload?  most programs use statusbar for this.
-  -> option 1: titlebar can show a percentage when it's loading a new page.
-  -> option 2: toggle a statusbar everytime we start loading a new page.
-* uri bar -> yes, even though we can write stuff to the fifo, it can still
-* be convenient to change the url manually and stuff, so a widget in uzbl
-* itself is good.
-* tabs -> yes. you don't have to use them, but you can.
-* back/forward/.. buttons? -> no: use keyboard shortcuts.
-* searching in a page? not sure.. maybe we can abuse the statusbar for that
-* too.
-  eg toggle it on when the user wants to search for something and then do
-* searching in some vim-like fashion.
-  we don't need a gtk text entry widget, just a feedback display of what the
-* current command is.
-* scrollbar? no: use keyboard shortcuts.  we should however have some info
-* about the page length and where we are.
-  -> option 1: put a percentage in the window title
-  -> option 2: everytime you hit a key to change position, temporarily make
-  -> a statusbar visible and put the percentage in the statusbar.
-  what will we do with pages who are too wide? horizontal scrolling?
-all of the above goes in 1 bar at the top of the program. there should be a
-key to toggle visibility of it and one to toggle visibilety + focus on the
-entrybar at once.
index 5ea48dc..5e132f2 100644 (file)
@@ -113,6 +113,10 @@ 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 load predefined values into html forms. (eg login information)
+# if you have no config file yet, it will let you create settings easily.
+bind z = spawn ./examples/scripts/formfiller.sh
+
 # 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" ?
@@ -123,5 +127,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 (file)
index 0000000..73c1539
--- /dev/null
@@ -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 (executable)
index 0000000..e7ef3b5
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+# simple login form filler for uzbl.
+# put the form entry values you want to add (eg login information) in the file $keydir/<domain>
+# in the format <fieldname>: <value>
+# (these files can be automatically created for you by setting editor and triggering this script on a site without a config)
+
+[ -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
+
+[ -d $keydir ] || mkdir $keydir || exit 1
+
+domain=$(echo $url | sed -re 's|(http\|https)+://([A-Za-z0-9\.]+)/.*|\2|')
+if [[ -e $keydir/$domain ]]; then
+       gawk -F': ' '{ print "act js document.getElementsByName(\"" $1 "\")[0].value = \"" $2 "\";"}' $keydir/$domain >> $fifo
+else
+       curl "$url" | grep '<input' | sed -nre 's|.*<input.*?name="([[:graph:]]+)".*?/>.*|\1: |p' > $keydir/$domain
+       $editor $keydir/$domain
+fi
diff --git a/uzbl.c b/uzbl.c
index 28ff64f..bcbef83 100644 (file)
--- a/uzbl.c
+++ b/uzbl.c
@@ -745,7 +745,7 @@ setup_scanner() {
 }
 
 static gchar *
-expand_template(const char *template) {
+expand_template(const char *template, gboolean escape_markup) {
      if(!template) return NULL;
 
      GTokenType token = G_TOKEN_NONE;
@@ -761,11 +761,15 @@ expand_template(const char *template) {
              sym = (int)g_scanner_cur_value(uzbl.scan).v_symbol;
              switch(sym) {
                  case SYM_URI:
-                     buf = uzbl.state.uri?
-                         g_markup_printf_escaped("%s", uzbl.state.uri) :
-                         g_strdup("");
-                     g_string_append(ret, buf);
-                     g_free(buf);
+                     if(escape_markup) {
+                         buf = uzbl.state.uri?
+                             g_markup_printf_escaped("%s", uzbl.state.uri):g_strdup("");
+                         g_string_append(ret, buf);
+                         g_free(buf);
+                     }
+                     else
+                         g_string_append(ret, uzbl.state.uri?
+                                 uzbl.state.uri:g_strdup(""));
                      break;
                  case SYM_LOADPRGS:
                      buf = itos(uzbl.gui.sbar.load_progress);
@@ -778,39 +782,51 @@ expand_template(const char *template) {
                      g_free(buf);
                      break;
                  case SYM_TITLE:
-                     buf = uzbl.gui.main_title?
-                         g_markup_printf_escaped("%s", uzbl.gui.main_title) :
-                         g_strdup("");
-                     g_string_append(ret, buf);
-                     g_free(buf);
+                     if(escape_markup) {
+                         buf = uzbl.gui.main_title?
+                             g_markup_printf_escaped("%s", uzbl.gui.main_title):g_strdup("");
+                         g_string_append(ret, buf);
+                         g_free(buf);
+                     }
+                     else
+                         g_string_append(ret, uzbl.gui.main_title?
+                                 uzbl.gui.main_title:g_strdup(""));
                      break;
                  case SYM_SELECTED_URI:
-                     buf = uzbl.state.selected_url?
-                         g_markup_printf_escaped("%s", uzbl.state.selected_url) :
-                         g_strdup("");
-                     g_string_append(ret, buf);
-                     g_free(buf);
-                    break;
+                     if(escape_markup) {
+                         buf = uzbl.state.selected_url?
+                             g_markup_printf_escaped("%s", uzbl.state.selected_url):g_strdup("");
+                         g_string_append(ret, buf);
+                         g_free(buf);
+                     }
+                     else
+                         g_string_append(ret, uzbl.state.selected_url?
+                                 uzbl.state.selected_url:g_strdup(""));
+                     break;
                  case SYM_NAME:
                      buf = itos(uzbl.xwin);
                      g_string_append(ret,
-                         uzbl.state.instance_name?uzbl.state.instance_name:buf);
+                             uzbl.state.instance_name?uzbl.state.instance_name:buf);
                      g_free(buf);
                      break;
                  case SYM_KEYCMD:
-                     buf = uzbl.state.keycmd->str?
-                         g_markup_printf_escaped("%s", uzbl.state.keycmd->str) :
-                         g_strdup("");
-                     g_string_append(ret, buf);
-                     g_free(buf);
+                     if(escape_markup) {
+                         buf = uzbl.state.keycmd->str?
+                             g_markup_printf_escaped("%s", uzbl.state.keycmd->str):g_strdup("");
+                         g_string_append(ret, buf);
+                         g_free(buf);
+                     }
+                     else
+                         g_string_append(ret, uzbl.state.keycmd->str?
+                                 uzbl.state.keycmd->str:g_strdup(""));
                      break;
                  case SYM_MODE:
                      g_string_append(ret,
-                         uzbl.behave.insert_mode?"[I]":"[C]");
+                             uzbl.behave.insert_mode?"[I]":"[C]");
                      break;
                  case SYM_MSG:
                      g_string_append(ret,
-                         uzbl.gui.sbar.msg?uzbl.gui.sbar.msg:"");
+                             uzbl.gui.sbar.msg?uzbl.gui.sbar.msg:"");
                      break;
                      /* useragent syms */
                  case SYM_WK_MAJ:
@@ -1171,7 +1187,7 @@ cmd_useragent() {
         g_free (uzbl.net.useragent);
         uzbl.net.useragent = NULL;
     } else {
-        gchar *ua = expand_template(uzbl.net.useragent);
+        gchar *ua = expand_template(uzbl.net.useragent, FALSE);
         if (ua)
             g_object_set(G_OBJECT(uzbl.net.soup_session), SOUP_SESSION_USER_AGENT, ua, NULL);
         g_free(uzbl.net.useragent);
@@ -1229,7 +1245,7 @@ runcmd(WebKitWebView* page, GArray *argv) {
 
 static void
 parse_cmd_line(const char *ctl_line) {
-    gchar **tokens;
+    gchar **tokens = NULL;
 
     /* SET command */
     if(ctl_line[0] == 's' || ctl_line[0] == 'S') {
@@ -1237,7 +1253,6 @@ parse_cmd_line(const char *ctl_line) {
         if(tokens[0][0] == 0) {
             gchar* value = parseenv(g_strdup(tokens[2]));
             set_var_value(tokens[1], value);
-            g_strfreev(tokens);
             g_free(value);
         }
         else
@@ -1248,7 +1263,6 @@ parse_cmd_line(const char *ctl_line) {
         tokens = g_regex_split(uzbl.comm.get_regex, ctl_line, 0);
         if(tokens[0][0] == 0) {
             get_var_value(tokens[1]);
-            g_strfreev(tokens);
         }
         else
             printf("Error in command: %s\n", tokens[0]);
@@ -1259,7 +1273,6 @@ parse_cmd_line(const char *ctl_line) {
         if(tokens[0][0] == 0) {
             gchar* value = parseenv(g_strdup(tokens[2]));
             add_binding(tokens[1], value);
-            g_strfreev(tokens);
             g_free(value);
         }
         else
@@ -1270,7 +1283,6 @@ parse_cmd_line(const char *ctl_line) {
         tokens = g_regex_split(uzbl.comm.act_regex, ctl_line, 0);
         if(tokens[0][0] == 0) {
             parse_command(tokens[1], tokens[2]);
-            g_strfreev(tokens);
         }
         else
             printf("Error in command: %s\n", tokens[0]);
@@ -1286,7 +1298,6 @@ parse_cmd_line(const char *ctl_line) {
             if (g_strstr_len(ctl_line, 7, "n") || g_strstr_len(ctl_line, 7, "N"))
                 run_keycmd(TRUE);
             update_title();
-            g_strfreev(tokens);
         }
     }
     /* Comments */
@@ -1297,6 +1308,9 @@ parse_cmd_line(const char *ctl_line) {
     else
         printf("Command not understood (%s)\n", ctl_line);
 
+    if(tokens)
+        g_strfreev(tokens);
+
     return;
 }
 
@@ -1531,12 +1545,12 @@ update_title (void) {
 
     if (b->show_status) {
         if (b->title_format_short) {
-            parsed = expand_template(b->title_format_short);
+            parsed = expand_template(b->title_format_short, FALSE);
             gtk_window_set_title (GTK_WINDOW(uzbl.gui.main_window), parsed);
             g_free(parsed);
         }
         if (b->status_format) {
-            parsed = expand_template(b->status_format);
+            parsed = expand_template(b->status_format, TRUE);
             gtk_label_set_markup(GTK_LABEL(uzbl.gui.mainbar_label), parsed);
             g_free(parsed);
         }
@@ -1548,7 +1562,7 @@ update_title (void) {
         }
     } else {
         if (b->title_format_long) {
-            parsed = expand_template(b->title_format_long);
+            parsed = expand_template(b->title_format_long, FALSE);
             gtk_window_set_title (GTK_WINDOW(uzbl.gui.main_window), parsed);
             g_free(parsed);
         }