/[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.3 - (hide annotations) (download)
Sun Jul 25 06:54:29 2004 UTC (20 years, 9 months ago) by wakaba
Branch: MAIN
CVS Tags: suikawiki3-redirect, HEAD
Branch point for: helowiki, helowiki-2005
Changes since 1.2: +8 -1 lines
Property Editor implemented

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24