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

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.8 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
12
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 {my %Index;
24 sub new_index ($$) { ++$Index{$_[1]} }
25 }
26
27 ## Obsolete
28 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 {my %Formatter;
35 sub formatter ($$) {
36 my $t = $_[1]; $t =~ tr/-/_/;
37 unless ($Formatter{$t}) {
38 $Formatter{$t} = new SuikaWiki::Plugin::xml_formatter
39 -category_name => $t;
40 }
41 return $Formatter{$t};
42 }}
43
44 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 sub get_data ($$$$;%) {
57 my ($self, $prop, $key, %opt) = @_;
58 ## TODO: common interface to WikiDB
59 ## TODO: error recovering
60 $main::WIKI->{db}->get ($prop => $key);
61 }
62
63 ## Obsolete
64 sub regist ($@) {
65 }
66
67 =back
68
69 =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 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 }
97
98 =item $p->{wiki}
99
100 Wiki implementation $p is associated with
101
102 =back
103
104 =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 =head1 SEE ALSO
122
123 suikawiki.pl, suikawiki-config.ph, <IW:SuikaWiki:SuikaWiki>
124
125 =head1 LICENSE
126
127 Copyright 2002-2003 Wakaba <[email protected]>
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 1; # $Date: 2003/11/25 12:43:13 $

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24