💾 Archived View for tilde.pink › ~semaphore › gemlog › scripts.gmi captured on 2023-01-29 at 17:29:33. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

 ,---.               ,--.         ,--.          
'   .-'  ,---.,--.--.`--' ,---. ,-'  '-. ,---.  
`.  `-. | .--'|  .--',--.| .-. |'-.  .-'(  .-'  
.-'    |\ `--.|  |   |  || '-' '  |  |  .-'  `) 
`-----'  `---'`--'   `--'|  |-'   `--'  `----'  
                         `--'                   

I use some things to that when I enter "gemlog" in the terminal, I am able to title my log, tag it (with limited tags), and have a link to the new log populate in various places - the gemlog digest, the atom feed, and, if I have tagged it with something (e.g. 'cfa'), then it will be linked on that page too.

There are 4 things that make this work for me. First, a 'blank' atom feed, second a preformatted header .txt for the log, third a preformatted digest page and fourth a bash script.

I'll paste all of these below. The bash script could do with some optimisations. I learned more about sed so I reckon there's a good few lines and at least one variable that could be removed! It's all a learning process :D

This is the atom feed of all my Gemlogs.

These are handy for feed-readers etc - the Gemini browser Amphora has a feed-reader baked in that works really well. I have a link to Amphora in "links".

The 'blank' atom feed

Below is the 'blank' feed I started with:

<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <id>gemini://gemini.ctrl-c.club/~semaphore/gemlog/digest.gmi</id>
  <title>Semaphore's Gemlog</title>
<updated>2021-03-15T00:00:00+00:00</updated>
  <author>
    <name>gemini.ctrl-c.club/~semaphore</name>
    <email>semaphore@ctrl-c.club</email>
  </author>
  <link href="gemini://gemini.ctrl-c.club/~semaphore/gemlog/atom.xml" rel="self"/>
  <link href="gemini://gemini.ctrl-c.club/~semaphore/gemlog/digest.gmi" rel="alternate"/>
  <generator uri="gemini://gemini.ctrl-c.club/~semaphore" version="0.0.1">World's Shittest Script, by Semaphore</generator>
</feed>

gemlogheader.txt

This is the header which is inserted to the top of gemlog we've just created:

The header file [.txt]

Preformatted digest.gmi

This is the gemlog digest, which will have a link to the new entry inserted to the top of the list.

The digest file, again with entries added.

The bash script gemlog.sh

This is a copy of the bash script I run, obviously it has my filepaths etc.

The gemlog.sh file

An explanation of how the script works

Firstly, $backslashheaven was me ragequitting on a problem, but I've since learn more about sed so I'll get around to cleaning it up one day and update it here too. But not today! Basically, the script;

1. Asks for the title of the post (e.g. 'I Sent Morse For The First Time' or 'Martial Arts Grading Soon!"'), then asks for a filename (e.g. 'sendmorse' or 'grading'), then asks for if there's any tags (e.g. 'radio' or 'ma').

2. The script then creates a .gmi of the filename I specified, then adds the preformatted header, the date, the title and at the end it adds a link to go back to the digest page. Because this is is done with echo >>, it's formatted for gemini already.

3. It updates the atom feed, by;

a) removing the </feed> at the end of the .xml, and removing the line timestamping when the feed was last updated;

b) adding an entry at the bottom of the .xml with all the necessary stuff - the title, actual location in the internet of the log, the date and other things;

c) re-adding the </feed> to the end of the .xml now that the new entry is in, and reinserting a new timestamp showing when the atom feed was updated (i.e. just now);

4. Adding a link for the new gemlog post to the digest page, which includes the date & title of the log, with the most recent gemlog post on top.

5. If a tag was specified, then the new post will also be linked at the bottom of the relevant page (for instance, if it's a tag about firefighting then it well be added to the main CFA page). This should hopefully allow pages that would otherwise be a bit static to be more dynamic, having some usual or generic stuff, but then with any new developments also added added at the bottom, by way of a link to a gemlog.

6. Last, but certainly not least, Gedit opens to actually write the post. Once I'm done writing I save the file. When I learn vim I'll use that instead of gedit. Until then I'll use gedit. Get off my back, you're not my real mum/dad!

7. When I'm all done and happy I rsync the whole pod to both tilde.pink and ctrl-c.club (which will include any new gemlogs, new firecalls, or any other changes).

8. The rsync is acheived with a different bash script that was fun to write and does probably too many things ;) But it updates all servers and timestamps the changes on both, as well as updates the timestamp on the landing page I have up at https://ctrl-c.club/~semaphore

The digest page

Back to the main page