diff options
-rw-r--r-- | doc/dwb.1 | 9 | ||||
-rw-r--r-- | doc/dwb.1.txt | 3 | ||||
-rw-r--r-- | src/config.h | 2 | ||||
-rw-r--r-- | src/dwb.c | 12 | ||||
-rw-r--r-- | src/view.c | 8 | ||||
-rw-r--r-- | util/settings.pre | 2 |
6 files changed, 29 insertions, 7 deletions
@@ -2,12 +2,12 @@ .\" Title: dwb .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.77.1 <http://docbook.sf.net/> -.\" Date: 07/20/2012 +.\" Date: 07/26/2012 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" -.TH "DWB" "1" "07/20/2012" "\ \&" "\ \&" +.TH "DWB" "1" "07/26/2012" "\ \&" "\ \&" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -3401,6 +3401,11 @@ and \fIDWB_REFERER\fR available which can be used in a script, for example: .RE +.PP +\fBsearchengine\-submit\-pattern\fR +.RS 4 +The pattern which will be replaced with the search terms\&. +.RE .sp .if n \{\ .RS 4 diff --git a/doc/dwb.1.txt b/doc/dwb.1.txt index f461422f..80c34e81 100644 --- a/doc/dwb.1.txt +++ b/doc/dwb.1.txt @@ -1422,6 +1422,9 @@ your application, so you can simply set this to 'xdg-open'. There are also the environment variables 'DWB_URI', 'DWB_SCHEME', 'DWB_COOKIES', 'DWB_USER_AGENT', and 'DWB_REFERER' available which can be used in a script, for example: +*searchengine-submit-pattern*:: +The pattern which will be replaced with the search terms. + -------- #!/bin/sh diff --git a/src/config.h b/src/config.h index 1065f71e..2911d204 100644 --- a/src/config.h +++ b/src/config.h @@ -1138,4 +1138,6 @@ static WebSettings DWB_SETTINGS[] = { SETTING_GLOBAL, BOOLEAN, { .b = false }, NULL, { 0 }, }, { { "bars-padding", "Padding of the status, download, completion and tab bars", }, SETTING_GLOBAL, INTEGER, { .i = 0 }, NULL, { 0 }, }, + { { "searchengine-submit-pattern", "The pattern which will be replaced with the search terms", }, + SETTING_GLOBAL, CHAR, { .p = NULL }, NULL, { 0 }, }, };/*}}}*/ @@ -1517,7 +1517,11 @@ static char * dwb_get_search_engine_uri(const char *uri, const char *text) { char *ret = NULL; if (uri != NULL && text != NULL) { - GRegex *regex = g_regex_new(HINT_SEARCH_SUBMIT, 0, 0, NULL); + char *hint_search_submit = GET_CHAR("searchengine-submit-pattern"); + if (hint_search_submit == NULL) { + hint_search_submit = HINT_SEARCH_SUBMIT; + } + GRegex *regex = g_regex_new(hint_search_submit, 0, 0, NULL); char *escaped = g_uri_escape_string(text, NULL, true); ret = g_regex_replace(regex, uri, -1, 0, escaped, 0, NULL); g_free(escaped); @@ -1568,7 +1572,11 @@ void dwb_submit_searchengine(void) { char buffer[64]; char *value; - snprintf(buffer, 64, "{ \"searchString\" : \"%s\" }", HINT_SEARCH_SUBMIT); + char *hint_search_submit = GET_CHAR("searchengine-submit-pattern"); + if (hint_search_submit == NULL) { + hint_search_submit = HINT_SEARCH_SUBMIT; + } + snprintf(buffer, 64, "{ \"searchString\" : \"%s\" }", hint_search_submit); if ( (value = js_call_as_function(MAIN_FRAME(), CURRENT_VIEW()->hint_object, "submitSearchEngine", buffer, &value)) ) { dwb.state.form_name = value; } @@ -484,8 +484,12 @@ view_navigation_policy_cb(WebKitWebView *web, WebKitWebFrame *frame, WebKitNetwo case WEBKIT_WEB_NAVIGATION_REASON_FORM_SUBMITTED: if (dwb.state.mode == SEARCH_FIELD_MODE) { webkit_web_policy_decision_ignore(policy); - dwb.state.search_engine = dwb.state.form_name && !g_strrstr(uri, HINT_SEARCH_SUBMIT) - ? g_strdup_printf("%s?%s=%s", uri, dwb.state.form_name, HINT_SEARCH_SUBMIT) + char *hint_search_submit = GET_CHAR("searchengine-submit-pattern"); + if (hint_search_submit == NULL) { + hint_search_submit = HINT_SEARCH_SUBMIT; + } + dwb.state.search_engine = dwb.state.form_name && !g_strrstr(uri, hint_search_submit) + ? g_strdup_printf("%s?%s=%s", uri, dwb.state.form_name, hint_search_submit) : g_strdup(uri); dwb_save_searchengine(); webkit_web_policy_decision_ignore(policy); diff --git a/util/settings.pre b/util/settings.pre index 2f5ad149..74b7df45 100644 --- a/util/settings.pre +++ b/util/settings.pre @@ -150,4 +150,4 @@ scheme-handler Application or script that handles uris with schemes that cannot sync-files text Interval to save history to disk, 0 means save immediately tab-key-cycles-through-elements checkbox Tab cycles through elements in insert mode update-search-delay text Delay before updating search results in milliseconds - +searchengine-submit-pattern text The pattern which will be replaced with the search terms |