From 9e8324381a639d0a2c85d7590dd5cf1bb84f8f4f Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 11 May 2019 01:39:43 +0200 Subject: Makefile: Fix .mo building target for BSD make --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 2635716..c6f21fe 100644 --- a/Makefile +++ b/Makefile @@ -17,9 +17,9 @@ LIBS = `pkg-config --libs $(DEPS)` all: $(OBJS) $(TRANS) -%.mo: - mkdir -p locale/$*/LC_MESSAGES - msgfmt -o locale/$*/LC_MESSAGES/$(PACKAGE).mo po/$*.po +${TRANS}: + mkdir -p locale/${@:.mo=}/LC_MESSAGES + msgfmt -o locale/${@:.mo=}/LC_MESSAGES/$(PACKAGE).mo po/${@:.mo=.po} po/messages.pot: xgettext --keyword=_ --language=C -o $@ --add-comments --sort-output -j badwolf.c -- cgit v1.3.1-23-gd82d From 72bbbd0101a67f169629f952a158f3b1ae00b3ac Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 11 May 2019 04:48:17 +0200 Subject: Makefile: po/messages.pot depends on badwolf.c --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index c6f21fe..85c938b 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ ${TRANS}: mkdir -p locale/${@:.mo=}/LC_MESSAGES msgfmt -o locale/${@:.mo=}/LC_MESSAGES/$(PACKAGE).mo po/${@:.mo=.po} -po/messages.pot: +po/messages.pot: badwolf.c xgettext --keyword=_ --language=C -o $@ --add-comments --sort-output -j badwolf.c po/%.po: po/messages.pot -- cgit v1.3.1-23-gd82d From e725cc9ed52539205ff9c702f6915e162f474170 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 11 May 2019 04:54:36 +0200 Subject: Makefile: translations depends on po/%.po --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 85c938b..74ddedd 100644 --- a/Makefile +++ b/Makefile @@ -17,16 +17,16 @@ LIBS = `pkg-config --libs $(DEPS)` all: $(OBJS) $(TRANS) -${TRANS}: - mkdir -p locale/${@:.mo=}/LC_MESSAGES - msgfmt -o locale/${@:.mo=}/LC_MESSAGES/$(PACKAGE).mo po/${@:.mo=.po} - po/messages.pot: badwolf.c xgettext --keyword=_ --language=C -o $@ --add-comments --sort-output -j badwolf.c po/%.po: po/messages.pot msgmerge --update $@ $< +${TRANS}: po/${@:.mo=.po} + mkdir -p locale/${@:.mo=}/LC_MESSAGES + msgfmt -o locale/${@:.mo=}/LC_MESSAGES/$(PACKAGE).mo po/${@:.mo=.po} + .c: $(CC) -std=c11 $(CFLAGS) $(CDEPS) -o $@ $< $(LDFLAGS) $(LIBS) -- cgit v1.3.1-23-gd82d From 3ba43be13812acf9b8d12186d74468cd0e295b79 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 11 May 2019 07:57:07 +0200 Subject: Add a simple way to fix the URL It tries to load it as a file before trying a URL to avoid loading something meant as local. Closes: https://gitlab.com/lanodan/badWolf/issues/6 --- Makefile | 2 +- badwolf.1 | 2 +- badwolf.c | 35 ++++++++++++++++++++++++++++++++--- 3 files changed, 34 insertions(+), 5 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 74ddedd..7bd30db 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ TRANS = fr.mo CC = cc CFLAGS = -g -Wall -Wextra -CDEPS = `pkg-config --cflags $(DEPS)` -DDATADIR=\"$(DATADIR)\" -DPACKAGE=\"$(PACKAGE)\" +CDEPS = `pkg-config --cflags $(DEPS)` -DDATADIR=\"$(DATADIR)\" -DPACKAGE=\"$(PACKAGE)\" -D_DEFAULT_SOURCE LIBS = `pkg-config --libs $(DEPS)` all: $(OBJS) $(TRANS) diff --git a/badwolf.1 b/badwolf.1 index f039518..0d0d75a 100644 --- a/badwolf.1 +++ b/badwolf.1 @@ -9,7 +9,7 @@ .Sh SYNOPSIS .Nm .Op Ar webkit/gtk options -.Op Ar url +.Op Ar url or path .Sh DESCRIPTION .Nm is a minimalist browser that care about privacy, it is based on WebKitGTK and thus also accepts WebKitGTK (and depdendencies) flags and environment variables, unfortunately there doesn't seems to be manpages for theses. diff --git a/badwolf.c b/badwolf.c index 1cdaab6..abc0fef 100644 --- a/badwolf.c +++ b/badwolf.c @@ -8,6 +8,7 @@ #include /* g_fprintf() */ #include #include /* LC_* */ +#include /* realpath() */ #include const gchar *homepage = "https://hacktivis.me/projects/badwolf"; @@ -36,6 +37,7 @@ struct Client GtkWidget *search; }; +gchar *ensure_uri_scheme(gchar *text); static gboolean WebViewCb_close(WebKitWebView *webView, gpointer user_data); static gboolean commonCb_key_press_event(struct Window *window, GdkEvent *event, struct Client *browser); @@ -80,6 +82,33 @@ static void notebookCb_switch__page(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer user_data); gint get_tab_position(GtkContainer *notebook, GtkWidget *child); +gchar * +ensure_uri_scheme(gchar *text) +{ + if(text == NULL) return "about:blank"; + + char *scheme = g_uri_parse_scheme(text); + + if(scheme != NULL) + return text; + else + { + gchar *f; + char *path; + path = realpath(text, NULL); + + if(path != NULL) + { + f = g_strdup_printf("file://%s", path); + free(path); + } + else + f = g_strdup_printf("http://%s", text); + + return f; + } +} + static void badwolf_about_dialog(GtkWindow *main_window) { @@ -425,10 +454,10 @@ WebViewCb_create(WebKitWebView *related_web_view, static gboolean locationCb_activate(GtkEntry *location, gpointer user_data) { - const char *target_url; + char *target_url; struct Client *browser = (struct Client *)user_data; - target_url = gtk_entry_get_text(location); + target_url = ensure_uri_scheme((char *)gtk_entry_get_text(location)); if(target_url != NULL) webkit_web_view_load_uri(browser->webView, target_url); @@ -502,7 +531,7 @@ struct Client * new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web_view) { struct Client *browser = g_malloc(sizeof(struct Client)); - if(target_url == NULL) target_url = "about:blank"; + target_url = ensure_uri_scheme(target_url); browser->window = window; browser->box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); -- cgit v1.3.1-23-gd82d