X-Git-Url: http://git.jankratochvil.net/?p=www.jankratochvil.net.git;a=blobdiff_plain;f=project%2FLib.pm;fp=project%2FLib.pm;h=6ccc6e3b3e4885856d48821490ddaee5d1bcbc6d;hp=4fde2771bb5957dd0557b461277bbd7bbadc11e9;hb=678dde71232fbad0b45a902bfac847d502f8555d;hpb=117ef7704903cb15496dc4dad9bdef4b03828ed7 diff --git a/project/Lib.pm b/project/Lib.pm index 4fde277..6ccc6e3 100644 --- a/project/Lib.pm +++ b/project/Lib.pm @@ -28,15 +28,11 @@ use Carp qw(cluck confess); use Exporter; our @EXPORT=qw(); -our @ISA=qw(My::Web Exporter); +Wrequire 'Lib'; +our @ISA=qw(My::Web Lib Exporter); -sub LIST_FILENAME() -{ - # Do not: path_abs_disk("/project/SUBDIRS"); - # as we would need $W->{"r"} for the possibly relative path resolving. - return My::Web::dir_top_abs_disk()."/project/SUBDIRS"; -} +my $LIST_ABSPATH="/project/SUBDIRS"; sub print_project @@ -174,77 +170,12 @@ my($tableit,$val,$key,$ListItem)=@_; print vskip; } -sub hashlikearray_get_keys(@) -{ -my(@hashlikearray)=@_; - - my @r; - while (@hashlikearray) { - push @r,shift @hashlikearray; # key - shift @hashlikearray; # val - } - return @r; -} - -sub project_arrayref_to_hashref($$) -{ -my($self,$arrayref)=@_; - - Wrequire 'My::Hash'; - return My::Hash->new({ - @$arrayref, - "keys_array"=>[ hashlikearray_get_keys(@$arrayref) ], - },"My::Hash::Sub","My::Hash::Readonly"); -} - -sub title ($$) -{ -my($class,$hashref)=@_; - - cluck if !$hashref->{"name"} || !$hashref->{"summary"}; - return $hashref->{"name"}.": ".$hashref->{"summary"}, -} - # Returns: hashref if !wantarray(), list if wantarray(). sub list($) { my($self)=@_; - # This cache is "headers_in" hits safe - only local files reading. - our %list_cache; - our @list_cache; - if (!@list_cache) { - My::Web->make_file(LIST_FILENAME()); - local *F; - open F,LIST_FILENAME() or do { - cluck "Error opening \"".LIST_FILENAME()."\": $!"; - return; - }; - my @r=split(" ",do { undef $/; ; }); - close F or cluck "Error closing \"".LIST_FILENAME()."\": $!"; - cluck "No projects found?" if !@r; - @list_cache=@r; - %list_cache=map(($_=>1),@list_cache); - } - return \%list_cache if !wantarray(); - return @list_cache; -} - -# Returns: hashlist of hashrefs if !$name. -sub name_to_hashref($;$) -{ -my($class,$name)=@_; - - cluck if !wantarray() && !$name; - # Do not cache the result to get all the items &Wrequire-mapped. - return map(($_=>$class->name_to_hashref($_)),$class->list()) if !$name; - cluck join(" ","Project name \"$name\" not listed in 'list_cache':",$class->list()) - if !$class->list()->{$name}; - # Never cache anything to be stable for "headers_in" hits. - Wrequire "project::${name}::Index"; - my $arrayref=eval('\@project::'.$name.'::Index::ListItem'); - do { warn "Broken project/$name/Index.pm"; return undef(); } if !@$arrayref; - return $class->project_arrayref_to_hashref($arrayref); + return $self->list_abspath($LIST_ABSPATH); } # $args{"ListItem"}=\%...; @@ -342,29 +273,20 @@ my($class,$platform_selected,%args)=@_; $r.=''."\n"; $r.=''."\n"; if (!$args{"novskip"}) { - $r.="
\n"; - $r.=My::Web::vskip "6ex"; + Wrequire 'WebConfig'; + $r.=WebConfig->vskip_hr(); } return $r; } -sub section ($$) +sub section($$) { my($class,$name)=@_; my $item=$class->name_to_hashref($name); - my $title=$class->title($item); - my $r=""; - - print $class->platforms($item->{"platform"},"novskip"=>1); - - $r.=''."\n"; - $r.=''."\n"; - $r.='
'."\n"; - $r.=a_href "/project/$name/",$title; - $r.='
'."\n"; - $r.=vskip "1ex"; - return $r; + return "" + .$class->platforms($item->{"platform"},"novskip"=>1) + .$class->SUPER::section($name); } 1;