Headline

An extension of Contribution:perl, using Technology:Dancer as a framework for Feature:Web UI.

Characteristics

The most prominent feature of this contribution is the Feature:Web UI. The Server is implemented using Dancer and communicates with the Client via the Web UI REST API.

Illustration

Technology:Dancer uses route handlers to apply incoming connections to specified subroutines.

# When a client GETs the root URL, send the default client page.
get  '/'     => sub { send file '/web ui.html' };
# Sends the model to a client requesting it via AJAX. It is automatically converted to JSON by Dancer.
ajax '/tree' => sub { $model };

Each action from the client is handled via such a route handler.

Take for example the handler for Feature:Restructuring:

ajax '/restructure' => sub {
    # Get source and target from AJAX parameters
    my ($source, $error) = object from(param 'id');
    return $error if not $source;
    (my $target, $error) = object from(param 'target');
    return $error if not $target;

    # Client might try to restructure wrong types
    $target->child types->{$source->type name}
        or return err('Restructure: Incompatible types.');

    # Get the list the source is to be inserted into
    my $list   = $target->children;
    # The pos parameter is optional, either use it or the end of the list
    my $pos    = param 'pos' // $#$list;
    # Remove the source from the model
    my ($rm)   = remove(sub { $ [0] == $source }, $model->children);
    # Adjust pos in case the element is to be re-inserted into the same list
    my $offset = $rm && $rm->{list} == $list && $pos >= $rm->{index}
               ? $pos - 1
               : $pos;
    # Insert it at the right position
    splice $list, $offset, 0, $source;

    # Tell the client to restructure too
    return {
        commands => {
            type   => 'move',
            source => $source->id,
            target => $target->id,
            pos    => $pos,
        },
    };
};

Relationships

Architecture

Just like Contribution:perl, except it also comes with the perl script to start the server.

Usage

Please see the readme.pod on GitHub for details.


There are no revisions for this page.

User contributions

    This user never has never made submissions.

    User edits

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.