feat: add readability mode, and explain how to enable it.
This commit is contained in:
parent
9a533b7e26
commit
be043958f0
|
@ -52,6 +52,7 @@ typedef enum {
|
|||
finder_next,
|
||||
finder_prev,
|
||||
newtab,
|
||||
/*prettify,*/
|
||||
hidebar
|
||||
} func;
|
||||
|
||||
|
@ -81,6 +82,7 @@ static struct {
|
|||
{ CTRL, KEY(n), finder_next },
|
||||
{ CTRL | SFT, KEY(N), finder_prev },
|
||||
{ CTRL, KEY(t), newtab },
|
||||
// { CTRL, KEY(p), prettify },
|
||||
{ 0x0, KEY(Escape), hidebar }
|
||||
};
|
||||
/* For controls more akin to normal browsers, use:
|
||||
|
|
62
plugins/readability/README.md
Normal file
62
plugins/readability/README.md
Normal file
|
@ -0,0 +1,62 @@
|
|||
## Readability
|
||||
|
||||
Taken from <https://raw.githubusercontent.com/ushnisha/readability-reader-webextensions/master/content_scripts/tranquilize.js>
|
||||
|
||||
|
||||
## To enable it
|
||||
|
||||
In rose.c uncomment:
|
||||
|
||||
```
|
||||
|
||||
// #include "plugins/readability/readability.h"
|
||||
|
||||
/*
|
||||
case prettify:
|
||||
{
|
||||
|
||||
char* readability_js = malloc(READABILITY_N+1);
|
||||
read_readability_js(readability_js);
|
||||
webkit_web_view_run_javascript(notebook_get_webview(notebook),
|
||||
readability_js,
|
||||
NULL, NULL, NULL);
|
||||
free(readability_js);
|
||||
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
```
|
||||
|
||||
In config.h, uncomment:
|
||||
|
||||
```
|
||||
|
||||
typedef enum {
|
||||
goback,
|
||||
goforward,
|
||||
refresh,
|
||||
refresh_force,
|
||||
back_to_home,
|
||||
toggle_fullscreen,
|
||||
zoomin,
|
||||
zoomout,
|
||||
zoom_reset,
|
||||
next_tab,
|
||||
prev_tab,
|
||||
close_tab,
|
||||
show_searchbar,
|
||||
show_finder,
|
||||
finder_next,
|
||||
finder_prev,
|
||||
newtab,
|
||||
/*prettify,*/
|
||||
hidebar
|
||||
} func;
|
||||
|
||||
...
|
||||
|
||||
// { CTRL, KEY(p), prettify },
|
||||
|
||||
|
||||
```
|
BIN
plugins/readability/readability
Executable file
BIN
plugins/readability/readability
Executable file
Binary file not shown.
29
plugins/readability/readability.c
Normal file
29
plugins/readability/readability.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define READABILITY_N 84251 + 1
|
||||
|
||||
void read_readability_js(char* string){
|
||||
FILE *fp=fopen("/home/loki/Documents/core/software/fresh/C/rose-browser/rose-bud-personal/plugins/readability/readability.js", "r");
|
||||
if (!fp) { // fp is NULL, fopen failed
|
||||
fprintf(stderr, "Failed to open file\n");
|
||||
string=NULL;
|
||||
return;
|
||||
}
|
||||
int i=0;
|
||||
int c;
|
||||
while ((c = fgetc(fp)) != EOF){
|
||||
string[i++] = c;
|
||||
}
|
||||
string[i]='\0';
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
/*
|
||||
int main(){
|
||||
char* readability_js = malloc(READABILITY_N+1);
|
||||
read_readability_js(readability_js);
|
||||
printf("%s", readability_js);
|
||||
free(readability_js);
|
||||
}
|
||||
*/
|
8
plugins/readability/readability.h
Normal file
8
plugins/readability/readability.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef READABILITY
|
||||
#define READABILITY
|
||||
|
||||
#define READABILITY_N 84251 + 1
|
||||
|
||||
void read_readability_js(char* string);
|
||||
|
||||
#endif
|
2340
plugins/readability/readability.js
Normal file
2340
plugins/readability/readability.js
Normal file
File diff suppressed because it is too large
Load Diff
8
plugins/readability/recompute_READABILITY_N.sh
Executable file
8
plugins/readability/recompute_READABILITY_N.sh
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
function sedr(){
|
||||
find ./ -type f -exec sed -i -e "$1" {} \;
|
||||
} ## e.g., sedr "s/target/replacement/g"
|
||||
|
||||
READABILITY_N=$(wc -c ./plugins/*/readability.js | cut -d " " -f 1)
|
||||
sedr "s/^#define READABILITY_N .*/#define READABILITY_N $READABILITY_N + 1/g"
|
||||
|
18
rose.c
18
rose.c
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include "config.h"
|
||||
// #include "plugins/libre_redirect/libre_redirect.h"
|
||||
// #include "plugins/readability/readability.h"
|
||||
|
||||
#define CACHE \
|
||||
"base-cache-directory", CACHE_DIR, \
|
||||
|
@ -303,11 +304,28 @@ int handle_key(func id, GtkNotebook *notebook)
|
|||
case newtab:
|
||||
notebook_append(notebook, NULL);
|
||||
gtk_notebook_set_show_tabs(notebook, true);
|
||||
break;
|
||||
|
||||
case hidebar:
|
||||
entry_mode = _HIDDEN;
|
||||
show_bar(notebook);
|
||||
break;
|
||||
/*
|
||||
case prettify:
|
||||
{
|
||||
|
||||
char* readability_js = malloc(READABILITY_N+1);
|
||||
read_readability_js(readability_js);
|
||||
webkit_web_view_run_javascript(notebook_get_webview(notebook),
|
||||
readability_js,
|
||||
NULL, NULL, NULL);
|
||||
free(readability_js);
|
||||
|
||||
break;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user