10 ms·
Serving my blog posts as Linux manual pages
- heartag 3y agoThat's a fun idea, and well executed.
- Annatar 3y agoOne could pipe that output directly to nroff or groff: | soelim | tbl | eqn | nroff -man - | $PAGER | soelim | tbl | eqn | nroff -man -Tpost - | /usr/lib/postscript/bin/dpost | ps2pdf - > ~/Desktop/blog.PDF | soelim | tbl | eqn | groff -Tps -man - | ps2pdf - > ~/Desktop/blog.PDF
- anthk 3y agowith groff you don't need soelim | tbl... just run | groff -Tpdf -step -k > ~/Desktop/blog.pdf
- nulbyte 3y agoI never thought of making a blog post a man page. That's pretty awesome, actually. I'd be interested to see the code for the underlying conversion, but maybe I'll just try my hand at it myself this weekend. Btw, in Bash, you can use process substitution to avoid littering your folder with files, if you don't want to save them: $ man <(curl ...)
- rahimnathwani 3y ago> I'd be interested to see the code for the underlying conversion The post includes the template he used. You can adapt it to any templating engine or put some placeholders in and use sed or whatever.
- worble 3y agoCool idea. I'm starting on the timer until we get "serving my blog posts as playable DOOM wads".
- vonjuice 3y agoAdd it to the list of the handful of actually cool things that AI could facilitate.
- chanamasala 3y ago[flagged]
- bravetraveler 3y agoSomewhere lower than both of us me: for engaging with this you: for making an account to post this in the first place
- yrro 3y agoFYI, 'curl -sL -H "Accept: text/roff" https://jamesg.blog/2024/02/28/programming-projects/ https://jamesg.blog/2024/02/28/programming-projects/ | man -l /dev/stdin' works for me - no need to safe the roff file locally.
- zerojames 3y agoUnfortunately, that command doesn't work on macOS (`/usr/bin/man: illegal option -- l`). I tried to get a one-liner with piping working on my Mac but I always ran into errors. The -l flag doesn't exist in the macOS man implementation (I consulted the man page; meta!).
- jolmg 3y agoThe `-l` can be skipped (probably because there are `/`s in man's argument): curl -sL -H "Accept: text/roff" https://jamesg.blog/2024/02/28/programming-projects/ | man /dev/stdin
- BossingAround 3y ago(which still doesn't work on mac)
- divbzero 3y agoThis still doesn’t work for me on macOS, perhaps a difference in how /dev/stdin is implemented? Fortunately, macOS has ZSH as the default shell so the following does work: man =(curl -sL -H "Accept: text/roff" https://jamesg.blog/2024/02/28/programming-projects/)
- penguinjanitor 3y agoMaybe 'man <(curl -sL -H "Accept: text/roff" https://jamesg.blog/2024/02/28/programming-projects/ https://jamesg.blog/2024/02/28/programming-projects/)' works then?
- BossingAround 3y ago
- masto 3y agoI don't know why this particular thing set off my pedanticism. Someone is slightly wrong on the Internet! Maybe because it started right off being needlessly Linux-centric. Or that I thought it would be one thing but it turned out to be a brief demo of content negotiation in NGINX. In any case, a few pointless things that I seem compelled to say: * It's not returning roff, as such. Those things like `.TH` are not part of roff, they are part of the macro package for writing man pages. * I was disappointed that there was no markdown-to-roff conversion, which seemed like it was going to be the interesting part of this post. At least use one of the existing ones. * On a similar note, this means that the text isn't really formatted correctly. roff is meant for one sentence per line of input, to distinguish between `.` to end a sentence vs. other uses. * Also also wik, this means that any line starting with a `.` will be interpreted as a command, potentially wreaking havoc. Or maybe I'm just a grumpy old man.
- zerojames 3y agoI appreciate you sharing this! I wasn't aware of the exact ontology of how roff vs. man relate, and I went through several iterations of this post trying to get this right. There being other tools -- groff, nroff, etc. -- added to my confusion. A blog post unto itself is "here is what roff/man page/nroff/other variants are, here's how to use them." I would have appreciated a succinct description; I'm sure others would, too. As for markdown to roff, I thought about it as a v2. As I started to think about implementing a parser, someone shared https://github.com/sunaku/md2man https://github.com/sunaku/md2man with me, which appears to solve the problem. I'd need to figure out how to integrate this into my (Python) site that is built on GitHub Pages; a bit of tinkering would be required :D
- deleted 3y ago[deleted]
- jorams 3y ago> * I was disappointed that there was no markdown-to-roff conversion I found this rather surprising too. Pandoc can trivially convert markdown to man-page roff. Insert that into the given template and it looks like more like an actual man page.
- yegle 3y agoIt would be cool to provide a deb repo as a way of subscribing to your blog. So `apt update` will pull in all blog posts, `man your-blog` will show the latest post with links to the index of all your other posts.
- zerojames 3y ago_adds to their TODO list :D_
- tutfbhuf 3y agoPlease also create an AUR package for Arch Linux.
- basilgohar 3y agoRelease as a Flatpak and make it distro agnostic!
- gkbrk 3y agoMake it even better and release an AppImage!
- edvinbesic 3y agoEven even better, put it on the web so it’s accessible from anywhere
- busfahrer 3y agoSpeaking of URLs that do fancy stuff on the terminal, I once stumbled upon this one from textfiles.com, it's essentially a short animated movie on the terminal using VT100 terminal codes, all served from a URI. On modern systems you can use rate-limiting to watch it: curl --limit-rate 1000 http://textfiles.com/sf/STARTREK/trek.vt http://textfiles.com/sf/STARTREK/trek.vt && reset (the reset is there because it might mess up your terminal) Other terminal-powered URIs: curl cheat.sh/tar (gets examples on how to use the program after the /) curl wttr.in/berlin (gets weather info with terminal formatting)
- hk__2 3y agoIf you want to do your own ASCII video via telnet, I did it in Go a few years back: https://github.com/bfontaine/RickASCIIRoll https://github.com/bfontaine/RickASCIIRoll It’s actually quite simple; the hardest part is to generate the frames but that can be done with ffmpeg+img2txt.py: https://github.com/bfontaine/RickASCIIRoll/tree/master/moviemaker https://github.com/bfontaine/RickASCIIRoll/tree/master/movie....
- anthk 3y agoUse tritty to fake a 1200/9600 BPS baud rate.
- kolme 3y agoThere's also star wars over telnet: https://itsfoss.com/star-wars-linux/ https://itsfoss.com/star-wars-linux/
- ryukoposting 3y agoWow, this is really cool. It also completely borked my terminal! What fun.
- dancek 3y agoYears ago I made an ANSI art viewer with modem speed emulation. It has an outdated mirror of https://16colo.rs/ https://16colo.rs/ so most ANSI art that's ever been published is viewable. See e.g. curl ansi.hrtk.in/ungenannt_1453.ans
- gglitch 3y agoFun project :) Next step: Texinfo, which will output to info, html, and pdf, among others, and which includes links and indexes.
- pjmlp 3y agoCool experiment, as means to serve UNIX man pages.
- throwaway81523 3y agoThat doesn't look like man pages. Was it supposed to be an example? (EDIT: oh nm, I see, I have to view the image. Nice. But the web view should also look like that.) I noticed the "written by human, not AI" logo, a little too cute but the sentiment is good. I had been thinking of putting something like "this page created by natural stupidity" in mine.
- rahimnathwani 3y agoIf you like this you might like mdless, which does exactly what the name suggests. https://github.com/ttscoff/mdless https://github.com/ttscoff/mdless
- divbzero 3y agoNow all we need is a Markdown to roff converter… which apparently already exists. https://github.com/postmodern/kramdown-man https://github.com/postmodern/kramdown-man https://rtomayko.github.io/ronn/ronn.1.html https://rtomayko.github.io/ronn/ronn.1.html https://kristaps.bsd.lv/lowdown/ https://kristaps.bsd.lv/lowdown/
- ajvpot 3y agoI love pandoc[0] for tasks like this. It supports most markup formats I've needed. [0]: https://pandoc.org/ https://pandoc.org/
- anthk 3y agomd2groff existed since forever from the suckless/2f30/cat-v and so on communities. https://codeberg.org/nereusx/md2roff https://codeberg.org/nereusx/md2roff
- deleted 3y ago[deleted]
- dpassens 3y agoThe correct media type would be text/troff, as per RFC 4263 (https://www.rfc-editor.org/rfc/rfc4263.html https://www.rfc-editor.org/rfc/rfc4263.html).
- slipperybeluga 3y ago[dead]
- jedberg 3y agoIronically it breaks when you request this page as a man page. :)
- medstrom 3y agoThere is an Emacs package that installs Abelson & Sussman's SICP (Structure and Interpretation of Computer Programs) into the Info directory. Simply type M-x package-install sicp RET That gave me the idea that one could install a whole bookshelf of blog archives through some modified feed reader. Reading Info in Emacs, you even get bookmarks.
- felideon 3y agoFYI, SICP is from Abelson and Sussman.
- medstrom 3y agoMy bad, thanks.
- anthk 3y agoGet chicken-scheme too. Then, as root: chicken-install srfi-203 chicken-install srtfi216 ~/.csirc for sicp: (import scheme) (import (srfi 203)) (import (srfi 216)) (define (inc x) (+ x 1)) (define (dec x) (- x 1)) Then user geiser and geiser for chicken as usual.
- Gormo 3y agoThere's no need to fork or use an intermediate file; you can just pipe straight into `man`: `curl -sL -H "Accept: text/roff" https://jamesg.blog/2024/02/28/programming-projects/ https://jamesg.blog/2024/02/28/programming-projects/ | man -l -`
- hereonout2 3y agoShould have read the manual.
- godelski 3y agoPlease don't... Actually yrro posted something similar 2hrs before you and now we have the whole {curl,wget} pipe into command discussion again... Friends don't let friends pipe streams into commands https://news.ycombinator.com/item?id=39554044 https://news.ycombinator.com/item?id=39554044
- rezonant 3y agoThe top reply to that comment rightfully points out that this applies to your shell specifically. This isn't a concern for formats that don't have executable code (and I assume roff doesn't, right?) You might say, yes, but it's still a good idea to review the file before you open it. OK sure, but that isn't going to work for binary files anyway, so "Friends don't let friends pipe streams into commands" should not be the general rule. "Friends don't let friends pipe streams into shells" is certainly a good enough general rule.
- adriangrigore 3y agoI prefer my own UNIX web dev solution https://mkws.sh https://mkws.sh! Man pages ar too much imo.
- hk__2 3y ago> I prefer my own UNIX web dev solution https://mkws.sh https://mkws.sh! Man pages ar too much imo. Those are orthogonal subjects; you could generate your own static page with your generator AND also serve them as manpages. The linked article does not suggest to server manpages to everyone, just to user agents that request them.
- anthk 3y agoWIth mandoc and maybe groff you can typeset pages to man pages, HTML, PS and PDF files.
- harryvederci 3y agoI feel like this is too accessible. Anyone doing this but with Vim help files?
- darkwater 3y agoMaybe I can search the interwebs to answer this question but I prefer to ask the HN crowd. Back in highschool in remember someone (on an HP-UX) showing me that you could jump to any underlined word (referring to a section) by pressing some key combination, but for the life of me I cannot remember which. I already checked man(1) and man(7), and could not find it either. Maybe this is just a fake memory?
- epcoa 3y agoI’m not familiar with any custom man viewer functionality but maybe you're thinking of the CDE help viewer, dthelpview which would display man pages.
- darkwater 3y agoNo, it was in a dumb text terminal. But maybe I just made it up, and I'm confusing it with classic "hjkl" navigation.
- enriquto 3y agoyou can, from inside vim. You press "K" over a word and it opens the manpage. If you have configured vim as your manpage viewer, you can thus navigate all manpages.
- sovietswag 3y agoThis sounds like texinfo (invoke via the ‘info’ command). Fun fact ironically a lot of the original groff documentation is written in texinfo, see: https://lists.gnu.org/archive/html/groff/2005-10/msg00107.html https://lists.gnu.org/archive/html/groff/2005-10/msg00107.ht...
- ksherlock 3y agoIf it was man, keep in mind that "man ohman" is essentially "nroff -man /usr/share/man/man1/ohman.1 | $PAGER" so you're not interacting with man or nroff but a pager. Nowadays, less (or more, which is probably actually less) is the most common pager but there were others and HPUX may have used something like pg. pg was an AT&T thing, more was a BSD thing, less was a GNU thing. With all 3, / starts a regular expression search so you could use that to search for anything, underlined or not. Less also supports tag files so you could use 't' to jump to the next tag.
- _xerces_ 3y agoFor the lazy or short of time, does with worth with tldr pages :) https://tldr.sh/ https://tldr.sh/
- urbandw311er 3y agoLittle real world application, super fun challenge. This is why I come here.
- akritid 3y agoWith some plumbing, it should be possible to follow links: match the URL with regex using the terminal and launch the link target in a new window.
- deleted 3y ago[deleted]
- sureglymop 3y agoI did a somewhat similar thing on my portfolio page. The server recognizes curl and wget and then serves the page as plaintext. If a PDF is requested, it sends my CV. My idea is that if a recruiter overcomes that first hurdle of getting to the CV, then I may as well hear them out.
- notorandit 3y agoUnix man pages. Man pages were here since long before Linux existed!
- ubermonkey 3y agothis is gloriously demented.
- channel_t 3y agoThis is awesome. I would love to see a whole ass social network (or a webring?) that was just a directory of man pages that I could get lost in.
- treadmill 3y agoLolz. The comments here are seriously motivating me to set something up to 0wn people who pipe curl output into random commands. How dense can you get.