Hacker News Digest is a little web application to browse the SQLite database of Hacker News stories and comments created with hn2sqlite
- sqlite3 and a web server, obviously
- Lua 5.2
- lsqlitelib Lua bindings for sqlite (lua52 branch)
Setup with althttpd
-
Compile lsqlitelib and copy
sqlite.so
toHackerNewsDigest/default.website
. Alternatively, setLUA_CPATH
to an appropiate value so that Lua can find the module (e.gexport LUA_CPATH="$HOME/lsqlite3lib/?.so;./?.so"
) -
move the database created with hn2sqlite to
HackerNewsDigest/default.website
. The app expects the database to be calledhn-all-stories+comments.sqlite
; change as appropiate. -
Start the web server:
TZ= ~/althttpd/althttpd -logfile logfile -root $HOME/althttpd/HackerNewsDigest/ -port 8080
The TZ
enviroment variable is set to an empty string to get timestamps as
UTC, rather than local time.
The application serves just two URLs: one for stories listed by date and one for the comments of a specific story.
-
The story URL looks like
http://localhost:8080/nph-hn.lua/stories/$year/$month/$day/$hour/$min?author=$author
. The?author=...
part and all date and time fields are optional, so that for example http://localhost:8080/nph-hn.lua/stories/2013/12/31 lists all the stories for 31 Dec 2013. -
The comments URL looks like
http://localhost:8080/nph-hn.lua/comments/$objectID
but I don't think this is too important as you would access it normally from the stories page.
- This service draws much code and ideas from MVC Web Development with Kepler.
- The javascript code for collapsing/expanding threaded comments is taken from https://github.com/niyazpk/Collapsible-comments-for-Hacker-News
- The CSS code of the story listing page is original from repo.or.cz
HackerNewsDigest
is distributed under the
MIT license.