Mahlathini Development Foundation is a small non-profit organisation that specialises in agricultural development of smallholders in rural environments. A custom solution has been created for Mahlathini to serve their research papers, manuals and training videos in an organised structure with inline viewing of PDF files.
Their website can be viewed here.
Mahlathini provided all of its research papers and manuals in either PDF or Microsoft Word format. These documents are usually information dense in an academic format, and are very large. They are also specifically formatted, and as such a simple conversion from Word document to html would not suffice. As such, the best solution was to convert PDF to html while keeping all formatting.
The biggest challenge with this was performance: if the server (shared hosting) was to convert the PDFs to html, then it would struggle – even if just to convert them once off – and result in timeouts.
I created a custom static site generator in Node.js for this solution. The website compiler takes a directory of files (just a normal folder), recursively iterates through it, and converts each of the files to html using Twig templates. A hierarchical structure is automatically generated from the tree of the directory.
Due to the static nature of the website, it is incredibly fast. There is no processing involved aside from the server delivering the files to the client. To further improve performance, lazy loading of images has been employed, as well as gzip compression to reduce the size of the files transferred.