I did something similar a (very) long time ago (15 years back!), a static site generator and blog engine entirely coded in sh (yes, not even Bash) + coreutils. The idea was to use those scripts in git hooks, as they provide a template engine that allows to use the Git repository as a storage backend and publishing method, both for posts content (as file or as commit bodies) and for meta data about posts (author, date, etc). It was fun to build and got a few dozen users at the time, some even contributed small bugfixes and features :).
It's job is to help me make my website. Thus, its scope, (mis)feature set, polish will always be production-grade, where production is "works on my machine(s)" :)
Love it! My personal sites tend to start hand-written, evolve into a bash script, occasionally advance into python, but mostly just stay in bash, because it's convenient, doesn't need to please anyone else (nor would it!), and is already built for text processing into files. (I write a lot of scrappy shell scripts for my job too. I guess I should start asking an AI to generate whatever I want directly instead. Cobbling together a script is more fun though...)
I wonder what would be a good way to generate a website with minimal software installations, for example in standard github runner image. This example uses comrak tool to process markdown into HTML.
I've come up with using Java and XSLT. Java is installed in Github Runner image and there's built-in XSLT support in Java standard library. You can write HTML and use XSLT to add header, footer and do other processings if necessary.
So basically I want to generate a website in github runner without accessing network to install something else.
I guess one could just `cat header.html content.html footer.html` but that requires a lot of tiny things like extracting title from content and inserting it into header, etc. Nothing that lots of greps and seds couldn't handle, of course...
For minimal stuff, I just have a pre-commit hook that runs
pandoc -s README.md -o index.html
I've done the xlst thing as well, but to generate markdown instead of HTML from Zotero export XML as the input. https://github.com/captn3m0/boardgame-research. But again, I throw the make command into a pre-commit because I want the README to be updated in the same commit.
npm pack builds the file locally, then we expose it to the container filesystem where we do a build and check the outputs. You can move dependencies to bundledDependencies in npm to embed them in the image.
However, this is assuming you're rebuilding the static site generator itself every time. If you just want to build a site using an existing static site generator, it's much easier provided that the site generator itself is easy to use (for example, ours has a one-liner to take you all the way from nothing to a local static site running on localhost, see https://statue.dev)
If you aren't changing the SSG code itself between container runs you'd just mount the markdown to the container and pre-install the ssg in the Dockerfile itself. For statue.dev that would just be a Dockerfile almost exactly the same as the one we use already, except you'd use your own script, and RUN this in the Dockerfile itself: yes | npx sv create . --template minimal --types ts --no-add-ons --install npm && npm install statue-ssg && npx statue init && npm install
In your script you'd just npm run build then do whatever it is you want to do to send the files somewhere, and wherever starts the script, you'd do something like -v "pathtomymarkdown/foo:/test-package/" - not sure how to do this in github runners.
Depending on how interested you/other people are in doing this with statue.dev, we could prob get something like this (where the markdown is parameterized, not the npm package) working by Tuesday. We're building out the sandbox/build features on our cloud platform as we speak, this could be one of the first use cases/defaults.
In fact, that is my line of thinking, except "using whatever already exists on my computer(s)", which is: bash, sed, grep, jq, awk, pandoc, inotifywait, and xdotool.
The point being exactly to avoid whatever a third party may or may not deign to let me use, without hassle.
The title seems to be a bit misleading IMHO because it does not really only use `sh` but heavily `sed` it seems, which is a whole programming language well suited for templating. I've in the old days written a Macromedia Dreamweaver compatible template engine using such a scheme, which I personally used quite a long time actually without Dreamweaver because this WordPress madness was even a thing.
Bit of an unknown feature, but tree can output HTML. I've used tree -H to generate directory listings more than once.
Yes, in shell, but requiring 'comrak', whatever that is. I also generate[0] html[1] from markdown for my vimwiki.
[0]: https://github.com/tasuki/vitwiki/blob/master/build.sh [1]: https://wiki.tasuki.org/
https://github.com/kivikakk/comrak - common mark renderer
I do somewhat wonder why not pandoc, but it is still an interesting project
pandoc is big (nearly 200MB binary on Debian) and does far more than just Markdown -> HTML
I did something similar a (very) long time ago (15 years back!), a static site generator and blog engine entirely coded in sh (yes, not even Bash) + coreutils. The idea was to use those scripts in git hooks, as they provide a template engine that allows to use the Git repository as a storage backend and publishing method, both for posts content (as file or as commit bodies) and for meta data about posts (author, date, etc). It was fun to build and got a few dozen users at the time, some even contributed small bugfixes and features :).
The README is here: https://p4bl0.net/shebang/fugitive-readme.html
My first blog was made with NanoBlogger, which was what you would call a static site generator today. It's made in Bash.
I remember setting up a few of these back in the day.
https://nanoblogger.sourceforge.net/
I've set up a few with that too, it was a great bit of software and a great concept.
This is fun. I do love a good bit of shell scripting. Also makes me want to make my own little ssg in whatever way I see fit.
Very much pro-this. Mine says:
It's job is to help me make my website. Thus, its scope, (mis)feature set, polish will always be production-grade, where production is "works on my machine(s)" :)
Love it! My personal sites tend to start hand-written, evolve into a bash script, occasionally advance into python, but mostly just stay in bash, because it's convenient, doesn't need to please anyone else (nor would it!), and is already built for text processing into files. (I write a lot of scrappy shell scripts for my job too. I guess I should start asking an AI to generate whatever I want directly instead. Cobbling together a script is more fun though...)
I wonder what would be a good way to generate a website with minimal software installations, for example in standard github runner image. This example uses comrak tool to process markdown into HTML.
I've come up with using Java and XSLT. Java is installed in Github Runner image and there's built-in XSLT support in Java standard library. You can write HTML and use XSLT to add header, footer and do other processings if necessary.
So basically I want to generate a website in github runner without accessing network to install something else.
I guess one could just `cat header.html content.html footer.html` but that requires a lot of tiny things like extracting title from content and inserting it into header, etc. Nothing that lots of greps and seds couldn't handle, of course...
For minimal stuff, I just have a pre-commit hook that runs
I've done the xlst thing as well, but to generate markdown instead of HTML from Zotero export XML as the input. https://github.com/captn3m0/boardgame-research. But again, I throw the make command into a pre-commit because I want the README to be updated in the same commit.
We do basically this for our tests in statue: https://github.com/accretional/statue/tree/main/test/hermeti...
npm pack builds the file locally, then we expose it to the container filesystem where we do a build and check the outputs. You can move dependencies to bundledDependencies in npm to embed them in the image.
However, this is assuming you're rebuilding the static site generator itself every time. If you just want to build a site using an existing static site generator, it's much easier provided that the site generator itself is easy to use (for example, ours has a one-liner to take you all the way from nothing to a local static site running on localhost, see https://statue.dev)
If you aren't changing the SSG code itself between container runs you'd just mount the markdown to the container and pre-install the ssg in the Dockerfile itself. For statue.dev that would just be a Dockerfile almost exactly the same as the one we use already, except you'd use your own script, and RUN this in the Dockerfile itself: yes | npx sv create . --template minimal --types ts --no-add-ons --install npm && npm install statue-ssg && npx statue init && npm install
In your script you'd just npm run build then do whatever it is you want to do to send the files somewhere, and wherever starts the script, you'd do something like -v "pathtomymarkdown/foo:/test-package/" - not sure how to do this in github runners.
Depending on how interested you/other people are in doing this with statue.dev, we could prob get something like this (where the markdown is parameterized, not the npm package) working by Tuesday. We're building out the sandbox/build features on our cloud platform as we speak, this could be one of the first use cases/defaults.
In fact, that is my line of thinking, except "using whatever already exists on my computer(s)", which is: bash, sed, grep, jq, awk, pandoc, inotifywait, and xdotool.
The point being exactly to avoid whatever a third party may or may not deign to let me use, without hassle.
For GitHub just use Jekyll provided by GitHub itself?
A good way to do that with anything, I found, is a Makefile which downloads and compiles the few things it needs :D
Slight tangent, what is a good markdown editor for Linux? I need spell check and a preview at least.
I just use vim and have a binding for F5 to build the current document then open the result in the browser window.
Lovely. It's gratifying to see this broadly matches my own personal SSG: bash, find, sed, envsubst, and pandoc rather than comrak.
i write in markdown, use lowdown + make to build html, push the html to a branch that my hoster serves from : https://piraty.dev/
The title seems to be a bit misleading IMHO because it does not really only use `sh` but heavily `sed` it seems, which is a whole programming language well suited for templating. I've in the old days written a Macromedia Dreamweaver compatible template engine using such a scheme, which I personally used quite a long time actually without Dreamweaver because this WordPress madness was even a thing.
why not perl?
Sometimes we are very self-aware, but we still do things just because...
- It is a wee publishing system made of pipelined workflows, optionally driven by streams of file events (for the hotreloadin' bits).
- It will not surprise a Perl/PHP gentleperson hacker from the last century.
- It exists because one whistles silly tunes and shaves yaks.
fell out of popularity lately
What is wrong with people.
Please have a moment to read the title of this site again :)
Care to elaborate? I don’t see anything of issue here, in fact it’s pretty good.
I don't get this kind of indignation against anything shell related.