Welcome to Enzed Online!
What does a Kyrgyz glacier have to do with an IT consultancy? Not a lot, but it does highlight one of the fundamental keys of engagement in web design: to pique curiosity on landing on your site to encourage reading on, you've generally got a couple of seconds to do that before the visitor's attention span runs out and they move on to the next attention grabber. Mostly though, it's there because Kyrgyzstan has some of the best and most undeveloped hiking I've ever come across. If you have a chance, go!
This website was created using Python, Django, and Wagtail CMS. On the tech blog, I'll be sharing plenty of experiences, pitfalls, and tips for anyone who might find this beneficial.
About me: I have 23 years of experience in IT across a broad range of industries and roles, mostly as a contractor and consultant, ultimately as head of IT for a leading international tourism company in New Zealand. In between, I love to travel, hike and photograph (the three happily go together), as well as experiment with different cuisines from around the world.
These days, you'll find me in the countryside close to Barcelona. If you're an employer looking to fill a position in your team that you believe I'd be a good fit for, either on a project basis or on a more permanent basis, please visit my About page or contact me directly here. I have rights to work in Spain, the UK, New Zealand, and Australia, and would be happy to consider other locations as well.
Here, I'll be sharing insights from my professional experiences, studies in data science and web development, and explanations of how this site was built for anyone interested in learning.
If technology isn't your thing, check out my other major passions: travel, hiking, photography, and world cuisine. I like to combine as many of these as I can whenever I get the opportunity ...
Latest Blog Posts
Add Heading Blocks with Bookmarks in Wagtail
Wagtail’s Draftail rich text editor lacks any way to add bookmarks to heading tags so that you can link back to that position on the page from elsewhere. In this example, I create a simple StreamBlock to add to your Streamfields that includes heading size, alignment and an optional bookmark. I use ChoiceBlocks for the field values, a custom template with some basic logic and also include some validation to ensure the entered bookmark is a valid slug. This is a good example to work through if you're starting out with Wagtail and getting used to working with blocks and StreamFields.
Best Asian Chilli Sauce Recipe
I love this sauce. I think I might be addicted to it. It gets added to so many dishes I make and even gets used as pesto, steak sauce and sandwich spread. Make it as hot or mild as you like. Easy to make, using easy to find ingredients. If you like chilli sauce with a bang of ginger and garlic, this is for you!
Adding MapBox Blocks to Wagtail Stream Fields
Upgrading to Wagtail 3.0
Wagtail 3.0 is out with a lot of significant changes in architecture requiring code updates. The biggest work I found was the change in the way custom edit panels are handled in the admin interface which isn't well documented yet. Here are some examples I worked through to get up and running.
Embedding Shiny Apps for Interactive Data Analysis
Shiny Apps are great tool for creating interactive R programs which can be embedded into any web page. Depending on the app, it can be built as a dashboard for reporting and analysis, extracting data or even running fully fledged machine learning algorithms based on your requirements.
This example walks you through creating an interactive Leaflet Map, publishing it to a Shiny Server and embedding it in your website.
Adding Multi-column Formats to R Markdown Documents
A well-hidden feature in markdown is the DIV notation that lets you create multi-column format in your outputs. Extremely useful for displaying tabular content or tables alongside the accompanying graph.
Here's a quick example of the latter using R Markdown.
Better Looking Tables with kable in Your R Markdown Documents
If you're using knitr with R markdown documents, you've probably come across the ubiquitous Xtable to display your dataframes and had to wrestle with either LaTeX or css to get the tables displaying with any sense of readability. The kable package comes with a lot of easy to use features including bootstrap styling to make life much easier.
Improve Response Times on Your NGINX Web Server
NGINX is a lightweight and fast web server that meets the content delivery needs of most small to medium sites. Loading speed is now a crucial metric in how the search engines rank websites. With a little basic configuration you can vastly improve the performance of your server and reduce delivery times. Here, I give an introduction to enabling HTTP/2, gzip compression and cache headers.
Creating a table of contents or menu based on content is time-consuming for editors and prone to errors. You may need such a feature on your data fed pages and not even have the ability to create and link to content on the page.
Here, I create an automated, on-the-fly table of contents without the need for hard-coded anchor links, regardless of the source of your content. It's easily adaptable to turn into a nav bar or similar menu. Similarly, this technique could be used to produce a summary with links on an API data feed page for rapid data analysis and drill-down capability.
At the end, I wrap it in a Wagtail stream block ready to drop into your templates.
Translating Static Template Text with Wagtail Localize
You have all your page content and snippet components translating successfully, but what to do with all those bits of static text in the non-Wagtail pages?
Static text lurks in the error pages, search results, e-mail templates and any Django pages that may be getting served on your site.
Here's an easy way to keep it all under the Wagtail Localize umbrella without the pain of making PO files and peppering your templates with blocktrans tags.
Dealing with UNIQUE Fields on a Multi-lingual Site
In Django and Wagtail, for many translation models, a copy of the page tree is made for each language rather than inserting the translated text directly into the template or model. This poses a problem for models that have fields with UNIQUE constraints as attempting to save a copy of the default language instance will trigger an integrity error (ie duplicate key). Fortunately, if you're using the TranslatableMixin, there's a way around this.