gemini.git

going-flying.com gemini git repository

summary

tree

log

refs

36952b78790725b1cd37219ff23de503b29a4b6c - Matthew Ernisse - 1649384894

new post

view tree

view raw

diff --git a/build/build.py b/build/build.py
index 872f513..0514630 100755
--- a/build/build.py
+++ b/build/build.py
@@ -1,6 +1,7 @@
 #!/usr/bin/env python3
 
 import datetime
+import feedparser
 import jinja2
 import os
 import pytz
@@ -8,6 +9,10 @@ import re
 import sys
 
 from feedgen.feed import FeedGenerator
+from urllib.parse import quote_plus as quote
+
+sys.path.append('/var/gemini/capcom')
+import gusmobile
 
 URLBASE = 'gemini://going-flying.com/~mernisse/'
 
@@ -84,7 +89,7 @@ class GeminiFeed(object):
 	''' Wrapper for FeedGenerator that contains way too many hardcoded
 	defaults.
 	'''
-	def __init__(self):
+	def __init__(self, fn=None):
 		self.feed = FeedGenerator()
 		self.feed.id('gemini://going-flying.com/~mernisse/')
 		self.feed.title('~mernisse')
@@ -101,13 +106,40 @@ class GeminiFeed(object):
 			rel='self'
 		)
 
+		self.file_name = fn
+
+		# If there is already a gemlog atom feed sitting on disk save
+		# the date of it so that we can notify Antenna if we end up
+		# having new posts in it.
+		self.last_date = 0
+		if os.path.exists(self.file_name):
+			try:
+				parsed = feedparser.parse(self.file_name)
+			except Exception as e:
+				print(f'Failed to load {fn}: {e!s}')
+				return
+
+			self.last_date = parsed['feed']['updated']
+
 	def add(self, title, link, pubdate):
+		''' Add an entry to the feed. '''
 		entry = self.feed.add_entry()
 		entry.title(title)
 		entry.id(link)
 		entry.updated(pubdate)
 		entry.link(href=link, rel='alternate')
 
+	def should_notify(self):
+		''' Return True if we should notifiy services that we've
+		updated the feed.'''
+		if self.last_date == 0:
+			return False
+
+		if self.feed['updated'] <= self.last_date:
+			return False
+
+		return True
+
 	def write(self, fn):
 		self.feed.atom_file(fn)
 
@@ -176,7 +208,7 @@ if __name__ == '__main__':
 	adir = os.path.join(bdir, 'articles')
 	tdir = os.path.dirname(os.path.realpath(__file__))
 
-	feed = GeminiFeed()
+	feed = GeminiFeed(os.path.join(bdir, 'feed.xml'))
 
 	with open(os.path.join(tdir, 'template.txt'), encoding='utf-8') as fd:
 		article_template = fd.read()
@@ -226,3 +258,14 @@ if __name__ == '__main__':
 		fd.write(index_template.render({'articles': articles}))
 
 	feed.write(os.path.join(bdir, 'atom.xml'))
+	if not feed.should_notify():
+		sys.exit()
+
+	myurl = quote('gemini://going-flying.com/~mernisse/atom.xml')
+
+	# gusmobile has a bug where it needs the port in the URL I guess.
+	url = 'gemini://warmedal.se:1965/~antenna/submit'
+	# resp = gusmobile.fetch(f'{url}?{myurl}')
+	# if not resp.status == 20:
+	# 	print('Failed to notify Antenna')
+	print(f'Would call {url}?{myurl}')
diff --git a/users/mernisse/articles/26.gmi b/users/mernisse/articles/26.gmi
new file mode 100644
index 0000000..c267b71
--- /dev/null
+++ b/users/mernisse/articles/26.gmi
@@ -0,0 +1,34 @@
+---
+Title:          USENET Notes
+Date:           04/07/2022 22:15
+
+Around 20 years ago I was early enough in my career that I still harbored
+the illusion that there was any way to hold back the insanity of people. 
+My frustrations were mounting and I found solace in reading things from
+similarly beset individuals.  Simon Travaglia's BOFH[1] was an early
+companion.  There were also forums, mailing lists and USENET news groups
+where one could express themselves.
+
+=> http://bofharchive.com [1]
+
+Over the years I stopped using most of these things, largely because I
+entered a form of recovery from the systems administration trade and went
+into a somewhat more well thanked field... sales.  Late last year though
+I went and started poking around USENET again.  It is much less active
+than before however it is still there (it predates the Internet, after all)
+and there are still interesting topics being discussed regularly.  It
+got me thinking a bit about my website[2] and I was about start working
+on a NNTP frontend when I discovered that the kind soul who wrote
+gmane[3] also wrote a RSS to news gateway, gwene[4].  I promptly put my
+RSS feed and registered the newsgroup gwene.com.going-flying.blog[5].
+
+=> https://www.going-flying.com/
+=> https://gmane.io/
+=> https://gwene.org/
+=> nntp://news.gwene.org/gwene.com.going-flying.blog/
+
+It does a pretty good job, though since my RSS feed contains HTML you
+will want a news reader that understands HTML.  That being said I render
+a pretty minimal markup for RSS articles and I include the full article
+text so it should be a pretty good experience to read for gemini
+enthusiasts.