From 282031245c014608aacfad799e23db32261cf323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian-Samuel=20Geb=C3=BChr?= Date: Wed, 26 Jul 2023 12:43:34 +0200 Subject: [PATCH] Rename from mastodon->fediverse --- .drone.yml | 4 ++-- DEVELOPMENT.md | 6 +++--- Dockerfile | 4 ++-- README.md | 21 ++++++++++++------- .../cli.py | 6 +++--- .../helpers.py | 2 +- .../models.py | 0 pyproject.toml | 10 ++++----- 8 files changed, 29 insertions(+), 24 deletions(-) rename {mastodon_blocklist_deploy => fediverse_blocklist_deploy}/cli.py (96%) rename {mastodon_blocklist_deploy => fediverse_blocklist_deploy}/helpers.py (96%) rename {mastodon_blocklist_deploy => fediverse_blocklist_deploy}/models.py (100%) diff --git a/.drone.yml b/.drone.yml index 038246d..224af70 100644 --- a/.drone.yml +++ b/.drone.yml @@ -10,7 +10,7 @@ platform: steps: - name: build commands: - - docker build -t gcrkrause/mastodon-blocklist-deploy . + - docker build -t gcrkrause/fediverse-blocklist-deploy . - name: push environment: USERNAME: @@ -19,7 +19,7 @@ steps: from_secret: docker-hub-pw commands: - docker login -u $USERNAME -p $PASSWORD - - docker push gcrkrause/mastodon-blocklist-deploy + - docker push gcrkrause/fediverse-blocklist-deploy - docker image prune -a -f when: event: diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 5556f57..b12e98a 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -4,14 +4,14 @@ In order to have a common development environment, its nice to use docker. Its quite easy. To build a new image, simply run -`docker build . -t mastodon_blocklist_deploy` +`docker build . -t fediverse_blocklist_deploy` Now you can execute any commands using -`docker run --rm mastodon_blocklist_deploy --help` +`docker run --rm fediverse_blocklist_deploy --help` If you want to avoid building new containers for each change, simply mount your code into the container using -`docker run --rm -v $(pwd):/app mastodon_blocklist_deploy` +`docker run --rm -v $(pwd):/app fediverse_blocklist_deploy` Please be aware that changes to the package itself require a rebuild anyways. diff --git a/Dockerfile b/Dockerfile index 0cccbfc..f3eb817 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,9 +4,9 @@ ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 COPY pyproject.toml poetry.lock README.md /app/ -COPY mastodon_blocklist_deploy /app/mastodon_blocklist_deploy +COPY fediverse_blocklist_deploy /app/fediverse_blocklist_deploy WORKDIR /app -ENTRYPOINT ["mastodon_blocklist_deploy"] +ENTRYPOINT ["fediverse_blocklist_deploy"] RUN pip install -e . diff --git a/README.md b/README.md index e93c597..8e34dcd 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# mastodon-blocklist-deploy +# fediverse-blocklist-deploy -A small tool to deploy blocklist updates to a mastodon server using its API. +A small tool to deploy blocklist updates to a fediverse server using its API. ## Concept The idea is to maintain a blocklist in a simple structured file in this repository. All changes need to be deployed to -the mastodon server, this is supposed to be automated with Drone CI. +the fediverse server, this is supposed to be automated with Drone CI. In order to compare the list entries, we can read the whole blocklist using [the get endpoint](https://docs.joinmastodon.org/methods/admin/domain_blocks/#get). At the same time we read the @@ -19,17 +19,22 @@ and structured file format. Since Python 3.11 got native support for [toml](http supports [Array of Tables](https://toml.io/en/v1.0.0#array-of-tables), I'd prefer to use this. +# Supported server types + +- [x] Mastodon +- [X] GoToSocial + # Basic usage ## ``` -usage: mastodon_blocklist_deploy [-h] [-s SERVER] [-t TOKEN] [-i INPUT_FILE] [-r REMOTE_BLOCKLIST] [-o OUTPUT] [-v] [-n] +usage: fediverse_blocklist_deploy [-h] [-s SERVER] [-t TOKEN] [-i INPUT_FILE] [-r REMOTE_BLOCKLIST] [-o OUTPUT] [-v] [-n] [--format FORMAT] [--private] {diff,deploy,export} -Deploy blocklist updates to a mastodon server +Deploy blocklist updates to a fediverse server positional arguments: {diff,deploy,export} Either use 'diff' to check the difference between local blockĺist and the blocklist on the server, 'deploy' @@ -64,7 +69,7 @@ options: 1. **Export the current blocklist from the server** ``` -mastodon_blocklist_deploy export -s yourserver -t yourtoken -o blocklist.toml +fediverse_blocklist_deploy export -s yourserver -t yourtoken -o blocklist.toml ``` 2. **Manually add something to the blocklist** @@ -83,12 +88,12 @@ private_comment = "We discussed this after X and Y and now that Z happend we dec 3. **Check the difference between the local and remote blocklist** ``` -mastodon_blocklist_deploy diff -s yourserver -t yourtoken -i blocklist.toml +fediverse_blocklist_deploy diff -s yourserver -t yourtoken -i blocklist.toml ``` 4. **Apply the local blocklist to the server** ``` -mastodon_blocklist_deploy apply -s yourserver -t yourtoken -i blocklist.toml +fediverse_blocklist_deploy apply -s yourserver -t yourtoken -i blocklist.toml ``` diff --git a/mastodon_blocklist_deploy/cli.py b/fediverse_blocklist_deploy/cli.py similarity index 96% rename from mastodon_blocklist_deploy/cli.py rename to fediverse_blocklist_deploy/cli.py index 6c87248..58923c9 100644 --- a/mastodon_blocklist_deploy/cli.py +++ b/fediverse_blocklist_deploy/cli.py @@ -6,8 +6,8 @@ import requests import os import toml -from mastodon_blocklist_deploy.models import Instance -from mastodon_blocklist_deploy.helpers import blocklist_to_markdown, blocklist_to_toml, blocklist_to_csv, \ +from fediverse_blocklist_deploy.models import Instance +from fediverse_blocklist_deploy.helpers import blocklist_to_markdown, blocklist_to_toml, blocklist_to_csv, \ blocklist_to_json @@ -89,7 +89,7 @@ def merge(input_file, merge_target, format: str = "toml", private: bool = False, def cli(): - parser = argparse.ArgumentParser(description='Deploy blocklist updates to a mastodon server') + parser = argparse.ArgumentParser(description='Deploy blocklist updates to a fediverse server') parser.add_argument('action', choices=['diff', 'deploy', 'export', 'merge'], help="Either use 'diff' to check the difference between local blockĺist and the blocklist on " "the server, 'deploy' to apply the current local blocklist or 'export' to export the remote " diff --git a/mastodon_blocklist_deploy/helpers.py b/fediverse_blocklist_deploy/helpers.py similarity index 96% rename from mastodon_blocklist_deploy/helpers.py rename to fediverse_blocklist_deploy/helpers.py index 09393a5..5ec9f75 100644 --- a/mastodon_blocklist_deploy/helpers.py +++ b/fediverse_blocklist_deploy/helpers.py @@ -1,4 +1,4 @@ -from mastodon_blocklist_deploy.models import Instance +from fediverse_blocklist_deploy.models import Instance import toml import io import csv diff --git a/mastodon_blocklist_deploy/models.py b/fediverse_blocklist_deploy/models.py similarity index 100% rename from mastodon_blocklist_deploy/models.py rename to fediverse_blocklist_deploy/models.py diff --git a/pyproject.toml b/pyproject.toml index 95afb23..4b244c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,12 @@ [tool.poetry] -name = "mastodon-blocklist-deploy" +name = "fediverse-blocklist-deploy" version = "0.1.0" -description = "A small tool to deploy blocklist updates to a mastodon server using its API." +description = "A small tool to deploy blocklist updates to a fediverse server using its API." authors = ["Georg Krause ", "Julian-Samuel Gebühr "] readme = "README.md" -packages = [{include = "mastodon_blocklist_deploy"}] +packages = [{include = "fediverse_blocklist_deploy"}] license = "MIT" -keywords = ["mastodon", "blocklist", "fediverse"] +keywords = ["fediverse", "blocklist", "fediverse"] [tool.poetry.dependencies] @@ -16,7 +16,7 @@ rich = "^13.0.1" toml = "^0.10.2" [tool.poetry.scripts] -mastodon_blocklist_deploy = 'mastodon_blocklist_deploy.cli:cli' +fediverse_blocklist_deploy = 'fediverse_blocklist_deploy.cli:cli' [build-system]