-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.pl
executable file
·37 lines (33 loc) · 1.16 KB
/
index.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/perl
# This is the index for Fandom.
use strict;
use warnings FATAL => qw( all );
use CGI::Carp qw(fatalsToBrowser);
use CGI::Simple;
use FindBin qw($Bin);
use HTML::Entities qw(encode_entities);
use lib "$Bin/../files/lib";
use Page::Base qw(page);
use Page::File qw(file_directory file_list print_file_menu);
use Page::Story qw(story);
use Page::Story::Magic::Movie qw(movie_magic);
my $cgi = CGI::Simple->new;
my $page = $cgi->param('page') ? encode_entities($cgi->param('page'),'/<>"') : undef;
my $pages_dir = file_directory('Fandom', 'text');
my @pages = file_list($pages_dir, { 'type' => 'f', 'uppercase' => 1, 'sort' => 'article', 'text' => 1 });
my $heading = q(Lady Aleena's fandom);
my $page_file = "$pages_dir/index.txt";
if ( $page && grep { $_ eq $page } @pages ) {
$heading = $page;
$page_file = "$pages_dir/$page.txt";
$page_file =~ s/ /_/g;
}
my $magic = movie_magic( dots => '..' );
$magic->{'pages'} = sub { print_file_menu('page', \@pages, $page, 2) };
page(
'heading' => $heading,
'selected' => $page,
'code' => sub {
story('file' => $page_file, 'magic' => { 'doc magic' => $magic, 'line magic' => $magic });
}
);