commit dc2e7b6542d0a8af6f2b836cf914326029117235
parent cac6f6dd8d5fc754d66291f6601095130d21ef16
Author: h <h@abbcd.net>
Date: Sun, 14 Nov 2021 22:25:29 +0000
[surf][patch][history]: Add 2.1-compatible patch
Add a patch, compatible with surf 2.1, to write timestamped urls to a
browsing history file.
Diffstat:
2 files changed, 72 insertions(+), 0 deletions(-)
diff --git a/surf.suckless.org/patches/history/index.md b/surf.suckless.org/patches/history/index.md
@@ -50,6 +50,7 @@ Download
* [surf-tip-history.diff](surf-tip-history.diff) (2952) (20091215)
* [surf-0.4.1-history.diff](surf-0.4.1-history.diff) (1346) (20101225)
* [surf-history-20181009-2b71a22.diff](surf-history-20181009-2b71a22.diff) (3405) (20181009)
+* [surf-2.1-history.diff](surf-2.1-history.diff) (1645) (20211114)
Authors
-------
@@ -58,3 +59,4 @@ Authors
* Peter John Hartman (wart_) <http://durandus.trilidun.org/durandus/>
* Samuel Baldwin (shardz) <recursive.forest@gmail.com>
* Marcin sZpak <szpak@reakcja.org>
+* Howard Cornwell <h@abbcd.net>
diff --git a/surf.suckless.org/patches/history/surf-2.1-history.diff b/surf.suckless.org/patches/history/surf-2.1-history.diff
@@ -0,0 +1,70 @@
+diff --git a/config.def.h b/config.def.h
+index b6ae4fc..74b1968 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -6,6 +6,8 @@ static char *styledir = "~/.surf/styles/";
+ static char *certdir = "~/.surf/certificates/";
+ static char *cachedir = "~/.surf/cache/";
+ static char *cookiefile = "~/.surf/cookies.txt";
++static char *historyfile = "~/.surf/history.txt";
++
+
+ /* Webkit default features */
+ /* Highest priority value will be used.
+diff --git a/surf.c b/surf.c
+index e709f35..9c9fc90 100644
+--- a/surf.c
++++ b/surf.c
+@@ -347,9 +347,10 @@ setup(void)
+ curconfig = defconfig;
+
+ /* dirs and files */
+- cookiefile = buildfile(cookiefile);
+- scriptfile = buildfile(scriptfile);
+- certdir = buildpath(certdir);
++ cookiefile = buildfile(cookiefile);
++ historyfile = buildfile(historyfile);
++ scriptfile = buildfile(scriptfile);
++ certdir = buildpath(certdir);
+ if (curconfig[Ephemeral].val.i)
+ cachedir = NULL;
+ else
+@@ -589,6 +590,7 @@ loaduri(Client *c, const Arg *a)
+ } else {
+ webkit_web_view_load_uri(c->view, url);
+ updatetitle(c);
++ updatehistory(c);
+ }
+
+ g_free(url);
+@@ -659,6 +661,22 @@ updatetitle(Client *c)
+ }
+ }
+
++void
++updatehistory(const char *url)
++{
++ FILE *f;
++ f = fopen(historyfile, "a+");
++
++ char b[20];
++ time_t now = time (0);
++ strftime (b, 20, "%Y-%m-%dT%H:%M:%S", localtime (&now));
++ fputs(b, f);
++
++ fprintf(f, " %s\n", url);
++ fclose(f);
++
++}
++
+ void
+ gettogglestats(Client *c)
+ {
+@@ -1085,6 +1103,7 @@ cleanup(void)
+ close(spair[0]);
+ close(spair[1]);
+ g_free(cookiefile);
++ g_free(historyfile);
+ g_free(scriptfile);
+ g_free(stylefile);
+ g_free(cachedir);