package main;
use strict;

## [OBSOLETE] URI (or part of URI) of Wiki CGI itself and its external addons
	## Note: If your Wiki CGI URI is <http://foo.example/path/to/wiki.cgi>,
	##       	cookie-path: /path/to/
	##       	script-short-name: wiki.cgi
	##       URI parts MUST NOT contains "&" and/or non-URI characters.
  our %uri = (
    cookie_path		=> '/~wakaba/-temp/expwiki/',
    external_script	=> '../wiki/script/',
    script_short_name	=> 'wiki',
    ## If you use CVS repository of WikiDatabase,
    #cvs_repository	=> 'http://path-to-viewcvs/path-to-repository/',
  );
  our $url_cgi = "http://".($main::ENV{HTTP_HOST} || $main::ENV{SERVER_NAME}.($main::ENV{SERVER_PORT}==80?'':":$main::ENV{SERVER_PORT}"))."$uri{cookie_path}$uri{script_short_name}";
  $uri{wiki_abs} = $url_cgi;
  $uri{wiki} = qq($uri{cookie_path}$uri{script_short_name});	

## Path to modules and databases
  push @main::INC, qw'lib ../wiki/lib lib';

## Constructing a new instance of the WikiEngine
  require SuikaWiki::Implementation;
  our $WIKI = SuikaWiki::Implementation->new;

  ## Obsolete interface
  our %PathTo = (	## Path to your data, from the main CGI script (NOT from this config script)
    CachePrefix 	=> q(./wikidata/.cache.),  # WikiPlugin
    TempPrefix 	=> q(./wikidata/.tmp.),            # WikiPlugin, Image
    convert	=> q(/usr/X11R6/bin/convert),      # Image
  );

## Filesystem path mapping
  for (
     [db__content__dir        => q"./wikidata/page"],
     [db__content__error_log  => q"./wikidata/log/db-content.log"],
     [db__lock__dir           => q"./wikidata/lock/"],
  ) {
    $WIKI->{config}->{path_to}->{$_->[0]} = $_->[1];
  }

## WikiPlugin
  push @{$WIKI->{event}->{plugin_manager_loaded}}, sub {
    ## Obsolete interface
    push @SuikaWiki::Plugin::plugin_directory, (
#   	q(../wiki/lib/SuikaWiki/Plugin/),
#  	q(../wiki/misc/plugins/),
        q(lib/SuikaWiki/Plugin/),
        q(misc/plugins/),
    );
    SuikaWiki::Plugin->import_plugins ();
    
    ## Plugin style new configuration file
    require 'wikidata/config.ph';
  };

## WikiDatabase : Mapping of logical to physical
  push @{$WIKI->{event}->{database_loaded}}, sub {
      ## Main content
      $WIKI->{db}->_set_prop_db (content => {-db_open => sub {
        require SuikaWiki::DB::FileSystem::YukiWikiDBNS;
        SuikaWiki::DB::FileSystem::YukiWikiDBNS->new 
          (directory => $WIKI->{config}->{path_to}->{db__content__dir},
           logfile   => $WIKI->{config}->{path_to}->{db__content__error_log},
           suffix    => '.txt',
           -lock => &{$WIKI->{var}->{db}->{lock_prop}} ('content'));
      }, -own => 1});
      
      ## Last modified
      $WIKI->{db}->_set_prop_db (lastmodified => {-db_open => sub {
        require SuikaWiki::DB::FileSystem::SuikaWikiMetaInfo09;
        SuikaWiki::DB::FileSystem::SuikaWikiMetaInfo09->new
          (directory => $WIKI->{config}->{path_to}->{db__content__dir},
           -lock => &{$WIKI->{var}->{db}->{lock_prop}} ('lastmodified'));
      }, -prop => 'last_modified', -own => 1});
  
  ## OBSOLETE interface for transition
    $WIKI->{db}->get (content => ['dummy']);
    *main::database = $WIKI->{db}->{prop}->{content}->{-db}->{db_hash};
    $SuikaWiki::Plugin::DB = $WIKI->{db};
    for (@{$SuikaWiki::Plugin::On{WikiDatabaseLoaded}||[]}) { &{$_} }
    
    package wiki::dummy;
    sub meta {undef};
    sub list_items {};
    sub STORE {};
  };

  ## [OBSOLETE] Name of Special WikiPage (linked as parts of navigations)
  our %PageName = (
    FrontPage	=> 'HomePage',
    IndexPage	=> 'IndexPage',
    InterWikiName	=> 'Wiki//InterWikiName',
    SearchPage	=> 'Wiki//Page//Search',
    CreatePage	=> 'Wiki//Page//Create',
    MenuBar	=> 'Wiki//MenuBar',
    RecentChanges	=> 'RecentChanges',
    RefererDontRecord	=> 'Wiki//Referer//IgnoreSite',
    RefererSiteName	=> 'Wiki//Referer//SiteName',
    ResourceNS	=> 'Wiki//Resource//',
    StyleList	=> 'Wiki//Style//List//',
    UserAgentList	=> 'Wiki//UserAgentList',
    AdminSpecialPage	=> "\x11\x11Admin\x11Special\x11Page\x11\x11",
  );
  
  ## WikiName of special purpose WikiPages
  $WIKI->{config}->{page} = {
    Default         => [qw/HomePage/],
    NewPageTemplate => [qw/Wiki NewPageTemplate/],
  };
  our %PageOf = %{$WIKI->{config}->{page}};
  
  ## WikiNamespace constants
  $WIKI->{config}->{name}->{space}->{separator} = '//';
  $WIKI->{config}->{name}->{space}->{separator_reg} = qr#//#;
  
  ## Character code
  $WIKI->{config}->{charset}->{internal} = 'euc-jp';
  $WIKI->{config}->{charset}->{output} = 'iso-2022-jp';
  $WIKI->{config}->{charset}->{uri_param} = ''; # auto detect
  $WIKI->{config}->{charset}->{uri_query} = ''; # auto detect
  
  ## Expires duration templates
  $WIKI->{config}->{entity}->{expires} = {
    edit      => {delta => 60},
    view      => {delta => 2*3600},
    lm_flaged => {delta => 30*24*3600},
  };

=head1 NAME

suikawiki-config.ph --- SuikaWiki: Configuration of the wiki

=head1 LICENSE

Copyright 2003 Wakaba <w@suika.fam.cx>

This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

=cut

1; # $Date: 2003/10/30 07:48:44 $