commit - db7cc27a493175cc7a9fbabb072245257200b278
commit + 1b41207930840b1c656c4e2e9f1d93580dd48efa
blob - cc356cac157231e9db7a71c8fdae21dc0900fbb9
blob + c1d967f490815b2e8de2b946fb61fc54f3703484
--- ChangeLog
+++ ChangeLog
2021-06-19 Omar Polo <op@omarpolo.com>
+ * pages.c: added about:about, about:blank and about:help pages
+
* defaults.c (config_setvari): add fill-column config to manage the max-width when filling the page.
(config_setvars): add new-tab-url config to specify the default url for new tabs.
blob - ba64ad31f7f56325498038b378b001f58c186aea
blob + b8fe7c58c56417d766e860d0d8a3e49d226a6866
--- fs.c
+++ fs.c
static void die(void) __attribute__((__noreturn__));
static void serve_bookmarks(uint32_t);
+static void send_page(struct imsg *, const char *);
static void handle_get(struct imsg*, size_t);
static void handle_quit(struct imsg*, size_t);
static void handle_bookmark_page(struct imsg*, size_t);
}
static void
+send_page(struct imsg *imsg, const char *page)
+{
+ imsg_compose(ibuf, IMSG_BUF, imsg->hdr.peerid, 0, -1,
+ page, strlen(page));
+ imsg_compose(ibuf, IMSG_EOF, imsg->hdr.peerid, 0, -1, NULL, 0);
+ imsg_flush(ibuf);
+}
+
+static void
handle_get(struct imsg *imsg, size_t datalen)
{
char *data;
if (data[datalen-1] != '\0')
die();
- if (!strcmp(data, "about:new")) {
- imsg_compose(ibuf, IMSG_BUF, imsg->hdr.peerid, 0, -1,
- about_new, strlen(about_new));
- imsg_compose(ibuf, IMSG_EOF, imsg->hdr.peerid, 0, -1, NULL, 0);
- imsg_flush(ibuf);
+ if (!strcmp(data, "about:about")) {
+ send_page(imsg, about_about);
+ } else if (!strcmp(data, "about:blank")) {
+ send_page(imsg, about_blank);
} else if (!strcmp(data, "about:bookmarks")) {
serve_bookmarks(imsg->hdr.peerid);
+ } else if (!strcmp(data, "about:help")) {
+ send_page(imsg, about_help);
+ } else if (!strcmp(data, "about:new")) {
+ send_page(imsg, about_new);
} else {
p = "# not found!\n";
imsg_compose(ibuf, IMSG_BUF, imsg->hdr.peerid, 0, -1, p, strlen(p));
blob - c4f498f127b4c2c6bd5a602eb2442466e2e5480a
blob + 03ede1e4abf41aeb5ed9fdd2445f5ef6c7a97e0c
--- pages.c
+++ pages.c
#define CIRCUMLUNAR_SPACE "gemini://gemini.circumlunar.space"
+const char *about_about =
+ "# About pages\n"
+ "\n"
+ "Telescope has a number of \"special\" pages under `about:':\n"
+ "\n"
+ "=> about:about about:about : this page\n"
+ "=> about:blank about:blank : a blank page\n"
+ "=> about:bookmarks about:bookmarks : the bookmarks page\n"
+ "=> about:help about:help : help page\n"
+ "=> about:new about:new : the default new tab page\n"
+ "\n"
+ "These pages are built-in and don't require an internet connection.\n"
+ ;
+
+const char *about_blank = "\n";
+
+const char *about_help =
+ "# Help\n"
+ "\n"
+ "## What is Gemini?\n"
+ "\n"
+ "Gemini is a new internet protocol which:\n"
+ "\n"
+ "* is heavier than gopher\n"
+ "* is lighter than the web\n"
+ "* will not replace either\n"
+ "* strives for maximum power to weight ratio\n"
+ "* takes user privacy very seriously\n"
+ "\n"
+ "\n"
+ "## What is Telescope?\n"
+ "\n"
+ "Telescope is a Gemini browser written for fun. Other than taking"
+ " user privacy very seriously, it also takes security and semplicity"
+ " very seriously.\n"
+ "\n"
+ "Telescope is documented very carefully: read the manual page for"
+ " more information:\n"
+ "\n"
+ "> man telescope\n"
+ "\n"
+ "\n"
+ "## Tips\n"
+ "\n"
+ "### Appearance\n"
+ "\n"
+ "Telescope is fully customizable. If your terminal emulator"
+ " doesn't have problems with UTF-8 glyphs, try to load"
+ " Telescope with the following configuration:\n"
+ "\n"
+ "``` Example of configuration file with some pretty defaults\n"
+ "# break paragraphs at most at the 72th column\n"
+ "set fill-column = 72\n"
+ "\n"
+ "# pretty prefixes\n"
+ "style line.item {\n"
+ " prefix \" • \"\n"
+ " cont \" \"\n"
+ "}\n"
+ "\n"
+ "style line.link {\n"
+ " prefix \"→ \"\n"
+ " cont \" \"\n"
+ "}\n"
+ "\n"
+ "style line.quote {\n"
+ " prefix \"» \"\n"
+ " cont \" \"\n"
+ "}\n"
+ "```\n"
+ ;
+
const char *about_new =
ASCII_ART
"\n"
blob - 1d2b3c2a1670836331646ff356b0308ead265cf6
blob + 205c9652b75da5595fa21d5826b53e1fde9c3363
--- telescope.h
+++ telescope.h
int setup_parser_for(struct tab*);
/* pages.c */
+extern const char *about_about;
+extern const char *about_blank;
+extern const char *about_help;
extern const char *about_new;
#define CANNOT_FETCH 0