#?SuikaWikiConfig/2.0 Plugin: @Name: WikiFormat @Description: @@@: WikiFormat - format independent proceding @@lang:en @License: %%Perl%% @Author: @@Name: @@@@: Wakaba @@@lang:ja @@@script:Latn @@Mail[list]: w@suika.fam.cx @Date.RCS: $Date: 2004/07/25 06:54:29 $ @RequiredPackage[list]: Error @Use: my $WIKIFORMCORE; my $WIKIRESOURCE; @Namespace: @@media-type: http://suika.fam.cx/~wakaba/-temp/2004/04/24/mt# PluginConst: @NS_XHTML1: http://www.w3.org/1999/xhtml @WIKIFORMCORE: {($WIKIFORMCORE ||= SuikaWiki::Plugin->module_package ('WikiFormCore'))} @WIKIRESOURCE: {($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))} Function: @Name: handler @Description: @@@: Getting format handler for given data @@lang:en @Main: my (undef, $content, %opt) = @_; my %type; if (not $opt{serialized_media_type} and $opt{content_prop}) { $type{serialized_media_type} = $opt{content_prop} ->get_attribute_value (); } $type{serialized_media_type} ||= $opt{serialized_media_type}; unless ($type{serialized_media_type}) { my $magic = $opt{magic}; if (not $magic and $$content =~ m[^(?:\#\?|/\*\s*)([\w.+-]+(?:/[\w.+-]+)?)]) { $magic = $1; } %type = $magic ? (magic => $magic) : (Type => 'text/x-suikawiki', Type_param => {version => '0.9'}); } my $def = SuikaWiki::Format::Definition->new_handler (%type, -error => sub { my ($err) = @_; __FUNCPACK{Error}__ ->report_error_simple ($opt{wiki} ||= $opt{o}->{wiki}, SuikaWiki::Plugin ->module_package ('WikiResource') ->get (name => 'WikiFormat:Error:Type=WikiFormat', wiki => $opt{wiki} || $opt{o}->{wiki}, o => $opt{o}) => $err->text, -trace => $opt{wiki}->{config} ->{debug}->{format}); }); $def->{wiki} = $opt{wiki} || $opt{o}->{wiki}; $def->{view} = $def->{wiki}->{view}; $def; ViewDefinition: @Mode: -wf--converter-not-found @Condition: @@http-method[list]: GET HEAD POST @Description: @@@: Converter to requested media type not found @@lang: en @template: @@http-status-code: 406 @@http-status-phrase: Converter Not Found @@media-type: text/html @@use-media-type-charset: 1 @@expires: %%error%% @@body: %html-document ( title => {%res (name => {WikiFormat:NoConverter:WebPageTitle});}p, link-meta => {%template (name => links);}p, content => { %block (id => tools1, class => tools, content => {%template (name => navbar);}p); %section ( title => {%res (name => {WikiFormat:NoConverter:Title});}p, heading, content => {%paragraph ( content => {%res (name => {WikiFormat:NoConverter:Description});}p, );%error-list ( no-error => {%res (name => {Error:NoErrorReported});}p, );}p, ); %block (id => footer, content => {%template (name => ws--footer);}p); }p, ); FormattingRule: @Category[list]: form-input view view-resource @Name: wf--select-media-type @Parameter: @@Name: source @@Type: CDATA @@Default: (auto) @@Description: @@@@: Default value provider. If specified, $o->{var}->{source}->{ $p->{source} } must be a CODE reference which returns the default value (a serialized media type, with additional information). @@@lang: en @Formatting: my $id = __FUNCPACK{WikiFormCore}__->control_id ($o, local_id => $p->{id}, require_local_id => 1); __ATTRNODE:%label__; my $has_label = 0; if ($p->{label}->count) { $has_label = 1; for ($p->{-parent}->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'label')) { $_->set_attribute (for => $id->{global_id}); $_->append_node ($p->{label}); } } my $select = $p->{-parent}->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'select'); $select->set_attribute (name => $id->{local_id}); $select->set_attribute (id => $id->{global_id}) if $has_label; __ATTRTEXT:%class__;__ATTRTEXT:%description__; $select->set_attribute (title => $p->{description}) if $p->{description}; $select->set_attribute (disabled => 'disabled') if $o->{form}->{disabled}; my @class = split /\s+/, $p->{class}; push @class, 'require' if $o->{form}->{require}->{id}->{$p->{id}}; $select->set_attribute (class => join ' ', @class) if @class; my $default; __ATTRTEXT:%source__; if ($p->{source}) { if (ref $o->{var}->{source}->{$p->{source}}) { my $d = $o->{var}->{source}->{$p->{source}} ->(p => $p, o => $o, type => ); $default = $d->{value}; } } else { if ($o->{var}->{content_prop}) { $default = $o->{var}->{content_prop}->get_attribute_value (, default => undef); } } unless ($default) { __ATTRTEXT:%default__; $default = $p->{default} || 'IMT:application/octet-stream##'; } my $mt = $o->{wiki}->{config}->{} || {}; for my $mtname (sort keys %$mt) { for my $option ($select->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'option')) { $option->set_attribute (title => $WIKIRESOURCE->get_text (name => 'WikiFormat:MediaType:Description:'.$mtname, o => $o, wiki => $o->{wiki}, default => $mtname)); $option->set_attribute (value => $mtname); if ($default eq $mtname) { $option->set_attribute (selected => 'selected'); undef $default; } $WIKIRESOURCE->get_op ('WikiFormat:MediaType:Label:'.$mtname, $o, $option, default => $mtname); } } if ($default) { for my $option ($select->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'option')) { $option->set_attribute (value => '#asis'); $option->set_attribute (title => $WIKIRESOURCE->get_text (name => 'WikiFormat:MediaType:Description:'.$default, o => $o, wiki => $o->{wiki}, default => $default)); $option->set_attribute (selected => 'selected'); $WIKIRESOURCE->get_op ('WikiFormat:MediaType:Label:'.$default, $o, $option, default => $default); } } ViewFragment: @Name: we--edit @Description: @@@: Edit form --- media type selection @@lang:en @Order: 420 @Formatting: %wf--select-media-type (id => wf--media-type); Resource: @WikiFormat:Error:Type=WikiFormat: @@@: WikiFormat @@lang: en @WikiFormat:NoConverter:Description: @@@: Converter to media type requested not found, so that your request cannot be completed. @@lang: en @WikiFormat:NoConverter:Title: @@@: Converter Not Found @@lang: en @WikiFormat:NoConverter:WebPageTitle: @@@: 406 Converter Not Found @@lang: en