- # 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 $/; <F>; });
- 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);