incorporate shortcuts plugin into rose.c and makefile
This commit is contained in:
parent
5fb7e79ad5
commit
c46e2ba398
5
makefile
5
makefile
|
@ -25,12 +25,13 @@ ADBLOCK=#'-L/usr/lib/wyebrowser/adblock.so'
|
||||||
|
|
||||||
## Plugins
|
## Plugins
|
||||||
LIBRE_REDIRECT=./plugins/libre_redirect/libre_redirect.c ./plugins/libre_redirect/str_replace_start.c
|
LIBRE_REDIRECT=./plugins/libre_redirect/libre_redirect.c ./plugins/libre_redirect/str_replace_start.c
|
||||||
READABILITY=./plugins/readability/readability.c
|
|
||||||
CUSTOM_STYLES=./plugins/style/style.c
|
CUSTOM_STYLES=./plugins/style/style.c
|
||||||
|
READABILITY=./plugins/readability/readability.c
|
||||||
|
SHORTCUTS=./plugins/shortcuts/shortcuts.c
|
||||||
|
|
||||||
STAND_IN=./plugins/stand_in/stand_in.c # gives function definitions for the above, which do nothing
|
STAND_IN=./plugins/stand_in/stand_in.c # gives function definitions for the above, which do nothing
|
||||||
|
|
||||||
PLUGS=$(LIBRE_REDIRECT) $(READABILITY) $(CUSTOM_STYLES)
|
PLUGS=$(LIBRE_REDIRECT) $(READABILITY) $(CUSTOM_STYLES) $(SHORTCUTS)
|
||||||
# PLUGS=$(STAND_IN)
|
# PLUGS=$(STAND_IN)
|
||||||
# Note that if you want some plugins but not others,
|
# Note that if you want some plugins but not others,
|
||||||
# You should edit the stand_in.c file
|
# You should edit the stand_in.c file
|
||||||
|
|
34
rose.c
34
rose.c
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include "plugins/libre_redirect/libre_redirect.h"
|
#include "plugins/libre_redirect/libre_redirect.h"
|
||||||
#include "plugins/readability/readability.h"
|
#include "plugins/readability/readability.h"
|
||||||
|
#include "plugins/shortcuts/shortcuts.h"
|
||||||
#include "plugins/style/style.h"
|
#include "plugins/style/style.h"
|
||||||
|
|
||||||
// #include "plugins/stand_in/stand_in.h"
|
// #include "plugins/stand_in/stand_in.h"
|
||||||
|
@ -91,15 +92,40 @@ WebKitWebView* notebook_get_webview(GtkNotebook* notebook)
|
||||||
notebook, gtk_notebook_get_current_page(notebook)));
|
notebook, gtk_notebook_get_current_page(notebook)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void redirect_if_annoying(WebKitWebView* view, const char* uri)
|
||||||
|
{
|
||||||
|
int l = LIBRE_N + strlen(uri) + 1;
|
||||||
|
char uri_filtered[l];
|
||||||
|
str_init(uri_filtered, l);
|
||||||
|
|
||||||
|
int check = libre_redirect(uri, uri_filtered);
|
||||||
|
|
||||||
|
if (check == 2) {
|
||||||
|
webkit_web_view_load_uri(view, uri_filtered);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void load_uri(WebKitWebView* view, const char* uri)
|
void load_uri(WebKitWebView* view, const char* uri)
|
||||||
{
|
{
|
||||||
if (g_str_has_prefix(uri, "http://") || g_str_has_prefix(uri, "https://") || g_str_has_prefix(uri, "file://") || g_str_has_prefix(uri, "about:")) {
|
if (g_str_has_prefix(uri, "http://") || g_str_has_prefix(uri, "https://") || g_str_has_prefix(uri, "file://") || g_str_has_prefix(uri, "about:")) {
|
||||||
webkit_web_view_load_uri(view, uri);
|
webkit_web_view_load_uri(view, uri);
|
||||||
} else {
|
} else {
|
||||||
// webkit_web_view_load_uri(view, uri);
|
// Check for shortcuts
|
||||||
char tmp[strlen(uri) + strlen(SEARCH)];
|
int l = SHORTCUT_N + strlen(uri) + 1;
|
||||||
snprintf(tmp, sizeof(tmp), SEARCH, uri);
|
char uri_expanded[l];
|
||||||
webkit_web_view_load_uri(view, tmp);
|
str_init(uri_expanded, l);
|
||||||
|
int check = shortcut_expand(uri, uri_expanded);
|
||||||
|
|
||||||
|
if (check == 2) {
|
||||||
|
webkit_web_view_load_uri(view, uri_expanded);
|
||||||
|
} else {
|
||||||
|
// Feed into search engine.
|
||||||
|
char tmp[strlen(uri) + strlen(SEARCH)];
|
||||||
|
snprintf(tmp, sizeof(tmp), SEARCH, uri);
|
||||||
|
webkit_web_view_load_uri(view, tmp);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user