From 0d057c3e9e6ee16fb6992a800d188587238c814e Mon Sep 17 00:00:00 2001 From: Peter Hofmann Date: Tue, 28 Apr 2020 16:11:25 +0200 Subject: Remove keyword searches Unmaintained code, better alternatives exist. --- browser.c | 66 +---------------------------------------------------- man1/lariza.1 | 6 +---- man1/lariza.usage.1 | 21 ++--------------- 3 files changed, 4 insertions(+), 89 deletions(-) diff --git a/browser.c b/browser.c index 05f8975..2862028 100644 --- a/browser.c +++ b/browser.c @@ -44,8 +44,6 @@ gboolean key_common(GtkWidget *, GdkEvent *, gpointer); gboolean key_downloadmanager(GtkWidget *, GdkEvent *, gpointer); gboolean key_location(GtkWidget *, GdkEvent *, gpointer); gboolean key_web_view(GtkWidget *, GdkEvent *, gpointer); -void keywords_load(void); -gboolean keywords_try_search(WebKitWebView *, const gchar *); void mainwindow_setup(void); gboolean menu_web_view(WebKitWebView *, WebKitContextMenu *, GdkEvent *, WebKitHitTestResult *, gpointer); @@ -96,7 +94,6 @@ gdouble global_zoom = 1.0; gchar *history_file = NULL; gchar *home_uri = "about:blank"; gboolean initial_wc_setup_done = FALSE; -GHashTable *keywords = NULL; gchar *search_text = NULL; GtkPositionType tab_pos = GTK_POS_TOP; gint tab_width_chars = 20; @@ -1014,7 +1011,7 @@ key_location(GtkWidget *widget, GdkEvent *event, gpointer data) search_text = g_strdup(t + 2); search(c, 0); } - else if (!keywords_try_search(WEBKIT_WEB_VIEW(c->web_view), t)) + else { f = ensure_uri_scheme(t); webkit_web_view_load_uri(WEBKIT_WEB_VIEW(c->web_view), f); @@ -1086,66 +1083,6 @@ key_web_view(GtkWidget *widget, GdkEvent *event, gpointer data) return FALSE; } -void -keywords_load(void) -{ - GError *err = NULL; - GIOChannel *channel = NULL; - gchar *path = NULL, *buf = NULL; - gchar **tokens = NULL; - - keywords = g_hash_table_new(g_str_hash, g_str_equal); - - path = g_build_filename(g_get_user_config_dir(), __NAME__, "keywordsearch", - NULL); - channel = g_io_channel_new_file(path, "r", &err); - if (channel != NULL) - { - while (g_io_channel_read_line(channel, &buf, NULL, NULL, NULL) - == G_IO_STATUS_NORMAL) - { - g_strstrip(buf); - if (buf[0] != '#') - { - tokens = g_strsplit(buf, " ", 2); - if (tokens[0] != NULL && tokens[1] != NULL) - g_hash_table_insert(keywords, g_strdup(tokens[0]), - g_strdup(tokens[1])); - g_strfreev(tokens); - } - g_free(buf); - } - g_io_channel_shutdown(channel, FALSE, NULL); - } - g_free(path); -} - -gboolean -keywords_try_search(WebKitWebView *web_view, const gchar *t) -{ - gboolean ret = FALSE; - gchar **tokens = NULL; - gchar *val = NULL, *escaped = NULL, *uri = NULL; - - tokens = g_strsplit(t, " ", 2); - if (tokens[0] != NULL && tokens[1] != NULL) - { - val = g_hash_table_lookup(keywords, tokens[0]); - if (val != NULL) - { - escaped = g_uri_escape_string(tokens[1], NULL, TRUE); - uri = g_strdup_printf((gchar *)val, escaped); - webkit_web_view_load_uri(web_view, uri); - g_free(uri); - g_free(escaped); - ret = TRUE; - } - } - g_strfreev(tokens); - - return ret; -} - void mainwindow_setup(void) { @@ -1361,7 +1298,6 @@ main(int argc, char **argv) } } - keywords_load(); if (cooperative_instances) cooperation_setup(); downloadmanager_setup(); diff --git a/man1/lariza.1 b/man1/lariza.1 index 0a7573e..a3cbb3f 100644 --- a/man1/lariza.1 +++ b/man1/lariza.1 @@ -1,4 +1,4 @@ -.TH lariza 1 "2020-04-25" "lariza" "User Commands" +.TH lariza 1 "2020-04-28" "lariza" "User Commands" .\" -------------------------------------------------------------------- .SH NAME lariza \- simple web browser @@ -90,10 +90,6 @@ Adblock patterns. See \fBlariza.usage\fP(1). Directory where trusted certificates are stored. See \fBlariza.usage\fP(1). .TP -\fI~/.config\:/lariza\:/keywordsearch\fP -Configuration file for keyword base searching. See -\fBlariza.usage\fP(1). -.TP \fI~/.config\:/lariza\:/scripts\fP Directory to store user-supplied JavaScript snippets. See \fBlariza.usage\fP(1). diff --git a/man1/lariza.usage.1 b/man1/lariza.usage.1 index ebed676..b1162a6 100644 --- a/man1/lariza.usage.1 +++ b/man1/lariza.usage.1 @@ -1,4 +1,4 @@ -.TH lariza 1 "2020-04-24" "lariza" "User Commands" +.TH lariza 1 "2020-04-28" "lariza" "User Commands" .\" -------------------------------------------------------------------- .SH NAME lariza.usage \- extended usage hints @@ -89,7 +89,7 @@ Reset zoom to $\fBLARIZA_ZOOM\fP. Reset the content of the location bar to the current URI. .TP \fBReturn\fP -Commit, i.e. begin searching, do a keyword based search or open the URI. +Commit, i.e. begin searching or open the URI. .P .SS "Download manager" .TP @@ -110,23 +110,6 @@ overwrite or resume downloads. If a file already exists, it won't be touched. Instead, the new file name will have a suffix such as \fB.1\fP, \fB.2\fP, \fB.3\fP, and so on. .\" -------------------------------------------------------------------- -.SH "KEYWORD BASED SEARCHING" -In this file, you can configure keywords and the associated URIs: -\fI~/.config\:/lariza\:/keywordsearch\fP. Each line has to look like -this: -.P -\f(CW -.nf -\&wi https://en.wikipedia.org/w/index.php?title=Special:Search&search=%s -.fi -\fP -.P -\fBwi\fP is the keyword, so when opening \fBwi foo\fP, \fBlariza\fP -will search in Wikipedia. Note the \fB%s\fP at the end of the URI: This -is where your search term will be placed. -.P -Lines starting with \fB#\fP are ignored. -.\" -------------------------------------------------------------------- .SH "USER-SUPPLIED JAVASCRIPT FILES" After a page has been successfully loaded, the directory \fI~/.config\:/lariza\:/user-scripts\fP will be scanned and each file in -- cgit v1.2.3