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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Thu Oct 30 07:45:10 2003 UTC (22 years, 8 months ago) by wakaba
Branch: MAIN
Changes since 1.1: +4 -29 lines
Remove some obsolete rules

1 #?SuikaWikiConfig/2.0
2
3 Plugin:
4 @Name: WikiStruct
5 @Description:
6 @@@: Structural elements
7 @@lang:en
8 @License: %%GPL%%
9 @Author:
10 @@Name:
11 @@@@: Wakaba
12 @@@lang:ja
13 @@@script:Latn
14 @@Mail[list]: w@suika.fam.cx
15 @Date.RCS: $Date: 2003/10/25 06:37:08 $
16
17 ViewFragment:
18 @Name: ws--page
19 @Description:
20 @@@: Basic page body structure
21 @Order: 0
22 @Formatting:
23 %section (level=>1,
24 type => body,
25 title => {%page-name;}p, heading, add-to-toc => 0,
26 content => {
27 %template (name => ws--pre-content);
28 %apply-template (name => content);
29 %template (name => ws--post-content);
30 }p,
31 );
32
33 ViewFragment:
34 @Name: ws--pre-content
35 @Description:
36 @@@: Before content body -- navigation bar
37 @@lang:en
38 @Order: 0
39 @Formatting:
40 %block (
41 id => tools1, class => tools,
42 content => {%template (name => navbar);}p,
43 );
44
45 ViewFragment:
46 @Name: ws--post-content
47 @Description:
48 @@@: After content body -- navigation bar
49 @@lang:en
50 @Order: 900
51 @Formatting:
52 %block (
53 id => tools2, class => tools,
54 content => {%template (name => navbar);}p,
55 );
56
57 ViewFragment:
58 @Name: ws--post-content
59 @Description:
60 @@@: After content body -- footer
61 @@lang:en
62 @Order: 1000
63 @Formatting:
64 %block (
65 id => footer,
66 content => {%template (name => ws--footer);}p,
67 );
68
69 PluginConst:
70 @NS_XHTML1:
71 http://www.w3.org/1999/xhtml
72
73 FormattingRule:
74 @Category[list]: view
75 @Name: section
76 @Description:
77 @@@:
78 A section
79
80 Note: "level" parameter used by SuikaWiki 2 will be obsoleted.
81 @@lang: en
82 @Parameter:
83 @@Name: add-to-toc
84 @@Type: boolean
85 @@Default: {1}
86 @@Description:
87 @@@@: Whether adding this section to the Table of Contents list
88 @@@lang:en
89 @Parameter:
90 @@Name: class
91 @@Type: classes
92 @@Default: (none)
93 @@Description:
94 @@@@: Class of section
95 @@@lang:en
96 @Parameter:
97 @@Name: content
98 @@Type: text
99 @@Default: ""
100 @@Description:
101 @@@@: Content of section
102 @@@lang:en
103 @Parameter:
104 @@Name: heading
105 @@Type: boolean
106 @@Default: {0}
107 @@Description: Output title as a heading
108 @Parameter:
109 @@Name: id
110 @@Type:
111 XML:ID
112 @@Default: (none)
113 @@Description:
114 @@@@:
115 Unique identifier
116
117 Note: its uniqueness is not verified by
118 the WikiEngine.
119
120 Note: unless explicily specified, anomymous identifier is generated
121 automatically if necessary
122 @@@lang:en
123 @Parameter:
124 @@Name: title
125 @@Type: text
126 @@Default: (none)
127 @@Description:
128 @@@@: Title (heading) text of the section
129 @@@lang:en
130 @Formatting:
131 my $toc = $o->{toc}||[]; $o->{toc} = [] if !defined $p->{add_to_toc} || $p->{add_to_toc};
132 my $c = $p->{content};
133 if ((ref ($c) && $c->count) || (!ref ($c) && length $c)) {
134 ($o->{toc}, $toc) = ($toc, $o->{toc});
135 $r = Message::Markup::XML->new (namespace_uri => $NS_XHTML1, local_name => ($p->{type}||'div'));
136 my $id = $p->{id} || 'h'.$o->new_index ('heading');
137 $r->set_attribute (id => $id);
138 $r->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'a')
139 ->set_attribute (name => $id) if $o->{use_anchor_name};
140 $r->set_attribute (class => ($p->{class} ? $p->{class} . ' ' : '') . 'wiki-section');
141
142 $r->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'h'.$p->{level})
143 ->append_node ($p->{title}, node_or_text => 1) if $p->{heading};
144 $r->append_text ("\n");
145 push @{$o->{toc}}, [$p->{level}-1 => $id => $p->{title}], @$toc if !defined $p->{add_to_toc} || $p->{add_to_toc};
146
147 $r->append_node ($c, node_or_text => 1);
148 } else {
149 $o->{toc} = $toc;
150 }
151
152 FormattingRule:
153 @Category[list]: view
154 @Name: paragraph
155 @Description:
156 @@@:
157 A paragraph
158 @@lang: en
159 @Parameter:
160 @@Name: class
161 @@Type: classes
162 @@Default: (none)
163 @@Description:
164 @@@@: Class of section
165 @@@lang:en
166 @Parameter:
167 @@Name: content
168 @@Type: text
169 @@Default: ""
170 @@Description:
171 @@@@: Content of section
172 @@@lang:en
173 @Parameter:
174 @@Name: id
175 @@Type:
176 XML:ID
177 @@Default: (none)
178 @@Description:
179 @@@@:
180 Unique identifier
181
182 Note: its uniqueness is not verified by
183 the WikiEngine.
184
185 Note: unless explicily specified, anomymous identifier is generated
186 automatically if necessary
187 @@@lang:en
188 @Formatting:
189 if ((ref ($p->{content}) && $p->{content}->count)
190 or (!ref ($p->{content}) && length $p)) {
191 $r = Message::Markup::XML->new
192 (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'p');
193 $r->append_node ($p->{content}, node_or_text => 1);
194 $r->set_attribute (class => $p->{class}) if $p->{class};
195 $r->set_attribute (id => $p->{id}) if $p->{id}; ## TODO: ensure ID syntax and uniquness
196 }
197
198
199 FormattingRule:
200 @Category[list]: view
201 @Name: block
202 @Description:
203 @@@:
204 A semantically-classed block
205 @@lang: en
206 @Parameter:
207 @@Name: class
208 @@Type: classes
209 @@Default: (none)
210 @@Description:
211 @@@@: Class of section
212 @@@lang:en
213 @Parameter:
214 @@Name: content
215 @@Type: text
216 @@Default: ""
217 @@Description:
218 @@@@: Content of section
219 @@@lang:en
220 @Parameter:
221 @@Name: id
222 @@Type:
223 XML:ID
224 @@Default: (none)
225 @@Description:
226 @@@@:
227 Unique identifier
228
229 Note: its uniqueness is not verified by
230 the WikiEngine.
231
232 Note: unless explicily specified, anomymous identifier is generated
233 automatically if necessary
234 @@@lang:en
235 @Formatting:
236 if ((ref ($p->{content}) && $p->{content}->count)
237 or (!ref ($p->{content}) && length $p)) {
238 $r = Message::Markup::XML->new
239 (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'div');
240 $r->append_node ($p->{content}, node_or_text => 1);
241 $r->set_attribute (class => 'block ' . $p->{class});
242 $r->set_attribute (id => $p->{id}) if $p->{id}; ## TODO: ensure ID syntax and uniquness
243 }
244
245 FormattingRule:
246 @Category[list]: view
247 @Name: toc
248 @Description:
249 @@@:
250 Table of contents list
251 @@lang: en
252 @Parameter:
253 @@Name: drag
254 @@Type: boolean
255 @@Default: {0}
256 @@Description:
257 @@@@:
258 Use drag-enabling script for M$IE
259 (For Gecko, it can be binded by stylesheet)
260 @@@lang:en
261 @Formatting:
262 return '' unless ref $o->{toc};
263 my $level;
264 for (@{$o->{toc}}) {
265 if ($level < $_->[0]) {
266 $r .= qq(<ul>\n);
267 $level++;
268 } elsif ($level > $_->[0]) {
269 $r .= qq(</li></ul>\n) x ($level - $_->[0]);
270 $level = $_->[0];
271 }
272 $r .= qq(</li><li><a href="#@{[$o->encode($_->[1])]}">@{[$o->escape($_->[2])]}</a>\n);
273 }
274 $r .= qq(</li></ul>\n) x ($level);
275 $r =~ s#<ul>\n</li>#<ul>#g;
276 if ($p->{drag}) {
277 my $ua = $o->user_agent_names;
278 if ($ua !~ m#Mozilla/[1-4]\.# || $ua =~ m#MSIE (?:[4-9]\.|\d\d)#) {
279 $r .= qq(<script type="text/javascript" src="@{[$o->escape($o->uri('external_script'))]}drag.js"></script>) if $ua !~ m#Gecko/#;
280 ## Gecko supports -moz-binding attribute of CSS, so use it.
281 }
282 }

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24