/[pub]/suikawiki/script/lib/SuikaWiki/Implementation.pm
Suika

Diff of /suikawiki/script/lib/SuikaWiki/Implementation.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by wakaba, Fri Jan 16 08:04:59 2004 UTC revision 1.8 by wakaba, Sun Feb 1 12:24:05 2004 UTC
# Line 1  Line 1 
1    
2  =head1 NAME  =head1 NAME
3    
4  SuikaWiki::Implementation --- SuikaWiki : Wiki Core Implementation  SuikaWiki::Implementation - SuikaWiki: WikiEngine Core
5    
6    =head1 DESCRIPTION
7    
8    This module implements core part of the SuikaWiki WikiEngine.
9    All implemented features of WikiEngine can be called directly
10    or indirectly from instance of this module (with some exception
11    such as functions provided by WikiPlugin modules).
12    
13    This module is part of SuikaWiki.
14    
15    =head1 SYNOPSIS
16    
17      require SuikaWiki::Implementation;
18      my $WIKI = new SuikaWiki::Implementation;
19      ...
20      $WIKI->exit;
21    
22    C<lib/suikawiki.pl> might be a good example for instanciating WikiEngine.
23    
24  =cut  =cut
25    
# Line 9  package SuikaWiki::Implementation; Line 27  package SuikaWiki::Implementation;
27  use strict;  use strict;
28  our $VERSION = do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};  our $VERSION = do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
29    
 our $INTERFACE_VERSION = '2.9.1';  
   
30  =head1 METHODS  =head1 METHODS
31    
32  =over 4  =over 4
# Line 23  Constructs new instance of wiki implemen Line 39  Constructs new instance of wiki implemen
39    
40  sub new ($;%) {  sub new ($;%) {
41    my $self = bless {    my $self = bless {
42      implementation_name => 'SuikaWiki',      driver_name => 'WikiImplementation',
43      implementation_version => 'impl'.$VERSION,      driver_version => '0.0',
44      interface_version => $INTERFACE_VERSION,      driver_uri_reference => q<about:>,
45        engine_name => 'SuikaWiki',
46        engine_version => '2.9.2',
47        engine_uri_reference => q<http://suika.fam.cx/~wakaba/-temp/wiki/wiki?SuikaWiki>,
48    }, shift;    }, shift;
49        
50    $self;    $self;
# Line 151  sub ___raise_event ($$$;%) { Line 170  sub ___raise_event ($$$;%) {
170    return 1;    return 1;
171  }  }
172    
173  =item $string = $wiki->version  =item $uri = $wiki->uri_reference (%option)
174    
175  Returns version string of the WikiEngine implementation.  Returning URI reference that refers the wiki or a WikiPage.
 This value is combination of the SuikaWiki Interface version and  
 implementation's version.  
