/[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.1 - (show annotations) (download)
Sat Oct 25 06:37:08 2003 UTC (22 years, 8 months ago) by wakaba
Branch: MAIN
New plugins

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:$
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 ViewFragment:
45 @Name: ws--post-content
46 @Description:
47 @@@: After content body -- navigation bar
48 @@lang:en
49 @Order: 100
50 @Formatting:
51 %section (level=>2,
52 id => children,
53 title => {%res(name=>{Children:Title});}p, heading,
54 content => {%page-list (ns=>{%page-name;}p,recursive=>0,type=>both,template=>{
55 %wiki-link(label=>{%ns-short-page-or-ns-name;}p);
56 });}p,
57 );
58 %section (level=>2,
59 id => see-also,
60 title => {%res(name=>SeeAlso);}p, heading,
61 content => {%search-result;}p,
62 );
63 %section (level=>2,
64 id => referer,
65 title => {%res(name=>Referer);}p, heading,
66 content => {%referer-list;}p,
67 );
68 %block (
69 id => last-modified,
70 content => {%res(name=>{LastModified=});%last-modified;}p,
71 );
72 %section (level=>2,
73 id => toc,
74 title => {%res(name=>{TOC:Title});}p, heading, add-to-toc => 0,
75 content => {%toc(drag);}p,
76 );
77 %block (
78 class => tools,
79 content => {%template (name => navbar);}p,
80 );
81
82 ViewFragment:
83 @Name: ws--post-content
84 @Description:
85 @@@: After content body -- footer
86 @@lang:en
87 @Order: 1000
88 @Formatting:
89 %block (
90 id => footer,
91 content => {%template (name => ws--footer);}p,
92 );
93
94 PluginConst:
95 @NS_XHTML1:
96 http://www.w3.org/1999/xhtml
97
98 FormattingRule:
99 @Category[list]: view
100 @Name: section
101 @Description:
102 @@@:
103 A section
104
105 Note: "level" parameter used by SuikaWiki 2 will be obsoleted.
106 @@lang: en
107 @Parameter:
108 @@Name: add-to-toc
109 @@Type: boolean
110 @@Default: {1}
111 @@Description:
112 @@@@: Whether adding this section to the Table of Contents list
113 @@@lang:en
114 @Parameter:
115 @@Name: class
116 @@Type: classes
117 @@Default: (none)
118 @@Description:
119 @@@@: Class of section
120 @@@lang:en
121 @Parameter:
122 @@Name: content
123 @@Type: text
124 @@Default: ""
125 @@Description:
126 @@@@: Content of section
127 @@@lang:en
128 @Parameter:
129 @@Name: heading
130 @@Type: boolean
131 @@Default: {0}
132 @@Description: Output title as a heading
133 @Parameter:
134 @@Name: id
135 @@Type:
136 XML:ID
137 @@Default: (none)
138 @@Description:
139 @@@@:
140 Unique identifier
141
142 Note: its uniqueness is not verified by
143 the WikiEngine.
144
145 Note: unless explicily specified, anomymous identifier is generated
146 automatically if necessary
147 @@@lang:en
148 @Parameter:
149 @@Name: title
150 @@Type: text
151 @@Default: (none)
152 @@Description:
153 @@@@: Title (heading) text of the section
154 @@@lang:en
155 @Formatting:
156 my $toc = $o->{toc}||[]; $o->{toc} = [] if !defined $p->{add_to_toc} || $p->{add_to_toc};
157 my $c = $p->{content};
158 if ((ref ($c) && $c->count) || (!ref ($c) && length $c)) {
159 ($o->{toc}, $toc) = ($toc, $o->{toc});
160 $r = Message::Markup::XML->new (namespace_uri => $NS_XHTML1, local_name => ($p->{type}||'div'));
161 my $id = $p->{id} || 'h'.$o->new_index ('heading');
162 $r->set_attribute (id => $id);
163 $r->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'a')
164 ->set_attribute (name => $id) if $o->{use_anchor_name};
165 $r->set_attribute (class => ($p->{class} ? $p->{class} . ' ' : '') . 'wiki-section');
166
167 $r->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'h'.$p->{level})
168 ->append_node ($p->{title}, node_or_text => 1) if $p->{heading};
169 $r->append_text ("\n");
170 push @{$o->{toc}}, [$p->{level}-1 => $id => $p->{title}], @$toc if !defined $p->{add_to_toc} || $p->{add_to_toc};
171
172 $r->append_node ($c, node_or_text => 1);
173 } else {
174 $o->{toc} = $toc;
175 }
176
177 FormattingRule:
178 @Category[list]: view
179 @Name: paragraph
180 @Description:
181 @@@:
182 A paragraph
183 @@lang: en
184 @Parameter:
185 @@Name: class
186 @@Type: classes
187 @@Default: (none)
188 @@Description:
189 @@@@: Class of section
190 @@@lang:en
191 @Parameter:
192 @@Name: content
193 @@Type: text
194 @@Default: ""
195 @@Description:
196 @@@@: Content of section
197 @@@lang:en
198 @Parameter:
199 @@Name: id
200 @@Type:
201 XML:ID
202 @@Default: (none)
203 @@Description:
204 @@@@:
205 Unique identifier
206
207 Note: its uniqueness is not verified by
208 the WikiEngine.
209
210 Note: unless explicily specified, anomymous identifier is generated
211 automatically if necessary
212 @@@lang:en
213 @Formatting:
214 if ((ref ($p->{content}) && $p->{content}->count)
215 or (!ref ($p->{content}) && length $p)) {
216 $r = Message::Markup::XML->new
217 (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'p');
218 $r->append_node ($p->{content}, node_or_text => 1);
219 $r->set_attribute (class => $p->{class}) if $p->{class};
220 $r->set_attribute (id => $p->{id}) if $p->{id}; ## TODO: ensure ID syntax and uniquness
221 }
222
223
224 FormattingRule:
225 @Category[list]: view
226 @Name: block
227 @Description:
228 @@@:
229 A semantically-classed block
230 @@lang: en
231 @Parameter:
232 @@Name: class
233 @@Type: classes
234 @@Default: (none)
235 @@Description:
236 @@@@: Class of section
237 @@@lang:en
238 @Parameter:
239 @@Name: content
240 @@Type: text
241 @@Default: ""
242 @@Description:
243 @@@@: Content of section
244 @@@lang:en
245 @Parameter:
246 @@Name: id
247 @@Type:
248 XML:ID
249 @@Default: (none)
250 @@Description:
251 @@@@:
252 Unique identifier
253
254 Note: its uniqueness is not verified by
255 the WikiEngine.
256
257 Note: unless explicily specified, anomymous identifier is generated
258 automatically if necessary
259 @@@lang:en
260 @Formatting:
261 if ((ref ($p->{content}) && $p->{content}->count)
262 or (!ref ($p->{content}) && length $p)) {
263 $r = Message::Markup::XML->new
264 (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'div');
265 $r->append_node ($p->{content}, node_or_text => 1);
266 $r->set_attribute (class => 'block ' . $p->{class});
267 $r->set_attribute (id => $p->{id}) if $p->{id}; ## TODO: ensure ID syntax and uniquness
268 }
269
270 FormattingRule:
271 @Category[list]: view
272 @Name: toc
273 @Description:
274 @@@:
275 Table of contents list
276 @@lang: en
277 @Parameter:
278 @@Name: drag
279 @@Type: boolean
280 @@Default: {0}
281 @@Description:
282 @@@@:
283 Use drag-enabling script for M$IE
284 (For Gecko, it can be binded by stylesheet)
285 @@@lang:en
286 @Formatting:
287 return '' unless ref $o->{toc};
288 my $level;
289 for (@{$o->{toc}}) {
290 if ($level < $_->[0]) {
291 $r .= qq(<ul>\n);
292 $level++;
293 } elsif ($level > $_->[0]) {
294 $r .= qq(</li></ul>\n) x ($level - $_->[0]);
295 $level = $_->[0];
296 }
297 $r .= qq(</li><li><a href="#@{[$o->encode($_->[1])]}">@{[$o->escape($_->[2])]}</a>\n);
298 }
299 $r .= qq(</li></ul>\n) x ($level);
300 $r =~ s#<ul>\n</li>#<ul>#g;
301 if ($p->{drag}) {
302 my $ua = $o->user_agent_names;
303 if ($ua !~ m#Mozilla/[1-4]\.# || $ua =~ m#MSIE (?:[4-9]\.|\d\d)#) {
304 $r .= qq(<script type="text/javascript" src="@{[$o->escape($o->uri('external_script'))]}drag.js"></script>) if $ua !~ m#Gecko/#;
305 ## Gecko supports -moz-binding attribute of CSS, so use it.
306 }
307 }

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24