/[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.5 - (hide annotations) (download)
Sun Feb 8 08:52:03 2004 UTC (22 years, 5 months ago) by wakaba
Branch: MAIN
Changes since 1.4: +32 -7 lines
SuikaWiki 3 WikiName interface supported

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24