From 341aa3fa1a2d1d01f479e18b308aacd291dbb8b1 Mon Sep 17 00:00:00 2001 From: "me@ow.nekobit.net" Date: Mon, 21 Mar 2022 19:35:29 +0000 Subject: [PATCH] Update README, config template, restructure documentation FossilOrigin-Name: f11602e6271c422280fd8474abf2ef63ec6021e144e8359f0ff145e423ad1333 --- .gitignore | 1 + INSTALL.md | 40 ------------ README.md | 24 ++++++-- config.h => config.def.h | 9 ++- docs/INSTALL.md | 61 +++++++++++++++++++ docs/sample/treebird.apache.conf | 20 ++++++ .../sample/treebird.nginx.conf | 0 .../sample/treebird.uwsgi.ini | 0 src/main.c | 6 +- 9 files changed, 107 insertions(+), 54 deletions(-) delete mode 100644 INSTALL.md rename config.h => config.def.h (87%) create mode 100644 docs/INSTALL.md create mode 100644 docs/sample/treebird.apache.conf rename treebird.nginx.conf => docs/sample/treebird.nginx.conf (100%) rename treebird.uwsgi.ini => docs/sample/treebird.uwsgi.ini (100%) diff --git a/.gitignore b/.gitignore index a5b6029..4be4109 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ filec **/*.o **/*.chtml mastodont-c +config.h \ No newline at end of file diff --git a/INSTALL.md b/INSTALL.md deleted file mode 100644 index 054628d..0000000 --- a/INSTALL.md +++ /dev/null @@ -1,40 +0,0 @@ -# Installing Treebird - -## Compiling - -You need the following libraries / packages: - -- libcurl - - Debian: `libcurl4-gnutls-dev` -- libcjson - - Debian: `libcjson-dev` - - Arch: `cjson` -- libpcre3 - - Debian: `libpcre3-dev` - -First, edit `config.h` to your instance's liking. - -`make` will clone the library, and compile both it and the project. - -`make update` should be run after updating, as it ensures both the library and the project are up to date. - -## Deploying - -After running `make`, Treebird's files will be in the `dist/` directory. _Copy_, ***DO NOT MOVE***, **everything but treebird.cgi** of this folder to your web server. Copy `treebird.cgi` to another directory of your choosing. - -- The example static files will be in `/var/www/treebird/`, with `treebird.cgi` in `/usr/local/bin/treebird.cgi`. - -### Using NGINX (and uWSGI) to serve Treebird -Treebird can be served over nginx by using a CGI server such as uwsgi. - -#### nginx -An example nginx configuration is available in [treebird.nginx.conf](./treebird.nginx.conf). -* Make sure to change `example.com` to your instance's domain. -* Make sure to change the `root` to wherever the static files are being stored - -#### uWSGI -uWSGI can be installed on debian with just `sudo apt isntall uwsgi`. - -An example configuration is available in [treebird.uwsgi.ini](./treebird.uwsgi.ini). This should be copied to `/etc/uwsgi/apps-enabled/treebird.ini` on debian (and potentially other) systems. - -##### Note: the uwsgi configuration file is currently very basic. \ No newline at end of file diff --git a/README.md b/README.md index c390fc5..c357228 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,28 @@ # Treebird -A pleroma frontend for cool people only. +![Treebird logo](./meta/treebird.png) + +A very lightweight Pleroma frontend. The goal is to create a frontend that's lightweight enough to be viewed without JS, but usable enough to improve the experience with JS. -Treebird uses C with FCGI, mastodont-c (another library that complements Treebird) for -communication, and plain JavaScript (100% optional). +Treebird uses C with FCGI, mastodont-c (library designed for Treebird, but can be used +for other applications as well), and plain JavaScript for the frontend (100% optional). -## Isn't FCGI outdated? +## Why? -No. +PleromaFE, pleroma's default frontend, uses way too much Javascript to be usable (and doesn't even support +all of it's own API features...). BloatFE is great, but designed only around Mastodon's api, and isn't as +modern or as lightweight as it could be. Soapbox is soapbox and does soapbox things. + +This led me to one choice, to develop my own frontend. + +## Compatibility + +Treebird respects compatibility with old browsers, and thus uses HTML table layouts, which are +supported even by most modern terminal web browsers. The core browser we aim to at least maintain compatibility +with is Netsurf, but most other browsers like GNU Emacs EWW, elinks, render Treebird wonderfully. ## Credits @@ -18,4 +30,4 @@ Please view the [`CREDITS`](./CREDITS) file. ## Installing -See [INSTALL.md](./INSTALL.md) +See [INSTALL.md](./docs/INSTALL.md) for instructions on Apache/Nginx. diff --git a/config.h b/config.def.h similarity index 87% rename from config.h rename to config.def.h index a1fe190..90afda8 100644 --- a/config.h +++ b/config.def.h @@ -16,7 +16,6 @@ * * The software's recognizable name. * - * * Example: "treebird" */ @@ -29,9 +28,9 @@ static char* const config_canonical_name = "treebird"; * This MUST include a slash at the end, and the protocol (like https://) at the * beginning * - * Example: "https://cum.desupost.soy/ + * Example: "https://shitposter.club/" */ -static char* const config_instance_url = "https://desuposter.club/"; +static char* const config_instance_url = "https://my-instace.social/"; /* * String: url_prefix @@ -41,7 +40,7 @@ static char* const config_instance_url = "https://desuposter.club/"; * * Example: "/treebird.cgi" */ -static char* const config_url_prefix = "/treebird.cgi"; +static char* const config_url_prefix = ""; /* * Bool: experimental_lookup @@ -62,6 +61,6 @@ static const int config_experimental_lookup = TRUE; * Enables the test page which dumps all CGI cookies, useful when * setting up a reverse proxy */ -static const unsigned config_test_page = TRUE; +static const unsigned config_test_page = FALSE; #endif // CONFIG_H diff --git a/docs/INSTALL.md b/docs/INSTALL.md new file mode 100644 index 0000000..78eab23 --- /dev/null +++ b/docs/INSTALL.md @@ -0,0 +1,61 @@ +# Installing Treebird + +## Compiling + +For the following GNU/Linux distributions, you will need the following libraries/packages: + +- libcurl + - Debian: `libcurl4-gnutls-dev` + - Arch: `curl` + - Void: `libcurl libcurl-devel` +- libcjson + - Debian: `libcjson-dev` + - Arch: `cjson` + - Void: `cJSON cJSON-devel` +- libpcre + - Debian: `libpcre3-dev` + - Void: `libpcre2` +- libfcgi + - Void: `fcgi fcgi-devel` + +Create a copy of `config.def.h` at `config.h`, edit the file with your information + +Run `make`. This will also clone mastodont-c, and compile both it and Treebird. + +If you `git pull` any changes, `make update` should be run after updating, as it ensures +the library is up to date. + +## Installation + +- TODO? + +Run `make install`, this might require root. + +If this succeeds (assuming you used default variables), you can now find Treebird at the following + +- `/usr/local/share/treebird/` - Contains CSS, images, and other meta files +- `/usr/local/bin/treebird` - Regular executable CGI file, test it by running it as is, it'll spit HTML out! + +### Using NGINX (and uWSGI) + +Treebird can be served over nginx by using a CGI server such as uwsgi. + +The example static files will be in `/var/www/treebird/`, with `treebird.cgi` at `/usr/local/bin/treebird`. + +After running `make`, Treebird's files will be in the `dist/` directory. _Copy_, ***DO NOT MOVE***, **everything but treebird.cgi** of this folder to your web server. Copy `treebird.cgi` to another directory of your choosing. + +#### nginx +An example nginx configuration is available in [treebird.nginx.conf](./sample/treebird.nginx.conf). +* Make sure to change `example.com` to your instance's domain. +* Make sure to change the `root` to wherever the static files are being stored + +#### uWSGI +uWSGI can be installed on debian with just `sudo apt isntall uwsgi`. + +An example configuration is available in [treebird.uwsgi.ini](./sample/treebird.uwsgi.ini). This should be copied to `/etc/uwsgi/apps-enabled/treebird.ini` on debian (and potentially other) systems. + +##### Note: the uwsgi configuration file is currently very basic. + +### Using Apache and mod_proxy_fcgi + +TODO \ No newline at end of file diff --git a/docs/sample/treebird.apache.conf b/docs/sample/treebird.apache.conf new file mode 100644 index 0000000..a7ca70d --- /dev/null +++ b/docs/sample/treebird.apache.conf @@ -0,0 +1,20 @@ +# TODO a lot of things +# THIS IS UNTESTED AND INCOMPLETE, ITS JUST FOR REFERENCE + +# Give access to our directory + + Require all granted + + + + DocumentRoot "/usr/local/share/treebird/dist" + + # Intercept meta files to be loaded before proxy + RewriteEngine on + RewriteRule ^/(.*).css /$1.css [L] + RewriteRule ^/(treebird\_logo|favicon).png /$1.png [L] + + # Set PATH_INFO variable + SetEnvIf Request_URI . proxy-fcgi-pathinfo=1 + ProxyPass / "fcgi://localhost:4000/" + \ No newline at end of file diff --git a/treebird.nginx.conf b/docs/sample/treebird.nginx.conf similarity index 100% rename from treebird.nginx.conf rename to docs/sample/treebird.nginx.conf diff --git a/treebird.uwsgi.ini b/docs/sample/treebird.uwsgi.ini similarity index 100% rename from treebird.uwsgi.ini rename to docs/sample/treebird.uwsgi.ini diff --git a/src/main.c b/src/main.c index bf3b00f..b616d0b 100644 --- a/src/main.c +++ b/src/main.c @@ -40,7 +40,7 @@ int main(void) // Global init mastodont_global_curl_init(); - unsigned run_count = 0; + unsigned run_count = 1; // API for (;FCGI_Accept() >= 0; ++run_count) @@ -75,8 +75,6 @@ int main(void) { "/notifications", content_notifications }, }; - printf("Run: %d\r\n", run_count); - handle_paths(&api, paths, sizeof(paths)/sizeof(paths[0])); // Cleanup @@ -88,6 +86,8 @@ int main(void) // can't even think reading them memset(&cookies, 0, sizeof(cookies)); memset(&post, 0, sizeof(post)); + + ++run_count; } mastodont_global_curl_cleanup();