/[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.9 - (hide annotations) (download)
Mon Dec 1 07:43:35 2003 UTC (21 years, 7 months ago) by wakaba
Branch: MAIN
Changes since 1.8: +12 -103 lines
Removed some obsolete functions

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 wakaba 1.9 our $VERSION = do{my @r=(q$Revision: 1.8 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
12 wakaba 1.1
13     =head1 PLUGIN INTERFACE
14    
15     =over 4
16    
17     =item $o->new_index ($index_name)
18    
19     Increments the index number and returns the new index number.
20    
21     =cut
22    
23 wakaba 1.9 {my %Index;
24 wakaba 1.1 sub new_index ($$) { ++$Index{$_[1]} }
25 wakaba 1.9 }
26 wakaba 1.1
27 wakaba 1.8 ## Obsolete
28 wakaba 1.1 sub magic_and_content ($$) {
29     my ($magic, $page) = ('', $_[1]);
30     $magic = $1 if $page =~ s!^((?:\#\?|/\*|<\?)[^\x02\x0A\x0D]+)[\x02\x0A\x0D]+!!s;
31     ($magic, $page);
32     }
33    
34 w 1.5 {my %Formatter;
35     sub formatter ($$) {
36     my $t = $_[1]; $t =~ tr/-/_/;
37 wakaba 1.7 unless ($Formatter{$t}) {
38 wakaba 1.8 $Formatter{$t} = new SuikaWiki::Plugin::xml_formatter
39     -category_name => $t;
40 wakaba 1.7 }
41 w 1.5 return $Formatter{$t};
42     }}
43    
44 wakaba 1.8 sub module_package ($$) {
45     my ($self, $module) = @_;
46     my $pack = $SuikaWiki::Plugin::Registry::Info{$module}->{module_name};
47     if ($pack) {
48     return $pack;
49     } else {
50     ## TODO: throw
51     die "Module $module not loaded";
52     }
53     }
54    
55     ## Obsolete
56 wakaba 1.6 sub get_data ($$$$;%) {
57     my ($self, $prop, $key, %opt) = @_;
58     ## TODO: common interface to WikiDB
59     ## TODO: error recovering
60 wakaba 1.7 $main::WIKI->{db}->get ($prop => $key);
61 wakaba 1.6 }
62    
63 wakaba 1.9 ## Obsolete
64 wakaba 1.1 sub regist ($@) {
65     }
66    
67     =back
68    
69 wakaba 1.6 =head1 WIKIPLUGIN MANAGER OBJECT
70    
71     This part implements WikiPlugin manager object of SuikaWiki WikiPlugin
72     implementation model, second edition.
73    
74     =over 4
75    
76     =item $p = SuikaWiki::Plugin->new (wiki => $WIKI)
77    
78     Constructs new instance of WikiPlugin manager
79    
80     =cut
81    
82     sub new ($%) {
83     my $class = shift;
84     my $self = bless {@_}, $class;
85    
86     $self;
87     }
88    
89 wakaba 1.9 sub load_directory ($;@) {
90     shift;
91     for my $dir (@_) {
92     opendir PDIR, $dir;
93     require $dir.'/'.$_ for grep {substr ($_, -3) eq '.pm'} readdir (PDIR);
94     closedir PDIR;
95     }
96 wakaba 1.6 }
97    
98     =item $p->{wiki}
99    
100     Wiki implementation $p is associated with
101    
102     =back
103    
104 wakaba 1.8 =cut
105    
106     package SuikaWiki::Plugin::xml_formatter;
107     require Message::Util::Formatter::Node;
108     our @ISA = 'Message::Util::Formatter::Node';
109     require Message::Markup::XML::Node;
110    
111     sub rule_def ($) {
112     $SuikaWiki::Plugin::Rule{$_[0]->{-category_name}};
113     }
114    
115     sub replace_option ($) {
116     return {
117     -class => 'Message::Markup::XML::Node',
118     };
119     }
120    
121 wakaba 1.1 =head1 SEE ALSO
122    
123     suikawiki.pl, suikawiki-config.ph, <IW:SuikaWiki:SuikaWiki>
124    
125     =head1 LICENSE
126    
127     Copyright 2002-2003 Wakaba <w@suika.fam.cx>
128    
129     This program is free software; you can redistribute it and/or
130     modify it under the same terms as Perl itself.
131    
132     =cut
133    
134 wakaba 1.9 1; # $Date: 2003/11/25 12:43:13 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24