What's New in WebGUI 8.0 #5 - Asset Helpers

By far the biggest change we've made in WebGUI 8 is the new Admin Console.
Though parts of it may look familiar, it has been completely rewritten from
the ground up to be a flexible, extensible, responsive JavaScript application
making calls to JSON services in Perl.

I could talk about how to use the admin interface, but I don't think that's
why you would read this blog, so instead I'm going to talk about how you can add functionality to it.

Asset Services

Since Assets are the basic unit of both application and content in WebGUI,
much of the Admin Console is spent interacting with Assets. It does so by
calling out to Asset Helpers.

By default, every asset has a helper to Cut, Copy, Duplicate, Delete, and
more. When a helper gets called, it returns a JSON data structure explaining
to the Admin Console what to do next.

But our asset helpers are not only useful inside of the Admin Console. Because
they're all built on a simple JSON API, you can call them from anywhere. For
example, the Asset Helper to resize and rotate images could be used by anyone
with edit privileges to the Image.

Because we already have these Asset Helpers, the new Asset Manager (now called
the Tree view) uses them to perform all of its tasks. This means, again, more
code reuse and less code in WebGUI.

Side note: I love deleting code much more than writing it.

Adding Helpers

What would a plugin point be without a way to override what already exists? In
our case, if you want another helper to handle the "cut" operation, you can
make it happen.

If you have your own asset, you can override the getHelpers method, which
returns a hashref of helper descriptions: