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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations) (download)
Sun Feb 8 08:52:03 2004 UTC (22 years, 6 months ago) by wakaba
Branch: MAIN
Changes since 1.6: +116 -13 lines
SuikaWiki 3 WikiName interface supported

1 #?SuikaWikiConfig/2.0
2
3 Plugin:
4 @Name: WikiRead
5 @Description:
6 @@@: Showing WikiPage content
7 @@lang:en
8 @License: %%GPL%%
9 @Author:
10 @@Name:
11 @@@@: Wakaba
12 @@@lang:ja
13 @@@script:Latn
14 @@Mail[list]: [email protected]
15 @Date.RCS: $Date: 2004/02/01 12:19:16 $
16 @RequiredModule[list]:
17 SuikaWiki::Format::Definition
18 @RequiredPlugin[list]:
19 WikiFormat
20 WikiView
21 WikiStruct
22 WikiLinking
23 HTML
24 SuikaWiki09
25 @Use:
26 require SuikaWiki::Format::Definition;
27 use Message::Util::Error;
28
29 ViewDefinition:
30 @Mode: read
31 @Condition:
32 @@http-method[list]:
33 GET
34 HEAD
35 POST
36 @Description:
37 @@@: Show WikiPage content as whole
38 @@lang: en
39 @template:
40 @@http-status-code: 200
41 @@media-type: text/html
42 @@use-media-type-charset: 1
43 @@expires: %%view%%
44 @@body:
45 %html-document (
46 title => {%res (name => {View:WebPageTitle});}p,
47 link-meta => {%template (name => links);}p,
48 content => {
49 %template (
50 name => ws--page,
51 -content => {
52 %block (
53 class => "bodytext",
54 content => {%template (name => wr--read-body);}p,
55 );
56 },
57 );
58 }p,
59 );
60
61 ViewFragment:
62 @Template[list]:wr--read-body
63 @Order: 0
64 @Description:
65 @@@: "Read" mode body -- WikiPage main content
66 @@lang:en
67 @Formatting:
68 %read (comment);
69
70 PluginConst:
71 @NS_XHTML1:
72 http://www.w3.org/1999/xhtml
73
74 FormattingRule:
75 @Category[list]: view
76 @Name: read
77 @Description:
78 @@@:
79 Show the WikiPage to be "read"
80 @@lang: en
81 @Parameter:
82 @@Name: page
83 @@Type: WikiName
84 @@Default: (current)
85 @@Description:
86 @@@@: WikiPage shown
87 @@@lang:en
88 @Parameter:
89 @@Name: comment
90 @@Type: boolean
91 @@Default: {0}
92 @@Description:
93 @@@@: Append comment form
94 @@@lang:en
95 @Parameter:
96 @@Name: IsFragment
97 @@Type: boolean
98 @@Default: (auto)
99 @@Description:
100 @@@@:
101 Specify whether convertion result should be "fragment" format.
102 (For example, "text/html" fragment will not have "html" element
103 as the root element.)
104 @@@lang: en
105 @Parameter:
106 @@Name: Name
107 @@Type: product-name-token
108 @@Default: (auto)
109 @@Description:
110 @@@@:
111 Media type name (product style).
112 @@@lang: en
113 @Parameter:
114 @@Name: return-type
115 @@Type: token
116 @@Default: (default)
117 @@Description:
118 @@@@:
119 Select how the content converted to be returned.
120 \
121 (default): Result is appended to the parent node.
122 \
123 'ToString': Result is returned as a Perl string.
124 \
125 'ToOctetStream': Result is returned as a Perl byte string.
126 \
127 Nothing is returned in case convertion to specified returning method
128 is not defined by the Format definition.
129 @Parameter:
130 @@Name: Type
131 @@Type: internet-media-type-subtype
132 @@Default: (auto)
133 @@Description:
134 @@@@:
135 Internet media type (type/subtype pair) to which content should be
136 converted.
137 \
138 Note that media type parameters cannot be specified here.
139 Way to specify them are under consideration.
140 \
141 Neither Type nor Name is specified, defaulted to
142 (Type => {text/html}, IsFragment => 1).
143 @Parameter:
144 @@Name: Version
145 @@Type: product-version-token
146 @@Default: (auto)
147 @@Description:
148 @@@@:
149 Media type version (product style).
150 \
151 Name parameter should also be specified, otherwise Version makes
152 no mean.
153 @Parameter:
154 @@Name: when-no-converter
155 @@Type: token
156 @@Default: "exception"
157 @@Description:
158 @@@@:
159 Specify how behave if Converter not found.
160 \
161 'exception': Throw an exception.
162 \
163 '406': Turn to -wf--converter-not-found mode.
164 \
165 'ignore': Ignore. Returned value is not defined.
166 @Formatting:
167 __ATTRTEXT:%page__;__ATTRTEXT:%comment__;
168 my $page = $o->{wiki}->name ($p->{page} || $o->{wiki}->{var}->{page});
169 my $content;
170 try {
171 $content = $o->{wiki}->{db}->get (content => $page);
172 } catch SuikaWiki::DB::Util::Error with {
173 $content = undef;
174 };
175
176 my %param;
177 if ($p->{Type} or $p->{Name}) {
178 for (qw/Type Name Version IsFragment return_type/) {
179 $param{$_} = $p->{$_};
180 }
181 ## TODO: Type_param
182 } else {
183 %param = (Type => 'text/html', IsFragment => 1);
184 }
185
186 my $return;
187 try {
188 my $format = SuikaWiki::Plugin->module_package ('WikiFormat')
189 ->handler (\$content,
190 o => $o, wiki => $o->{wiki});
191 $return = $format->convert
192 (\$content, %param,
193 -parent => $p->{-parent},
194 o => $o, page => $page,
195 -with_annotation_input => $p->{comment});
196 } catch SuikaWiki::Format::Definition::error with {
197 my $err = shift;
198
199 if ($p->{when_no_converter} eq '406') {
200 SuikaWiki::Plugin->module_package ('Error')
201 ->report_error_simple
202 ($o->{wiki}, WikiFormat => $err->text);
203 $o->{wiki}->view_in_mode (mode => '-wf--converter-not-found',
204 method => 'GET');
205 throw SuikaWiki::View::Implementation::error
206 -type => 'ERROR_REPORTED';
207 } elsif ($p->{when_no_converter} ne 'ignore') {
208 $err->throw;
209 }
210 };
211 if ($p->{return_type} eq 'ToString' or
212 $p->{return_type} eq 'ToOctetStream') {
213 $p->{-parent}->append_new_node (type => '#xml', value => $return);
214 }
215
216 ViewFragment:
217 @Name: links
218 @Description:
219 @@@: Link to read mode of the WikiPage
220 @@lang:en
221 @Formatting:
222 %link-wiki(mode=>read,rel=>view,class=>wiki-cmd,
223 description=>{%res(name=>{Link:View:Description});}p,up-to-date);
224
225 ViewFragment:
226 @Name: navbar
227 @Description:
228 @@@: Link to read mode of the WikiPage
229 @Order: 0
230 @Formatting:
231 %link-to-wikipage (
232 rel => view,
233 mode => read,
234 up-to-date,
235 label => {%link-to-it (
236 class => wiki-cmd,
237 label => {%res(name=>ViewThisPage);}p,
238 description => {%res(name=>ViewThisPageLong);}p,
239 );},
240 );
241
242 Resource:
243 @Link:View:Description:
244 @@@: Show this WikiPage in reading mode
245 @@lang:en
246 @Mode:read:
247 @@@: Browsing
248 @@lang: en
249 @ViewThisPage:
250 @@@: View
251 @@lang:en
252 @ViewThisPageLong:
253 @@@: Show latest version of this WikiPage
254 @@lang:en
255 @View:WebPageTitle:
256 @@@: %page-name;
257 @@lang:en
258
259

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24