/[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.7 - (hide annotations) (download)
Fri Jan 16 07:47:46 2004 UTC (22 years, 5 months ago) by wakaba
Branch: MAIN
Changes since 1.6: +57 -15 lines
Automatic leveling implemented

1 wakaba 1.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 wakaba 1.7 @Date.RCS: $Date: 2003/12/29 13:05:07 $
16 wakaba 1.1
17     ViewFragment:
18     @Name: ws--page
19     @Description:
20     @@@: Basic page body structure
21     @Order: 0
22     @Formatting:
23 wakaba 1.7 %section (
24 wakaba 1.1 type => body,
25 wakaba 1.7 title => {%page-name;}p, heading,
26 wakaba 1.1 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 wakaba 1.2
45 wakaba 1.1 ViewFragment:
46     @Name: ws--post-content
47     @Description:
48     @@@: After content body -- navigation bar
49     @@lang:en
50 wakaba 1.2 @Order: 900
51 wakaba 1.1 @Formatting:
52     %block (
53 wakaba 1.2 id => tools2, class => tools,
54 wakaba 1.1 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 wakaba 1.3 @NS_XHTML2:
73     http://www.w3.org/2002/06/xhtml2
74 wakaba 1.1
75     FormattingRule:
76     @Category[list]: view
77     @Name: section
78     @Description:
79     @@@:
80     A section
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 wakaba 1.7 @@Type: ID
111 wakaba 1.1 @@Default: (none)
112     @@Description:
113     @@@@:
114     Unique identifier
115 wakaba 1.7 \
116 wakaba 1.1 Note: its uniqueness is not verified by
117     the WikiEngine.
118 wakaba 1.7 \
119 wakaba 1.1 Note: unless explicily specified, anomymous identifier is generated
120     automatically if necessary
121     @@@lang:en
122     @Parameter:
123     @@Name: title
124     @@Type: text
125     @@Default: (none)
126     @@Description:
127     @@@@: Title (heading) text of the section
128     @@@lang:en
129     @Formatting:
130 wakaba 1.7 local $o->{var}->{ws__section_depth} = $o->{var}->{ws__section_depth} + 1;
131 wakaba 1.3 __ATTRNODE:%content__;
132     if ($p->{content}->count) {
133 wakaba 1.6 __ATTRTEXT:%type__;__ATTRTEXT:%class__;__ATTRTEXT:%id__;
134     my $section = __FUNCPACK__->append_new_div
135     ($p->{-parent},
136     type => $p->{type},
137     wiki => $o->{wiki},
138     id => $p->{id} || 'h'.$o->new_index
139     ('heading'),
140     class1 => 'wiki-section',
141     class2 => $p->{class});
142 wakaba 1.3 __ATTRTEXT:%heading__;
143     if ($p->{heading}) {
144 wakaba 1.7 if ($o->{var}->{ws__section_depth} > 6) {
145     my $h = $section->append_new_node (type => '#element',
146     namespace_uri => $NS_XHTML1,
147     local_name => 'div');
148     $h->set_attribute (class => 'heading h'
149     .$o->{var}->{ws__section_depth});
150     __ATTRNODE:%title->{$h}__;
151     } else {
152     __ATTRNODE:%title->{
153     $section->append_new_node
154     (type => '#element',
155     namespace_uri => $NS_XHTML1,
156     local_name => 'h'.$o->{var}->{ws__section_depth})
157     }__;
158     }
159 wakaba 1.3 }
160     $section->append_text ("\n");
161     $section->append_node ($p->{content});
162     }
163 wakaba 1.1
164     FormattingRule:
165 wakaba 1.3 @Category[list]:
166     view
167     view-resource
168     form-input
169 wakaba 1.1 @Name: paragraph
170     @Description:
171     @@@:
172     A paragraph
173     @@lang: en
174     @Parameter:
175     @@Name: class
176     @@Type: classes
177     @@Default: (none)
178     @@Description:
179     @@@@: Class of section
180     @@@lang:en
181     @Parameter:
182     @@Name: content
183     @@Type: text
184     @@Default: ""
185     @@Description:
186     @@@@: Content of section
187     @@@lang:en
188     @Parameter:
189     @@Name: id
190     @@Type:
191     XML:ID
192     @@Default: (none)
193     @@Description:
194     @@@@:
195     Unique identifier
196 wakaba 1.3 \
197 wakaba 1.1 Note: its uniqueness is not verified by
198     the WikiEngine.
199 wakaba 1.3 \
200 wakaba 1.1 Note: unless explicily specified, anomymous identifier is generated
201     automatically if necessary
202     @@@lang:en
203     @Formatting:
204 wakaba 1.3 __ATTRNODE:%content__;
205     if ($p->{content}->count) {
206     my $block = $p->{-parent}->append_new_node
207 wakaba 1.1 (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'p');
208 wakaba 1.3 $block->append_node ($p->{content});
209     __ATTRTEXT:%class__;__ATTRTEXT:%id__;
210     $block->set_attribute (class => $p->{class}) if $p->{class};
211 wakaba 1.5 __FUNCPACK__->set_id ($block, $p->{id}, $o->{wiki});
212 wakaba 1.1 }
213    
214     FormattingRule:
215 wakaba 1.3 @Category[list]:
216     view
217     view-resource
218     form-input
219 wakaba 1.1 @Name: block
220     @Description:
221     @@@:
222     A semantically-classed block
223     @@lang: en
224     @Parameter:
225     @@Name: class
226     @@Type: classes
227     @@Default: (none)
228     @@Description:
229     @@@@: Class of section
230     @@@lang:en
231     @Parameter:
232     @@Name: content
233     @@Type: text
234     @@Default: ""
235     @@Description:
236     @@@@: Content of section
237     @@@lang:en
238     @Parameter:
239     @@Name: id
240     @@Type:
241     XML:ID
242     @@Default: (none)
243     @@Description:
244     @@@@:
245     Unique identifier
246 wakaba 1.3 \
247 wakaba 1.1 Note: its uniqueness is not verified by
248     the WikiEngine.
249 wakaba 1.3 \
250 wakaba 1.1 Note: unless explicily specified, anomymous identifier is generated
251     automatically if necessary
252     @@@lang:en
253     @Formatting:
254 wakaba 1.3 __ATTRNODE:%content__;
255     if ($p->{content}->count) {
256 wakaba 1.6 __ATTRTEXT:%class__;__ATTRTEXT:%id__;
257     my $block = __FUNCPACK__->append_new_div ($p->{-parent},
258     id => $p->{id},
259     class1 => 'block',
260     class2 => $p->{class},
261     wiki => $o->{wiki});
262 wakaba 1.3 $block->append_node ($p->{content}, node_or_text => 1);
263     __ATTRTEXT:%class__;__ATTRTEXT:%id__;
264 wakaba 1.1 }
265    
266     FormattingRule:
267 wakaba 1.3 @Category[list]:
268     view
269     view-resource
270     form-input
271     @Name: line
272 wakaba 1.1 @Description:
273     @@@:
274 wakaba 1.3 A semantically line
275 wakaba 1.1 @@lang: en
276     @Parameter:
277 wakaba 1.3 @@Name: class
278     @@Type: classes
279     @@Default: (none)
280     @@Description:
281     @@@@: Class of section
282     @@@lang:en
283     @Parameter:
284     @@Name: content
285     @@Type: text
286     @@Default: ""
287 wakaba 1.1 @@Description:
288 wakaba 1.3 @@@@: Content of the line
289 wakaba 1.1 @@@lang:en
290     @Formatting:
291 wakaba 1.3 __ATTRNODE:%content__;
292     if ($p->{content}->count) {
293     $p->{-parent}->append_node ($p->{content}, node_or_text => 1);
294     $p->{-parent}->append_new_node
295     (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'br')
296     ->option (use_EmptyElemTag => 1);
297     }
298    
299     @ ( XHTML 2 ) :
300    
301     __ATTRNODE:%content__;
302     if ($p->{content}->count) {
303     my $block = $p->{-parent}->append_new_node
304     (type => '#element', namespace_uri => $NS_XHTML2, local_name => 'l');
305     $block->append_node ($p->{content}, node_or_text => 1);
306     __ATTRTEXT:%class__;
307     $block->set_attribute (class => 'block ' . $p->{class});
308 wakaba 1.5 }
309 wakaba 1.6
310     Function:
311     @Name: append_new_div
312     @Description:
313     @@@:
314     Appending a new DIV element
315     @@lang:en
316     @Main:
317     my (undef, $parent, %opt) = @_;
318     my $div = $parent->append_new_node (type => '#element',
319     namespace_uri => $NS_XHTML1,
320     local_name => $opt{type}||'div');
321     $div->append_new_node (type => '#element',
322     namespace_uri => $NS_XHTML1,
323     local_name => 'p')
324     if $opt{wiki}->{var}->{client}->{downgrade}->{html_no_div};
325     __FUNCPACK__->set_id ($div, $opt{id}, $opt{wiki}) if $opt{id};
326     my @class = (split (/\s+/, $opt{class1}), split (/\s+/, $opt{class2}));
327     $div->set_attribute (class => join ' ', @class) if @class;
328     $parent->append_text ("\n");
329     return $div;
330 wakaba 1.5
331     Function:
332     @Name: set_id
333     @Description:
334     @@@:
335     Set id attribute if necessary.
336     \
337     HTML A element with name attribute is also appended
338     if client user agent is of old version.
339     @@lang:en
340     @Main:
341     my (undef, $node, $id, $wiki) = @_;
342     return unless $id;
343     $node->set_attribute (id => $id);
344     if ($wiki->{var}->{client}->{downgrade}->{html_no_id}) {
345     my $a = $node->append_new_node (type => '#element',
346     namespace_uri => $NS_XHTML1,
347     local_name => 'a');
348     $a->set_attribute (name => $id);
349     unshift @{$node->child_nodes}, pop @{$node->child_nodes};
350 wakaba 1.3 }
351 wakaba 1.7
352     Function:
353     @Name: set_section_id
354     @Description:
355     @@@:
356     Set id attribute for the section node, with id generated from
357     section title
358     @@lang: en
359     @Main:
360     my (undef, $node, $id, $wiki, %opt) = @_;
361     $id ||= __FUNCPACK__->(wiki => $wiki, %opt);
362     $node->set_attribute (id => $id);
363     if ($wiki->{var}->{client}->{downgrade}->{html_no_id}) {
364     my $a = $node->append_new_node (type => '#element',
365     namespace_uri => $NS_XHTML1,
366     local_name => 'a');
367     $a->set_attribute (name => $id);
368     unshift @{$node->child_nodes}, pop @{$node->child_nodes};
369     }
370    
371     Function:
372     @Name: get_section_id
373     @Main:
374     my (undef, %opt) = @_;
375     unless ($opt{id}) {
376     $opt{id} = $opt{title};
377     ## TODO: Use Punycode
378     $opt{id} =~ s/([^0-9A-Za-z_-])/sprintf '.%02X', ord $1/ge;
379     $opt{id} = uc ($opt{prefix} || 'WS--SECTION') . '--TEMP--' . $opt{id};
380     }
381     if ($__FUNCPACK__::IDIndex{$opt{id}}++) {
382     $opt{id} .= '..' . $__FUNCPACK__::IDIndex{$opt{id}};
383     }
384     $opt{id};
385    

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24