-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.pl
executable file
·45 lines (41 loc) · 1.39 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
38
39
40
41
42
43
44
45
#!/usr/bin/perl
# This is the site index.
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);
use Page::Story qw(story);
use Page::Story::Magic::IRC qw(irc_magic);
use Page::Story::Magic::Programs qw(program_magic);
use Page::Story::Magic::PlayerCharacters qw(pc_magic);
my $cgi = CGI::Simple->new;
my $page = $cgi->param('page') ? encode_entities($cgi->param('page'),'/<>"') : undef;
my $pages_dir = file_directory(undef, 'text');
my @pages = file_list($pages_dir, { 'type' => 'f', 'uppercase' => 0, 'sort' => 'article', 'text' => 1 });
my $heading = 'index';
my $page_file = "$pages_dir/index.txt";
if ( $page && grep { $_ eq $page } @pages ) {
$heading = $page eq 'about' ? 'About Lady Aleena' :
$page eq 'irc' ? 'IRC channels I visit' :
$page eq 'twitter' ? 'So, you want me to follow you on Twitter.' :
undef;
$page_file = "$pages_dir/$page.txt";
$page_file =~ s/ /_/g;
}
my $magic = {
%{&program_magic},
%{&pc_magic},
%{&irc_magic}
};
page(
'heading' => $heading,
'selected' => $page,
'code' => sub {
story('file' => $page_file, 'magic' => { 'line magic' => $magic, 'doc magic' => $magic })
}
);