| 1 |
wakaba |
1.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]: w@suika.fam.cx |
| 15 |
wakaba |
1.8 |
@Date.RCS: $Date: 2004/02/08 08:52:03 $ |
| 16 |
wakaba |
1.2 |
@RequiredModule[list]: |
| 17 |
wakaba |
1.3 |
SuikaWiki::Format::Definition |
| 18 |
wakaba |
1.2 |
@RequiredPlugin[list]: |
| 19 |
wakaba |
1.5 |
WikiFormat |
| 20 |
wakaba |
1.2 |
WikiView |
| 21 |
|
|
WikiStruct |
| 22 |
|
|
WikiLinking |
| 23 |
|
|
HTML |
| 24 |
|
|
SuikaWiki09 |
| 25 |
wakaba |
1.3 |
@Use: |
| 26 |
|
|
require SuikaWiki::Format::Definition; |
| 27 |
wakaba |
1.6 |
use Message::Util::Error; |
| 28 |
wakaba |
1.1 |
|
| 29 |
|
|
ViewDefinition: |
| 30 |
|
|
@Mode: read |
| 31 |
|
|
@Condition: |
| 32 |
|
|
@@http-method[list]: |
| 33 |
|
|
GET |
| 34 |
|
|
HEAD |
| 35 |
wakaba |
1.7 |
POST |
| 36 |
wakaba |
1.1 |
@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 |
wakaba |
1.2 |
title => {%res (name => {View:WebPageTitle});}p, |
| 47 |
|
|
link-meta => {%template (name => links);}p, |
| 48 |
wakaba |
1.1 |
content => { |
| 49 |
|
|
%template ( |
| 50 |
|
|
name => ws--page, |
| 51 |
|
|
-content => { |
| 52 |
|
|
%block ( |
| 53 |
wakaba |
1.3 |
class => "bodytext", |
| 54 |
wakaba |
1.2 |
content => {%template (name => wr--read-body);}p, |
| 55 |
wakaba |
1.1 |
); |
| 56 |
|
|
}, |
| 57 |
|
|
); |
| 58 |
|
|
}p, |
| 59 |
|
|
); |
| 60 |
|
|
|
| 61 |
wakaba |
1.2 |
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 |
wakaba |
1.1 |
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 |
wakaba |
1.7 |
@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 |
wakaba |
1.1 |
@Formatting: |
| 167 |
wakaba |
1.3 |
__ATTRTEXT:%page__;__ATTRTEXT:%comment__; |
| 168 |
wakaba |
1.7 |
my $page = $o->{wiki}->name ($p->{page} || $o->{wiki}->{var}->{page}); |
| 169 |
wakaba |
1.6 |
my $content; |
| 170 |
|
|
try { |
| 171 |
|
|
$content = $o->{wiki}->{db}->get (content => $page); |
| 172 |
|
|
} catch SuikaWiki::DB::Util::Error with { |
| 173 |
wakaba |
1.8 |
my $err = shift; |
| 174 |
|
|
$err->throw if $err->{-type} eq 'ERROR_REPORTED'; |
| 175 |
wakaba |
1.6 |
$content = undef; |
| 176 |
|
|
}; |
| 177 |
wakaba |
1.4 |
|
| 178 |
wakaba |
1.7 |
my %param; |
| 179 |
|
|
if ($p->{Type} or $p->{Name}) { |
| 180 |
|
|
for (qw/Type Name Version IsFragment return_type/) { |
| 181 |
|
|
$param{$_} = $p->{$_}; |
| 182 |
|
|
} |
| 183 |
|
|
## TODO: Type_param |
| 184 |
|
|
} else { |
| 185 |
|
|
%param = (Type => 'text/html', IsFragment => 1); |
| 186 |
|
|
} |
| 187 |
|
|
|
| 188 |
|
|
my $return; |
| 189 |
|
|
try { |
| 190 |
|
|
my $format = SuikaWiki::Plugin->module_package ('WikiFormat') |
| 191 |
|
|
->handler (\$content, |
| 192 |
|
|
o => $o, wiki => $o->{wiki}); |
| 193 |
|
|
$return = $format->convert |
| 194 |
|
|
(\$content, %param, |
| 195 |
|
|
-parent => $p->{-parent}, |
| 196 |
|
|
o => $o, page => $page, |
| 197 |
|
|
-with_annotation_input => $p->{comment}); |
| 198 |
|
|
} catch SuikaWiki::Format::Definition::error with { |
| 199 |
|
|
my $err = shift; |
| 200 |
|
|
|
| 201 |
|
|
if ($p->{when_no_converter} eq '406') { |
| 202 |
|
|
SuikaWiki::Plugin->module_package ('Error') |
| 203 |
|
|
->report_error_simple |
| 204 |
|
|
($o->{wiki}, WikiFormat => $err->text); |
| 205 |
|
|
$o->{wiki}->view_in_mode (mode => '-wf--converter-not-found', |
| 206 |
|
|
method => 'GET'); |
| 207 |
|
|
throw SuikaWiki::View::Implementation::error |
| 208 |
|
|
-type => 'ERROR_REPORTED'; |
| 209 |
|
|
} elsif ($p->{when_no_converter} ne 'ignore') { |
| 210 |
|
|
$err->throw; |
| 211 |
|
|
} |
| 212 |
|
|
}; |
| 213 |
|
|
if ($p->{return_type} eq 'ToString' or |
| 214 |
|
|
$p->{return_type} eq 'ToOctetStream') { |
| 215 |
|
|
$p->{-parent}->append_new_node (type => '#xml', value => $return); |
| 216 |
|
|
} |
| 217 |
wakaba |
1.1 |
|
| 218 |
|
|
ViewFragment: |
| 219 |
|
|
@Name: links |
| 220 |
|
|
@Description: |
| 221 |
|
|
@@@: Link to read mode of the WikiPage |
| 222 |
|
|
@@lang:en |
| 223 |
|
|
@Formatting: |
| 224 |
|
|
%link-wiki(mode=>read,rel=>view,class=>wiki-cmd, |
| 225 |
wakaba |
1.4 |
description=>{%res(name=>{Link:View:Description});}p,up-to-date); |
| 226 |
wakaba |
1.1 |
|
| 227 |
|
|
ViewFragment: |
| 228 |
|
|
@Name: navbar |
| 229 |
|
|
@Description: |
| 230 |
|
|
@@@: Link to read mode of the WikiPage |
| 231 |
|
|
@Order: 0 |
| 232 |
|
|
@Formatting: |
| 233 |
wakaba |
1.3 |
%link-to-wikipage ( |
| 234 |
|
|
rel => view, |
| 235 |
|
|
mode => read, |
| 236 |
|
|
up-to-date, |
| 237 |
|
|
label => {%link-to-it ( |
| 238 |
|
|
class => wiki-cmd, |
| 239 |
|
|
label => {%res(name=>ViewThisPage);}p, |
| 240 |
|
|
description => {%res(name=>ViewThisPageLong);}p, |
| 241 |
|
|
);}, |
| 242 |
|
|
); |
| 243 |
wakaba |
1.1 |
|
| 244 |
|
|
Resource: |
| 245 |
|
|
@Link:View:Description: |
| 246 |
|
|
@@@: Show this WikiPage in reading mode |
| 247 |
|
|
@@lang:en |
| 248 |
wakaba |
1.7 |
@Mode:read: |
| 249 |
|
|
@@@: Browsing |
| 250 |
|
|
@@lang: en |
| 251 |
wakaba |
1.1 |
@ViewThisPage: |
| 252 |
|
|
@@@: View |
| 253 |
|
|
@@lang:en |
| 254 |
|
|
@ViewThisPageLong: |
| 255 |
|
|
@@@: Show latest version of this WikiPage |
| 256 |
|
|
@@lang:en |
| 257 |
|
|
@View:WebPageTitle: |
| 258 |
|
|
@@@: %page-name; |
| 259 |
|
|
@@lang:en |
| 260 |
|
|
|
| 261 |
|
|
|