surf-2.1-history.diff (1659B)
1 diff --git a/config.def.h b/config.def.h 2 index b6ae4fc..74b1968 100644 3 --- a/config.def.h 4 +++ b/config.def.h 5 @@ -6,6 +6,8 @@ static char *styledir = "~/.surf/styles/"; 6 static char *certdir = "~/.surf/certificates/"; 7 static char *cachedir = "~/.surf/cache/"; 8 static char *cookiefile = "~/.surf/cookies.txt"; 9 +static char *historyfile = "~/.surf/history.txt"; 10 + 11 12 /* Webkit default features */ 13 /* Highest priority value will be used. 14 diff --git a/surf.c b/surf.c 15 index e709f35..d7c2166 100644 16 --- a/surf.c 17 +++ b/surf.c 18 @@ -347,9 +347,10 @@ setup(void) 19 curconfig = defconfig; 20 21 /* dirs and files */ 22 - cookiefile = buildfile(cookiefile); 23 - scriptfile = buildfile(scriptfile); 24 - certdir = buildpath(certdir); 25 + cookiefile = buildfile(cookiefile); 26 + historyfile = buildfile(historyfile); 27 + scriptfile = buildfile(scriptfile); 28 + certdir = buildpath(certdir); 29 if (curconfig[Ephemeral].val.i) 30 cachedir = NULL; 31 else 32 @@ -589,6 +590,7 @@ loaduri(Client *c, const Arg *a) 33 } else { 34 webkit_web_view_load_uri(c->view, url); 35 updatetitle(c); 36 + updatehistory(url); 37 } 38 39 g_free(url); 40 @@ -659,6 +661,20 @@ updatetitle(Client *c) 41 } 42 } 43 44 +void 45 +updatehistory(const char *url) 46 +{ 47 + FILE *f; 48 + f = fopen(historyfile, "a+"); 49 + 50 + char timestamp[20]; 51 + time_t now = time (0); 52 + strftime (timestamp, 20, "%Y-%m-%dT%H:%M:%S", localtime (&now)); 53 + 54 + fprintf(f, "%s %s\n", timestamp, url); 55 + fclose(f); 56 +} 57 + 58 void 59 gettogglestats(Client *c) 60 { 61 @@ -1085,6 +1101,7 @@ cleanup(void) 62 close(spair[0]); 63 close(spair[1]); 64 g_free(cookiefile); 65 + g_free(historyfile); 66 g_free(scriptfile); 67 g_free(stylefile); 68 g_free(cachedir);