From 87e27b9b3e47671484c7eb77d61b75fffc89624f Mon Sep 17 00:00:00 2001 From: Date: Sun, 29 Jan 2006 14:58:03 +0100 Subject: [PATCH] goto_url_hook takes 2 params not 1. Some dumbprefixes defined in hooks.py --- contrib/python/hooks.py | 30 ++++++++++++++++++++++++++++-- src/scripting/python/hooks.c | 6 ++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/contrib/python/hooks.py b/contrib/python/hooks.py index 97f63178..fe75b5f6 100644 --- a/contrib/python/hooks.py +++ b/contrib/python/hooks.py @@ -1,5 +1,31 @@ -def goto_url_hook(url): - return None +dumbprefixes = { + "7th" : "http://7thguard.net/", + "b" : "http://babelfish.altavista.com/babelfish/tr", + "bz" : "http://bugzilla.elinks.cz", + "bug" : "http://bugzilla.elinks.cz", + "d" : "http://www.dict.org", + "g" : "http://www.google.com/", + "gg" : "http://www.google.com/", + "go" : "http://www.google.com/", + "fm" : "http://www.freshmeat.net/", + "sf" : "http://www.sourceforge.net/", + "dbug" : "http://bugs.debian.org/", + "dpkg" : "http://packages.debian.org/", + "pycur" : "http://www.python.org/doc/current/", + "pydev" : "http://www.python.org/dev/doc/devel/", + "pyhelp" : "http://starship.python.net/crew/theller/pyhelp.cgi", + "pyvault" : "http://www.vex.net/parnassus/", + "e2" : "http://www.everything2.org/", + "sd" : "http://www.slashdot.org/" +} + +def goto_url_hook(url, current_url): + global dumbprefixes + + if dumbprefixes.has_key(url): + return dumbprefixes[url]; + else: + return None def follow_url_hook(url): return None diff --git a/src/scripting/python/hooks.c b/src/scripting/python/hooks.c index 8473ad7b..0c610338 100644 --- a/src/scripting/python/hooks.c +++ b/src/scripting/python/hooks.c @@ -21,7 +21,8 @@ /* The events that will trigger the functions below and what they are expected * to do is explained in doc/events.txt */ -extern PyObject *pDict, *pModule; +extern PyObject *pDict; +extern PyObject *pModule; static void do_script_hook_goto_url(struct session *ses, unsigned char **url) @@ -37,7 +38,8 @@ do_script_hook_goto_url(struct session *ses, unsigned char **url) } else { str = struri(cur_loc(ses)->vs.uri); } - pValue = PyObject_CallFunction(pFunc, "s", str); + + pValue = PyObject_CallFunction(pFunc, "ss", *url, str); if (pValue && (pValue != Py_None)) { const unsigned char *res = PyString_AsString(pValue); -- 2.11.4.GIT