This repository has been archived on 2021-03-22. You can view files and clone it, but cannot push or open issues or pull requests.
backend/README.adoc

141 lines
4.9 KiB
Plaintext
Raw Normal View History

2020-06-29 03:01:30 +02:00
= fediblock-backend
:showtitle:
:toc: preamble
:project: fediblock-backend
2020-06-29 06:13:38 +02:00
:uri-base: https://schlomp.space/FediBlock/backend
2020-06-29 03:01:30 +02:00
:uri-branch-main: {uri-base}/src/branch/main
:uri-gcc: https://gcc.gnu.org/
:uri-clang: https://clang.llvm.org/
:uri-cmake: https://cmake.org/
:uri-catch: https://github.com/catchorg/Catch2
:uri-dpkg: https://packages.qa.debian.org/dpkg
:uri-rpm-build: http://www.rpm.org
:uri-clang-tidy: https://clang.llvm.org/extra/clang-tidy/
2020-06-29 06:35:19 +02:00
:uri-cgicc: https://www.gnu.org/software/cgicc/
:uri-nlohmann-json: https://nlohmann.github.io/json/
2020-07-01 03:51:00 +02:00
:uri-libgit2: https://libgit2.org/
2020-07-02 02:15:30 +02:00
:uri-libcurl: https://curl.haxx.se/libcurl/
2020-10-15 09:16:49 +02:00
:uri-icu: http://site.icu-project.org/
2020-06-29 03:01:30 +02:00
*{project}* turns form data into JSON and opens a pull request on
2020-07-04 03:10:08 +02:00
link:https://schlomp.space/FediBlock/data[FediBlock/data]. Also included are
2020-10-17 11:34:05 +02:00
tools to generate a HTML list and an RSS generator.
2020-06-29 03:01:30 +02:00
2020-07-01 12:07:38 +02:00
== Usage
.nginx config
[source,nginx]
--------------------------------------------------------------------------------
2020-10-18 00:38:46 +02:00
fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=fediblock:10m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
add_header X-Cache $upstream_cache_status;
server {
# […]
expires 1h;
location /add {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/cgi-fcgiwrap.socket-1;
fastcgi_param SCRIPT_FILENAME /usr/bin/fediblock-backend;
fastcgi_param HOME "/var/lib/nginx"; # When I didn't set it, HOME was /root.
}
location /rss {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/cgi-fcgiwrap.socket-1;
fastcgi_param SCRIPT_FILENAME /usr/bin/fediblock-backend-gen_rss;
fastcgi_param HOME "/var/lib/nginx";
fastcgi_cache fediblock;
fastcgi_cache_valid 200 10m;
}
2020-07-14 18:03:22 +02:00
}
2020-07-01 12:07:38 +02:00
--------------------------------------------------------------------------------
.Generate SSH key
[source,shell]
--------------------------------------------------------------------------------
sudo -u nginx ssh-keygen -t ed25519 -f ~nginx/.local/share/fediblock-backend/ssh_id
--------------------------------------------------------------------------------
Don't forget to add the key to the data repo.
2020-07-02 11:30:34 +02:00
Generate an access token and save it in
2020-07-14 18:03:22 +02:00
`~nginx/.local/share/fediblock-backend/gitea_access_token`.
2020-07-02 11:30:34 +02:00
[NOTE]
On non-Linux systems the data path is `~nginx/.fediblock-backend` unless
`XDG_DATA_HOME` is set.
2020-10-17 03:07:37 +02:00
Make sure the user that runs the CGI programs can create lockfiles. In Linux,
the locations are `/run/user/<UID>` or `/run/lock`, on UNIX the location is
`/var/run`. If none of these locations exist, `/tmp` is used as a fallback.
2020-07-02 11:30:34 +02:00
=== Generate HTML blocklist
2020-10-17 07:30:18 +02:00
After compiling, run `fediblock-backend-gen_html`. The screenshots will be
copied into the target directory and the output will be the HTML file.
2020-07-02 11:30:34 +02:00
.Example: Generate the HTML blocklist in `~/blocklist/`
[source,shell]
--------------------------------------------------------------------------------
2020-10-17 07:30:18 +02:00
fediblock-backend-gen_html ~/blocklist > ~/blocklist/index.html
2020-07-02 11:30:34 +02:00
--------------------------------------------------------------------------------
Existing screenshots will not be overwritten.
2020-10-15 09:15:26 +02:00
[NOTE]
The RSS generator expects the blocklist to be in
`http(s)://your-domain/blocklist/`.
2020-06-29 03:01:30 +02:00
== Install
=== From source
==== Dependencies
* Tested OS: Linux
* C\++ compiler with C++17 support (tested: link:{uri-gcc}[GCC] 7/8/9/10,
link:{uri-clang}[clang] 6/7/10)
* link:{uri-cmake}[CMake] (at least: 3.10)
2020-06-29 06:48:22 +02:00
* link:{uri-cgicc}[cgicc] (tested: 3.2)
2020-06-29 09:09:37 +02:00
* link:{uri-nlohmann-json}[nlohmann-json] (tested: 3.7 / 2.1)
* link:{uri-libgit2}[libgit2] with SSH support (tested: 1.0 / 0.26)
2020-07-02 02:15:30 +02:00
* link:{uri-libcurl}[libcurl] (at least: 7.56)
2020-10-15 09:16:49 +02:00
* link:{uri-icu}[ICU] (tested: 67.1 / 60.2)
2020-06-29 03:01:30 +02:00
* Optional
2020-06-29 09:09:37 +02:00
** Tests: link:{uri-catch}[Catch] (tested: 2.5 / 1.10)
2020-06-29 03:01:30 +02:00
** DEB package: link:{uri-dpkg}[dpkg] (tested: 1.19)
** RPM package: link:{uri-rpm-build}[rpm-build] (tested: 4.11)
==== Get sourcecode
[source,shell]
--------------------------------------------------------------------------------
2020-06-29 06:56:56 +02:00
git clone https://schlomp.space/FediBlock/backend.git
2020-06-29 03:01:30 +02:00
--------------------------------------------------------------------------------
==== Compile
[source,shell]
--------------------------------------------------------------------------------
mkdir -p build && cd build
cmake ..
cmake --build . -- --jobs=$(nproc --ignore=1)
--------------------------------------------------------------------------------
.CMake options:
* `-DCMAKE_BUILD_TYPE=Debug` for a debug build.
* `-DWITH_TESTS=YES` if you want to compile the tests.
* `-DWITH_CLANG-TIDY=YES` to check the sourcecode with
link:{uri-clang-tidy}[clang-tidy] while compiling.
* One of:
** `-DWITH_DEB=YES` if you want to be able to generate a deb-package.
** `-DWITH_RPM=YES` if you want to be able to generate an rpm-package.
To create a deb or rpm package, run `make package` after compiling.
include::{uri-base}/raw/branch/main/CONTRIBUTING.adoc[]