Skip to content
Permalink
Browse files

Render feeds as json, not markdown

  • Loading branch information
frioux committed Nov 30, 2019
1 parent 0e30ea5 commit fbbcdadea7a2c95b773adfe567b7f31966e72906
Showing with 60 additions and 55 deletions.
  1. +7 −7 README.mdwn
  2. +16 −16 help_generated.go
  3. +17 −12 internal/tool/rss/rss.go
  4. +20 −20 internal/tool/rss/rss_test.go
@@ -310,16 +310,16 @@ a single root for all files in the zipfile.

### `rss`

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

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

### `slack-deaddrop`
@@ -311,16 +311,16 @@ a single root for all files in the zipfile.
### ` + "`" + `rss` + "`" + `
` + "`" + `rss` + "`" + ` is a minimalist rss client. Outputs links as markdown on STDOUT. Takes urls
` + "`" + `rss` + "`" + ` is a minimalist rss client. Outputs JSON on STDOUT. Takes urls
to feeds and path to state file. Example usage:
` + "`" + `` + "`" + `` + "`" + `bash
$ rss -state feed.json https://blog.afoolishmanifesto.com/index.xml
[Announcing shellquote](https://blog.afoolishmanifesto.com/posts/announcing-shellquote/)
[Detecting who used the EC2 metadata server with BCC](https://blog.afoolishmanifesto.com/posts/detecting-who-used-ec2-metadata-server-bcc/)
[Centralized known_hosts for ssh](https://blog.afoolishmanifesto.com/posts/centralized-known-hosts-for-ssh/)
[Buffered Channels in Golang](https://blog.afoolishmanifesto.com/posts/buffered-channels-in-golang/)
[C, Golang, Perl, and Unix](https://blog.afoolishmanifesto.com/posts/c-golang-perl-and-unix/)
$ rss -state feed.json https://blog.afoolishmanifesto.com/index.xml | jq -r '" * [" + .title + "](" +.link+")"'
* [Announcing shellquote](https://blog.afoolishmanifesto.com/posts/announcing-shellquote/)
* [Detecting who used the EC2 metadata server with BCC](https://blog.afoolishmanifesto.com/posts/detecting-who-used-ec2-metadata-server-bcc/)
* [Centralized known_hosts for ssh](https://blog.afoolishmanifesto.com/posts/centralized-known-hosts-for-ssh/)
* [Buffered Channels in Golang](https://blog.afoolishmanifesto.com/posts/buffered-channels-in-golang/)
* [C, Golang, Perl, and Unix](https://blog.afoolishmanifesto.com/posts/c-golang-perl-and-unix/)
` + "`" + `` + "`" + `` + "`" + `
### ` + "`" + `slack-deaddrop` + "`" + `
@@ -466,22 +466,22 @@ func init() {

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

"rss": readme[9010:9768],
"rss": readme[9010:9814],

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

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

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

"srv": readme[10398:10581],
"srv": readme[10444:10627],

"toml2json": readme[10581:10756],
"toml2json": readme[10627:10802],

"undefer": readme[10756:11064],
"undefer": readme[10802:11110],

"uni": readme[11064:11226],
"uni": readme[11110:11272],

"yaml2json": readme[11226:11303],
"yaml2json": readme[11272:11349],
}
}
@@ -2,6 +2,7 @@ package rss

import (
"context"
"encoding/json"
"flag"
"fmt"
"io"
@@ -14,16 +15,16 @@ import (
)

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

renderItems(w, items)

return nil
return renderItems(w, items)
}

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

func renderItems(out io.Writer, items []*gofeed.Item) {
func renderItems(out io.Writer, items []*gofeed.Item) error {
e := json.NewEncoder(out)

for _, i := range items {
fmt.Fprintf(out, "[%s](%s)\n", i.Title, i.Link)
if err := e.Encode(i); err != nil {
return err
}
}

return nil
}

// Return items in feed that are not in sync
@@ -431,25 +431,25 @@ might realize.</p>
buf := &bytes.Buffer{}
err = run(f.Name(), []string{ts.URL}, buf)
assert.NoError(t, err)
assert.Equal(t, `[Sorting Books](https://blog.afoolishmanifesto.com/posts/sorting-books/)
[Automating Email](https://blog.afoolishmanifesto.com/posts/automating-email/)
[How to Add a Subscription Service to Your Blog](https://blog.afoolishmanifesto.com/posts/how-to-add-a-subscription-mode-to-your-blog/)
[Fixing Buggy Haskell Programs with Go](https://blog.afoolishmanifesto.com/posts/fixing-buggy-haskell-programs-with-golang/)
[Learning Day 2: DIY Games](https://blog.afoolishmanifesto.com/posts/learning-day-2-diy-games/)
[Busting the Cloudflare Cache](https://blog.afoolishmanifesto.com/posts/busting-cloudflare-cache/)
[graphviz describing multi-stage docker builds](https://blog.afoolishmanifesto.com/posts/graphviz/)
[Amygdala](https://blog.afoolishmanifesto.com/posts/amygdala/)
[Deploying to Kubernetes at ZipRecruiter](https://blog.afoolishmanifesto.com/posts/deploying-to-kubernetes-at-ziprecruiter/)
[Full Text Search for ebooks](https://blog.afoolishmanifesto.com/posts/full-text-search-for-ebooks/)
[Learning Day 1: go](https://blog.afoolishmanifesto.com/posts/learning-day-1-golang/)
[Go Interfaces](https://blog.afoolishmanifesto.com/posts/go-interfaces/)
[The Evolution of The Minotaur](https://blog.afoolishmanifesto.com/posts/the-evolution-of-minotaur/)
[Self-Control on a Phone](https://blog.afoolishmanifesto.com/posts/self-control-on-a-phone/)
[Updates to my Notes Linking Tools](https://blog.afoolishmanifesto.com/posts/notes-linking-update/)
[Goals for 2019](https://blog.afoolishmanifesto.com/posts/goals-2019/)
[Self-Signed and Pinned Certificates in Go](https://blog.afoolishmanifesto.com/posts/golang-self-signed-and-pinned-certs/)
[Validating Kubernetes Manifests](https://blog.afoolishmanifesto.com/posts/validating-kubernetes-manifests/)
[go generate: barely a framework](https://blog.afoolishmanifesto.com/posts/go-generate/)
[Go Doesn't Have Generics](https://blog.afoolishmanifesto.com/posts/golang-no-generics/)
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"]}
{"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"]}
{"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"]}
{"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"]}
{"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"]}
{"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"]}
{"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"]}
{"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"]}
{"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"]}
{"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"]}
{"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"]}
{"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"]}
{"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"]}
{"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"]}
{"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"]}
{"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"]}
{"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"]}
{"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"]}
{"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"]}
{"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"]}
`, buf.String())
}

0 comments on commit fbbcdad

Please sign in to comment.
You can’t perform that action at this time.