From 46a331dae8db622a491466ca9a0df3a5937ca80f Mon Sep 17 00:00:00 2001 From: t Date: Sat, 11 Jul 2026 23:19:23 -0600 Subject: back-port gemini capsule gemlog --- weblog/a-new-post-script.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 weblog/a-new-post-script.md (limited to 'weblog/a-new-post-script.md') diff --git a/weblog/a-new-post-script.md b/weblog/a-new-post-script.md new file mode 100644 index 0000000..c4ad068 --- /dev/null +++ b/weblog/a-new-post-script.md @@ -0,0 +1,30 @@ +--- +post_date: 2023-05-09 +--- + +# A new-post script + +I got to take a new "newpost" script for a spin just now and was really pleased with it. + +It: +- Moves the post file into my gemlog directory, renaming it in the process according to the date and the title, which it pulls from the first H1 in the post. +- Adds a link to the post to my index/homepage. I bail out to python for this since it's a little heavier - more on that in a minute. +- Alerts Antenna to the index page change. This is probably where 90% of the value comes in. + +## Mixing languages + +Now I'm feeling a little motivated to evict python from this script, because there's some friction in doing this task partly in bash and partly in python. + +Python isn't the greatest scripting language for one-liners, and using the -c switch isn't really useful any more beyond that. So for now this script (1) creates a tempfile, (2) dumps mostly hard-coded python into it (from a bash HEREDOC), (3) executes it, (4) captures the return code, (5) unconditionally removes the tempfile, and (6) exits the script if the return code was unsatisfactory. That's...not great. + +Although as I type this I guess I can probably execute "python" directly on a named pipe with bash `<(cat < Note: This was ported from my old gemini capsule, still served on gemini at `gemini.ctrl-c.club/~tjp` -- cgit v1.3