Turns form data into JSON and opens a pull request. https://fediblock.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
tastytea 7a9b3e92a4
Remove unneeded using.
1 week ago
cmake Update FindFilesystem, re-enable support for CMake 3.10. 4 months ago
src Remove unneeded using. 1 week ago
tests Fix test. 4 months ago
.clang-format Update .clang-format. 3 weeks ago
.drone.yml CI: Work around pugixml-CMake failure in Ubuntu bionic. 3 weeks ago
.editorconfig Add skeleton. 4 months ago
.gitignore Add skeleton. 4 months ago
AUTHORS Add skeleton. 4 months ago
CMakeLists.txt Use pugixml for RSS generation. 3 weeks ago
CODE_OF_CONDUCT.adoc Add skeleton. 4 months ago
CONTRIBUTING.adoc Fix URIs in contributing guidelines. 4 months ago
CREDITS Use pugixml for RSS generation. 3 weeks ago
LICENSE Add skeleton. 4 months ago
README.adoc Use pugixml for RSS generation. 3 weeks ago

README.adoc

fediblock-backend

fediblock-backend turns form data into JSON and opens a pull request on FediBlock/data. Also included are tools to generate a HTML list and an RSS generator.

Usage

nginx config
# Use 100 MiB cache with a 1 MiB memory zone (enough for ~8,000 keys).
# Delete data that has not been accessed for 10 minutes.
fastcgi_cache_path /var/cache/nginx/fediblock levels=1:2 max_size=100m
                   keys_zone=fediblock:1m inactive=10m use_temp_path=off;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
add_header X-Cache $upstream_cache_status;

server {
    # […]

    expires 30m;

    location ~* "(png|jpe?g|webp|gif)$" {
        expires 6d;
    }

    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 15m; # Cache answers for up to 15 minutes.
        fastcgi_cache_lock on;  # Relay only one identical request at a time.
    }
}
Generate SSH key
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.

Generate an access token and save it in ~nginx/.local/share/fediblock-backend/gitea_access_token.

Note
On non-Linux systems the data path is ~nginx/.fediblock-backend unless XDG_DATA_HOME is set.

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.

Generate HTML blocklist

After compiling, run fediblock-backend-gen_html. The screenshots will be copied into the target directory and the output will be the HTML file.

Example: Generate the HTML blocklist in ~/blocklist/
fediblock-backend-gen_html ~/blocklist > ~/blocklist/index.html

Existing screenshots will not be overwritten.

Note
The RSS generator expects the blocklist to be in http(s)://your-domain/blocklist/.

Install

From source

Dependencies

  • Tested OS: Linux

  • C++ compiler with C++17 support (tested: GCC 7/8/9/10, clang 6/7/10)

  • CMake (at least: 3.10)

  • cgicc (tested: 3.2)

  • nlohmann-json (tested: 3.7 / 2.1)

  • libgit2 with SSH support (tested: 1.0 / 0.26)

  • libcurl (at least: 7.56)

  • ICU (tested: 67.1 / 60.2)

  • fmt (tested: 7.0 / 4.0)

  • pugixml (tested: 1.10 / 1.8)

  • Optional

    • Tests: Catch (tested: 2.5 / 1.10)

    • DEB package: dpkg (tested: 1.19)

    • RPM package: rpm-build (tested: 4.11)

Get sourcecode

git clone https://schlomp.space/FediBlock/backend.git

Compile

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 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.

How to contribute

Read the Code of Conduct.

Reporting bugs or suggesting enhancements

Before reporting a bug, please perform a search to see if the problem has already been reported. If it has, add a comment to the existing issue instead of opening a new one. Same for enhancements.

You can also contact me via E-Mail, XMPP or the Fediverse if you don’t want to open an account.

Pull requests

Please use similar coding conventions as the rest of the project. The basic rule to remember is to write code in the same style as the existing/surrounding code.

Add a copyright line with the year, your name and your email address to the files you edited. Add your name and email to AUTHORS. Unless you don’t want to.

You can also send me your patches via E-Mail, ideally using git send-email.