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

Contents of /suikawiki/script/lib/SuikaWiki/Plugin.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Thu Apr 3 01:08:16 2003 UTC (22 years, 1 month ago) by wakaba
Branch: MAIN
New.

1 wakaba 1.1 # -*- perl -*-
2    
3     =head1 NAME
4    
5     SuikaWiki::Plugin --- SuikaWiki: Plugin manager and the interface to the Wiki database from plugins
6    
7     =cut
8    
9     package SuikaWiki::Plugin;
10     use strict;
11     our $VERSION = do{my @r=(q$Revision: 1.5 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
12     our ($plugin_directory, %List, %Index, %Cache);
13     push @main::INC, $plugin_directory.'/../..';
14    
15     =head1 PLUGIN INTERFACE
16    
17     =over 4
18    
19     =item $o->new_index ($index_name)
20    
21     Increments the index number and returns the new index number.
22    
23     =cut
24    
25     sub new_index ($$) { ++$Index{$_[1]} }
26    
27     =item $o->magic_and_conten ($document)
28    
29     Splits the documents into the magic line and content part.
30    
31     =cut
32    
33     sub magic_and_content ($$) {
34     my ($magic, $page) = ('', $_[1]);
35     $magic = $1 if $page =~ s!^((?:\#\?|/\*|<\?)[^\x02\x0A\x0D]+)[\x02\x0A\x0D]+!!s;
36     ($magic, $page);
37     }
38    
39     =head1 PLUGIN MANAGER
40    
41     =over 4
42    
43     =item SuikaWiki::Plugin::import_plugins
44    
45     Searchs plugins into $plugin_directory and loads all plugins found.
46     This method should be called at least one time before plugin-required-features
47     are used.
48    
49     =cut
50    
51     sub import_plugins () {
52     opendir PDIR, $plugin_directory;
53     my @plugin = grep {s/\.pm$//} readdir (PDIR);
54     closedir PDIR;
55     for (@plugin) {
56     eval qq{ use SuikaWiki::Plugin::$_ } unless /[^A-Za-z0-9_]/;
57     push @{$List{_all}}, qq(SuikaWiki::Plugin::$_);
58     }
59     }
60    
61     =item SuikaWiki::Plugin::regist ($plugin_package, @categories)
62    
63     Regists the plugin categories provided by the plugin package.
64     This method should be called from plugin packages.
65    
66     Example:
67    
68     sub import {
69     my $self = shift;
70     $self->SuikaWiki::Plugin::regist (qw/wikiform_input/);
71     }
72    
73     =cut
74    
75     sub regist ($@) {
76     my $pack = shift;
77     for (@_) {
78     push @{$List{$_}}, $pack;
79     }
80     }
81    
82     =back
83    
84     =head1 SEE ALSO
85    
86     suikawiki.pl, suikawiki-config.ph, <IW:SuikaWiki:SuikaWiki>
87    
88     =head1 LICENSE
89    
90     Copyright 2002-2003 Wakaba <w@suika.fam.cx>
91    
92     This program is free software; you can redistribute it and/or
93     modify it under the same terms as Perl itself.
94    
95     =cut
96    
97     1; # $Date: $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24  
Google Analytics is used in this page; Cookies are used. 忍者AdMax is used in this page; Cookies are used. Privacy policy.