#?SuikaWikiConfig/2.0 Plugin: @Name: SuikaWikiImage09 @Description: @@@: SuikaWikiImage/0.9 support @@lang:en @License: %%GPL%% @Author: @@Name: @@@@: Wakaba @@@lang:ja @@@script:Latn @@Mail[list]: w@suika.fam.cx @Date.RCS: $Date: 2004/04/25 07:06:50 $ @RequiredModule[list]: @RequiredPlugin[list]: SuikaWiki09 @Use: my $SW09; my $WIKIRESOURCE; my $MODE = { 'image/vnd.microsoft.icon' => { mode => 'image-x-icon', type => 'image/vnd.microsoft.icon', suffix => 'ico', }, 'image/x-icon' => { mode => 'image-x-icon', type => 'image/vnd.microsoft.icon', suffix => 'ico', }, 'image/jpeg' => { mode => 'image-jpeg', type => 'image/jpeg', suffix => 'jpeg', }, 'image/png' => { mode => 'image-png', type => 'image/png', suffix => 'png', }, }; PluginConst: @NS_XHTML1: http://www.w3.org/1999/xhtml @NS_SW09: urn:x-suika-fam-cx:markup:suikawiki:0:9: @SW09: {($SW09 ||= SuikaWiki::Plugin->module_package ('SuikaWiki09'))} @WIKIRESOURCE: {($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))} Format: @Name: SuikaWikiImage @Version: 0.9 @Type: @@@: text/x.suikawiki.image @@version: 0.9 @ModuleName: SuikaWiki::Image::V0_9 @Inherit[list]: SuikaWiki::V0_9 @Description: @@@: SuikaWikiImage/0.9 document with an image format @@lang:en @Converter: @@Type: text/html @@IsFragment: 1 @@Description: @@@@: Converting SuikaWikiImage/0.9 to Hypertext Markup Language fragment @@@lang:en @@Main: $opt->{o}->{wiki} ||= $self->{wiki}; ## Text format -> XML format my $xml = $SW09->get_xml_tree (text => $source, opt => $opt, wiki => $self->{wiki}); $self->convert ($source, %$opt, Type => 'text/html', IsFragment => 1, IsPlaceholder => 1); ## SuikaWiki/0.9 -> XHTML 1 $SW09->sw09_to_xhtml1 (source => $xml, parent => $opt->{-parent}, o => $opt->{o}, page => $opt->{page}); if ($opt->{-with_annotation_input}) { SuikaWiki::Plugin->module_package ('WikiFormCore') ->make_content_form_in_html ($opt->{-parent}, $WIKIRESOURCE->get (name => 'SuikaWiki/0.9:form:footannotate:input', o => $opt->{o}, wiki => $opt->{o}->{wiki}), option => $WIKIRESOURCE->get (name => 'SuikaWiki/0.9:form:footannotate:option', o => $opt->{o}, wiki => $opt->{o}->{wiki}), o => $opt->{o}, wiki => $opt->{o}->{wiki}, output => { page => $opt->{page}, }); } @Converter: @@Type: text/html @@IsFragment: 1 @@IsPlaceholder: 1 @@Description: @@@@: Placeholder for image embedding @@@lang: en @@Main: ## Text format -> XML format my $xml = $SW09->get_xml_tree (text => $source, opt => $opt, wiki => $self->{wiki}); my $param = __FUNCPACK__->_get_parameter_and_image ($xml); my $fig = $opt->{-parent}->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'div'); $fig->set_attribute (class => 'fig'); my $img = $fig->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'img'); $img->option (use_EmptyElemTag => 1); $img->set_attribute (src => $self->{wiki}->uri_reference (page => $opt->{page}, mode => $MODE->{$param->{'image-type'}} ->{mode}, with_lm => 1, base => 1)); $img->set_attribute (alt => $param->{'image-alt'}); $img->set_attribute (title => $opt->{page}->stringify (wiki => $self->{wiki})); $img->set_attribute (class => 'embed'); $img->set_attribute (longdesc => $self->{wiki}->uri_reference (page => $opt->{page}, base => 1)); $img->set_attribute (type => $MODE->{$param->{'image-type'}}->{type}); @Converter: @@Type: image/png @@ToOctetStream: ## Text format -> XML format my $xml = $SW09->get_xml_tree (text => $source, opt => $opt, wiki => $self->{wiki}); my $param = __FUNCPACK__->_get_parameter_and_image ($xml); unless ($param->{'image-type'} eq 'image/png') { ## TODO: CORE::die "Image type $param->{'image-type'} not supported"; } require MIME::Base64; return MIME::Base64::decode_base64 ($param->{-body}); @Converter: @@Type: image/vnd.microsoft.icon @@ToOctetStream: ## Text format -> XML format my $xml = $SW09->get_xml_tree (text => $source, opt => $opt, wiki => $self->{wiki}); my $param = __FUNCPACK__->_get_parameter_and_image ($xml); unless ($param->{'image-type'} eq 'image/vnd.microsoft.icon' or $param->{'image-type'} eq 'image/x-icon') { ## TODO: CORE::die "Image type $param->{'image-type'} not supported"; } require MIME::Base64; return MIME::Base64::decode_base64 ($param->{-body}); Function: @Name: _get_parameter_and_image @Main: my (undef, $xml) = @_; my %param; for (@{$xml->child_nodes}) { if ($_->node_type eq '#element' and $_->local_name eq 'document') { for (@{$_->child_nodes}) { if ($_->node_type eq '#element') { if ($_->local_name eq 'head') { for (@{$_->child_nodes}) { if ($_->node_type eq '#element' and $_->local_name eq 'parameter') { my $name = $_->get_attribute_value ('name'); for (@{$_->child_nodes}) { if ($_->node_type eq '#element' and $_->local_name eq 'value') { $param{$name} = $_->inner_text; } } } } } elsif ($_->local_name eq 'image') { $param{-body} = $_->inner_text; last; } } }}} \ \%param; Resource: @WikiFormat:MediaType:Description:IMT:text/x.suikawiki.image;version="0.9"##: @@@: SuikaWikiImage/0.9 (text format), i.e. SuikaWiki/0.9 + image embedding, as used in SuikaWiki 2 @@lang: en @WikiFormat:MediaType:Label:IMT:text/x.suikawiki.image;version="0.9"##: @@@: SuikaWikiImage/0.9 (text format) @@lang: en @WikiFormat:MediaType:Description:MAGIC:SuikaWikiImage/0.9##: @@@: SuikaWikiImage/0.9 (text format), i.e. SuikaWiki/0.9 + image embedding, as used in SuikaWiki 2 @@lang: en @WikiFormat:MediaType:Label:MAGIC:SuikaWikiImage/0.9##: @@@: SuikaWikiImage/0.9 (text format) @@lang: en