~samhh/samhh.com

f2d9d564f27f6d553233430be2a2dbace7b06454 — Sam A. Horvath-Hunt 4 months ago 59f9807
Remove malformed RSS openring patch

It should have been fixed in the relevant feed, but seemingly isn't. In
any case the patch doesn't seem to be working any more...
4 files changed, 0 insertions(+), 67 deletions(-)

M .build.yml
M README.md
M makefile
D openring.patch
M .build.yml => .build.yml +0 -2
@@ 16,8 16,6 @@ tasks:
# `$PATH`.
- openring: |
    cd openring
    git checkout 28dc22a
    git am ../samhh.com/openring.patch
    go build -o openring
    sudo cp openring /usr/bin
- build: |

M README.md => README.md +0 -2
@@ 3,5 3,3 @@
The statically-generated source for [samhh.com](https://samhh.com).

Currently building against Hugo 0.92.

A patch is applied against openring to support RSS date formats not to spec.

M makefile => makefile +0 -1
@@ 8,7 8,6 @@ dev:
build:
	rm -rf public
	openring \
		-t 2006-01-02 \
		-s https://drewdevault.com/blog/index.xml \
		-s https://lexi-lambda.github.io/feeds/all.rss.xml \
		-s https://blog.ploeh.dk/rss.xml \

D openring.patch => openring.patch +0 -62
@@ 1,62 0,0 @@
From 58bbca2fbef6f59635db5dc9ba1bc4c8d7e4f29c Mon Sep 17 00:00:00 2001
From: "Sam A. Horvath-Hunt" <hello@samhh.com>
Date: Mon, 6 Dec 2021 14:41:45 +0000
Subject: [PATCH] Add custom time layout support

---
 openring.go | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/openring.go b/openring.go
index aa74469..718708b 100644
--- a/openring.go
+++ b/openring.go
@@ -19,8 +19,22 @@ import (
 	"github.com/microcosm-cc/bluemonday"
 )
 
+type timeLayoutSlice []string
 type urlSlice []*url.URL
 
+func (ts *timeLayoutSlice) String() string {
+	var str []string
+	for _, t := range *ts {
+		str = append(str, t)
+	}
+	return strings.Join(str, ", ")
+}
+
+func (ts *timeLayoutSlice) Set(val string) error {
+	*ts = append(*ts, val)
+	return nil
+}
+
 func (us *urlSlice) String() string {
 	var str []string
 	for _, u := range *us {
@@ -53,8 +67,10 @@ func main() {
 		perSource  = getopt.Int("p", 1, "articles to take from each source")
 		summaryLen = getopt.Int("l", 256, "length of summaries")
 		urlsFile   = getopt.String("S", "", "file with URLs of sources")
-		sources    []*url.URL
+		timeLayouts []string
+		sources     []*url.URL
 	)
+	getopt.Var((*timeLayoutSlice)(&timeLayouts), "t", "list of additional time formats")
 	getopt.Var((*urlSlice)(&sources), "s", "list of sources")
 
 	getopt.Usage = func() {
@@ -99,6 +115,10 @@ func main() {
 		panic(err)
 	}
 
+        for _, layout := range timeLayouts {
+          rss.TimeLayouts = append(rss.TimeLayouts, layout)
+        }
+
 	log.Println("Fetching feeds...")
 	var feeds []*rss.Feed
 	for _, source := range sources {
-- 
2.34.1