fix mastodon post encoding

This commit is contained in:
Jonas Heinrich 2025-05-10 12:57:43 +02:00
parent 3086d63cc7
commit 27a4b1a094
3 changed files with 92 additions and 8 deletions

85
flake.nix Normal file
View file

@ -0,0 +1,85 @@
{
description = "Invoiceplane invoice template development shell";
inputs.nixpkgs.url = "nixpkgs/master";
outputs = { self, nixpkgs, ... }@inputs:
let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
start =
pkgs.writeShellScriptBin "start" ''
set -e
export NIXPKGS_ALLOW_INSECURE=1
export QEMU_NET_OPTS="hostfwd=tcp::8080-:80"
${pkgs.nixos-shell}/bin/nixos-shell --flake .
'';
in {
nixosConfigurations.vm = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs.inputs = inputs;
pkgs = import nixpkgs {
overlays = [
(self: super: {
froide-govplan = super.froide-govplan.overridePythonAttrs (oldAttrs: rec {
src = ./.;
#pkgs.fetchFromGitHub {
# owner = "onny";
# repo = "froide-govplan";
# rev = "81697ce37cfdee7b5d0f667c50b13062ed9786c3";
# hash = "sha256-ooHGlCKgZL+TMh6OtopKtbkV0MhT4udLCOIC+C3Ytdw=";
#};
dependencies = oldAttrs.dependencies ++ [ oldAttrs.passthru.python.pkgs.mastodon-py ];
postInstall = oldAttrs.postInstall + ''
rm -r $out/${pkgs.python3.sitePackages}/froide_govplan/templates
ln -sf /var/lib/froide-govplan/templates $out/${pkgs.python3.sitePackages}/froide_govplan/templates
cp -r froide_govplan/static $out/${pkgs.python3.sitePackages}/froide_govplan/
'';
});
})
];
};
modules = [
({ lib, config, pkgs, ... }: {
virtualisation = {
memorySize = 8000;
diskSize = 4096;
cores = 4;
};
disabledModules = [ "services/web-apps/froide-govplan.nix" ];
imports = [ ./froide-govplan.nix ];
services.froide-govplan = {
enable = true;
package = pkgs.froide-govplan;
settings = {
DEBUG = lib.mkForce true;
CSRF_TRUSTED_ORIGINS = [ "http://localhost:8080" ];
MASTODON_ACCESS_TOKEN = "WvUND5mp_tPQ9dgMrKWVXpUbP2gKpxRD3ejg10z74pg";
MASTODON_API_BASE_URL = "https://social.project-insanity.org";
};
};
nixos-shell.mounts.extraMounts = {
"/var/lib/froide-govplan/templates" = {
target = /home/onny/projects/froide-govplan/froide_govplan/templates;
cache = "none";
};
};
system.stateVersion = "25.05";
services.getty.autologinUser = "root";
})
];
};
packages = { inherit start; };
defaultPackage.x86_64-linux = start;
};
}

View file

@ -7,9 +7,8 @@ from .models import GovernmentPlanUpdate, GovernmentPlan
import re import re
def strip_html_tags(text): def strip_html_tags(text):
text = text.decode('utf-8')
tag_re = re.compile(r'<[^>]+>') tag_re = re.compile(r'<[^>]+>')
return tag_re.sub('', text) return tag_re.sub('', text).decode('utf-8')
def post_to_mastodon(text): def post_to_mastodon(text):
mastodon = Mastodon( mastodon = Mastodon(

View file

@ -11,18 +11,18 @@
{% block title %} {% block title %}
{{ object.title }} - VerwaltungsTracker {{ object.title }} - VerwaltungsTracker
{% endblock title %} {% endblock title %}
{% block ogTitle %}
{{ object.title }} - VerwaltungsTracker
{% endblock ogTitle %}
{% block meta %}
{% include "snippets/meta.html" %}
{% endblock meta %}
{% block metaDescription %} {% block metaDescription %}
{{ object.quote | addquotes }} {{ object.quote | addquotes }}
{% endblock %} {% endblock %}
{% block ogTitle %}
{{ object.title }} - VerwaltungsTracker
{% endblock ogTitle %}
{% block ogDescription %} {% block ogDescription %}
{{ object.quote | addquotes }} {{ object.quote | addquotes }}
{% endblock %} {% endblock %}
{% block meta %}
{% include "snippets/meta.html" %}
{% endblock meta %}
{% block app_body %} {% block app_body %}
<h1 class="text-body-emphasis">{{ object.title }}</h1> <h1 class="text-body-emphasis">{{ object.title }}</h1>