going-flying.com gemini git repository
e3cc47fb3634924389d97c6911ff571d73180a7f - Matthew Ernisse - 1595981897
some index work and unfold paragraphs in the source material for my gemlog (are we sure about that name?)
diff --git a/build/build.py b/build/build.py index 2a1b83c..394f91f 100755 --- a/build/build.py +++ b/build/build.py @@ -11,6 +11,7 @@ from feedgen.feed import FeedGenerator URLBASE = 'gemini://going-flying.com/~mernisse/' + class GlogMetaReader(object): meta_re = re.compile( r'^[ ]{0,3}(?P<key>[A-Za-z0-9_-]+):\s*(?P<value>.*)' @@ -99,6 +100,53 @@ class GeminiFeed(object): self.feed.atom_file(fn) +class GeminiTextUnfolder(object): + ''' Take a text file with manually formatted paragraphs and + unfold them for transmission as text/gemini documents. + ''' + def __init__(self, s): + self.lines = s.split('\n') + + def __str__(self): + ''' Actually do the paragraph unfolding. ''' + buf = '' + out = [] + in_pre = False + + for line in self.lines: + # Notice preformatted blocks so we do not unfold them. + if line.startswith('```'): + if in_pre: + in_pre = False + else: + in_pre = True + + out.append(line) + continue + + # Always add blank lines. If we are in a preformatted + # block then don't do anything else but if we aren't + # we are unfolding a paragraph and we should stop doing + # that now and append the buffer. + if line.strip() == '': + out.append(line) + + if in_pre: + continue + + out.append(buf.strip()) + buf = '' + + if in_pre: + out.append(line) + continue + + # add a trailing space to replace the stripped \n + buf += line + ' ' + + return '\n'.join(out) + + if __name__ == '__main__': bdir = os.path.abspath(sys.argv[1]) @@ -138,10 +186,12 @@ if __name__ == '__main__': ) output = os.path.join(bdir, fn) + content = GeminiTextUnfolder(article.content) with open(output, 'w', encoding='utf-8') as fd: fd.write(article_template.render({ 'article': article, + 'content': content, 'up': URLBASE })) diff --git a/build/template.txt b/build/template.txt index 6dcfc8a..89237d2 100644 --- a/build/template.txt +++ b/build/template.txt @@ -1,7 +1,11 @@ # [{{article.meta.date.strftime('%m/%d/%Y @%H:%M')}}]: {{ article.meta.title }} +## Raw {{article.content}} +## unfolded +{{content}} + => {{ up }} back 🚀 © MMXX matt@going-flying.com diff --git a/index.gmi b/index.gmi index ec6e5f5..3f57353 100644 --- a/index.gmi +++ b/index.gmi @@ -12,14 +12,18 @@ I have some plans to make more content available here, but for the moment there is really only this and a version of what you might call my microblog rendered into text/gemini. For the interested this capsule is running on Molly Brown in a Docker container, but started life as geminid in a Docker container. +## Things that are here => /~mernisse/ ~mernisse (gemlog) => /thoughts/ Gemini mirror of my web microblog, basically. => /how-built.gmi How this capsule is built, vaguely. => /cgi-bin/bofh.py BOFH-style Excuse Server + +## Things that are elsewhere => https://www.going-flying.com HTTPS version of going-flying.com -=> https://ssl.ub3rgeek.net/git/?p=containers.git;a=tree;f=geminid;hb=HEAD Git repository for this geminid in a container +=> https://ssl.ub3rgeek.net/git/?p=containers.git;a=tree;f=geminid;hb=HEAD Git repository of geminid in a container => https://ssl.ub3rgeek.net/git/?p=containers.git;a=tree;f=mollybrown;hb=HEAD Git repository for this Molly Brown in a container => gemini://gemini.uxq.ch geminid Information +=> https://tildegit.org/solderpunk/molly-brown Molly Brown information => gemini://gemini.circumlunar.space Gemini Information