summaryrefslogtreecommitdiff
path: root/surf/patches/surf-2.1-history.diff
blob: 453750d6fd1a84c804b2d15f373a445d33b59f3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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..d7c2166 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(url);
 	}
 
 	g_free(url);
@@ -659,6 +661,20 @@ updatetitle(Client *c)
 	}
 }
 
+void
+updatehistory(const char *url)
+{
+	FILE *f;
+	f = fopen(historyfile, "a+");
+
+	char timestamp[20];
+	time_t now = time (0);
+	strftime (timestamp, 20, "%Y-%m-%dT%H:%M:%S", localtime (&now));
+
+	fprintf(f, "%s %s\n", timestamp, url);
+	fclose(f);
+}
+
 void
 gettogglestats(Client *c)
 {
@@ -1085,6 +1101,7 @@ cleanup(void)
 	close(spair[0]);
 	close(spair[1]);
 	g_free(cookiefile);
+	g_free(historyfile);
 	g_free(scriptfile);
 	g_free(stylefile);
 	g_free(cachedir);