Mojo Wonk Blog.

A semi-offical blog dedicated to the Mojolicious web framework

Day 15: Practical Web Content Munging

An eyeball of alarming size

Following brian d foy's great write-up of using Mojo::DOM selectors from Day 5, I thought it'd be fun to talk about some website migration scripts I recently built using Mojo::UserAgent and Mojo::DOM, in order to show some basic practical usage of these modules. I've never really used Mojo before, but I recently needed to migrate a website that hasn't had a redesign in about 15 years, and it seemed like a great fit for my content mangling needs. In the past I would have used regexes, and probably would have spent at least as much time manually massaging the input or output into the right shape as I spent writing code. Mojo::DOM made it easy for me, a Mojolicious beginner, to get the results I wanted really quickly.

From Static Site to Static Site Generator

The problem I set out to solve was taking an old static website that was once hosted on and migrating it to an exciting website. But, this time, it'll be a modern take on a static website. Instead of editing HTML by hand and using home-built page munging scripts that would do things like insert news items or changelog entries at the top of the content div using regexes, I'll be using a modern static website generator. There are several to choose from, including the well-known Jekyll, which is written in Ruby, Hugo, built with Go, and Statocles, which is in Perl and runs this site. For my project, I chose Hugo, for its speed and maturity.

Continue reading Day 15: Practical Web Content Munging...

Day 14: A Practical Example of Mojo::DOM

A typical industrial platform model overlaid with a laser scan

With recent versions of Mojolicious, Mojo::DOM gained a lot of power that I have been excited to try, but haven't had the time for. Recently, I had a problem at my real job (in Engineering, Procurement, and Construction, or EPC for short) that I solved with Mojo::DOM (and other parts of Mojolicious) in a very short time – including learning how to use Mojo::DOM, which I had never done before.

Continue reading Day 14: A Practical Example of Mojo::DOM...

Day 12: Using Minion in Dancer Apps

Stylistic photograph of Disney-style minion toys

At $work, we have built an API with Dancer that generates PDF documents and XML files. This API is a critical component of an insurance enrollment system: PDFs are generated to deliver to the client in a web browser immediately, and the XML is delivered to the carrier as soon as it becomes available. Since the XML often takes a significant amount of time to generate, the job is generated in the background so as not to tie up the application server for an extended amount of time. When this was done, a homegrown process management system was developed, and works by fork()ing a process, tracking its pid, and hoping we can later successfully reap the completed process.

There have been several problems with this approach: - it's fragile - it doesn't scale - it's too easy to screw something up as a developer

In 2019, we have to ramp up to take on a significantly larger workload. The current solution simply will not handle the amount of work we anticipate needing to handle. Enter Minion.

Note: The techniques used in this article work equally well with Dancer or Dancer2.

Continue reading Day 12: Using Minion in Dancer Apps...