/[pub]/suikawiki/script/lib/SuikaWiki/Plugin/SuikaWikiConfig20.wp2
Suika

Contents of /suikawiki/script/lib/SuikaWiki/Plugin/SuikaWikiConfig20.wp2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Sun Apr 25 07:06:50 2004 UTC (22 years, 2 months ago) by wakaba
Branch: MAIN
CVS Tags: release-3-0-0
Branch point for: paragraph-200404
Changes since 1.1: +10 -2 lines
LeafProp database module added; content_prop implemented; Media type property implemented

1 #?SuikaWikiConfig/2.0
2
3 Plugin:
4 @Name: SuikaWikiConfig20
5 @Description:
6 @@@: SuikaWikiConfig/2.0 configuration format
7 @@lang:en
8 @License: %%Perl%%
9 @Author:
10 @@Name:
11 @@@@: Wakaba
12 @@@lang:ja
13 @@@script:Latn
14 @@Mail[list]: [email protected]
15 @Date.RCS:
16 $Date: 2004/02/08 08:52:03 $
17 @RequiredPackage[list]:
18 Message::Markup::SuikaWikiConfig20::Node
19 Message::Markup::SuikaWikiConfig20::Parser
20 @RequiredPlugin[list]:
21 PlainText
22
23 PluginConst:
24 @NS_XHTML1:
25 http://www.w3.org/1999/xhtml
26
27 Format:
28 @Name: SuikaWikiConfig
29 @Version: 2.0
30 @Type:
31 @@@: application/x.suikawiki.config
32 @@version: 2.0
33 @ModuleName:
34 SuikaWikiConfig::V2_0
35 @Inherit[list]:
36 Text::Plain
37 @Use:
38 use Message::Markup::XML::QName qw(NS_xml_URI);
39
40 @Converter:
41 @@Name: SuikaWikiConfig
42 @@Version: 2.0
43 @@Type:
44 @@@@: application/x.suikawiki.config
45 @@@version: 2.0
46 @@Main:
47 __FUNCPACK__->get_tree (text => $source,
48 opt => $opt, wiki => $self->{wiki});
49
50 @Converter:
51 @@Type: text/html
52 @@IsFragment: 1
53 @@Main:
54 my $cfg = __FUNCPACK__->get_tree (text => $source,
55 opt => $opt, wiki => $self->{wiki});
56 my $comment_node_dt
57 = SuikaWiki::Plugin->module_package ('WikiResource')
58 ->get (name => 'SuikaWikiConfig/2.0:Type:#comment',
59 wiki => $self->{wiki}, o => $opt->{o});
60 my $to_str;
61 $to_str = sub {
62 my ($src, $parent) = @_;
63 my $nt = $src->node_type;
64 if ($nt eq '#element') {
65 $parent->append_new_node (type => '#element',
66 namespace_uri => $NS_XHTML1,
67 local_name => 'dt')
68 ->append_text ($src->local_name);
69 my $node = $parent->append_new_node
70 (type => '#element',
71 namespace_uri => $NS_XHTML1,
72 local_name => 'dd');
73 my $value = $src->inner_text;
74 if (length $value) {
75 my $val = $node->append_new_node
76 (type => '#element',
77 namespace_uri => $NS_XHTML1,
78 local_name => 'pre');
79 $val->set_attribute (class => 'value');
80 $val->set_attribute (space => 'preserve',
81 namespace_uri => NS_xml_URI);
82 $val->append_text ($value);
83 }
84 my $ol;
85 for (@{$src->child_nodes}) {
86 $ol ||= $node->append_new_node
87 (type => '#element',
88 namespace_uri => $NS_XHTML1,
89 local_name => 'dl');
90 $to_str->($_ => $ol);
91 }
92 } elsif ($nt eq '#comment') {
93 $parent->append_new_node (type => '#element',
94 namespace_uri => $NS_XHTML1,
95 local_name => 'dt')
96 ->append_text ($comment_node_dt);
97 my $node = $parent->append_new_node
98 (type => '#element',
99 namespace_uri => $NS_XHTML1,
100 local_name => 'dd');
101 $node->set_attribute (class => 'comment');
102 $node->set_attribute
103 (space => 'preserve', namespace_uri => NS_xml_URI);
104 $node->append_text ($src->inner_text);
105 } else { # #document or #fragment
106 my $dl = $parent->append_new_node
107 (type => '#element',
108 namespace_uri => $NS_XHTML1,
109 local_name => 'dl');
110 $dl->set_attribute (class => 'SuikaWikiConfig-2-0');
111 for (@{$src->child_nodes}) {
112 $to_str->($_ => $dl);
113 }
114 }
115 };
116 $to_str->($cfg => $opt->{-parent});
117
118 Function:
119 @Name: get_tree
120 @Main:
121 my (undef, %opt) = @_;
122 require Message::Markup::SuikaWikiConfig20::Parser;
123 if ($opt{opt}->{page}) {
124 unless ($__FUNCPACK__::DBLoaded) {
125 $opt{wiki}->{db}->_set_prop_db (swc20__tree => {-db_open => sub {
126 require SuikaWiki::DB::Hash;
127 new SuikaWiki::DB::Hash;
128 }});
129 $__FUNCPACK__::DBLoaded++;
130 }
131
132 my $parser = Message::Markup::SuikaWikiConfig20::Parser->new;
133 my $tree = $parser->parse_text (${$opt{text}});
134
135 $opt{wiki}->{db}->set (swc20__tree => $opt{opt}->{page} => $tree);
136 $tree;
137 } else {
138 Message::Markup::SuikaWikiConfig20::Parser
139 ->new
140 ->parse_text (${$opt{text}});
141 }
142
143 Resource:
144 @SuikaWikiConfig/2.0:Type:#comment:
145 (Comment)
146 @WikiFormat:MediaType:Description:IMT:application/x.suikawiki.config;version="2.0"##:
147 @@@:
148 SuikaWikiConfig/2.0 (text format), standard configuration format
149 for SuikaWiki 3
150 @@lang: en
151 @WikiFormat:MediaType:Label:IMT:application/x.suikawiki.config;version="2.0"##:
152 @@@: SuikaWikiConfig/2.0 (text format)
153 @@lang: en
154

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24