]> git.armaanb.net Git - chorizo.git/commitdiff
Remove keyword searches
authorPeter Hofmann <scm@uninformativ.de>
Tue, 28 Apr 2020 14:11:25 +0000 (16:11 +0200)
committerPeter Hofmann <scm@uninformativ.de>
Tue, 28 Apr 2020 14:21:17 +0000 (16:21 +0200)
Unmaintained code, better alternatives exist.

browser.c
man1/lariza.1
man1/lariza.usage.1

index 05f8975bae8166a7bf30bc5c21cbec6ad869b523..28620284260b1111bcfa0112c228bf5728cae286 100644 (file)
--- 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();
index 0a7573e4f563f8d3a85cafb4c033a446aff9a24f..a3cbb3f4925084642971af60e0cf3dbbdc951989 100644 (file)
@@ -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).
index ebed6766d43e936913df2f42574af73765f38dd7..b1162a6666ebd3000b920361aa81b824fbdc3773 100644 (file)
@@ -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