/[pub]/suikawiki/script/misc/plugins/format/swimg09.pm
Suika

Contents of /suikawiki/script/misc/plugins/format/swimg09.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Sun May 16 23:05:49 2010 UTC (15 years, 11 months ago) by wakaba
Branch: MAIN
CVS Tags: suikawiki3-redirect, HEAD
added latest .pm files

1 use strict;
2 package SuikaWiki::Plugin::Registry;
3
4
5 our %Info;
6 $Info{q#SuikaWikiImage09#}->{Name} = q#SuikaWikiImage09#;
7 $Info{q#SuikaWikiImage09#}->{q#Version#} = q#2004.0831.0328#;
8 $Info{q#SuikaWikiImage09#}->{q#InterfaceVersion#} = q#2.9.1#;
9 $Info{q#SuikaWikiImage09#}->{q#mkpluginVersion#} = q#2.1.19#;
10 $Info{q#SuikaWikiImage09#}->{q#module_name#} = q#SuikaWiki::Plugin::plugin::SuikaWikiImage091040731032808EjFd#;
11 $Info{q#SuikaWikiImage09#}->{RequiredPlugin} = [q#SuikaWiki09#];
12 $Info{q#SuikaWikiImage09#}->{RequiredModule} = [];
13 $Info{q#SuikaWikiImage09#}->{Description} = [[q#SuikaWikiImage/0.9 support#, q#en#, q##]];
14 $Info{q#SuikaWikiImage09#}->{License} = [[q#%%GPL%%#, q##, q##]];
15 $Info{q#SuikaWikiImage09#}->{Author} = [[[[q#Wakaba#, q#ja#, q#Latn#]], [[q#w@suika.fam.cx#]], [q##]]];
16 package SuikaWiki::Plugin::plugin::SuikaWikiImage091040731032808EjFd;
17
18
19 #line 1 "(WikiPlugin module source swimg09.wp2, block Plugin/Use)"
20 my $SW09;
21 my $WIKIRESOURCE;
22 my $MODE = {
23 'image/vnd.microsoft.icon' => {
24 mode => 'image-x-icon',
25 type => 'image/vnd.microsoft.icon',
26 suffix => 'ico',
27 },
28 'image/x-icon' => {
29 mode => 'image-x-icon',
30 type => 'image/vnd.microsoft.icon',
31 suffix => 'ico',
32 },
33 'image/jpeg' => {
34 mode => 'image-jpeg',
35 type => 'image/jpeg',
36 suffix => 'jpeg',
37 },
38 'image/png' => {
39 mode => 'image-png',
40 type => 'image/png',
41 suffix => 'png',
42 },
43 };
44 #line 1 "(WikiPlugin module SuikaWikiImage09, chunk 1)"
45
46 package SuikaWiki::Format::Definition::SuikaWiki::Image::V0_9;
47
48 our @ISA;
49 push @ISA, q#SuikaWiki::Format::Definition::SuikaWiki::V0_9#;
50 $SuikaWiki::Format::Definition::Class{q#MAGIC:SuikaWikiImage/0.9\#\##} = 'SuikaWiki::Format::Definition::SuikaWiki::Image::V0_9';
51 $SuikaWiki::Format::Definition::Class{q#IMT:text/x.suikawiki.image;version="0.9"\#\##} = 'SuikaWiki::Format::Definition::SuikaWiki::Image::V0_9';
52
53 #line 251 "(WikiPlugin module SuikaWikiImage09, chunk from ../../../bin/mkplugin2.pl)"
54 our $Converter;
55 sub convert ($$;%) {
56 my ($self, $source, %opt) = @_;
57 my $t = SuikaWiki::Format::Definition->serialize_media_type (%opt);
58 my $converter = $Converter->{$t->{_}};
59 return ($converter->{$opt{return_type} or 'Main'} or
60 CORE::die "Buggy implementation: $t->{_}/@{[$opt{return_type} or 'Main']} not defined")
61 ->($self, $source, \%opt)
62 if $converter;
63 $self->SUPER::convert ($source, %opt);
64 }
65
66 #line 1 "(WikiPlugin module SuikaWikiImage09, chunk 2)"
67 $Converter->{q#IMT:text/html\#\#f#} = {q#Type#, q#text/html#, q#serialized_type#, q#IMT:text/html\#\#f#, q#Type_param#, {}, q#IsFragment#, q#1#, q#Main#, sub {my ($self, $source, $opt) = @_;
68 #line 1 "(WikiPlugin module source swimg09.wp2, block //Converter/Main)"
69 $opt->{o}->{wiki} ||= $self->{wiki};
70 my $xml = ($SW09 ||= SuikaWiki::Plugin->module_package ('SuikaWiki09'))->get_xml_tree (text => $source, opt => $opt,
71 wiki => $self->{wiki});
72 $self->convert ($source, %$opt,
73 Type => 'text/html', IsFragment => 1,
74 IsPlaceholder => 1);
75 ($SW09 ||= SuikaWiki::Plugin->module_package ('SuikaWiki09'))->sw09_to_xhtml1 (source => $xml, parent => $opt->{-parent},
76 o => $opt->{o}, page => $opt->{page});
77 if ($opt->{-with_annotation_input}) {
78 SuikaWiki::Plugin->module_package ('WikiFormCore')
79 ->make_content_form_in_html
80 ($opt->{-parent},
81 ($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))->get
82 (name => 'SuikaWiki/0.9:form:footannotate:input',
83 o => $opt->{o}, wiki => $opt->{o}->{wiki}),
84 option => ($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))->get
85 (name => 'SuikaWiki/0.9:form:footannotate:option',
86 o => $opt->{o}, wiki => $opt->{o}->{wiki}),
87 o => $opt->{o},
88 wiki => $opt->{o}->{wiki},
89 output => {
90 page => $opt->{page},
91 });
92 }
93 #line 1 "(WikiPlugin module SuikaWikiImage09, chunk 3)"
94 }};
95 $Converter->{q#IMT:text/html\#\#fp#} = {q#Type#, q#text/html#, q#serialized_type#, q#IMT:text/html\#\#fp#, q#IsPlaceholder#, q#1#, q#Type_param#, {}, q#IsFragment#, q#1#, q#Main#, sub {my ($self, $source, $opt) = @_;
96 #line 1 "(WikiPlugin module source swimg09.wp2, block //Converter/Main)"
97 my $xml = ($SW09 ||= SuikaWiki::Plugin->module_package ('SuikaWiki09'))->get_xml_tree (text => $source, opt => $opt,
98 wiki => $self->{wiki});
99 my $param = SuikaWiki::Plugin::plugin::SuikaWikiImage091040731032808EjFd->_get_parameter_and_image ($xml);
100 my $fig = $opt->{-parent}->append_new_node
101 (type => '#element',
102 namespace_uri => q#http://www.w3.org/1999/xhtml#,
103 local_name => 'div');
104 $fig->set_attribute (class => 'fig');
105 my $img = $fig->append_new_node
106 (type => '#element',
107 namespace_uri => q#http://www.w3.org/1999/xhtml#,
108 local_name => 'img');
109 $img->option (use_EmptyElemTag => 1);
110 $img->set_attribute (src => $self->{wiki}->uri_reference
111 (page => $opt->{page},
112 mode => $MODE->{$param->{'image-type'}}
113 ->{mode},
114 with_lm => 1, base => 1));
115 $img->set_attribute (alt => $param->{'image-alt'});
116 $img->set_attribute (title => $opt->{page}->stringify
117 (wiki => $self->{wiki}));
118 $img->set_attribute (class => 'embed');
119 $img->set_attribute (longdesc => $self->{wiki}->uri_reference
120 (page => $opt->{page},
121 base => 1));
122 $img->set_attribute (type => $MODE->{$param->{'image-type'}}->{type});
123 #line 1 "(WikiPlugin module SuikaWikiImage09, chunk 4)"
124 }};
125 $Converter->{q#IMT:image/png\#\##} = {q#ToOctetStream#, sub {my ($self, $source, $opt) = @_;
126 #line 1 "(WikiPlugin module source swimg09.wp2, block //Converter/ToOctetStream)"
127 my $xml = ($SW09 ||= SuikaWiki::Plugin->module_package ('SuikaWiki09'))->get_xml_tree (text => $source, opt => $opt,
128 wiki => $self->{wiki});
129 my $param = SuikaWiki::Plugin::plugin::SuikaWikiImage091040731032808EjFd->_get_parameter_and_image ($xml);
130 unless ($param->{'image-type'} eq 'image/png') {
131 CORE::die "Image type $param->{'image-type'} not supported";
132 }
133 require MIME::Base64;
134 return MIME::Base64::decode_base64 ($param->{-body});
135 #line 1 "(WikiPlugin module SuikaWikiImage09, chunk 5)"
136 }, q#Type#, q#image/png#, q#serialized_type#, q#IMT:image/png\#\##, q#Type_param#, {}};
137 $Converter->{q#IMT:image/vnd.microsoft.icon\#\##} = {q#ToOctetStream#, sub {my ($self, $source, $opt) = @_;
138 #line 1 "(WikiPlugin module source swimg09.wp2, block //Converter/ToOctetStream)"
139 my $xml = ($SW09 ||= SuikaWiki::Plugin->module_package ('SuikaWiki09'))->get_xml_tree (text => $source, opt => $opt,
140 wiki => $self->{wiki});
141 my $param = SuikaWiki::Plugin::plugin::SuikaWikiImage091040731032808EjFd->_get_parameter_and_image ($xml);
142 unless ($param->{'image-type'} eq 'image/vnd.microsoft.icon' or
143 $param->{'image-type'} eq 'image/x-icon') {
144 CORE::die "Image type $param->{'image-type'} not supported";
145 }
146 require MIME::Base64;
147 return MIME::Base64::decode_base64 ($param->{-body});
148 #line 1 "(WikiPlugin module SuikaWikiImage09, chunk 6)"
149 }, q#Type#, q#image/vnd.microsoft.icon#, q#serialized_type#, q#IMT:image/vnd.microsoft.icon\#\##, q#Type_param#, {}};
150
151 package SuikaWiki::Plugin::plugin::SuikaWikiImage091040731032808EjFd;
152
153
154 sub _get_parameter_and_image {
155
156 #line 1 "(WikiPlugin module source swimg09.wp2, block Function[Name='_get_parameter_and_image']/Main)"
157 my (undef, $xml) = @_;
158 my %param;
159 for (@{$xml->child_nodes}) {
160 if ($_->node_type eq '#element' and
161 $_->local_name eq 'document') {
162 for (@{$_->child_nodes}) {
163 if ($_->node_type eq '#element') {
164 if ($_->local_name eq 'head') {
165 for (@{$_->child_nodes}) {
166 if ($_->node_type eq '#element' and
167 $_->local_name eq 'parameter') {
168 my $name = $_->get_attribute_value ('name');
169 for (@{$_->child_nodes}) {
170 if ($_->node_type eq '#element' and
171 $_->local_name eq 'value') {
172 $param{$name} = $_->inner_text;
173 }
174 }
175 }
176 }
177 } elsif ($_->local_name eq 'image') {
178 $param{-body} = $_->inner_text;
179 last;
180 }
181 }
182 }}}
183 \%param;
184 }
185
186 #line 1 "(WikiPlugin module SuikaWikiImage09, chunk 7)"
187
188
189 package SuikaWiki::Plugin::Resource;
190
191 our $BaseResource;
192 $BaseResource->{q#en#}->{q##}->{q#WikiFormat:MediaType:Description:IMT:text/x.suikawiki.image;version="0.9"\#\##} = q#SuikaWikiImage/0.9 (text format), i.e. SuikaWiki/0.9 + image embedding, as used in SuikaWiki 2#;
193 $BaseResource->{q#en#}->{q##}->{q#WikiFormat:MediaType:Label:IMT:text/x.suikawiki.image;version="0.9"\#\##} = q#SuikaWikiImage/0.9 (text format)#;
194 $BaseResource->{q#en#}->{q##}->{q#WikiFormat:MediaType:Description:MAGIC:SuikaWikiImage/0.9\#\##} = q#SuikaWikiImage/0.9 (text format), i.e. SuikaWiki/0.9 + image embedding, as used in SuikaWiki 2#;
195 $BaseResource->{q#en#}->{q##}->{q#WikiFormat:MediaType:Label:MAGIC:SuikaWikiImage/0.9\#\##} = q#SuikaWikiImage/0.9 (text format)#;
196 package SuikaWiki::Plugin::Registry;
197
198 $Info{q#SuikaWikiImage09#}->{provide} = {};
199
200 1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24