/[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.11 - (show annotations) (download)
Sun Jul 25 06:54:29 2004 UTC (21 years, 11 months ago) by wakaba
Branch: MAIN
CVS Tags: suikawiki3-redirect, HEAD
Branch point for: helowiki, helowiki-2005
Changes since 1.10: +7 -1 lines
Property Editor 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/03/19 03:44:15 $
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 } elsif ($param_name eq 'x') {
330 if (index ($opt{-value_flag}, 'p') > -1) {
331 $param_value = $f->replace ($param_value, param => $o);
332 }
333 push @{$p->{-ws__list}}, [$param_value]
334 if $param_value->count;
335 } else {
336 if (index ($opt{-name_flag}, 'p') > -1) {
337 $param_name = $f->replace ($param_name, param => $o);
338 }
339 if (index ($opt{-value_flag}, 'p') > -1) {
340 $param_value = $f->replace ($param_value, param => $o);
341 }
342 push @{$p->{-ws__list}}, [$param_name => $param_value]
343 if $param_value->count;
344 }
345 @Formatting:
346 my $dl = $p->{-parent}
347 ->append_new_node (type => '#element',
348 namespace_uri => $NS_XHTML1,
349 local_name => 'dl');
350 for (@{$p->{-ws__list}}) {
351 $dl->append_new_node (type => '#element',
352 namespace_uri => $NS_XHTML1,
353 local_name => 'dt')
354 ->append_node ($_->[0], node_or_text => 1);
355 $dl->append_new_node (type => '#element',
356 namespace_uri => $NS_XHTML1,
357 local_name => 'dd')
358 ->append_node ($_->[1], node_or_text => 1) if length $_->[1];
359 }
360
361 Function:
362 @Name: append_new_div
363 @Description:
364 @@@:
365 Appending a new DIV element
366 @@lang:en
367 @Main:
368 my (undef, $parent, %opt) = @_;
369 my $div = $parent->append_new_node (type => '#element',
370 namespace_uri => $NS_XHTML1,
371 local_name => $opt{type}||'div');
372 $div->append_new_node (type => '#element',
373 namespace_uri => $NS_XHTML1,
374 local_name => 'p')
375 if $opt{wiki}->{var}->{client}->{downgrade}->{html_no_div};
376 __FUNCPACK__->set_id ($div, $opt{id}, $opt{wiki}) if $opt{id};
377 my @class = (split (/\s+/, $opt{class1}), split (/\s+/, $opt{class2}));
378 $div->set_attribute (class => join ' ', @class) if @class;
379 $parent->append_text ("\n");
380 return $div;
381
382 Function:
383 @Name: set_id
384 @Description:
385 @@@:
386 Set id attribute if necessary.
387 \
388 HTML A element with name attribute is also appended
389 if client user agent is of old version.
390 @@lang:en
391 @Main:
392 my (undef, $node, $id, $wiki) = @_;
393 return unless $id;
394 $node->set_attribute (id => $id);
395 if ($wiki->{var}->{client}->{downgrade}->{html_no_id}) {
396 my $a = $node->append_new_node (type => '#element',
397 namespace_uri => $NS_XHTML1,
398 local_name => 'a');
399 $a->set_attribute (name => $id);
400 unshift @{$node->child_nodes}, pop @{$node->child_nodes};
401 }
402
403 Function:
404 @Name: set_section_id
405 @Description:
406 @@@:
407 Set id attribute for the section node, with id generated from
408 section title
409 @@lang: en
410 @Main:
411 my (undef, $node, $id, $wiki, %opt) = @_;
412 $id ||= __FUNCPACK__->get_section_id (wiki => $wiki, %opt);
413 $node->set_attribute (id => $id);
414 if ($wiki->{var}->{client}->{downgrade}->{html_no_id}) {
415 my $a = $node->append_new_node (type => '#element',
416 namespace_uri => $NS_XHTML1,
417 local_name => 'a');
418 $a->set_attribute (name => $id);
419 unshift @{$node->child_nodes}, pop @{$node->child_nodes};
420 }
421
422 Function:
423 @Name: get_section_id
424 @Main:
425 my (undef, %opt) = @_;
426 unless ($opt{id}) {
427 $opt{id} = $opt{title};
428 ## TODO: Use Punycode
429 $opt{id} =~ s/([^0-9A-Za-z_-])/sprintf '.%02X', ord $1/ge;
430 $opt{id} = uc ($opt{prefix} || 'WS--SECTION') . '--TEMP--' . $opt{id};
431 }
432 if ($__FUNCPACK__::IDIndex{$opt{id}}++) {
433 $opt{id} .= '..' . $__FUNCPACK__::IDIndex{$opt{id}};
434 }
435 $opt{id};
436

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24