From: Michal Vaner Date: Fri, 29 Aug 2008 14:32:11 +0000 (+0200) Subject: Links not only to parent but all the way up X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=1c1f422006b7a43bf9a3c112134353e4bc130a85;p=pciids.git Links not only to parent but all the way up --- diff --git a/PciIds/Address/Base.pm b/PciIds/Address/Base.pm index 5f78ec9..d390c9d 100644 --- a/PciIds/Address/Base.pm +++ b/PciIds/Address/Base.pm @@ -35,4 +35,14 @@ sub defaultRestrict( $ ) { return "" }; sub defaultRestrictList( $ ) { return [] }; +sub path( $ ) { + my( $self ) = @_; + my @result; + my $address = $self; + while( defined( $address = $address->parent() ) ) { + push @result, $address; + } + return \@result; +} + 1; diff --git a/PciIds/Address/Pci.pm b/PciIds/Address/Pci.pm index 61bead4..54a15af 100644 --- a/PciIds/Address/Pci.pm +++ b/PciIds/Address/Pci.pm @@ -15,7 +15,7 @@ sub pretty( $ ) { $_ = $self->get(); s/^PC\/?//; s/\//:/g; - s/([0-9a-f]{4,4})([0-9a-f]{4,4})/$1 $2/g; + s/([0-9a-f]{4})([0-9a-f]{4})/$1 $2/g; my $prefix = ''; if( /:.*:/ ) { $prefix = 'Subsystem'; @@ -30,7 +30,7 @@ sub pretty( $ ) { sub tail( $ ) { my( $new ) = ( shift->get() ); $new =~ s/.*\/(.)/$1/; - $new =~ s/([0-9a-f]{4,4})([0-9a-f]{4,4})/$1 $2/g; + $new =~ s/([0-9a-f]{4})([0-9a-f]{4})/$1 $2/g; return $new; } @@ -52,4 +52,12 @@ sub append( $$ ) { return ( PciIds::Address::Base::new( $self->{'value'} . ( ( $self->{'value'} =~ /\/$/ ) ? '' : '/' ) . $suffix ), undef ); } +sub path( $ ) { + my( $self ) = @_; + my $result = PciIds::Address::Base::path( $self ); + my( $vid ) = ( $self->get() =~ /^PC\/[0-9a-f]{4}\/[0-9a-f]{4}\/([0-9a-f]{4})/ ); + splice @{$result}, 2, 0, PciIds::Address::new( "PC/$vid" ) if( defined $vid ) && ( $result->[1]->get() ne "PC/$vid" ); + return $result; +} + 1; diff --git a/PciIds/Address/Toplevel.pm b/PciIds/Address/Toplevel.pm index 26e78bb..55e5039 100644 --- a/PciIds/Address/Toplevel.pm +++ b/PciIds/Address/Toplevel.pm @@ -69,4 +69,8 @@ sub defaultRestrictList( $ ) { } } +sub parent( $ ) { + return undef; +} + 1; diff --git a/PciIds/Html/List.pm b/PciIds/Html/List.pm index 2e08e2d..4115bbb 100644 --- a/PciIds/Html/List.pm +++ b/PciIds/Html/List.pm @@ -28,11 +28,7 @@ sub list( $$$$ ) { genMenu( $address, $args, $auth ); print htmlDiv( 'name', '

'.encode( $name ) ) if( defined( $name ) ); print htmlDiv( 'description', '

'.encode( $description ) ) if( defined( $description ) ); - if( defined( $address->parent() ) ) { - print '

'.encode( $address->parent()->pretty() ).""; - } else { - print '

Main page'; - } + genPath( $address, 0 ); my $diss = 0; my $comment; foreach $comment ( @{$tables->history( $address->get() )} ) { diff --git a/PciIds/Html/Util.pm b/PciIds/Html/Util.pm index 54d1935..790421d 100644 --- a/PciIds/Html/Util.pm +++ b/PciIds/Html/Util.pm @@ -7,7 +7,7 @@ use PciIds::Users; use Apache2::Const qw(:common :http); use APR::Table; -our @EXPORT = qw(&genHtmlHead &htmlDiv &genHtmlTail &genTableHead &genTableTail &parseArgs &buildExcept &buildArgs &genMenu &genCustomMenu &encode &setAddrPrefix &HTTPRedirect); +our @EXPORT = qw(&genHtmlHead &htmlDiv &genHtmlTail &genTableHead &genTableTail &parseArgs &buildExcept &buildArgs &genMenu &genCustomMenu &encode &setAddrPrefix &HTTPRedirect &genPath); sub encode( $ ) { return encode_entities( shift, "\"'&<>" ); @@ -120,4 +120,16 @@ sub HTTPRedirect( $$ ) { return HTTP_SEE_OTHER; } +sub genPath( $$ ) { + my( $address, $printAddr ) = @_; + my $path = $address->path(); + push @{$path}, $address if( $printAddr ); + print "

\n"; +} + 1; diff --git a/static/screen.css b/static/screen.css index 0aca195..d5aee1f 100644 --- a/static/screen.css +++ b/static/screen.css @@ -39,7 +39,8 @@ body padding-left: 5px; padding-right: 5px; } -.menu ul +.menu ul, +.navigation ul { list-style-type: none; }