[wiki] [sites] [surf][patch][history]: Add 2.1-compatible patch || h

From: <git_AT_suckless.org>
Date: Sun, 14 Nov 2021 23:27:35 +0100

commit dc2e7b6542d0a8af6f2b836cf914326029117235
Author: h <h_AT_abbcd.net>
Date: Sun Nov 14 22:25:29 2021 +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.

diff --git a/surf.suckless.org/patches/history/index.md b/surf.suckless.org/patches/history/index.md
index d0133eda..2852f521 100644
--- a/surf.suckless.org/patches/history/index.md
+++ b/surf.suckless.org/patches/history/index.md
_AT_@ -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
 -------
_AT_@ -58,3 +59,4 @@ Authors
 * Peter John Hartman (wart_) <http://durandus.trilidun.org/durandus/>
 * Samuel Baldwin (shardz) <recursive.forest_AT_gmail.com>
 * Marcin sZpak <szpak_AT_reakcja.org>
+* Howard Cornwell <h_AT_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
new file mode 100644
index 00000000..0fa58153
--- /dev/null
+++ b/surf.suckless.org/patches/history/surf-2.1-history.diff
_AT_@ -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
+_AT_@ -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
+_AT_@ -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
+_AT_@ -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);
+_AT_@ -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
", url);
++ fclose(f);
++
++}
++
+ void
+ gettogglestats(Client *c)
+ {
+_AT_@ -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);
Received on Sun Nov 14 2021 - 23:27:35 CET

This archive was generated by hypermail 2.3.0 : Sun Nov 14 2021 - 23:36:45 CET