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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (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.6: +47 -1 lines
Property Editor implemented

1 #?SuikaWikiConfig/2.0
2
3 Plugin:
4 @Name: HTML
5 @Description:
6 @@@: Hypertext Markup Language support
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:57:54 $
17 @RequiredModule[list]:
18 WikiLinking
19 @Namespace:
20 @@sw:
21 http://suika.fam.cx/~wakaba/archive/2004/7/20/sw#
22 @Use:
23 use Message::Util::Error;
24
25 PluginConst:
26 @NS_XHTML1:
27 http://www.w3.org/1999/xhtml
28 @NS_XHTML2:
29 http://www.w3.org/2002/06/xhtml2
30
31 FormattingRule:
32 @Category[list]: view
33 @Name: html-document
34 @Description:
35 @@@:
36 A HTML document
37 @@lang: en
38 @Parameter:
39 @@Name: content
40 @@Type: text
41 @@Default: ""
42 @@Description:
43 @@@@: Content of the documente (in the BODY element)
44 @@@lang:en
45 @Parameter:
46 @@Name: link-meta
47 @@Type: node
48 @@Default: (none)
49 @@Description:
50 @@@@:
51 Metainformation that should be included as part of HEAD element
52 @@@lang:en
53 @Parameter:
54 @@Name: pre-element
55 @@Type: CDATA
56 @@Default:
57 %template (name => ht--pre-element-content);
58 @@Description:
59 @@@@: Pre-root element content (such as PIs)
60 @@@lang: en
61 @Parameter:
62 @@Name: profile
63 @@Type:
64 html:uris
65 @@Default:
66 "http://suika.fam.cx/~wakaba/-temp/wiki/wiki?WikiHTMLMetaProfile"
67 @@Description:
68 @@@@:
69 Profile URIs of metainformation (xhtml1:head/@profile or
70 xhtml2:html/@profile)
71 @@@lang: en
72 @Parameter:
73 @@Name: stylesheets
74 @@Type: CDATA
75 @@Default:
76 %template (name => ht--stylesheets-html);
77 @@Description:
78 @@@@: Stylesheet references
79 @@@lang: en
80 @Parameter:
81 @@Name: title
82 @@Type: text
83 @@Default: (none)
84 @@Description:
85 @@@@: Title (heading) text of the document
86 @@@lang:en
87 @Formatting:
88 my $HTML = $p->{-parent}->append_new_node (type => '#document');
89 $p->{pre_element} ||= ($p->{-parse_flag}->{pre_element} = 1,
90 '%template (name => ht--pre-element-content);');
91 __ATTRNODE:%pre_element->{$HTML}__;
92 my $H = $HTML->append_new_node (type => '#element',
93 namespace_uri => $NS_XHTML1,
94 local_name => 'html');
95 $H->append_text ("\n");
96 my $h = $H->append_new_node (type => '#element',
97 namespace_uri => $NS_XHTML1,
98 local_name => 'head');
99 __ATTRTEXT:%profile__;
100 ## Note: HTML 4 requires author being interested in employing
101 ## link types not referred by it and/or META name
102 ## to specify profile URI.
103 $h->set_attribute (profile => ($p->{profile} or
104 q<http://suika.fam.cx/~wakaba/-temp/wiki/wiki?WikiHTMLMetaProfile>));
105 $h->append_text ("\n ");
106 ## Note: CGI/1.1 draft 3 (section 9.2) recommends CGI script
107 ## either not to use relative URI reference or to use
108 ## BASE element, to clarify what the resource referred,
109 ## since CGI script has no reliable way to know the
110 ## Request-URI.
111 $h->append_new_node (type => '#element',
112 namespace_uri => $NS_XHTML1,
113 local_name => 'base')
114 ->set_attribute (href => $o->{wiki}->{input}->request_uri);
115 $h->append_text ("\n ");
116 __ATTRNODE:%title->{$h->append_new_node (type => '#element',
117 namespace_uri => $NS_XHTML1,
118 local_name => 'title')}__;
119 $h->append_text ("\n ");
120 __ATTRNODE:%link_meta->{$h}__;
121 $p->{stylesheets} ||= ($p->{-parse_flag}->{stylesheets} = 1,
122 '%template (name => ht--stylesheets-html);');
123 __ATTRNODE:%stylesheets->{$h}__;
124 __ATTRNODE:%content->{$H}__;
125
126 FormattingRule:
127 @Category[list]: view
128 @Name: html-meta
129 @Description:
130 @@@:
131 name/val pair of metainformation (META element)
132 @@lang: en
133 @Parameter:
134 @@Name: content
135 @@Type: text
136 @@Default: ""
137 @@Description:
138 @@@@: Value (meta/@content)
139 @@@lang:en
140 @Parameter:
141 @@Name: name
142 @@Type: text
143 @@Default: ""
144 @@Description:
145 @@@@: Name (meta/@name)
146 @@@lang:en
147 @Formatting:
148 my $meta = $p->{-parent}->append_new_node
149 (type => '#element',
150 namespace_uri => $NS_XHTML1,
151 local_name => 'meta');
152 $meta->option (use_EmptyElemTag => 1);
153
154 __ATTRTEXT:%name__;__ATTRTEXT:%content__;
155 for my $attr (qw/name content/) {
156 $meta->set_attribute ($attr => $p->{$attr}) if defined $p->{$attr};
157 }
158
159 FormattingRule:
160 @Category[list]:
161 view
162 view-resource
163 @Name: link-wiki
164 @Description:
165 @@@:
166 Link from the document to the WikiPage (HTML's LINK element).
167 \
168 Note that this rule is a shortcut for WikiLinking rules.
169 @@lang:en
170 @Parameter:
171 @@Name: base-page
172 @@Type: WikiName
173 @@Default: (current)
174 @@Description:
175 @@@@:Base WikiName (Relative WikiName is resolved with)
176 @@@lang:en
177 @Parameter:
178 @@Name: class
179 @@Type:
180 HTML4:class
181 @@Default: (none)
182 @@Description:
183 @@@@:Classes of the link or anchor
184 @@@lang:en
185 @Parameter:
186 @@Name: description
187 @@Type: CDATA
188 @@Default: (none)
189 @@Description:
190 @@@@:Description of the link or anchor (HTML's LINK/@title)
191 @@@lang:en
192 @Parameter:
193 @@Name: hreflang
194 @@Type:
195 HTML4:LanguageCode
196 @@Default:(none)
197 @@Description:
198 @@@@:(Human) language the linked WikiPage written in
199 @@@lang:en
200 @Parameter:
201 @@Name: label
202 @@Type: CDATA
203 @@Default: (none)
204 @@Description:
205 @@@@:Source anchor label
206 @@@lang:en
207 @Parameter:
208 @@Name: mode
209 @@Type: WikiMode
210 @@Default:(default)
211 @@Description:
212 @@@@:Mode of the Wiki linked to
213 @@@lang:en
214 @Parameter:
215 @@Name: page
216 @@Type: WikiName
217 @@Default: (current)
218 @@Description:
219 @@@@:WikiPage linked to
220 @@@lang:en
221 @Parameter:
222 @@Name: page-anchor-name
223 @@Type:
224 XML:ID
225 @@Default: (none)
226 @@Description:
227 @@@@:Identifier in WikiPage linked to
228 @@@lang:en
229 @Parameter:
230 @@Name: page-anchor-no
231 @@Type:
232 SGML:NUMBER
233 @@Default: (none)
234 @@Description:
235 @@@@:Numeral anchor index in the WikiPage linked to
236 @@@lang:en
237 @Parameter:
238 @@Name: rel
239 @@Type:
240 HTML4:LinkTypes
241 @@Default:(none)
242 @@Description:
243 @@@@:Link relationships
244 @@@lang:en
245 @Parameter:
246 @@Name: rev
247 @@Type:
248 HTML4:LinkTypes
249 @@Default:(none)
250 @@Description:
251 @@@@:Link relationship (reverse)
252 @@@lang:en
253 # @Parameter: title : obsolete
254 @Parameter:
255 @@Name: type
256 @@Type:
257 HTML4:ContentType
258 @@Default:(none)
259 @@Description:
260 @@@@:Media type the linked WikiPage provided with
261 @@@lang:en
262 @Parameter:
263 @@Name: up-to-date
264 @@Type: boolean
265 @@Default: "0"
266 @@Description:
267 @@@@:Appends random "up-to-date" parameter to the URI reference
268 @@@lang:en
269 @Parameter:
270 @@Name: with-lm
271 @@Type: boolean
272 @@Default:"0"
273 @@Description:
274 @@@@:Appends "last-modified" parameter to the URI reference
275 @@@lang:en
276 @Formatting:
277 __ATTRTEXT:%class__;
278 __ATTRNODE:%label__;__ATTRNODE:%description__;__ATTRNODE:%title__;
279 __ATTRTEXT:%page__;__ATTRTEXT:%base_page__;__ATTRTEXT:%page_anchor_no__;
280 __ATTRTEXT:%with_lm__;__ATTRTEXT:%up_to_date__;
281 __ATTRTEXT:%hreflang__;__ATTRTEXT:%type__;
282 __ATTRTEXT:%mode__;
283 __ATTRTEXT:%rel__;__ATTRTEXT:%rev__;
284 SuikaWiki::Plugin->module_package ('WikiLinking')
285 ->to_wikipage_in_html (
286 {
287 label => qq(%html-link;\n),
288 -class => $p->{class},
289 -label => $p->{label}, # obsolete
290 -description => $p->{description} || $p->{title},
291 } => {
292 base => $o->{wiki}->name ($p->{base_page} || $o->{page}),
293 page_name_relative => $o->{wiki}->name ($p->{page} ||
294 $o->{wiki}->{var}->{page}),
295 page_anchor_no => $p->{page_anchor_no},
296 page_anchor_name=> $p->{page_anchor_name},
297 wiki_mode => $p->{mode},
298 _with_lm => $p->{with_lm},
299 _up_to_date => $p->{up_to_date},
300 -lang => $p->{hreflang},
301 -type => $p->{type},
302 }, {
303 o => $o,
304 parent => $p->{-parent},
305 -rel => $p->{rel},
306 -rev => $p->{rev},
307 });
308
309 FormattingRule:
310 @Category[list]:
311 page-link
312 link-to-resource
313 @Name:html-link
314 @Description:
315 @@@:HTML LINK element
316 @@lang:en
317 @Parameter:
318 @@Name: description
319 @@Type: text
320 @@Default: (auto)
321 @@Description:
322 @@@@: Human readable description.
323 @@@lang: en
324 @Formatting:
325 my $LINK = $p->{-parent}->append_new_node
326 (type => '#element',
327 namespace_uri => $NS_XHTML1,
328 local_name => 'link');
329 $LINK->set_attribute (href => $o->{link}->{dest}->{uri});
330 $p->{description} ||= ($p->{-parse_flag}->{description} = 1,
331 $o->{link}->{src}->{-ht__alt_description});
332 __ATTRTEXT:%description__;
333 if (length $p->{description}) {
334 $LINK->set_attribute (title => $p->{description});
335 } elsif (defined $o->{link}->{src}->{-description}) {
336 $LINK->set_attribute (title => $o->{link}->{src}->{-description}->inner_text);
337 } elsif (defined $o->{link}->{src}->{-label}) {
338 $LINK->set_attribute (title => $o->{link}->{src}->{-label}->inner_text);
339 }
340 my @class = (split (/\s+/, $p->{class}),
341 split (/\s+/, $o->{link}->{src}->{-class}));
342 if ($o->{wiki}->uri_is_part_of_wiki ($o->{link}->{dest}->{absolute_uri} or
343 $o->{link}->{dest}->{uri})) {
344 push @class, 'wiki'; ## Link to the page within the Wiki
345 }
346 $LINK->set_attribute (class => join ' ', @class) if @class;
347
348 $LINK->set_attribute (rel => $o->{link}->{option}->{-rel})
349 if $o->{link}->{option}->{-rel};
350 $LINK->set_attribute (rev => $o->{link}->{option}->{-rev})
351 if $o->{link}->{option}->{-rev};
352
353 $LINK->set_attribute (hreflang => $o->{link}->{dest}->{-lang})
354 if $o->{link}->{dest}->{-lang};
355 $LINK->set_attribute (type => $o->{link}->{dest}->{-type})
356 if $o->{link}->{dest}->{-type};
357
358 $LINK->option (use_EmptyElemTag => 1);
359
360 FormattingRule:
361 @Category[list]:
362 form-input
363 view
364 view-resource
365 page-link
366 @Name: span
367 @Formatting:
368 my $span = $p->{-parent}->append_new_node (type => '#element',
369 namespace_uri => $NS_XHTML1,
370 local_name => 'span');
371 __ATTRTEXT:%class__;
372 $span->set_attribute (class => $p->{class});
373 __ATTRNODE:%content->{$span}__;
374
375 FormattingRule:
376 @Category[list]: view
377 @Name: html--meta-keywords
378 @Description:
379 @@lang: en
380 @@@:
381 An HTML meta element with name of "keywords"
382 @Parameter:
383 @@Name: page
384 @@Type: WikiName
385 @@Default: (current)
386 @@Description:
387 @@@lang: en
388 @@@@: WikiPage of which keywords are shown.
389 @Formatting:
390 my $page = $o->{wiki}->name ($p->{page} || $o->{wiki}->{var}->{page});
391 my $content_prop;
392 try {
393 $content_prop = $o->{wiki}->{db}->get (content_prop => $page);
394 } catch SuikaWiki::DB::Util::Error with {
395 my $err = shift;
396 $err->throw if $err->{-type} eq 'ERROR_REPORTED';
397 } catch SuikaWiki::Format::Definition::error with {
398 #
399 };
400
401 if ($content_prop) {
402 my $kwd = $content_prop->get_attribute_value (<Q:sw:keyword>);
403 if (ref $kwd and @$kwd) {
404 for my $META ($p->{-parent}->append_new_node
405 (type => '#element',
406 namespace_uri => $NS_XHTML1,
407 local_name => 'meta')) {
408 $META->set_attribute (name => 'keywords');
409 $META->set_attribute (content => join ', ', @$kwd);
410 ## NOTE: Keyword that contains COMMAs will be broken.
411 $META->option (use_EmptyElemTag => 1);
412 }
413 }
414 }

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24