This is a console application that I wrote for browsing HN in a terminal. It has an ncurses UI and uses libcurl to query the HN API [0]. Currently works on Linux and Mac. I also ported it to web with Emscripten's Fetch API so it can be easily demonstrated [1].
I’m just calling system() with “xdg-open” and url as argument. This is what a quick google search told me can be used for openning a browser from a C++ program. Maybe “xdg-open” is not available on Catalina. It is on Mojave I think.
I love the concept, and would use it daily if there were features for adding/removing/viewing favorites. This is something that the official API doesn't support, so it's not something I'm faulting this application for. Impressive for sure.
Also +1 on wlqlwlql's dark-mode idea, although a color theme in general might be a better approach (but perhaps overly complicated?).
This might not be addressing your issue directly, but for my browser extension Refined Hacker News [1], once a user is logged-in in the browser site it is fairly simple to "construct" the favorite-ing endpoint URL. The URL endpoint is "/fave" and requires two query parameters: `auth` and `id`. "auth" is a random string that is unique for each story/comment and is generated from the HN server (it's required for authorization of the "favorite" request), and "id" is the story/comment's ID number.
The auth string of a story for "fave" is the same as the auth string for the "hide" and "flag" links (since they are already present, the links' hrefs contain that auth string), and so we can extract the auth string from their hrefs and use it for favoriting and un-favoriting.
The "favorite"/"follow" function is something I was also thinking about. I have some ideas about it - something like an extra feed window where only favorited (and related) things show up.
Regarding color themes - these are super easy to add.
Wow, the vim keybindings are very intiutive. I just pressed O without thinking about it and it opened the highlighted link in a browser. although I miss using h and l for going right and left. also, I don't know about others but it took me some time to figure out the enter key to open comments page. maybe that should be mentioned in the help window.
Looking at the API request counter/how it renders it seems like you're pinging the API for every news item? 43 for just the "news" and "show" sections seems pretty high.
If that were the case I'd be worried about hitting an API limit, etc.
It's just the way the API works - to get the details for a single story (i.e. title, score, user, time, etc.) you need a single API request. Once the stories are fetched, then you can query the API only for those that have changed.
I was wondering what is the API limit - I haven't hit it yet. Will see.
Gotcha - it's times like that that I go with an old-fashioned raw HTTP request and parse it with a DOM parsing engine. Sometimes the "web-facing API" (so-to-speak) is better than the official API.
Yes, an API that is isomorphic to the website itself would be much easier to use. Our plan is for the next version of HN's API to simply serve a JSON version of every page.
In the meantime, if you scrape the HTML, please respect https://news.ycombinator.com/robots.txt and don't do it more than once per 30 seconds. HN's app server runs on a single core, so we don't have a lot of performance to spare! This is in the works to change as well.
> HN's app server runs on a single core, so we don't have a lot of performance to spare!
That's interesting. Is there any more information about HN's tech stack? I know it's built on top of the Lisp dialect Arc, but I wonder about the server specs and would be happy to be pointed at some resource.
Although I experienced HN being down, I guess the overall uptime and availability is pretty decent. Keep up the good work!
Few UX comments:
1. There are a few advanced features that are enabled by default that I think should be hidden by default: stats and multiple panes
2. It's unclear how to get back when entering an article
Thanks for the feedback - I agree those features should be disabled by default. Just wanted to have them enabled now so people don't accidentally miss them
That's nice! There are some other mentions about color themes, but I'm wondering if it could just respect my terminal's color theme with background & foreground colors?
FYI works fine on mac but requires cmake (I downloaded and built cmake from source with no problems on 10.14.6, but other installation options are available)
Yeah I could see putting things like baseball game scores in a terminal, because you don't really want to be browsing mlb.com at work - but HackerNews should be considered work related if you're a dev.
If your dayjob doesn't allow you to spend 1 hour a day keeping up on tech news/interests, then maybe you need a better job.
[0] - https://github.com/HackerNews/API
[1] - https://hnterm.ggerganov.com