5 ms·
Creating a simple blog system with a 500-line bash script (2011)
- pixelbeat 14y agoIt's cool to see static web sites becoming popular. As for comments (dynamic) you could integrate with discuss, or as I do wrote my own simple comments app for google app engine. Details here: http://www.pixelbeat.org/docs/web/feed.html http://www.pixelbeat.org/docs/web/feed.html
- unmole 14y agoShouldn't the link be http://www.pixelbeat.org/docs/web/comments/ http://www.pixelbeat.org/docs/web/comments/
- carlesfe 14y agoAuthor here. Feel free to drop any comments, this was a "weekend project" as I couldn't find anything as simple as that. By the way, I recently uploaded the code to github: https://github.com/carlesfe/bashblog https://github.com/carlesfe/bashblog and some people are using it to publish their blogs via dropbox and site44, cool!
- danso 14y ago1. Thanks! 2. I referenced this in a sub-comment: what are the options of parsing Markdown using a bash-only blogging utility?
- carlesfe 14y agoIt is theoretically easy, one would only have to add a parse_markdown() function which converts MD to HTML, there are many parsers out there. For me, after many years of making web pages, HTML is easier than Markdown.
- oliverhunt 14y agoI know this probably isn't meant for me since I don't seem to know what I'm doing. But how do you run this? An answer in a bit more detail than your github link would be useful. I have it on my server in a public folder and now I don't know what to do.
- carlesfe 14y agoOpen a shell on your public server, run ./bb.sh post, and that's it. You can now access your blog from your public URL.
- Cigano 14y agoIs the motivation something like "we can't install some kind of PHP and a database for you"?
- carlesfe 14y agoNot actually, the motivation is "my server is quite slow so I don't want to run dynamic content on it" :)
- p4bl0 14y agoSee also my little project fugitive [1] a blog engine running on top of git using hooks written in Bash (not much more than 500 lines either), well technically it's even written in bare sh. [1] http://gitorious.org/fugitive http://gitorious.org/fugitive
- rson 14y agoI really wanted to do this exact thing before I started using Jekyll, kudos to you for accomplishing it. I think the only thing that I might have done differently would have been to allow myself to use Perl since it is a dependency of git anyway.
- p4bl0 14y agoAnd you would have been sooooooooo right. Since I wanted to use sh only and not even Bash, I don't even have some useful Bash features such as arrays, so I use temporary files for many many things. Plus invoking a git process for each meta information, plus an awefull lot of sed processes for the templating system… I have a few users with a growing number of blogposts who are complaining about the speed when regenerating their archives page and RSS feed. But now I don't feel like rewriting it in Perl. Plus I had a lot of fun coding in sh. If you or anyone feels like writing a fugitive clone in Perl, I can assure you a few users as soon as its working!
- eksith 14y agoI'm SO going to use this! If only because of the ridiculous simplicity of it all. Maybe I won't replace my main blog, but I can see this in use for something simple I've had in mind for a while. And why did we stop using plain HTML files for simple blogs (that are self-hosted)? Do I really need a "CMS" and/or framework to spew some formatted content if I'm not even gonna have comments? I've seen blogs that use some custom Ruby app or PHP and they're just a combination of an archive index and posts.
- danso 14y agoJust wondering, but have you heard of Jekyll or Octopress? Both are static HTML generators (Jekyll is done in ruby, octopress is a layer on top of it) https://github.com/mojombo/jekyll https://github.com/mojombo/jekyll http://octopress.org/ http://octopress.org/
- eksith 14y agoYes, I have, but... Jekyll is done in ruby, octopress is a layer on top of it This kinda defeats the "simple" bit doesn't it? ;) I have nothing against these and if that floats your boat, then by all means, use it. But just the idea of not having to install anything (in fact, nothing) extra and just having this all work with a single file is very appealing to me.
- danso 14y agoAh yes, it's true...but for a Ruby developer, something that involves Ruby is just about as good as something that involves bash :) I guess I was thinking of "simple" in terms of the static HTML and deploy. I don't think you actually have to run any Ruby commands, you just run a command line task and it reads the textfiles from the specified directory. Unless I missed it in the OP's description, one huge advantage that Jekyll has over the OP's bash solution is the ability to write in Markdown, made possible by the inclusion of Markdown parsing Ruby libraries. So the complexity added in the framework part, IMO, is more than made up in the simplicity of actual content-production.
- FraaJad 14y agoThe grand-daddy of bash based static site generators: http://nanoblogger.sourceforge.net http://nanoblogger.sourceforge.net Example use: http://www.cs.uni.edu/~wallingf/blog/ http://www.cs.uni.edu/~wallingf/blog/ (9 years) Incidentally, the creator of nb announced that he is postponing the development of nb indefinitely last month. OP: Do you think you might want to take up that development?
- carlesfe 14y agoI checked nb before writing bashblog, but it's not as simple as it seems. I actually spent some hours trying to modify it to suit it to my needs, without any luck
- mgi 14y agoI like this. I used to have an emacs org-mode set up to edit/publish blog post (sadly just to discover that I haven't much to say in a blog). My set up allowed me to publish "data" content (mostly images) that can be linked into a post. How do you handle this with bashblog?
- carlesfe 14y agoIt doesn't handle it. You just upload the image to a public folder in your server, then link it from your html content. All pages are edited with vim and treated as plain HTML, there is no post processing --except for adding dates, headers, etc
- danso 14y agoI know not everyone is a fan of Disqus, but it's as easy to implement (OK, the scripting side, anyway) as Google Analytics. Probably wouldn't be more than a couple of lines to have that option and then put Disqus comments at the bottom of the template.
- przemoc 14y agoProblem with using Disqus (and similar solutions) is that comments are at Disqus, so you have no real control over them. Yet not many people care about it. Ask HN: Open source commenting systems for static pages - alternatives to Juvia? https://news.ycombinator.com/item?id=4125787 https://news.ycombinator.com/item?id=4125787
- jnxfgf456 14y ago500 lines seems like an awful lot for something this incomplete.
- bensw 14y agoMarkdown Support?
- tquai 14y agoI did this once, too. It's so nice to hear other people appreciate the approach! The "CMS" I wrote was about 75 lines of sh, and had slightly fewer features than the one linked here. That's the beauty of writing your own: you decide what to include, and no more. cp wc sort awk etc. is all you need. If you want it to look beautiful, that's where design and CSS come into play, both of which are outside the scope of content management.
- sigil 14y agoBy the way, cperciva's blog is also generated by a shell script called "blogsh." Pretty similar to OP's here, except the templating is external rather than built into the script. I got a copy by request back in 2008 -- good stuff. http://www.daemonology.net/blog/2005-09-12-blogsh.html http://www.daemonology.net/blog/2005-09-12-blogsh.html