summaryrefslogtreecommitdiff
path: root/network/surf/patches/searchengines.diff
diff options
context:
space:
mode:
Diffstat (limited to 'network/surf/patches/searchengines.diff')
-rw-r--r--network/surf/patches/searchengines.diff69
1 files changed, 69 insertions, 0 deletions
diff --git a/network/surf/patches/searchengines.diff b/network/surf/patches/searchengines.diff
new file mode 100644
index 0000000000..97aa6a4922
--- /dev/null
+++ b/network/surf/patches/searchengines.diff
@@ -0,0 +1,69 @@
+diff -Naur surf-0.6/config.def.h surf-0.6.patched/config.def.h
+--- surf-0.6/config.def.h 2013-02-10 13:40:14.000000000 -0500
++++ surf-0.6.patched/config.def.h 2013-07-03 16:40:14.000000000 -0400
+@@ -93,3 +93,10 @@
+ { MODKEY|GDK_SHIFT_MASK,GDK_v, toggle, { .v = "enable-plugins" } },
+ };
+
++static SearchEngine searchengines[] = {
++ { "d", "https://duckduckgo.com/html/?q=%s" },
++ { "g", "https://www.google.com/search?q=%s" },
++ { "dict", "http://www.thefreedictionary.com/%s" },
++ { "sb", "http://slackbuilds.org/result/?search=%s&sv=@SLACKVER@" },
++ { "sw", "http://search.slackware.eu/cgi-bin/search.cgi?rm=search&needle=%s&haystack=2&sver=@SVER@&button-search=Search" },
++};
+diff -Naur surf-0.6/surf.c surf-0.6.patched/surf.c
+--- surf-0.6/surf.c 2013-02-10 13:40:14.000000000 -0500
++++ surf-0.6.patched/surf.c 2013-07-03 15:25:44.000000000 -0400
+@@ -76,6 +76,11 @@
+
+ G_DEFINE_TYPE(CookieJar, cookiejar, SOUP_TYPE_COOKIE_JAR_TEXT)
+
++typedef struct {
++ char *token;
++ char *uri;
++} SearchEngine;
++
+ static Display *dpy;
+ static Atom atoms[AtomLast];
+ static Client *clients = NULL;
+@@ -139,6 +144,7 @@
+ static void navigate(Client *c, const Arg *arg);
+ static Client *newclient(void);
+ static void newwindow(Client *c, const Arg *arg, gboolean noembed);
++static gchar *parseuri(const gchar *uri);
+ static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d);
+ static void populatepopup(WebKitWebView *web, GtkMenu *menu, Client *c);
+ static void popupactivate(GtkMenuItem *menu, Client *);
+@@ -627,8 +633,8 @@
+ u = g_strdup_printf("file://%s", rp);
+ free(rp);
+ } else {
+- u = g_strrstr(uri, "://") ? g_strdup(uri)
+- : g_strdup_printf("http://%s", uri);
++ u = parseuri(uri);
++
+ }
+
+ /* prevents endless loop */
+@@ -893,6 +899,20 @@
+ }
+ }
+
++gchar *
++parseuri(const gchar *uri) {
++ guint i;
++
++ for (i = 0; i < LENGTH(searchengines); i++) {
++ if (searchengines[i].token == NULL || searchengines[i].uri == NULL || *(uri + strlen(searchengines[i].token)) != ' ')
++ continue;
++ if (g_str_has_prefix(uri, searchengines[i].token))
++ return g_strdup_printf(searchengines[i].uri, uri + strlen(searchengines[i].token) + 1);
++ }
++
++ return g_strrstr(uri, "://") ? g_strdup(uri) : g_strdup_printf("http://%s", uri);
++}
++
+ static void
+ pasteuri(GtkClipboard *clipboard, const char *text, gpointer d) {
+ Arg arg = {.v = text };