Skip to content

Commit fbbcdad

Browse files
committed
Render feeds as json, not markdown
1 parent 0e30ea5 commit fbbcdad

File tree

4 files changed

+60
-55
lines changed

4 files changed

+60
-55
lines changed

README.mdwn

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -310,16 +310,16 @@ a single root for all files in the zipfile.
310310

311311
### `rss`
312312

313-
`rss` is a minimalist rss client. Outputs links as markdown on STDOUT. Takes urls
313+
`rss` is a minimalist rss client. Outputs JSON on STDOUT. Takes urls
314314
to feeds and path to state file. Example usage:
315315

316316
```bash
317-
$ rss -state feed.json https://blog.afoolishmanifesto.com/index.xml
318-
[Announcing shellquote](https://blog.afoolishmanifesto.com/posts/announcing-shellquote/)
319-
[Detecting who used the EC2 metadata server with BCC](https://blog.afoolishmanifesto.com/posts/detecting-who-used-ec2-metadata-server-bcc/)
320-
[Centralized known_hosts for ssh](https://blog.afoolishmanifesto.com/posts/centralized-known-hosts-for-ssh/)
321-
[Buffered Channels in Golang](https://blog.afoolishmanifesto.com/posts/buffered-channels-in-golang/)
322-
[C, Golang, Perl, and Unix](https://blog.afoolishmanifesto.com/posts/c-golang-perl-and-unix/)
317+
$ rss -state feed.json https://blog.afoolishmanifesto.com/index.xml | jq -r '" * [" + .title + "](" +.link+")"'
318+
* [Announcing shellquote](https://blog.afoolishmanifesto.com/posts/announcing-shellquote/)
319+
* [Detecting who used the EC2 metadata server with BCC](https://blog.afoolishmanifesto.com/posts/detecting-who-used-ec2-metadata-server-bcc/)
320+
* [Centralized known_hosts for ssh](https://blog.afoolishmanifesto.com/posts/centralized-known-hosts-for-ssh/)
321+
* [Buffered Channels in Golang](https://blog.afoolishmanifesto.com/posts/buffered-channels-in-golang/)
322+
* [C, Golang, Perl, and Unix](https://blog.afoolishmanifesto.com/posts/c-golang-perl-and-unix/)
323323
```
324324

325325
### `slack-deaddrop`