176    
177  =cut  Load {input} before calling this method or specify appropriate C<wiki_uri>
178    option to get proper result.
179    
180  sub version ($) {  One or two URI reference(s) is returned as C<URI> object.
181    my ($self) = @_;  See C<base> option.
182    $self->{interface_version} . '-' . $self->{implementation_version};  
183  }  Available options:
184    
185    =over 4
186    
187    =item anchor_no => positive-integer (default: none)
188    
189    Numeral anchor index.  With this option, C<fragment> option
190    is ignored.
191    
192    =item base => URI reference (default: none)
193    
194    Base URI reference.  C<wantarray ? (relative, absolute) : relative> is
195    returned when C<base> is specified.  Otherwise, C<(absolute, absolute)>
196    is returned.
197    
198    =item fragment => URI reference fragment (default: none)
199    
200    URI refernece fragment.  This option value MUST be encoded
201    by URI escape encoding.
202    
203    =item mode => mode-name (default: "default")
204    
205    WikiView mode in which referred.
206    
207    =item page => [WikiName] (default: none)
208    
209    WikiName to that WikiPage URI reference is referring.
210    
211    =item param => {name1 => value1, name2 => value2,...} (default: none)
212    
213    Additional query parameters.  Names and values are automatically
214    encoded by URI escape encoding if necessary.
215    
216    =item up_to_date => 1/0 (default: 0)
217    
218    "Up-to-date" URI query parameter for cheating cache.
219    
220    =item wiki_uri => URI reference (default: auto)
221    
222    A base URI reference referring the wiki itself.
223    
224    =item with_lm => 1/0 (default: 0)
225    
226    "Last modified" URI query parameter for chating WWW browser history.
227    
228    =back
229    
230    =cut
231    
232  sub uri_reference ($;%) {  sub uri_reference ($;%) {
233    my ($self, %opt) = @_;    my ($self, %opt) = @_; ## Note: $opt{wiki_uri} must be a URI(.pm) if any.
234    my $uri = $self->___get_wiki_uri;    my $uri = $opt{wiki_uri} || $self->___get_wiki_uri;
235        
236    ## SuikaWiki 3.0 format    ## SuikaWiki 3.0 format
237    my $query_param = qr/[^0-9A-Za-z_.-]/;    my $query_param = qr/[^0-9A-Za-z_.-]/;
# Line 217  sub uri_reference ($;%) { Line 282  sub uri_reference ($;%) {
282    }    }
283  }  }
284    
285    =item 1/0 = $wiki->uri_is_part_of_wiki ($uri-reference)
286    
287    Check whether given URI reference is "part of" the wiki.
288    
289    =cut
290    
291  sub uri_is_part_of_wiki ($$) {  sub uri_is_part_of_wiki ($$) {
292    my ($self, $uri) = @_;    my ($self, $uri) = @_;
293    my $wiki_uri = ''.$self->___get_wiki_uri;    my $wiki_uri = ''.$self->___get_wiki_uri;
294    substr ($uri, 0, length ($wiki_uri)) eq $wiki_uri ? 1 : 0;    $uri = URI->new (substr ($uri, 0, length ($wiki_uri)));
295      $uri eq $wiki_uri ? 1 : 0;
296  }  }
297    
298  sub ___get_wiki_uri ($) {  sub ___get_wiki_uri ($) {
# Line 247  sub ___uri_escape_encode ($$;$) { Line 319  sub ___uri_escape_encode ($$;$) {
319    $s;    $s;
320  }  }
321    
322    =item $wiki->close_db
323    
324    Closing WikiDB (C<$wiki->{db}>).
325    
326    Although this method is automatically called by C<< $wiki->exit >>,
327    it is good practice to explicitly close something opened explicitly.
328    
329    =cut
330    
331  sub close_db ($) {  sub close_db ($) {
332    my $self = shift;    my $self = shift;
333    $self->{db}->close if ref $self->{db};    $self->{db}->close if ref $self->{db};
334    delete $self->{db};    delete $self->{db};
335  }  }
336    
337    =item $wiki->close_view
338    
339    Closing WikiView manager (C<< $wiki->close_view >>).
340    
341    =cut
342    
343  sub close_view ($) {  sub close_view ($) {
344    my $self = shift;    my $self = shift;
345    $self->{view}->exit if ref $self->{view};    $self->{view}->exit if ref $self->{view};
346    delete $self->{view};    delete $self->{view};
347  }  }
348    
349    =item $wiki->close_plugin
350    
351    Closing WikiPlugin manager (C<< $wiki->{plugin} >>).
352    Note that this method does not unload WikiPlugin modules.
353    (They are "merged" to script namespace so that unloading them
354    is almost impossible.)
355    
356    =cut
357    
358  sub close_plugin ($) {  sub close_plugin ($) {
359    my $self = shift;    my $self = shift;
360    $self->{plugin}->exit if ref $self->{plugin};    $self->{plugin}->exit if ref $self->{plugin};
361    delete $self->{plugin};    delete $self->{plugin};
362  }  }
363    
364    =item $wiki->close_input
365    
366    Closing input manager (C<< $wiki->{input} >>).
367    
368    =cut
369    
370  sub close_input ($) {  sub close_input ($) {
371    my $self = shift;    my $self = shift;
372    $self->{input}->exit if ref $self->{input};    $self->{input}->exit if ref $self->{input};
373    delete $self->{input};    delete $self->{input};
374  }  }
375    
376  =item $wiki->exit  =item 1/0 = $wiki->exit
377    
378  Exits wiki  Exitign the wiki.  This method closes input manager, WikiDB manager,
379    WikiView manager and WikiPlugin manager after C<close> event is raised.
380    Note that C<close> event handler can "cancel" exiting,
381    it makes this method return C<0>.
382    
383    This method is automatically called before C<$wiki> is destoroyed.
384    
385  =cut  =cut
386    
# Line 288  sub exit ($) { Line 395  sub exit ($) {
395    1;    1;
396  }  }
397    
398    ## TODO: Provides "cancelable" to close event.
399    
400  sub DESTROY ($) {  sub DESTROY ($) {
401    my $self = shift;    my $self = shift;
402    $self->exit unless $self->{exited};    $self->exit unless $self->{exited};
# Line 358  Filesystem path (or path fragment) to $n Line 467  Filesystem path (or path fragment) to $n
467    
468  Wiki main database  Wiki main database
469    
470    =item $wiki->{driver_name}
471    
472    Product name of the WikiDriver.
473    
474    For interoperability, only alphanumeric characters and limited symbols
475    (those allowed in RFC 2616 token) should be used as parts of product name.
476    
477    =item $wiki->{driver_version}
478    
479    WikiDriver version in string.
480    
481    For interoperability, only alphanumeric characters and limited symbols
482    (those allowed in RFC 2616 token) should be used as parts of product name.
483    
484    =item $wiki->{engine_name} (Read only)
485    
486    SuikaWiki WikiEngine name
487    
488    =item $wiki->{engine_version} (Read only)
489    
490    SuikaWiki WikiEngine version
491    
492  =item @{$wiki->{event}->{ $event_name }}  =item @{$wiki->{event}->{ $event_name }}
493    
494  Event handling procedures  Event handling procedures
# Line 393  C<view_in_mode> method is called. Line 524  C<view_in_mode> method is called.
524    
525  =back  =back
526    
 =item $wiki->{implementation_name} (default 'SuikaWiki')  
   
 Product name of the WikiEngine.  
   
 For interoperability, only alphanumeric characters and limited symbols  
 (those allowed in RFC 2616 token) should be used as parts of product name.  
   
 =item $wiki->{implementation_version} (default "impl$VERSION")  
   
 WikiEngine implementation's version in string.  
   
 For interoperability, only alphanumeric characters and limited symbols  
 (those allowed in RFC 2616 token) should be used as parts of product name.  
   
 =item $wiki->{interface_version} (Read only)  
   
 SuikaWiki Interface version implemented by this wiki implementation  
   
527  =item $wiki->{var}  =item $wiki->{var}
528    
529  Non-persistent wiki variable options  Non-persistent wiki variable options
# Line 475  WikiView implementation (an instance of Line 588  WikiView implementation (an instance of
588    
589  =head1 LICENSE  =head1 LICENSE
590    
591  Copyright 2003 Wakaba <[email protected]>  Copyright 2003-2004 Wakaba <[email protected]>.  All rights reserved.
592    
593  This program is free software; you can redistribute it and/or  This program is free software; you can redistribute it and/or
594  modify it under the same terms as Perl itself.  modify it under the same terms as Perl itself.

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24