1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
---
post_date: 2023-05-09
---
> Note: This was ported from my old gemini capsule, still served on gemini at `gemini.ctrl-c.club/~tjp`
# 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 <<EOF ...)` syntax? That's worth a shot.
EDIT: it was worth a shot, it works great.
## Automating Antenna
Where I *really* wanted to get with this script was something I could run which would unify (a) posting a new post, and (b) sending a request to antenna to alert it to the new post. If this isn't one-and-the-same step from a workflow standpoint, I will *definitely* forget to do the second part. And in the future, if more active aggregators in the Antenna style pop up, I can add them to the script once and have them integrated from there on out.
Shoddy multi-language paradigm or not, it was a pretty big and important step to get *some* automation in place.
|