Autor: Mario Breskic

  • Artikellinks aus WordPress in Linkwarden speichern

    Ein kurzer Snippet zum Ausprobieren. Benötigt WordPress und Linkwarden.1 Damit werden alle Links, die sich in einem Artikel bestimmter Kategorien befinden, beim Veröffentlichen zum Speichern an Linkwarden geschickt. Linkwarden schickt diese dann auch an archive.org, damit sie auch öffentlich verfügbar bleiben.

    Kontext dazu: Mein Mastodon‑Post hier, und dieser Bluesky‑Post.

    // Hooks into the WordPress publish_post action.
    // When a post is published, it triggers the send_post_links_to_linkwarden function.
    add_action('publish_post', 'send_post_links_to_linkwarden', 10, 2);

    function send_post_links_to_linkwarden($post_ID, $post) {
    // Only proceed if the post is in one of these categories.
    $preferred_categories = ['CHANGE_ME', 'CHANGE_ME_TOO'];

    // Set post_title
    $post_title = sanitize_text_field($post->post_title);


    // Get the category slugs of the published post.
    $post_categories = wp_get_post_categories($post_ID, ['fields' => 'slugs']);

    // Skip processing if the post doesn't belong to one of the preferred categories.
    if (empty(array_intersect($preferred_categories, $post_categories))) {
    error_log("[Linkwarden] Skipping post ID $post_ID because it is not in preferred categories.");
    return;
    }

    // Define the Linkwarden API base URL and access token.
    $api_base_url = ' https://YOUR_LINKWARDEN_URL/api/v1';
    $api_token = 'YOUR_API_TOKEN';

    // Extract all URLs from the post content.
    $content = $post->post_content;
    $urls = wp_extract_urls($content);

    // Exit if no URLs were found in the post.
    if (empty($urls)) {
    error_log("[Linkwarden] No URLs found in post ID $post_ID");
    return;
    }

    // Remove duplicate URLs.
    $urls = array_unique($urls);

    // Send each URL found in the post to the Linkwarden API.
    foreach ($urls as $url) {
    // Create the body of the request with the URL, post title as title and tag.
    $body = [
    'url' => $url,
    'title' => $post->post_title,
    'tags' => [ ['name'=> $post_title] ],
    'collectionId' => [
    'id' => COLLECTION_ID_NUMBER_NO_QUOTES_FOR_ME_PLEASE
    ],
    ];

    // Make a POST request to the Linkwarden /links endpoint.
    $response = wp_remote_post("{$api_base_url}/links", [
    'headers' => [
    'Authorization' => 'Bearer ' . $api_token,
    'Content-Type' => 'application/json',
    ],
    'body' => wp_json_encode($body),
    'timeout' => 10,
    ]);

    // Log an error if the HTTP request fails.
    if (is_wp_error($response)) {
    error_log("[Linkwarden] HTTP request error for URL $url: " . $response->get_error_message());
    continue;
    }

    // Check the response code to confirm successful addition.
    $code = wp_remote_retrieve_response_code($response);
    if ($code !== 201 && $code !== 200) {
    error_log("[Linkwarden] Unexpected response code $code for URL $url. Response: " . wp_remote_retrieve_body($response));
    } else {
    error_log("[Linkwarden] Successfully added URL $url from post ID $post_ID");
    }
    }
    }
    1. Getestet mit selbst-gehostetem Linkwarden als Docker-Volume. ↩︎
  • Satzspiegelrechner

    Was macht der Satzspiegelrechner?

    Der Satzspiegel­rechner ist ein Tool zur Visualisierung und Berechnung des Satzspiegels für ein Buchformat, hier exemplarisch für A5‑Seiten.
    Er zeigt, wie viele Zeilen bei einer vorgegebenen Buchstaben­höhe und einem fest­gelegten Zeilen­abstand auf die Seite passen, und stellt den Satz­spiegel (den be­druckbaren Bereich) mit typischen Seiten­rändern dar. So kann man Layout‑Parameter wie Buchstaben­höhe und Zeilen­abstand experimentell anpassen und direkt sehen, wie sich der Satzspiegel verändert.

    Wichtig: Dieses Tool ist aktuell noch ein Work in Progress – es befindet sich in einer sehr frühen Entwicklungsphase.

    Danke an Andreas Maxbauer für die Inspiration.

  • CRT-Pixel-Shader-Brush für BlackInk

    Dieses kurze Shader-Skript erzeugt RGB-Streifen entlang der Pinselbewegung und eignet sich als visuelles Experiment oder Ausgangspunkt für eigene Brush-Designs. Es kann direkt in BlackInk eingefügt werden – dazu einfach den Code in den „Brush Pixel Shader Editor“ kopieren und als neue Konfiguration speichern.

    Die Streifen entstehen durch eine einfache Modulo-Logik: Jede dritte Spalte wird abwechselnd rot, grün oder blau eingefärbt. Die Frequenz lässt sich über die uv.x-Skalierung anpassen. Die Berechnung erfolgt auf Basis der Pinselrichtung und ‑länge, wodurch das Muster dynamisch auf die Strichführung reagiert.

    cfg {
    name = "Vertical RGB Stripes";
    renderingTime = 60;
    }

    float4 main(idatas i) {
    // Normalize stroke space UVs
    box2 b = box2FromCenterAxe(i.strokeStartPos, length(i.strokePos - i.strokeStartPos), normalizeSafe(i.strokePos - i.strokeStartPos));
    float2 uv = 4 * b.toCenter(i.pos) / b.size;

    // Scale up horizontal frequency
    float stripe = floor(uv.x * 60); // visible stripes

    // Simple stripe pattern: R, G, B
    float3 col = float3(0.0, 0.0, 0.0);
    if (mod(stripe, 3) == 0) {
    col.r = 1.0;
    } else if (mod(stripe, 3) == 1) {
    col.g = 1.0;
    } else {
    col.b = 1.0;
    }

    return float4(col, 1.0);
    }
  • Neue Art, wie meine Toolbox aufgebaut ist. Integration mit IFTTT.

  • Mastodon-Server geupdatet

  • ActivityPub: „Hello World“

  • Suchfunktion verbessert: Suchergebnisanzahl und Highlighting des gesuchten Worts.