Changeset 119


Ignore:
Timestamp:
May 10, 2003, 10:16:06 PM (19 years ago)
Author:
kake
Message:

Use OpenGuides::Utils to set up the wiki object

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wiki.cgi

    r118 r119  
    2020use Geography::NationalGrid::GB;
    2121use OpenGuides::RDF;
     22use OpenGuides::Utils;
    2223use Template;
    2324use Time::Piece;
     
    2526
    2627# config vars
    27 my $config = Config::Tiny->new;
    28 $config = Config::Tiny->read('wiki.conf');
     28my $config = Config::Tiny->read('wiki.conf');
    2929
    3030# Read in configuration values from config file.
     
    4141my $template_path = $config->{_}->{template_path};
    4242
    43 # Require in the right database module.
    44 my $dbtype = $config->{_}->{dbtype};
    45 
    46 my %cgi_wiki_exts = ( postgres => "Pg",
    47                       mysql    => "MySQL" );
    48 
    49 my $cgi_wiki_module = "CGI::Wiki::Store::" . $cgi_wiki_exts{$dbtype};
    50 eval "require $cgi_wiki_module";
    51 die "Can't 'require' $cgi_wiki_module.\n" if $@;
    52 
    53 # Make store.
    54 my $store = $cgi_wiki_module->new(
    55     dbname => $config->{_}{dbname},
    56     dbuser => $config->{_}{dbuser},
    57     dbpass => $config->{_}{dbpass},
    58 );
    59 
    60 # Make search.
    61 my $indexdb = Search::InvertedIndex::DB::DB_File_SplitHash->new(
    62     -map_name  => $config->{_}{indexing_directory},
    63     -lock_mode => "EX"
    64 );
    65 my $search  = CGI::Wiki::Search::SII->new( indexdb => $indexdb );
    66 
    67 # Make formatter.
    68 my %macros = (
    69     '@SEARCHBOX' =>
    70         qq(<form action="$search_url" method="get">
    71            <input type="text" size="20" name="search">
    72            <input type="submit" name="Go" value="Search"></form>),
    73     qr/\@INDEX_LINK\s+\[\[(Category|Locale)\s+([^\]]+)\]\]/ =>
    74         sub { return qq(<a href="$script_name?action=index;index_type=) . uri_escape(lc($_[0])) . qq(;index_value=) . uri_escape($_[1]) . qq(">View all pages in $_[0] $_[1]</a>)
    75             }
    76 );
    77 
    78 my $formatter = CGI::Wiki::Formatter::UseMod->new(
    79     extended_links      => 1,
    80     implicit_links      => 0,
    81     allowed_tags        => [qw(a p b strong i em pre small img table td tr th
    82                                br hr ul li center blockquote kbd div code
    83                                strike sub sup font)],
    84     macros              => \%macros,
    85     node_prefix         => "$script_name?",
    86     edit_prefix         => "$script_name?action=edit&id="
    87 );
    88 
    89 my %conf = ( store     => $store,
    90              search    => $search,
    91              formatter => $formatter );
    92 
    93 my ($wiki, $locator, $q);
     43my ($wiki, $formatter, $locator, $q);
    9444eval {
    95     $wiki = CGI::Wiki->new(%conf);
     45    $wiki = OpenGuides::Utils->make_wiki_object( config => $config );
     46    $formatter = $wiki->formatter;
    9647    $locator = CGI::Wiki::Plugin::Locator::UK->new;
    9748    $wiki->register_plugin( plugin => $locator );
Note: See TracChangeset for help on using the changeset viewer.