Commits

Anonymous committed 109c265

read per-site settings from the rc file

Comments (0)

Files changed (3)

 extern char *error_msg;
 extern char *config_base;
 extern VSettings cursettings;
-static GList *dynamic_searchengines = NULL, *dynamic_uri_handlers = NULL;
+static GList *dynamic_searchengines = NULL, *dynamic_uri_handlers = NULL, *site_settings = NULL;
 
 void add_modkeys(char key);
 
 	gboolean found_malformed_lines = FALSE;
 	Searchengine *new;
 	URIHandler *newhandler;
+	SSettings *newsettings;
 
    if (access(config, F_OK) != 0)
         return FILE_NOT_FOUND;
 			continue;
 		t = strlen(s);
 		s[t - 1] = '\0';
-		if (strncmp(s, "searchengine", 12) == 0) {
+		if (strncmp(s, "site ", 5) == 0) {
+			buffer = (s + 4);
+			while (buffer[0] == ' ')
+				buffer++;
+			/* split line at whitespace */
+			index = split_string_at_whitespace(buffer);
+			if (index < 0 || buffer[0] == '\0' || buffer[index] == '\0') {
+				fprintf(stderr, "site settings: syntax error on line %d\n", linum);
+				found_malformed_lines = TRUE;
+				continue;
+			}
+			newsettings = malloc(sizeof(SSettings));
+			if (newsettings == NULL) {
+				fprintf(stderr, "Memory exhausted while loading site settings.\n");
+				exit(EXIT_FAILURE);
+			}
+			newsettings->url = g_strdup(buffer);
+			newsettings->settings = g_strdup(buffer+index);
+			site_settings = g_list_prepend(site_settings, newsettings);
+		} else if (strncmp(s, "searchengine", 12) == 0) {
 			buffer = (s + 12);
 			while (buffer[0] == ' ')
 				buffer++;
 } VSettings;
 
 typedef struct {
+   char *url;
+   char *settings;
+} SSettings;
+
+typedef struct {
 	guint mask;
 	guint modkey;
 	guint key;
 
 where the %s serves as a placeholder for the rest of the URI.
 
+.SH PER-SITE SETTINGS
+
+You can define overrides for many internal settings on a website basis. This
+includes anything you can define interactively using the :set command. This
+is useful to define exceptions to the default settings using a whitelist or
+blacklist approach.
+
+The following syntax must be used in the configuration file
+(without the angle brackets):
+
+.RS 4
+site <URL schema> <list of settings separated by pipe symbols (|)>
+.RE
+
+where any site which begins with the defined URL schema will use the defined
+special settings. Visiting another URL again in the same browser window will
+automatically revert the browser to the default settings.
+
 .SH BUGS
 There has not been any significant bug-hunting yet.
 .SH AUTHORS