/[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.10 - (show annotations) (download)
Fri Mar 19 03:44:15 2004 UTC (22 years, 3 months ago) by wakaba
Branch: MAIN
CVS Tags: release-3-0-0
Branch point for: paragraph-200404
Changes since 1.9: +5 -2 lines
New parameter {dest}->{param} implemented

1 #?SuikaWikiConfig/2.0
2
3 Plugin:
4 @Name: WikiStruct
5 @Description:
6 @@@: Structural elements
7 @@lang:en
8 @License: %%Perl%%
9 @Author:
10 @@Name:
11 @@@@: Wakaba
12 @@@lang:ja
13 @@@script:Latn
14 @@Mail[list]: w@suika.fam.cx
15 @Date.RCS:
16 $Date: 2004/02/14 10:55:01 $
17
18 ViewFragment:
19 @Name: ws--page
20 @Description:
21 @@@: Basic page body structure
22 @Order: 0
23 @Formatting:
24 %section (
25 type => body,
26 title => {%page-name;}p, heading,
27 content => {
28 %template (name => ws--pre-content);
29 %apply-template (name => content);
30 %template (name => ws--post-content);
31 }p,
32 );
33
34 ViewFragment:
35 @Name: ws--pre-content
36 @Description:
37 @@@: Before content body -- navigation bar
38 @@lang:en
39 @Order: 0
40 @Formatting:
41 %block (
42 id => tools1, class => tools,
43 content => {%template (name => navbar);}p,
44 );
45
46 ViewFragment:
47 @Name: ws--post-content
48 @Description:
49 @@@: After content body -- navigation bar
50 @@lang:en
51 @Order: 900
52 @Formatting:
53 %block (
54 id => tools2, class => tools,
55 content => {%template (name => navbar);}p,
56 );
57
58 ViewFragment:
59 @Name: ws--post-content
60 @Description:
61 @@@: After content body -- footer
62 @@lang:en
63 @Order: 1000
64 @Formatting:
65 %block (
66 id => footer,
67 content => {%template (name => ws--footer);}p,
68 );
69
70 PluginConst:
71 @NS_XHTML1:
72 http://www.w3.org/1999/xhtml
73 @NS_XHTML2:
74 http://www.w3.org/2002/06/xhtml2
75
76 FormattingRule:
77 @Category[list]:
78 view
79 view-resource
80 form-input
81 @Name: section
82 @Description:
83 @@@:
84 A section
85 @@lang: en
86 @Parameter:
87 @@Name: add-to-toc
88 @@Type: boolean
89 @@Default: {1}
90 @@Description:
91 @@@@: Whether adding this section to the Table of Contents list
92 @@@lang:en
93 @Parameter:
94 @@Name: class
95 @@Type: classes
96 @@Default: (none)
97 @@Description:
98 @@@@: Class of section
99 @@@lang:en
100 @Parameter:
101 @@Name: content
102 @@Type: text
103 @@Default: ""
104 @@Description:
105 @@@@: Content of section
106 @@@lang:en
107 @Parameter:
108 @@Name: heading
109 @@Type: boolean
110 @@Default: {0}
111 @@Description: Output title as a heading
112 @Parameter:
113 @@Name: id
114 @@Type: ID
115 @@Default: (none)
116 @@Description:
117 @@@@:
118 Unique identifier
119 \
120 Note: its uniqueness is not verified by
121 the WikiEngine.
122 \
123 Note: unless explicily specified, anomymous identifier is generated
124 automatically if necessary
125 @@@lang:en
126 @Parameter:
127 @@Name: title
128 @@Type: text
129 @@Default: (none)
130 @@Description:
131 @@@@: Title (heading) text of the section
132 @@@lang:en
133 @Formatting:
134 local $o->{var}->{ws__section_depth} = $o->{var}->{ws__section_depth} + 1;
135 __ATTRNODE:%content__;
136 if ($p->{content}->count) {
137 __ATTRTEXT:%type__;__ATTRTEXT:%class__;__ATTRTEXT:%id__;
138 my $section = __FUNCPACK__->append_new_div
139 ($p->{-parent},
140 type => $p->{type},
141 wiki => $o->{wiki},
142 id => $p->{id},
143 class1 => 'wiki-section',
144 class2 => $p->{class});
145 __ATTRTEXT:%heading__;
146 if ($p->{heading}) {
147 if ($o->{var}->{ws__section_depth} > 6) {
148 my $h = $section->append_new_node (type => '#element',
149 namespace_uri => $NS_XHTML1,
150 local_name => 'div');
151 $h->set_attribute (class => 'heading h'
152 .$o->{var}->{ws__section_depth});
153 __ATTRNODE:%title->{$h}__;
154 } else {
155 __ATTRNODE:%title->{
156 $section->append_new_node
157 (type => '#element',
158 namespace_uri => $NS_XHTML1,
159 local_name => 'h'.$o->{var}->{ws__section_depth})
160 }__;
161 }
162 }
163 $section->append_text ("\n");
164 $section->append_node ($p->{content});
165 }
166
167 FormattingRule:
168 @Category[list]:
169 view
170 view-resource
171 form-input
172 @Name: paragraph
173 @Description:
174 @@@:
175 A paragraph
176 @@lang: en
177 @Parameter:
178 @@Name: class
179 @@Type: classes
180 @@Default: (none)
181 @@Description:
182 @@@@: Class of section
183 @@@lang:en
184 @Parameter:
185 @@Name: content
186 @@Type: text
187 @@Default: ""
188 @@Description:
189 @@@@: Content of section
190 @@@lang:en
191 @Parameter:
192 @@Name: id
193 @@Type:
194 XML:ID
195 @@Default: (none)
196 @@Description:
197 @@@@:
198 Unique identifier
199 \
200 Note: its uniqueness is not verified by
201 the WikiEngine.
202 \
203 Note: unless explicily specified, anomymous identifier is generated
204 automatically if necessary
205 @@@lang:en
206 @Formatting:
207 __ATTRNODE:%content__;
208 if ($p->{content}->count) {
209 my $block = $p->{-parent}->append_new_node
210 (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'p');
211 $block->append_node ($p->{content});
212 __ATTRTEXT:%class__;__ATTRTEXT:%id__;
213 $block->set_attribute (class => $p->{class}) if $p->{class};
214 __FUNCPACK__->set_id ($block, $p->{id}, $o->{wiki});
215 }
216
217 FormattingRule:
218 @Category[list]:
219 view
220 view-resource
221 form-input
222 @Name: block
223 @Description:
224 @@@:
225 A semantically-classed block
226 @@lang: en
227 @Parameter:
228 @@Name: class
229 @@Type: classes
230 @@Default: (none)
231 @@Description:
232 @@@@: Class of section
233 @@@lang:en
234 @Parameter:
235 @@Name: content
236 @@Type: text
237 @@Default: ""
238 @@Description:
239 @@@@: Content of section
240 @@@lang:en
241 @Parameter:
242 @@Name: id
243 @@Type:
244 XML:ID
245 @@Default: (none)
246 @@Description:
247 @@@@:
248 Unique identifier
249 \
250 Note: its uniqueness is not verified by
251 the WikiEngine.
252 \
253 Note: unless explicily specified, anomymous identifier is generated
254 automatically if necessary
255 @@@lang:en
256 @Formatting:
257 __ATTRNODE:%content__;
258 if ($p->{content}->count) {
259 __ATTRTEXT:%class__;__ATTRTEXT:%id__;
260 my $block = __FUNCPACK__->append_new_div ($p->{-parent},
261 id => $p->{id},
262 class1 => 'block',
263 class2 => $p->{class},
264 wiki => $o->{wiki});
265 $block->append_node ($p->{content}, node_or_text => 1);
266 __ATTRTEXT:%class__;__ATTRTEXT:%id__;
267 }
268
269 FormattingRule:
270 @Category[list]:
271 view
272 view-resource
273 form-input
274 page-link
275 link-to-resource
276 @Name: line
277 @Description:
278 @@@:
279 A semantically line
280 @@lang: en
281 @Parameter:
282 @@Name: class
283 @@Type: classes
284 @@Default: (none)
285 @@Description:
286 @@@@: Class of section
287 @@@lang:en
288 @Parameter:
289 @@Name: content
290 @@Type: text
291 @@Default: ""
292 @@Description:
293 @@@@: Content of the line
294 @@@lang:en
295 @Formatting:
296 __ATTRNODE:%content__;
297 if ($p->{content}->count) {
298 $p->{-parent}->append_node ($p->{content}, node_or_text => 1);
299 $p->{-parent}->append_new_node
300 (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'br')
301 ->option (use_EmptyElemTag => 1);
302 }
303
304 @ ( XHTML 2 ) :
305
306 __ATTRNODE:%content__;
307 if ($p->{content}->count) {
308 my $block = $p->{-parent}->append_new_node
309 (type => '#element', namespace_uri => $NS_XHTML2, local_name => 'l');
310 $block->append_node ($p->{content}, node_or_text => 1);
311 __ATTRTEXT:%class__;
312 $block->set_attribute (class => 'block ' . $p->{class});
313 }
314
315 FormattingRule:
316 @Category[list]:
317 view
318 view-resource
319 form-input
320 @Name: list
321 @Pre:
322 $p->{-ws__list} ||= [];
323 @Attribute:
324 if ($param_name eq '-boolean') {
325 if (index ($opt{-name_flag}, 'p') > -1) {
326 $param_value = $f->replace ($param_value, param => $o);
327 }
328 push @{$p->{-ws__list}}, [$param_value] if $param_name->count;
329 } else {
330 if (index ($opt{-name_flag}, 'p') > -1) {
331 $param_name = $f->replace ($param_name, param => $o);
332 }
333 if (index ($opt{-value_flag}, 'p') > -1) {
334 $param_value = $f->replace ($param_value, param => $o);
335 }
336 push @{$p->{-ws__list}}, [$param_name => $param_value]
337 if $param_value->count;
338 }
339 @Formatting:
340 my $dl = $p->{-parent}
341 ->append_new_node (type => '#element',
342 namespace_uri => $NS_XHTML1,
343 local_name => 'dl');
344 for (@{$p->{-ws__list}}) {
345 $dl->append_new_node (type => '#element',
346 namespace_uri => $NS_XHTML1,
347 local_name => 'dt')
348 ->append_node ($_->[0], node_or_text => 1);
349 $dl->append_new_node (type => '#element',
350 namespace_uri => $NS_XHTML1,
351 local_name => 'dd')
352 ->append_node ($_->[1], node_or_text => 1) if length $_->[1];
353 }
354
355 Function:
356 @Name: append_new_div
357 @Description:
358 @@@:
359 Appending a new DIV element
360 @@lang:en
361 @Main:
362 my (undef, $parent, %opt) = @_;
363 my $div = $parent->append_new_node (type => '#element',
364 namespace_uri => $NS_XHTML1,
365 local_name => $opt{type}||'div');
366 $div->append_new_node (type => '#element',
367 namespace_uri => $NS_XHTML1,
368 local_name => 'p')
369 if $opt{wiki}->{var}->{client}->{downgrade}->{html_no_div};
370 __FUNCPACK__->set_id ($div, $opt{id}, $opt{wiki}) if $opt{id};
371 my @class = (split (/\s+/, $opt{class1}), split (/\s+/, $opt{class2}));
372 $div->set_attribute (class => join ' ', @class) if @class;
373 $parent->append_text ("\n");
374 return $div;
375
376 Function:
377 @Name: set_id
378 @Description:
379 @@@:
380 Set id attribute if necessary.
381 \
382 HTML A element with name attribute is also appended
383 if client user agent is of old version.
384 @@lang:en
385 @Main:
386 my (undef, $node, $id, $wiki) = @_;
387 return unless $id;
388 $node->set_attribute (id => $id);
389 if ($wiki->{var}->{client}->{downgrade}->{html_no_id}) {
390 my $a = $node->append_new_node (type => '#element',
391 namespace_uri => $NS_XHTML1,
392 local_name => 'a');
393 $a->set_attribute (name => $id);
394 unshift @{$node->child_nodes}, pop @{$node->child_nodes};
395 }
396
397 Function:
398 @Name: set_section_id
399 @Description:
400 @@@:
401 Set id attribute for the section node, with id generated from
402 section title
403 @@lang: en
404 @Main:
405 my (undef, $node, $id, $wiki, %opt) = @_;
406 $id ||= __FUNCPACK__->get_section_id (wiki => $wiki, %opt);
407 $node->set_attribute (id => $id);
408 if ($wiki->{var}->{client}->{downgrade}->{html_no_id}) {
409 my $a = $node->append_new_node (type => '#element',
410 namespace_uri => $NS_XHTML1,
411 local_name => 'a');
412 $a->set_attribute (name => $id);
413 unshift @{$node->child_nodes}, pop @{$node->child_nodes};
414 }
415
416 Function:
417 @Name: get_section_id
418 @Main:
419 my (undef, %opt) = @_;
420 unless ($opt{id}) {
421 $opt{id} = $opt{title};
422 ## TODO: Use Punycode
423 $opt{id} =~ s/([^0-9A-Za-z_-])/sprintf '.%02X', ord $1/ge;
424 $opt{id} = uc ($opt{prefix} || 'WS--SECTION') . '--TEMP--' . $opt{id};
425 }
426 if ($__FUNCPACK__::IDIndex{$opt{id}}++) {
427 $opt{id} .= '..' . $__FUNCPACK__::IDIndex{$opt{id}};
428 }
429 $opt{id};
430

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24