| 1 |
wakaba |
1.1 |
#?SuikaWikiConfig/2.0 |
| 2 |
|
|
|
| 3 |
|
|
Plugin: |
| 4 |
|
|
@Name: WikiFormat |
| 5 |
|
|
@Description: |
| 6 |
|
|
@@@: WikiFormat - format independent proceding |
| 7 |
|
|
@@lang:en |
| 8 |
wakaba |
1.4 |
@License: %%Perl%% |
| 9 |
wakaba |
1.1 |
@Author: |
| 10 |
|
|
@@Name: |
| 11 |
|
|
@@@@: Wakaba |
| 12 |
|
|
@@@lang:ja |
| 13 |
|
|
@@@script:Latn |
| 14 |
|
|
@@Mail[list]: w@suika.fam.cx |
| 15 |
wakaba |
1.4 |
@Date.RCS: |
| 16 |
wakaba |
1.6 |
$Date: 2004/04/25 07:06:50 $ |
| 17 |
wakaba |
1.1 |
@RequiredPackage[list]: |
| 18 |
|
|
Error |
| 19 |
wakaba |
1.5 |
@Use: |
| 20 |
|
|
my $WIKIFORMCORE; |
| 21 |
|
|
my $WIKIRESOURCE; |
| 22 |
|
|
@Namespace: |
| 23 |
|
|
@@media-type: |
| 24 |
|
|
http://suika.fam.cx/~wakaba/-temp/2004/04/24/mt# |
| 25 |
wakaba |
1.1 |
|
| 26 |
|
|
PluginConst: |
| 27 |
|
|
@NS_XHTML1: |
| 28 |
|
|
http://www.w3.org/1999/xhtml |
| 29 |
wakaba |
1.5 |
@WIKIFORMCORE: |
| 30 |
|
|
{($WIKIFORMCORE ||= SuikaWiki::Plugin->module_package ('WikiFormCore'))} |
| 31 |
|
|
@WIKIRESOURCE: |
| 32 |
|
|
{($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))} |
| 33 |
wakaba |
1.1 |
|
| 34 |
|
|
Function: |
| 35 |
|
|
@Name: handler |
| 36 |
|
|
@Description: |
| 37 |
|
|
@@@: |
| 38 |
|
|
Getting format handler for given data |
| 39 |
|
|
@@lang:en |
| 40 |
|
|
@Main: |
| 41 |
|
|
my (undef, $content, %opt) = @_; |
| 42 |
wakaba |
1.5 |
my %type; |
| 43 |
wakaba |
1.6 |
if (not $opt{serialized_media_type} and $opt{content_prop}) { |
| 44 |
wakaba |
1.5 |
$type{serialized_media_type} = $opt{content_prop} |
| 45 |
|
|
->get_attribute_value (<Q:media-type:media-type>); |
| 46 |
|
|
} |
| 47 |
wakaba |
1.6 |
unless ($type{serialized_media_type} ||= $opt{serialized_media_type}) { |
| 48 |
wakaba |
1.5 |
my ($magic) = $opt{magic} |
| 49 |
|
|
|| ($$content =~ m[^(?:\#\?|/\*\s*)([\w.+-]+(?:/[\w.+-]+)?)]); |
| 50 |
|
|
%type = $magic ? (magic => $magic) : |
| 51 |
|
|
(Type => 'text/x-suikawiki', |
| 52 |
|
|
Type_param => {version => '0.9'}); |
| 53 |
|
|
} |
| 54 |
|
|
my $def = SuikaWiki::Format::Definition->new_handler (%type, -error => sub { |
| 55 |
wakaba |
1.1 |
my ($err) = @_; |
| 56 |
|
|
SuikaWiki::Plugin->module_package ('Error') |
| 57 |
wakaba |
1.3 |
->report_error_simple ($opt{wiki} ||= $opt{o}->{wiki}, |
| 58 |
wakaba |
1.2 |
SuikaWiki::Plugin |
| 59 |
|
|
->module_package ('WikiResource') |
| 60 |
|
|
->get (name => 'WikiFormat:Error:Type=WikiFormat', |
| 61 |
|
|
wiki => $opt{wiki} || |
| 62 |
|
|
$opt{o}->{wiki}, |
| 63 |
|
|
o => $opt{o}) |
| 64 |
wakaba |
1.3 |
=> $err->text, |
| 65 |
|
|
-trace => $opt{wiki}->{config} |
| 66 |
wakaba |
1.4 |
->{debug}->{format}); |
| 67 |
wakaba |
1.1 |
}); |
| 68 |
|
|
$def->{wiki} = $opt{wiki} || $opt{o}->{wiki}; |
| 69 |
|
|
$def->{view} = $def->{wiki}->{view}; |
| 70 |
|
|
$def; |
| 71 |
wakaba |
1.2 |
|
| 72 |
wakaba |
1.3 |
ViewDefinition: |
| 73 |
|
|
@Mode: -wf--converter-not-found |
| 74 |
|
|
@Condition: |
| 75 |
|
|
@@http-method[list]: |
| 76 |
|
|
GET |
| 77 |
|
|
HEAD |
| 78 |
|
|
POST |
| 79 |
|
|
@Description: |
| 80 |
|
|
@@@: Converter to requested media type not found |
| 81 |
|
|
@@lang: en |
| 82 |
|
|
@template: |
| 83 |
|
|
@@http-status-code: 406 |
| 84 |
|
|
@@http-status-phrase: Converter Not Found |
| 85 |
|
|
@@media-type: text/html |
| 86 |
|
|
@@use-media-type-charset: 1 |
| 87 |
|
|
@@expires: %%error%% |
| 88 |
|
|
@@body: |
| 89 |
|
|
%html-document ( |
| 90 |
|
|
title => {%res (name => {WikiFormat:NoConverter:WebPageTitle});}p, |
| 91 |
|
|
link-meta => {%template (name => links);}p, |
| 92 |
|
|
content => { |
| 93 |
|
|
%block (id => tools1, class => tools, |
| 94 |
|
|
content => {%template (name => navbar);}p); |
| 95 |
|
|
%section ( |
| 96 |
|
|
title => {%res (name => {WikiFormat:NoConverter:Title});}p, heading, |
| 97 |
|
|
content => {%paragraph ( |
| 98 |
|
|
content => {%res (name => {WikiFormat:NoConverter:Description});}p, |
| 99 |
|
|
);%error-list ( |
| 100 |
|
|
no-error => {%res (name => {Error:NoErrorReported});}p, |
| 101 |
|
|
);}p, |
| 102 |
|
|
); |
| 103 |
|
|
%block (id => footer, content => {%template (name => ws--footer);}p); |
| 104 |
|
|
}p, |
| 105 |
|
|
); |
| 106 |
wakaba |
1.5 |
|
| 107 |
|
|
FormattingRule: |
| 108 |
|
|
@Category[list]: |
| 109 |
|
|
form-input |
| 110 |
|
|
view |
| 111 |
|
|
view-resource |
| 112 |
|
|
@Name: wf--select-media-type |
| 113 |
|
|
@Formatting: |
| 114 |
|
|
my $select = $p->{-parent}->append_new_node |
| 115 |
|
|
(type => '#element', |
| 116 |
|
|
namespace_uri => $NS_XHTML1, |
| 117 |
|
|
local_name => 'select'); |
| 118 |
|
|
my $id = $WIKIFORMCORE->control_id ($o, |
| 119 |
|
|
local_id => $p->{id}, |
| 120 |
|
|
require_local_id => 1); |
| 121 |
|
|
$select->set_attribute (name => $id->{local_id}); |
| 122 |
|
|
|
| 123 |
|
|
__ATTRNODE:%label__; |
| 124 |
|
|
my $has_label = 0; |
| 125 |
|
|
if ($p->{label}->count) { |
| 126 |
|
|
$has_label = 1; |
| 127 |
|
|
for ($p->{-parent}->append_new_node |
| 128 |
|
|
(type => '#element', |
| 129 |
|
|
namespace_uri => $NS_XHTML1, |
| 130 |
|
|
local_name => 'label')) { |
| 131 |
|
|
$_->set_attribute (for => $id->{global_id}); |
| 132 |
|
|
$_->append_node ($p->{label}); |
| 133 |
|
|
} |
| 134 |
|
|
} |
| 135 |
|
|
|
| 136 |
|
|
$select->set_attribute (id => $id->{global_id}) if $has_label; |
| 137 |
|
|
__ATTRTEXT:%class__;__ATTRTEXT:%description__; |
| 138 |
|
|
$select->set_attribute (title => $p->{description}) if $p->{description}; |
| 139 |
|
|
$select->set_attribute (disabled => 'disabled') if $o->{form}->{disabled}; |
| 140 |
|
|
my @class = split /\s+/, $p->{class}; |
| 141 |
|
|
push @class, 'require' if $o->{form}->{require}->{id}->{$p->{id}}; |
| 142 |
|
|
$select->set_attribute (class => join ' ', @class) if @class; |
| 143 |
|
|
|
| 144 |
|
|
my $default; |
| 145 |
|
|
if ($o->{var}->{content_prop}) { |
| 146 |
|
|
$default = $o->{var}->{content_prop}->get_attribute_value |
| 147 |
|
|
(<Q:media-type:media-type>, default => undef); |
| 148 |
|
|
} |
| 149 |
|
|
unless ($default) { |
| 150 |
|
|
__ATTRTEXT:%default__; |
| 151 |
|
|
$default = $p->{default} || 'IMT:application/octet-stream##'; |
| 152 |
|
|
} |
| 153 |
|
|
|
| 154 |
|
|
my $mt = $o->{wiki}->{config}->{<Q:media-type:accept-media-type>} || {}; |
| 155 |
|
|
for my $mtname (sort keys %$mt) { |
| 156 |
|
|
for my $option ($select->append_new_node |
| 157 |
|
|
(type => '#element', |
| 158 |
|
|
namespace_uri => $NS_XHTML1, |
| 159 |
|
|
local_name => 'option')) { |
| 160 |
|
|
$option->set_attribute (value => $mtname); |
| 161 |
|
|
$option->set_attribute (title => $WIKIRESOURCE->get_text |
| 162 |
|
|
(name => 'WikiFormat:MediaType:Description:'.$mtname, |
| 163 |
|
|
o => $o, wiki => $o->{wiki}, default => $mtname)); |
| 164 |
|
|
if ($default eq $mtname) { |
| 165 |
|
|
$option->set_attribute (selected => 'selected'); |
| 166 |
|
|
undef $default; |
| 167 |
|
|
} |
| 168 |
|
|
$WIKIRESOURCE->get_op ('WikiFormat:MediaType:Label:'.$mtname, |
| 169 |
|
|
$o, $option, default => $mtname); |
| 170 |
|
|
} |
| 171 |
|
|
} |
| 172 |
|
|
|
| 173 |
|
|
if ($default) { |
| 174 |
|
|
for my $option ($select->append_new_node |
| 175 |
|
|
(type => '#element', |
| 176 |
|
|
namespace_uri => $NS_XHTML1, |
| 177 |
|
|
local_name => 'option')) { |
| 178 |
|
|
$option->set_attribute (value => '#asis'); |
| 179 |
|
|
$option->set_attribute (title => $WIKIRESOURCE->get_text |
| 180 |
|
|
(name => 'WikiFormat:MediaType:Description:'.$default, |
| 181 |
|
|
o => $o, wiki => $o->{wiki}, default => $default)); |
| 182 |
|
|
$option->set_attribute (selected => 'selected'); |
| 183 |
|
|
$WIKIRESOURCE->get_op ('WikiFormat:MediaType:Label:'.$default, |
| 184 |
|
|
$o, $option, default => $default); |
| 185 |
|
|
|
| 186 |
|
|
} |
| 187 |
|
|
} |
| 188 |
|
|
|
| 189 |
|
|
ViewFragment: |
| 190 |
|
|
@Name: we--edit |
| 191 |
|
|
@Description: |
| 192 |
|
|
@@@: Edit form --- media type selection |
| 193 |
|
|
@@lang:en |
| 194 |
|
|
@Order: 420 |
| 195 |
|
|
@Formatting: |
| 196 |
|
|
%wf--select-media-type (id => wf--media-type); |
| 197 |
wakaba |
1.3 |
|
| 198 |
wakaba |
1.2 |
Resource: |
| 199 |
|
|
@WikiFormat:Error:Type=WikiFormat: |
| 200 |
|
|
@@@: WikiFormat |
| 201 |
wakaba |
1.3 |
@@lang: en |
| 202 |
|
|
@WikiFormat:NoConverter:Description: |
| 203 |
|
|
@@@: |
| 204 |
|
|
Converter to media type requested not found, so that your |
| 205 |
|
|
request cannot be completed. |
| 206 |
|
|
@@lang: en |
| 207 |
|
|
@WikiFormat:NoConverter:Title: |
| 208 |
|
|
@@@: Converter Not Found |
| 209 |
|
|
@@lang: en |
| 210 |
|
|
@WikiFormat:NoConverter:WebPageTitle: |
| 211 |
|
|
@@@: 406 Converter Not Found |
| 212 |
wakaba |
1.2 |
@@lang: en |
| 213 |
|
|
|
| 214 |
wakaba |
1.1 |
|