#!/usr/bin/perl # This is the index for Collections. use strict; use warnings FATAL => qw( all ); use CGI::Carp qw(fatalsToBrowser); use CGI::Minimal; use HTML::Entities qw(encode_entities); use lib '../files/lib'; use Base::Page qw(page story); use Util::Data qw(file_directory file_list); use Util::StoryMagic qw(program_magic); use Util::StoryMagic::Collection qw(collection_magic); my $cgi = CGI::Minimal->new; my $collection = $cgi->param('collection') ? encode_entities($cgi->param('collection'),'<>"') : undef; my $magic = $collection && $collection eq 'Program' ? program_magic : collection_magic; my $collections_dir = file_directory('Collections'); my @collections_list = file_list($collections_dir); my @collections = map { $_ =~ s/\.txt//; $_ =~ s/_/ /g; $_ } grep {/^\p{uppercase}/} @collections_list; my $heading = q(Lady Aleena's ); $heading .= $collection && grep( $collection =~ /$_/, @collections ) ? lc "$collection collection" : 'collections'; my $collection_file = $collection ? "$collections_dir/$collection.txt" : "$collections_dir/index.txt"; $collection_file =~ s/ /_/g; open(my $collection_fh, '<', $collection_file) || die $!; page( 'heading' => $heading, 'code' => sub { story($collection_fh, { 'doc magic' => $magic, 'line magic' => $magic }); } );