CatalystX-Menu-Tree
view release on metacpan or search on metacpan
Changes
gitignore
inc/Module/Install.pm
inc/Module/Install/Base.pm
inc/Module/Install/Can.pm
inc/Module/Install/Fetch.pm
inc/Module/Install/Makefile.pm
inc/Module/Install/Metadata.pm
inc/Module/Install/Win32.pm
inc/Module/Install/WriteAll.pm
lib/CatalystX/Menu/Tree.pm
Makefile.PL
MANIFEST This list of files
MANIFEST.SKIP
META.yml
README
t/00-load.t
t/01-output.t
t/lib/script/testapp_server.pl
t/lib/script/testapp_test.pl
t/lib/TestApp.pm
ExtUtils::MakeMaker: 6.42
Test::More: 0
configure_requires:
ExtUtils::MakeMaker: 6.42
distribution_type: module
generated_by: 'Module::Install version 0.87'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
name: CatalystX-Menu-Tree
no_index:
directory:
- inc
- t
inc: []
requires:
Catalyst::Runtime: 0
MRO::Compat: 0
perl: 5.8.0
resources:
Makefile.PL view on Meta::CPAN
use inc::Module::Install;
name 'CatalystX-Menu-Tree';
all_from 'lib/CatalystX/Menu/Tree.pm';
test_requires 'Test::More';
no_index 'inc';
requires 'Catalyst::Runtime';
requires 'MRO::Compat';
WriteAll();
CatalystX::Menu::Tree
=====================
INSTALLATION
To install this module type the following:
perl Makefile.PL
make
make test
make install
lib/CatalystX/Menu/Tree.pm view on Meta::CPAN
package CatalystX::Menu::Tree;
use 5.008000;
use strict;
use warnings;
use MRO::Compat;
use vars qw($VERSION);
$VERSION = '0.02';
=head1 NAME
CatalystX::Menu::Tree - Generate Catalyst application menus
=head1 SYNOPSIS
my $tree = CatalystX::Menu::Tree->new(
context => $c,
namespaces => [ $c->namespace ],
filter => sub {
my ($c, %action) = @_;
# return the list of k/v pairs that meet criteria
},
menupath_attr => 'MenuPath',
menutitle_attr => 'MenuTitle',
add_nodes => [
{
menupath => '/Bargains',
menutitle => 'Cheap stuff',
uri => '/products/cheap',
},
{
menupath => '/Returns',
menutitle => 'Return a product',
uri => '/products/returns',
},
],
);
=head1 DESCRIPTION
Builds the tree used by CatalystX::Menu::Suckerfish to construct an HTML UL
element for use as a degradable, CSS-styled menu or horizontal navbar.
Catalyst actions with the Private attribute are excluded from the tree.
=head2 Menu Attributes
=over
=item menupath_attr
Names the action attribute that contains the menu path:
menupath_attr => 'MenuPath'
# and in your controller:
sub foobar :Local
:MenuPath(/Foo/Bar)
:MenuTitle('Foobar and stuff')
{ ... }
Only actions with the menupath_attr attribute are processed. This attribute's
value determines where the action's menu item is placed in the menu structure
(HTML UL).
Depending on the attribute values collected from the processed actions, there
may be menu items containing only text. If you want a link to a landing page,
for example, instead of text, include an action for the landing page with the
appropriate MenuPath attribute in your controller, or add an entry manually
with the add_nodes parameter.
=item menutitle_attr
The menutitle_attr attribute will be used to add the HTML title attribute to
each list item. This should result in a balloon text with the title when the
pointing device hovers over each list item.
=back
t/lib/TestApp/Controller/Root.pm view on Meta::CPAN
package TestApp::Controller::Root;
use base Catalyst::Controller;
use CatalystX::Menu::Tree;
__PACKAGE__->config(namespace => q{});
sub begin :Private {
my ($self, $c) = @_;
# this is called in the CatalystX::Menu::Tree subclass
# e.g.
# my $menu = CatalystX::Menu::Suckerfish->new(...);
# $c->session->{menu} = $menu->output; # stash nested HTML UL element for use in TT View
require Data::Dumper;
my $menutree = CatalystX::Menu::Tree->new(
context => $c,
menupath_attr => 'MenuPath',
menutitle_attr => 'MenuTitle',
add_nodes => [
{
menupath => 'Foo/Bar',
menutitle => 'A foo bar',
uri => '/foobar',
},
],
);
my $tree = $menutree->{tree};
$c->stash->{tree1} = Data::Dumper->Dump([$tree],['$tree']);
$menutree = CatalystX::Menu::Tree->new(
context => $c,
menupath_attr => 'MenuPath',
add_nodes => [
{
menupath => 'Foo/Bar',
uri => '/foobar',
},
],
);
$tree = $menutree->{tree};
$c->stash->{tree2} = Data::Dumper->Dump([$tree],['$tree']);
}
t/lib/TestApp/Controller/Root.pm view on Meta::CPAN
}
sub tree2 :Local {
my ($self, $c) = @_;
$c->res->body($c->stash->{tree2});
}
sub public
:Local
:MenuPath(/Main/Public)
:MenuTitle('A public function')
{
my ($self, $c) = @_;
$c->res->body('public action');
}
sub aboutus
:Path(/about/us)
:MenuPath(/About us)
:MenuTitle('About us')
{
my ($self, $c) = @_;
$c->res->body('about us action');
}
1;
( run in 1.386 second using v1.01-cache-2.11-cpan-49f99fa48dc )