a static blog generator which tries to do as little as possible on the server side
Few years ago I switched my website to bashblog and was very happy. But with time, as number of posts was growing, bashblog began being slower and slower, especially in "edit" mode. Reason, as I think, was 'all_posts' page, which was regenerated every time anew, and many tag pages (many tags on each page times many pages on each tag equals long rebuilding time), and every single time script had to open each post page to read title (and maybe some text) from it. Not very good.
So I decided to try a different architecture:
instead of regenerating the index page anew, script patches it - this would require having some expected markup in the index page
search would also be a nice addition
and ability to change template a bit more freely than in bashblog
That's how lazyblog was born.
index page has special
<!-- begin ... -->...
<!-- end ... -->comments surrounding each post, which let
sedeasily find and delete needed part.
at the top of index page there is a
<!-- content starts here -->comment which lets
sedeasily find a place to put new post content to.
Result? bash script speed is pretty impressive - it processes each file in almost no time (the longest part is actually markdown processor). Client-side performance also tries to be as fast as possible, especially during page load (expensive DOM operations and rendering of below-the-fold content is delayed).
Actually, the hardest-to-optimize part was extracting data (post titles and tags)
from the actual webpage - turns out, the fastest way was just to create
<div> tags and extract data from them.
Other ways (including using regular expressions) are left in script.js.bak
There is also a
bb-import.sh script which imports posts from a bashblog installation,
assigning proper dates, tags, title, and sometimes intro text
(although manual correction sometimes is needed).
Github link: https://github.com/Lex-2008/lazyblog