💾 Archived View for tilde.cafe › ~stack › gemlog › 2021-10-30-gemlog-generator.gmi captured on 2024-08-31 at 13:03:04. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-07-22)
-=-=-=-=-=-=-
I wrote a tiny (16K executable) utility in C to index my gemlog. It is probably useful to others, so here is some information.
TLDR: install the 15k gemlog executable. After creating or modifying files in your gemlog directory, execute gemlog_index <dir> then sort and concatenate headers/footers to the output.
Why? It is a minimalist indexing solution, with no dependencies (other than essential libraries). It makes gemlog indexing scripts really simple.
gemlog_index <dir>
Iterates through the specified directory (use . for current directory) and returns an index of gemlog-compatible files in gemtext format. Files must end in .gmi and start with the date in YYYY-MM-DD format; the first line of each gemlog file must be a #HEADING (which is used to name the link). Incompatible files are ignored.
The resultant index contains links, one per line, to each of the files. Each link name is constructed from the date extracted from the first 10 characters of the filename followed by the first line (header) of the file. The initial # is elided. In other words, file named `2021-10-30_my_gemlog_10.gmi`, containing a header `#What's up with that?` will result in a corresponding line in the output:
=>2021-10-30_my_gemlog_10.gmi 2021-10-30 What's up with that?
Although the executable file will probably run on your x86 Linux system, you should probably compile gemlog_index.c on your own system with
gcc -o gemlog_index gemlog_index.c
and put the executable into some visible directory.
gemlog_index executable (~16Kb) for x86 linux
The intended usage on a linux machine is:
gemlog_index . | sort -r > index.gmi
Of course, you can use `cat` to concatenate a header or a footer to the index... I keep the header in a separate file called 'header', and
cat header.txt <(~/bin/gemlog_index . | sort -r ) > index.gmi
Save yourself some carpal tunnel pain and make an alias in your .aliases file...
Contact me as stack here at ctrl-c.club if I can be of assistance.