OverZealous Creations

Why you shouldn’t create a gulp plugin (or, how to stop worrying and learn to love existing node packages)

I’ve been experimenting with the gulp task runner for a week or so now. My goal has been to recreate some or most of the functionality of ngBoilerplate's Grunt-based build script. (Confused? Look at the bottom of this article for some more information about all these terms.)

One of the biggest concerns surrounding the project is the very opinionated design, and view that plugins for it should be extremely simple. I wasn’t in total agreement with this philosophy until today.

I want explain why you should resist the temptation to write a new plugin for everything you want to use gulp for.

Read More

Natural Sorting within Angular.js

I was reading Ben Nadel’s blog post, User-Friendly Sort Of Alpha-Numeric Data In JavaScript, and I was inspired to expand upon his ideas and turn it into a reusable module that fit better with the MVC pattern.

What I came up with is a full-featured naturalSort module that can be used with the built-in orderBy function.

What is Natural Sorting?

Normally, numerical values in strings are sorted using their ascii (or unicode) values in a non-inutitive manner. Natural sorting adjusts the sorting for these items to ensure that they are sorted in the order that the user would expect.

Example:

Before      After
----------- -----------
foo-1       foo-1
foo-11      foo-2
foo-2       foo-5
foo-25      foo-11
foo-5       foo-25

The algorithm here can also handle sorting dates in common formats (if included), and version strings.

Read More

Using Grails Scaffolding for Easy Admin

Last time, I showed you how to use UrlMappings to organize controllers by naming convention. This post builds upon part of that — the custom admin section — so you can quickly set up a simple administration section using Grails built-in scaffolding.

In this post, I’ll walk you through the steps necessary to modify the scaffolding templates so you can add a low-level “admin” section quickly to your application, that lives entirely under an /admin/ sub-path.

Read More

Grails UrlMappings Tricks

Grails allows really easy controller URI setup via UrlMappings. But there is one area where it can be a little frustrating: grouping controllers under a “subpath”.

Several examples stand out that have caused frustration:

  • An /api/ path to host just API calls.
  • An /admin/ path where simple scaffolded controllers live for admins.
  • A mobile path (/m/, for example), if you prefer completely different controllers for mobile.

In the following article, I describe a simple, single-application solution that allows new controllers to be added purely on naming convention.

Read More