help_generated.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -311,16 +311,16 @@ a single root for all files in the zipfile.
311311
312312
### ` + "`" + `rss` + "`" + `
313313
314-
` + "`" + `rss` + "`" + ` is a minimalist rss client. Outputs links as markdown on STDOUT. Takes urls
314+
` + "`" + `rss` + "`" + ` is a minimalist rss client. Outputs JSON on STDOUT. Takes urls
315315
to feeds and path to state file. Example usage:
316316
317317
` + "`" + `` + "`" + `` + "`" + `bash
318-
$ rss -state feed.json https://blog.afoolishmanifesto.com/index.xml
319-
[Announcing shellquote](https://blog.afoolishmanifesto.com/posts/announcing-shellquote/)
320-
[Detecting who used the EC2 metadata server with BCC](https://blog.afoolishmanifesto.com/posts/detecting-who-used-ec2-metadata-server-bcc/)
321-
[Centralized known_hosts for ssh](https://blog.afoolishmanifesto.com/posts/centralized-known-hosts-for-ssh/)
322-
[Buffered Channels in Golang](https://blog.afoolishmanifesto.com/posts/buffered-channels-in-golang/)
323-
[C, Golang, Perl, and Unix](https://blog.afoolishmanifesto.com/posts/c-golang-perl-and-unix/)
318+
$ rss -state feed.json https://blog.afoolishmanifesto.com/index.xml | jq -r '" * [" + .title + "](" +.link+")"'
319+
* [Announcing shellquote](https://blog.afoolishmanifesto.com/posts/announcing-shellquote/)
320+
* [Detecting who used the EC2 metadata server with BCC](https://blog.afoolishmanifesto.com/posts/detecting-who-used-ec2-metadata-server-bcc/)
321+
* [Centralized known_hosts for ssh](https://blog.afoolishmanifesto.com/posts/centralized-known-hosts-for-ssh/)
322+
* [Buffered Channels in Golang](https://blog.afoolishmanifesto.com/posts/buffered-channels-in-golang/)
323+
* [C, Golang, Perl, and Unix](https://blog.afoolishmanifesto.com/posts/c-golang-perl-and-unix/)
324324
` + "`" + `` + "`" + `` + "`" + `
325325
326326
### ` + "`" + `slack-deaddrop` + "`" + `
@@ -466,22 +466,22 @@ func init() {
466466

467467
"replace-unzip": readme[8780:9010],
468468

469-
"rss": readme[9010:9768],
469+
"rss": readme[9010:9814],
470470

471-
"slack-deaddrop": readme[9768:9988],
471+
"slack-deaddrop": readme[9814:10034],
472472

473-
"slack-open": readme[9988:10122],
473+
"slack-open": readme[10034:10168],
474474

475-
"sm-list": readme[10122:10398],
475+
"sm-list": readme[10168:10444],
476476

477-
"srv": readme[10398:10581],
477+
"srv": readme[10444:10627],
478478

479-
"toml2json": readme[10581:10756],
479+
"toml2json": readme[10627:10802],
480480

481-
"undefer": readme[10756:11064],
481+
"undefer": readme[10802:11110],
482482

483-
"uni": readme[11064:11226],
483+
"uni": readme[11110:11272],
484484

485-
"yaml2json": readme[11226:11303],
485+
"yaml2json": readme[11272:11349],
486486
}
487487
}

internal/tool/rss/rss.go

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package rss
22

33
import (
44
"context"
5+
"encoding/json"
56
"flag"
67
"fmt"
78
"io"
@@ -14,16 +15,16 @@ import (
1415
)
1516

1617
/*
17-
Run is a minimalist rss client. Outputs links as markdown on STDOUT. Takes urls
18+
Run is a minimalist rss client. Outputs JSON on STDOUT. Takes urls
1819
to feeds and path to state file. Example usage:
1920
2021
```bash
21-
$ rss -state feed.json https://blog.afoolishmanifesto.com/index.xml
22-
[Announcing shellquote](https://blog.afoolishmanifesto.com/posts/announcing-shellquote/)
23-
[Detecting who used the EC2 metadata server with BCC](https://blog.afoolishmanifesto.com/posts/detecting-who-used-ec2-metadata-server-bcc/)
24-
[Centralized known_hosts for ssh](https://blog.afoolishmanifesto.com/posts/centralized-known-hosts-for-ssh/)
25-
[Buffered Channels in Golang](https://blog.afoolishmanifesto.com/posts/buffered-channels-in-golang/)
26-
[C, Golang, Perl, and Unix](https://blog.afoolishmanifesto.com/posts/c-golang-perl-and-unix/)
22+
$ rss -state feed.json https://blog.afoolishmanifesto.com/index.xml | jq -r '" * [" + .title + "](" +.link+")"'
23+
* [Announcing shellquote](https://blog.afoolishmanifesto.com/posts/announcing-shellquote/)
24+
* [Detecting who used the EC2 metadata server with BCC](https://blog.afoolishmanifesto.com/posts/detecting-who-used-ec2-metadata-server-bcc/)
25+
* [Centralized known_hosts for ssh](https://blog.afoolishmanifesto.com/posts/centralized-known-hosts-for-ssh/)
26+
* [Buffered Channels in Golang](https://blog.afoolishmanifesto.com/posts/buffered-channels-in-golang/)
27+
* [C, Golang, Perl, and Unix](https://blog.afoolishmanifesto.com/posts/c-golang-perl-and-unix/)
2728
```
2829
2930
Command: rss
@@ -82,9 +83,7 @@ func syncFeed(state indexedStates, items []*gofeed.Item, urlString string, w io.
8283
state[urlString][i.GUID] = true
8384
}
8485

85-
renderItems(w, items)
86-
87-
return nil
86+
return renderItems(w, items)
8887
}
8988

9089
func run(statePath string, urls []string, w io.Writer) error {
@@ -149,10 +148,16 @@ func fixItems(feedURL *url.URL, items []*gofeed.Item) {
149148
}
150149
}
151150

152-
func renderItems(out io.Writer, items []*gofeed.Item) {
151+
func renderItems(out io.Writer, items []*gofeed.Item) error {
152+
e := json.NewEncoder(out)
153+
153154
for _, i := range items {
154-
fmt.Fprintf(out, "[%s](%s)\n", i.Title, i.Link)
155+
if err := e.Encode(i); err != nil {
156+
return err
157+
}
155158
}
159+
160+
return nil
156161
}
157162

158163
// Return items in feed that are not in sync

internal/tool/rss/rss_test.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -431,25 +431,25 @@ might realize.</p>
431431
buf := &bytes.Buffer{}
432432
err = run(f.Name(), []string{ts.URL}, buf)
433433
assert.NoError(t, err)
434-
assert.Equal(t, `[Sorting Books](https://blog.afoolishmanifesto.com/posts/sorting-books/)
435-
[Automating Email](https://blog.afoolishmanifesto.com/posts/automating-email/)
436-
[How to Add a Subscription Service to Your Blog](https://blog.afoolishmanifesto.com/posts/how-to-add-a-subscription-mode-to-your-blog/)
437-
[Fixing Buggy Haskell Programs with Go](https://blog.afoolishmanifesto.com/posts/fixing-buggy-haskell-programs-with-golang/)
438-
[Learning Day 2: DIY Games](https://blog.afoolishmanifesto.com/posts/learning-day-2-diy-games/)
439-
[Busting the Cloudflare Cache](https://blog.afoolishmanifesto.com/posts/busting-cloudflare-cache/)
440-
[graphviz describing multi-stage docker builds](https://blog.afoolishmanifesto.com/posts/graphviz/)
441-
[Amygdala](https://blog.afoolishmanifesto.com/posts/amygdala/)
442-
[Deploying to Kubernetes at ZipRecruiter](https://blog.afoolishmanifesto.com/posts/deploying-to-kubernetes-at-ziprecruiter/)
443-
[Full Text Search for ebooks](https://blog.afoolishmanifesto.com/posts/full-text-search-for-ebooks/)
444-
[Learning Day 1: go](https://blog.afoolishmanifesto.com/posts/learning-day-1-golang/)
445-
[Go Interfaces](https://blog.afoolishmanifesto.com/posts/go-interfaces/)
446-
[The Evolution of The Minotaur](https://blog.afoolishmanifesto.com/posts/the-evolution-of-minotaur/)
447-
[Self-Control on a Phone](https://blog.afoolishmanifesto.com/posts/self-control-on-a-phone/)
448-
[Updates to my Notes Linking Tools](https://blog.afoolishmanifesto.com/posts/notes-linking-update/)
449-
[Goals for 2019](https://blog.afoolishmanifesto.com/posts/goals-2019/)
450-
[Self-Signed and Pinned Certificates in Go](https://blog.afoolishmanifesto.com/posts/golang-self-signed-and-pinned-certs/)
451-
[Validating Kubernetes Manifests](https://blog.afoolishmanifesto.com/posts/validating-kubernetes-manifests/)
452-
[go generate: barely a framework](https://blog.afoolishmanifesto.com/posts/go-generate/)
453-
[Go Doesn't Have Generics](https://blog.afoolishmanifesto.com/posts/golang-no-generics/)
434+
assert.Equal(t, `{"title":"Sorting Books","description":"\u003cp\u003eI wrote a little program to sort lists of books.\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e","link":"https://blog.afoolishmanifesto.com/posts/sorting-books/","published":"Thu, 21 Mar 2019 07:25:18 +0000","publishedParsed":"2019-03-21T07:25:18Z","guid":"18e35dc0-5e01-4dd2-af7a-9a273134203f","categories":["perl","frew-warez"]}
435+
{"title":"Automating Email","description":"\u003cp\u003eI just automated a couple common email tasks.\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e","link":"https://blog.afoolishmanifesto.com/posts/automating-email/","published":"Mon, 18 Mar 2019 07:10:42 +0000","publishedParsed":"2019-03-18T07:10:42Z","guid":"ddbf4a02-d7b1-4736-8f0d-b5693027a6ca","categories":["mutt","golang"]}
436+
{"title":"How to Add a Subscription Service to Your Blog","description":"\u003cp\u003eI used to use a service to email subscribers updates to my blog. The service\nbroke, but I automated my way around it.\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e","link":"https://blog.afoolishmanifesto.com/posts/how-to-add-a-subscription-mode-to-your-blog/","published":"Thu, 07 Mar 2019 07:15:57 +0000","publishedParsed":"2019-03-07T07:15:57Z","guid":"0cf2f92a-232c-4b25-a2f7-48dedb0e723b","categories":["perl","blog","meta"]}
437+
{"title":"Fixing Buggy Haskell Programs with Go","description":"\u003cp\u003eI recently ran into a stupid bug in a program written in Haskell and found it\nmuch easier to paper over with a few lines of Go than to properly fix.\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e","link":"https://blog.afoolishmanifesto.com/posts/fixing-buggy-haskell-programs-with-golang/","published":"Wed, 27 Feb 2019 07:11:08 +0000","publishedParsed":"2019-02-27T07:11:08Z","guid":"b940dc2a-6ebd-4a0f-b6c2-3a5f452e2230","categories":["haskell","golang"]}
438+
{"title":"Learning Day 2: DIY Games","description":"\u003cp\u003eToday I did my second Learning Day; the subject was DIY Games.\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e","link":"https://blog.afoolishmanifesto.com/posts/learning-day-2-diy-games/","published":"Sat, 23 Feb 2019 19:41:55 +0000","publishedParsed":"2019-02-23T19:41:55Z","guid":"360a79f0-5b2f-48e0-a5e1-3e0e79d000e0","categories":["lua","pico-8","learning-day","self"]}
439+
{"title":"Busting the Cloudflare Cache","description":"\u003cp\u003eI automated blowing the cache for this blog. Read on to see how I did it.\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e","link":"https://blog.afoolishmanifesto.com/posts/busting-cloudflare-cache/","published":"Wed, 20 Feb 2019 07:15:17 +0000","publishedParsed":"2019-02-20T07:15:17Z","guid":"96139cd2-b350-4d4e-9a6e-045645ba8cdd","categories":["perl","meta","cloudflare"]}
440+
{"title":"graphviz describing multi-stage docker builds","description":"\u003cp\u003eI recently decided I should learn to use Graphviz more, as a great tool for\nmaking certain kinds of plots. Less than a week later a great use case\nsurfaced.\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e","link":"https://blog.afoolishmanifesto.com/posts/graphviz/","published":"Mon, 11 Feb 2019 07:27:10 +0000","publishedParsed":"2019-02-11T07:27:10Z","guid":"f35be163-f9b1-475b-b4c5-abc0d149bc6f","categories":["tool","graphviz","docker","ziprecruiter","perl"]}
441+
{"title":"Amygdala","description":"\u003cp\u003eThis past weekend I started re-creating a tool I used to have, using new tools,\ntechniques, and infrastructure. The tool allows, at least, adding to my own\ntodo list via SMS. It\u0026rsquo;s working great!\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e","link":"https://blog.afoolishmanifesto.com/posts/amygdala/","published":"Tue, 05 Feb 2019 07:12:26 +0000","publishedParsed":"2019-02-05T07:12:26Z","guid":"bca651f1-8ba4-4f18-9efe-b4b869f7bedc","categories":["golang","perl","amygdala"]}
442+
{"title":"Deploying to Kubernetes at ZipRecruiter","description":"\u003cp\u003eAt \u003ca href=\"https://www.ziprecruiter.com/hiring/technology\"\u003eZR\u003c/a\u003e we are working hard to\nget stuff migrated to Kubernetes, and a big part of that is our cicd pipeline.\nWe have that stable enough that I can explain the major parts.\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e","link":"https://blog.afoolishmanifesto.com/posts/deploying-to-kubernetes-at-ziprecruiter/","published":"Wed, 30 Jan 2019 07:36:37 +0000","publishedParsed":"2019-01-30T07:36:37Z","guid":"fcc31a7f-2696-45a8-8585-bbbf9ce521d6","categories":["ziprecruiter","kubernetes","cicd"]}
443+
{"title":"Full Text Search for ebooks","description":"\u003cp\u003eThis past weekend I did a learning day that inspired me to try SQLite for\nindexing my ebooks; it worked!\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e","link":"https://blog.afoolishmanifesto.com/posts/full-text-search-for-ebooks/","published":"Mon, 28 Jan 2019 07:30:26 +0000","publishedParsed":"2019-01-28T07:30:26Z","guid":"78bcacf7-dc50-4fdf-91c5-8365ab61c86f","categories":["meta","learning-day"]}
444+
{"title":"Learning Day 1: go","description":"\u003cp\u003eThis is the first Learning Day Log I\u0026rsquo;m publishing, and it\u0026rsquo;s about Go.\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e","link":"https://blog.afoolishmanifesto.com/posts/learning-day-1-golang/","published":"Sat, 26 Jan 2019 16:46:28 +0000","publishedParsed":"2019-01-26T16:46:28Z","guid":"2122f364-8a42-4734-880e-c5da312b7a5e","categories":["golang","learning-day","meta"]}
445+
{"title":"Go Interfaces","description":"\u003cp\u003eI did some work recently that depended on Go interfaces and I found it both\nstraightforward and elegant.\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e","link":"https://blog.afoolishmanifesto.com/posts/go-interfaces/","published":"Wed, 23 Jan 2019 08:30:03 +0000","publishedParsed":"2019-01-23T08:30:03Z","guid":"7a23bd20-d454-4384-bf0e-b5ccddf85833","categories":["golang","programming","programming-languages"]}
446+
{"title":"The Evolution of The Minotaur","description":"\u003cp\u003eI have a tool called The Minotaur that I just rewrote for the third time, and I\nthink, maybe, it\u0026rsquo;s done.\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e","link":"https://blog.afoolishmanifesto.com/posts/the-evolution-of-minotaur/","published":"Mon, 14 Jan 2019 07:33:50 +0000","publishedParsed":"2019-01-14T07:33:50Z","guid":"4e448322-1f08-4749-b8c2-607aac3dd5e4","categories":["perl","golang","ziprecruiter","mitsi","meta","toolsmith"]}
447+
{"title":"Self-Control on a Phone","description":"\u003cp\u003eToday I discovered that a lot of people feel alone in how they feel chained, in\none way or another, to their phones. I started the fight against that recently\nand thought my findings might help other people.\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e","link":"https://blog.afoolishmanifesto.com/posts/self-control-on-a-phone/","published":"Thu, 10 Jan 2019 19:28:00 +0000","publishedParsed":"2019-01-10T19:28:00Z","guid":"0d510493-61a5-4fb8-b93f-29f570befd77","categories":["meta","self-control","super-powers","phone"]}
448+
{"title":"Updates to my Notes Linking Tools","description":"\u003cp\u003eI recently improved some of my notes tools, most especially around linking to\nemails.\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e","link":"https://blog.afoolishmanifesto.com/posts/notes-linking-update/","published":"Tue, 08 Jan 2019 08:11:00 +0000","publishedParsed":"2019-01-08T08:11:00Z","guid":"2d7780f0-d095-4df6-97ac-cc1802b44cf5","categories":["frew-warez","golang","meta","vim"]}
449+
{"title":"Goals for 2019","description":"\u003cp\u003eAs many do, I am attempting to affect 2019 by picking skills to improve,\nsubjects to learn, ways I hope to improve as a person, and then deriving\n(hopefully) concrete milestones to benchmark that progress.\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e","link":"https://blog.afoolishmanifesto.com/posts/goals-2019/","published":"Sun, 30 Dec 2018 08:10:28 +0000","publishedParsed":"2018-12-30T08:10:28Z","guid":"bd3d010e-b286-4903-8d54-f8844a591cb4","categories":["goals","meta"]}
450+
{"title":"Self-Signed and Pinned Certificates in Go","description":"\u003cp\u003eI recently needed to generate some TLS certificates in Go and trust them.\nHere\u0026rsquo;s how I did it.\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e","link":"https://blog.afoolishmanifesto.com/posts/golang-self-signed-and-pinned-certs/","published":"Sun, 23 Dec 2018 07:29:05 +0000","publishedParsed":"2018-12-23T07:29:05Z","guid":"4e8b5670-3908-4ced-9ce7-b0f5dabfe085","categories":["golang","ssl","tls"]}
451+
{"title":"Validating Kubernetes Manifests","description":"\u003cp\u003eAt \u003ca href=\"https://www.ziprecruiter.com/hiring/technology\"\u003eZipRecruiter\u003c/a\u003e my team is\nhard at work making Kubernetes our production platform. This is an incredible\neffort and I can only take the credit for very small parts of it. The issue\nthat I was tasked with most recently was to verify and transform Kubernetes\nmanifests; this post demonstrates how to do that reliably.\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e","link":"https://blog.afoolishmanifesto.com/posts/validating-kubernetes-manifests/","published":"Tue, 18 Dec 2018 07:20:15 +0000","publishedParsed":"2018-12-18T07:20:15Z","guid":"0d291e43-0f72-4922-8790-275a114c951e","categories":["kubernetes","perl","golang"]}
452+
{"title":"go generate: barely a framework","description":"\u003cp\u003eI\u0026rsquo;ve been leaning on \u003ccode\u003ego generate\u003c/code\u003e at work a lot lately and, when discussing it\nwith friends, found that they had trouble understanding it. I figured I\u0026rsquo;d show\nsome examples to help.\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e","link":"https://blog.afoolishmanifesto.com/posts/go-generate/","published":"Mon, 19 Nov 2018 07:20:59 +0000","publishedParsed":"2018-11-19T07:20:59Z","guid":"fd338831-8f40-4b03-8bf6-144833a1112d","categories":["golang"]}
453+
{"title":"Go Doesn't Have Generics","description":"\u003cp\u003eGo doesn\u0026rsquo;t have generics. This isn\u0026rsquo;t news, but it\u0026rsquo;s more foundational than many\nmight realize.\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e","link":"https://blog.afoolishmanifesto.com/posts/golang-no-generics/","published":"Mon, 12 Nov 2018 09:37:49 +0000","publishedParsed":"2018-11-12T09:37:49Z","guid":"602effcf-b9e9-4e13-afb8-4a08907b3ead","categories":["golang","psa"]}
454454
`, buf.String())
455455
}

0 commit comments

Comments
 (0)