CatalystX-Menu-Suckerfish
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/Suckerfish.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-Suckerfish
no_index:
directory:
- inc
- t
inc: []
requires:
Catalyst::Runtime: 0
CatalystX::Menu::Tree: 0
HTML::Element: 0
HTML::Entities: 0
MRO::Compat: 0
perl: 5.8.0
resources:
license: http://dev.perl.org/licenses/
version: 0.03
Makefile.PL view on Meta::CPAN
use inc::Module::Install;
name 'CatalystX-Menu-Suckerfish';
all_from 'lib/CatalystX/Menu/Suckerfish.pm';
requires 'Catalyst::Runtime';
requires 'MRO::Compat';
requires 'HTML::Entities';
requires 'HTML::Element';
requires 'CatalystX::Menu::Tree';
test_requires 'Test::More';
no_index 'inc';
WriteAll();
CatalystX::Menu::Suckerfish
===========================
INSTALLATION
To install this module type the following:
perl Makefile.PL
make
make test
make install
lib/CatalystX/Menu/Suckerfish.pm view on Meta::CPAN
package CatalystX::Menu::Suckerfish;
use 5.008000;
use strict;
use warnings;
use base 'CatalystX::Menu::Tree';
use HTML::Entities;
use HTML::Element;
use MRO::Compat;
use vars qw($VERSION);
$VERSION = '0.03';
=head1 NAME
CatalystX::Menu::Suckerfish - Generate HTML UL for a CSS-enhanced Suckerfish menu
=head1 SYNOPSIS
package MyApp::Controller::Whatever;
sub someaction :Local
:MenuPath('Electronics/Computers')
:MenuTitle('Computers')
{ ... }
sub begin :Private {
my ($self, $c) = @_;
my $menu = CatalystX::Menu::Suckerfish->new(
context => $c,
ul_id => 'navmenu', # <ul id="navmenu"> ... </ul>
ul_class => 'sf-menu', # <ul id="navmenu" class="sf-menu"> ... </ul>
text_container => { # wrap plain text nodes in this HTML element
element => 'span', # so that styles can be applied if desired.
attrs => {
class => 'myspan',
},
},
top_order => [qw(Home * About)], # Put Home and About on the ends,
lib/CatalystX/Menu/Suckerfish.pm view on Meta::CPAN
Suckerfish menus: L<http://www.alistapart.com/articles/dropdowns>
Superfish jQuery menu plugin: L<http://users.tpg.com.au/j_birch/plugins/superfish/>
=head1 METHODS
=cut
=head2 C<new( $tree, %params )>
Takes a menu tree produced by Catalyst::Controller::Menutree (CatalystX::MenuTree)
and a list of key/value parameter pairs.
Params
=over
=item menupath_attr
Required (no validation)
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
Optional
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.
lib/CatalystX/Menu/Suckerfish.pm view on Meta::CPAN
element.
=item text_container
Specifies an HTML element (typically a SPAN) in which to enclose menu items
which don't include A elements. This makes it possible to apply similar styles
to both plain text and A elements for consistent appearance.
=item top_order
A list of top level menu item labels. Menu items are sorted alphabetically by
default. top_order allows you to specify the order of one or more items. The
asterisk (*) inserts any menu items not listed in top_order.
=item add_nodes
Optional
A reference to an array of hash references. See the L</SYNOPSIS>.
=back
t/lib/TestApp/Controller/Root.pm view on Meta::CPAN
package TestApp::Controller::Root;
use Moose;
BEGIN { extends 'Catalyst::Controller' }
use CatalystX::Menu::Suckerfish;
use Data::Dumper;
__PACKAGE__->config(namespace => q{});
my $frozen_tree = <<'EOF';
{
'About us' => {
'children' => {},
'menutitle' => 'About us',
'uri' => bless( do{\(my $o = 'http://localhost/about/us')}, 'URI::http' )
t/lib/TestApp/Controller/Root.pm view on Meta::CPAN
'uri' => bless( do{\(my $o = 'http://localhost/public')}, 'URI::http' )
}
}
}
};
EOF
sub begin :Private {
my ($self, $c) = @_;
my $menu = CatalystX::Menu::Suckerfish->new(
context => $c,
ul_id => 'navlist',
ul_class => 'navmenu',
menupath_attr => 'MenuPath',
menutitle_attr => 'MenuTitle',
top_order => [qw(Main * Help)],
text_container => { element => 'span', attrs => { class => 'menulabel' } },
);
$c->stash->{menu} = $menu->output;
# generate a menu for use with Filament Group iPod menu jQuery plugin
$menu = CatalystX::Menu::Suckerfish->new(
context => $c,
menupath_attr => 'MenuPath',
top_order => [qw(Main * Help)],
ul_container => { element => 'div', attrs => { id => 'divid', class => 'hidden' } },
text_container => { element => 'a', attrs => { href => '#' } },
);
$c->stash->{menu_in_div} = $menu->output;
}
sub index :Path :Args(0) {
my ($self, $c) = @_;
t/lib/TestApp/Controller/Root.pm view on Meta::CPAN
$c->res->body($c->stash->{menu});
}
sub menu_in_div :Local {
my ($self, $c) = @_;
$c->res->body($c->stash->{menu_in_div});
}
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.710 second using v1.01-cache-2.11-cpan-49f99fa48dc )