From 7f24335f97ee9c32666b22d5c031a4715fea45e2 Mon Sep 17 00:00:00 2001 From: David Eisinger Date: Wed, 19 Nov 2025 10:57:10 -0500 Subject: [PATCH] auto-generate image captions --- bin/encrypt | 19 ++++++++++++++++++- themes/v2/layouts/shortcodes/dither.html | 13 +++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/bin/encrypt b/bin/encrypt index 087e2ad..12899e8 100755 --- a/bin/encrypt +++ b/bin/encrypt @@ -1,5 +1,7 @@ #!/usr/bin/env ruby +require "open3" + file = ARGV.pop || raise("please supply a filename") raise("file '#{file}' does not exist") unless File.exist?(file) @@ -13,7 +15,22 @@ raise("file '#{file}' does not exist") unless File.exist?(file) -iter 1000000 ) -output = %[{{}}] +caption_cmd = ["codex", "exec", "caption this image: #{file}"] +caption_output, status = Open3.capture2e(*caption_cmd) + +unless status.success? + warn "Caption generation failed:\n#{caption_output}" + exit 1 +end + +caption = caption_output.split("\n").last.to_s.strip + +if caption.empty? + warn "Caption output was empty." + exit 1 +end + +output = %[{{}}#{ caption }{{}}] IO.popen("pbcopy", "w") { |pb| pb.write(output) } diff --git a/themes/v2/layouts/shortcodes/dither.html b/themes/v2/layouts/shortcodes/dither.html index e2851bc..0f3be5f 100644 --- a/themes/v2/layouts/shortcodes/dither.html +++ b/themes/v2/layouts/shortcodes/dither.html @@ -4,10 +4,11 @@ {{ $imgClass := .Get 2 }} - - {{ with .Inner }} -
- {{ . }} -
- {{ end }} +