A terminal UI for Discourse using Brick


I grew jealous of reddit-terminal-viewer and so I made a discourse version. Quick thanks to this FPComplete screencast for being such a great introduction to the topic.


Excellent! I can run it, but when I select a post:

f@x60s:/tmp/discourse-tui/dist-newstyle/build/i386-linux/ghc-8.6.4/discourse-tui-$ ./discourse-tui http://discourse.haskell.org
discourse-tui: JSONParseException Request {
host                 = "discourse.haskell.orgt"
port                 = 80
secure               = False
requestHeaders       = [("Accept","application/json")]
path                 = "/489.json"
queryString          = ""
method               = "GET"
proxy                = Nothing
rawBody              = False
redirectCount        = 10
responseTimeout      = ResponseTimeoutDefault
requestVersion       = HTTP/1.1
(Response {responseStatus = Status {statusCode = 200, statusMessage = "OK"}, responseVersion = HTTP/1.1, responseHeaders = [("Server","nginx"),("Date","Fri, 22 Mar 2019 00:22:53 GMT"),("Content-Type","text/html"),("Last-Modified","Sun, 21 Jan 2018 08:56:48 GMT"),("Transfer-Encoding","chunked"),("ETag","W/\"5a6455d0-33b9\""),("Content-Encoding","gzip")], responseBody = (), responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}) (ParseError {errorContexts = [], errorMessage = "Failed reading: not a valid json value", errorPosition = 1:1 (0)})


Thanks for pointing that out. I just pushed the fix.


It looks great! Good job!


Ok, i tried it and it definitely is a slick experience (especially considering how poorly discourse degrades on browsers like lynx)!

In case you care: discourse-tui compiles fine with cabal new- install too.

Again, good job!


Technical question: Are you using the built in list widget to render the comment threads? How are you dealing with rendering variable length replies? Are you rendering each reply in a fixed height box?


Yeah, I’m using the built in fixed-width one. I really had no idea how to do scrolling (as in down the page) otherwise. The top-level topics are fine as fixed-height, but it gets messy with replies/posts. The compromise I picked is to show 8 lines (adding empty space if it’s less), and let someone view the post full-page with the right arrow on keyboard.

If you know of a variable-height solution, please let me know.


It would be great to add markdown rendering as next step.

I know it’s not fair to propose and not do it, but I won’t find the time, so I’m just throwing the idea


I appreciate the idea! It would be amazing to have it show up as actual bold, italic, and links (and to also have clickable links open in a terminal browser as an option). Looking at the Brick.Markup documentation, it seems like there’s a reasonable way to pull it off. I’m already using pandoc to convert the raw html the API gives to markdown anyway.

It’s next on the list after implementing a way to like/post/reply.


Brick author here - for what it’s worth, I wouldn’t recommend using the Markup module for that. On the matterhorn project we do Brick renderings of Markdown, and it ends up being much better to just convert the Markdown AST to Vty images / Brick widgets directly. (We use Cheapskate for Markdown parsing and representation.)


Duly noted. I’ll definitely try Cheapskate.

Also, thank you for making Brick.


You’re welcome! I’m glad you’re enjoying it!


Author of the webinar here; Thank you for the kind words! (Ping me privately if there are other topics that you’d like to see covered!)