/[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.9 - (show annotations) (download)
Sun Apr 25 07:06:50 2004 UTC (22 years, 2 months ago) by wakaba
Branch: MAIN
CVS Tags: release-3-0-0
Branch point for: paragraph-200404
Changes since 1.8: +7 -2 lines
LeafProp database module added; content_prop implemented; Media type property implemented

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24