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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations) (download)
Tue Nov 25 12:38:22 2003 UTC (21 years, 5 months ago) by wakaba
Branch: MAIN
Changes since 1.2: +37 -24 lines
Use new WikiPlugin formatting interface

1 wakaba 1.1 #?SuikaWikiConfig/2.0
2    
3     Plugin:
4     @Name: WikiView
5     @Description:
6     @@@: WikiView interface for template context
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.3 @Date.RCS: $Date: 2003/10/30 07:45:10 $
16     @Use:
17     use Message::Markup::XML::Node qw(SGML_HEX_CHAR_REF);
18 wakaba 1.1
19     PluginConst:
20     @NS_XHTML1:
21     http://www.w3.org/1999/xhtml
22    
23     FormattingRule:
24     @Category[list]: view
25     @Name: template
26     @Description:
27     @@@:
28     Instantiate template.
29 wakaba 1.3 \
30 wakaba 1.1 In addition to normal parameters, parameter name prefixed by "-"
31     can be specified to replace "%apply-template (name => (name w/o prefix));"
32     in instantiated template.
33 wakaba 1.3 \
34 wakaba 1.1 Warning: Attemplt to apply template which directly or indirectly referring
35     "parent" template will make a infinite loop.
36     @@lang: en
37     @Parameter:
38     @@Name: name
39     @@Type: name
40     @@Default: #REQUIRED
41     @@Description:
42     @@@@: Template name
43     @@@lang:en
44     @Formatting:
45 wakaba 1.3 local $o->{var}->{wv__children} = $p;
46 wakaba 1.1 my $formatter = $o->formatter ('view');
47 wakaba 1.3 $formatter->replace ($o->{wiki}->{view}->assemble_template ($p->{name}),
48     param => $o, -parent => $p->{-parent});
49 wakaba 1.1
50     FormattingRule:
51     @Category[list]: view
52     @Name: apply-template
53     @Description:
54     @@@:
55     Instantiate template defined as a "-" prefixed parameter of "parent"
56     %template; rule.
57     @@lang: en
58     @Parameter:
59     @@Name: name
60     @@Type: name
61     @@Default: #REQUIRED
62     @@Description:
63     @@@@: Name of parameter defining the template, without "-" prefix
64     @@@lang:en
65     @Formatting:
66     my $template = $o->{var}->{wv__children}->{'_'.$p->{name}};
67     if (length $template) {
68 wakaba 1.3 $o->formatter ('view')->replace ($template,
69     param => $o, -parent => $p->{-parent});
70 wakaba 1.1 }
71    
72     FormattingRule:
73 wakaba 1.3 @Category[list]:
74     view
75     view-resource
76     form-input
77 wakaba 1.1 @Name: -bare-text
78     @Formatting:
79 wakaba 1.3 $p->{-parent}->append_text ($p->{-bare_text});
80    
81     FormattingRule:
82     @Category[list]:
83     view
84     view-resource
85     form-input
86     page-link
87     we--edit
88     @Name: -undef
89     @Formatting:
90     $p->{-parent}->append_text
91     ("[$f->{-category_name}/$rule_name: not defined]");
92 wakaba 1.1
93     FormattingRule:
94     @Category[list]:
95     view
96     view-resource
97     page-link
98     @Name: char
99     @Description:
100     @@@:
101     A character
102     @@lang: en
103     @Parameter:
104     @@Name: ucs
105     @@Type: "U+hhhh / U+hhhhhh / U-hhhhhhhh"
106     @@Default: #REQUIRED
107     @@Description:
108     @@@@: UCS code position of the character
109     @@@lang:en
110     @Formatting:
111 wakaba 1.3 __ATTRTEXT:%ucs__;
112 wakaba 1.1 if ($p->{ucs} =~ /^U\+([0-9A-Fa-f]{4,6})$/) {
113 wakaba 1.3 $p->{-parent}->append_new_node
114 wakaba 1.1 (type => '#reference',
115 wakaba 1.3 namespace_uri => SGML_HEX_CHAR_REF,
116 wakaba 1.1 value => hex $1);
117     } elsif ($p->{ucs} =~ /^U-([0-9A-Fa-f]{8})$/) {
118 wakaba 1.3 $p->{-parent}->append_new_node
119     (type => '#reference',
120     namespace_uri => SGML_HEX_CHAR_REF,
121 wakaba 1.1 value => hex $1);
122     } else {
123 wakaba 1.3 $p->{-parent}->append_new_node
124     (type => '#reference',
125     namespace_uri => SGML_HEX_CHAR_REF,
126     value => 0x0000FFFD);
127 wakaba 1.1 }

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24