I’m proud to announce the fruit of my efforts from the past few weeks:

(New) Android Zip Builder

I had a set of bash scripts that I used to generate the flashable zip files you can download from this site, but they were too messy to share with other people and not very portable. So, I started work on a program written in Go that would replace those scripts.

This is my first project written in Go. It took some time to get used to how Go works, the assumptions it makes about how your files are organized, even down to enforcing a certain code style. It was… new, to say the least.

The process was worth the initial struggle, though, as I’ve come out the other side with something I’m proud to share with the Android community. You can find documentation on how to use zip-builder on this site and the initial release on GitLab. Example configuration files are in the repository.

Subsequent releases will heavily improve on this one. You can see a list of accepted feature requests here.

BluestNight Features

BluestNight has received quite a few updates recently. Aside from the usual bug fixes, here’s what’s been added since last time:

Piwik is a nice alternative to Google for analytics, except that there is no built-in support for clicking a button to opt out of being tracked. They instead offer an <iframe> that a reader can interact with, but let’s face it: that looks ugly. Especially when the <iframe> has a white background and black text on a site with a black background and white text. Someone else thought it was a silly thing too and wrote a plugin for Piwik that enables using AJAX to opt in and out. Now BluestNight can make use of that plugin and provide users a simple one-click interface. You can read more about about how to enable that in the documentation.

A small bit of code has also been added to the site JavaScript search to check if Piwik is being used on the page and, if so, record what users searched for and what result they clicked on in the results.

Event Improvements

The event sidebar widget was feeling somewhat lackluster, so I took a day to spruce it up. Events are now filtered by ones that have not yet completed at the time of the site build. There is also a nice “Subscribe with iCal” button to make it easier to subscribe to changes to the events.

Previously, the widget used an https:// link to the generated iCal file. When a person downloaded the file to add to their calendar, it would be a one-time thing, not a subscription. The “Subscribe” button instead uses the webcal:// protocol, a widely used non-standard that indicates an iCal file that should be subscribed to.

Shortcodes

The past few weeks have seen four new shortcodes added to the theme.

The first is {{< static >}}, which works like the built-in {{< ref >}} shortcode, but with any link, not just other content files. This solves a problem with linking to static files on sites with a BaseURL containing a subdirectory (e.g. https://example.com/mysite/) where you are forced to either hardcode the absolute URL for the file or provide a relative path like ../../../images/my_image.png. It’s pretty simple, so you can read more about it in the documentation.

The next shortcode implemented was {{% alert %}}, which is used to create attention-grabbing alert boxes like the one below:

This is an alert box. It can contain Markdown and be placed anywhere on the page. There are also special alert parameters for the site configuration file and page frontmatter. Read more in the documentation.

The third shortcode is a bit more domain-specific. It’s actually a set of multiple nested shortcodes that can be used to generate a nice-looking form that is compatible with Netlify’s form handling, so it will only work when the site is hosted on Netlify. Support for other form handlers may be provided in the future, though. If you have one you’d like to see supported, let me know in the BluestNight issue tracker. Examples of where you can find this in use are the contact page and the BluestNight usage survey. You will want to look at the documentation if you plan on using this feature.

Finally, BluestNight has support for responsive tables. Tables look bad on mobile screens, especially as you add more columns. You can get around that by shifting each cell into its own row and each row into its own mini-table. This isn’t something I could do with the markdown implementation of tables, though, so I had to create a set of shortcodes to build a table instead. You can find examples and documentation on how to use the shortcodes here.

Intelligent Color Selection

One thing that had been bugging me for some time with this theme was the Patreon banner. It looked nice with the default colors and anything that didn’t deviate much from it, but it was virtually invisible when you changed the colors to a light theme. A workaround was to let the site author specify their own image, but that wasn’t enough. The theme needed to be smart enough to tell whether to use white or black text on a background.

And now it is.

Following the suggestion of this Stack Overflow answer, I set out to calculate the relative luminance of the main background color compared to black, which would help determine if the color was “light” or “dark”. Along the way, I had to:

  • Write partial templates to get RGB values from hexadecimal and rgb() color strings.
  • Realize Hugo can’t calculate fractional powers and implement Newton’s Method in a recursive partial to get around that.
  • Implement the algorithm to calculate the relative luminance while getting around weird parsing and scoping bugs.

It took some time, but now BluestNight can automagically detect whether to use the black-text or white-text banner in the sidebar. This capability may extend elsewhere in the future, as well.

And More

  • Added options for specifying different background images for different screen sizes, saving bandwidth and load times with smaller images.
  • Added subresource integrity checks to all possible remote files loaded on the page.
  • Added an example Nginx configuration file for Hugo to the documentation.
  • Added a “Subscribe with RSS” button to the “Recent Posts” sidebar widget.

Is That All?

No, there’s still more to do. There’s issue trackers for both zip-builder and BluestNight, as well as other personal projects not involving programming.

If you’d like to help out, feel free to fork one of the projects and tackle one of the issues yourself. Just be sure to make a merge request when you’re through! If you don’t program, you can help by just using the software and giving me feedback on it, especially with any bugs you come across. If you use BluestNight or just want to give some feedback on it, please take a moment and fill out this survey. If you like modifying your Android device, download the correct build for your computer and try building a zip using an example config or one of your own.

Until next time!

Comments