Weblocks Navigation Widget

WEBLOCKS-NAVIGATION-WIDGET ASDF System Details

Introduction

This addon for Weblocks frameworks allows you to define which widgets should be shown to the user dependening on URL's path.

The main entry-point is defroutes macro. Use it to define a subclass of navigation widget and then return this widget from the session initialization method of your Weblocks application.

API

Defines a new class with name CLASS-NAME, inherited from navigation-widget.

And a function make-{class-name} to make instances of this class.

Each entry in rules should be a list of two items. First item is a regex pattern to match URL path. Second item is a form to create a widget. A new widget will be created only if URL was changed.

Here is an example of a widget with two rules:

(defroutes tasks-routes
        ("/tasks/d+" (make-task-page))
        ("/tasks/" (make-task-list "Make my first Weblocks app"
                                   "Deploy it somewhere"
                                   "Have a profit")))

With these rules, when user opens URL /tasks/ a widget returned by MAKE-TASK-LIST will be set as current-widget and shown to the user. If user clicks on some task and URL change to /tasks/100500, then a widget for a task will be created by a call to MAKE-TASK-PAGE.

Pay attention that widget creation form is responsible for extraction of the parameters from the URL. In above case, MAKE-TASK-PAGE should call WEBLOCKS/REQUEST:GET-PATH and parse path to extract task's id. Probably this will change in future defroutes will catch matched path pieces.

Base class for all navigation widgets.

When rendered it tracks if URL was changed and creates a new child widget according to given navigation rules.

Usually you don't want to inherit from this class manually, but instead use defroutes macro.