| 1 |
wakaba |
1.1 |
#?SuikaWikiConfig/2.0 |
| 2 |
|
|
|
| 3 |
|
|
Plugin: |
| 4 |
|
|
@Name: SuikaWikiImage09 |
| 5 |
|
|
@Description: |
| 6 |
|
|
@@@: SuikaWikiImage/0.9 support |
| 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.2 |
@Date.RCS: $Date: 2004/02/08 08:47:26 $ |
| 16 |
wakaba |
1.1 |
@RequiredModule[list]: |
| 17 |
|
|
@RequiredPlugin[list]: |
| 18 |
|
|
SuikaWiki09 |
| 19 |
|
|
@Use: |
| 20 |
|
|
my $SW09; |
| 21 |
|
|
my $WIKIRESOURCE; |
| 22 |
|
|
|
| 23 |
|
|
my $MODE = { |
| 24 |
|
|
'image/vnd.microsoft.icon' => { |
| 25 |
|
|
mode => 'image-x-icon', |
| 26 |
|
|
type => 'image/vnd.microsoft.icon', |
| 27 |
|
|
suffix => 'ico', |
| 28 |
|
|
}, |
| 29 |
|
|
'image/x-icon' => { |
| 30 |
|
|
mode => 'image-x-icon', |
| 31 |
|
|
type => 'image/vnd.microsoft.icon', |
| 32 |
|
|
suffix => 'ico', |
| 33 |
|
|
}, |
| 34 |
|
|
'image/jpeg' => { |
| 35 |
|
|
mode => 'image-jpeg', |
| 36 |
|
|
type => 'image/jpeg', |
| 37 |
|
|
suffix => 'jpeg', |
| 38 |
|
|
}, |
| 39 |
|
|
'image/png' => { |
| 40 |
|
|
mode => 'image-png', |
| 41 |
|
|
type => 'image/png', |
| 42 |
|
|
suffix => 'png', |
| 43 |
|
|
}, |
| 44 |
|
|
}; |
| 45 |
|
|
|
| 46 |
|
|
PluginConst: |
| 47 |
|
|
@NS_XHTML1: |
| 48 |
|
|
http://www.w3.org/1999/xhtml |
| 49 |
|
|
@NS_SW09: |
| 50 |
|
|
urn:x-suika-fam-cx:markup:suikawiki:0:9: |
| 51 |
|
|
@SW09: |
| 52 |
|
|
{($SW09 ||= SuikaWiki::Plugin->module_package ('SuikaWiki09'))} |
| 53 |
|
|
@WIKIRESOURCE: |
| 54 |
|
|
{($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))} |
| 55 |
|
|
|
| 56 |
|
|
Format: |
| 57 |
|
|
@Name: SuikaWikiImage |
| 58 |
|
|
@Version: 0.9 |
| 59 |
|
|
@Type: |
| 60 |
|
|
@@@: text/x.suikawiki.image |
| 61 |
|
|
@@version: 0.9 |
| 62 |
|
|
@ModuleName: |
| 63 |
|
|
SuikaWiki::Image::V0_9 |
| 64 |
|
|
@Inherit[list]: |
| 65 |
|
|
SuikaWiki::V0_9 |
| 66 |
|
|
@Description: |
| 67 |
|
|
@@@: SuikaWikiImage/0.9 document with an image format |
| 68 |
|
|
@@lang:en |
| 69 |
|
|
|
| 70 |
|
|
@Converter: |
| 71 |
|
|
@@Type: text/html |
| 72 |
|
|
@@IsFragment: 1 |
| 73 |
|
|
@@Description: |
| 74 |
|
|
@@@@: Converting SuikaWikiImage/0.9 to Hypertext Markup Language fragment |
| 75 |
|
|
@@@lang:en |
| 76 |
|
|
@@Main: |
| 77 |
|
|
$opt->{o}->{wiki} ||= $self->{wiki}; |
| 78 |
|
|
|
| 79 |
|
|
## Text format -> XML format |
| 80 |
|
|
my $xml = $SW09->get_xml_tree (text => $source, opt => $opt, |
| 81 |
|
|
wiki => $self->{wiki}); |
| 82 |
|
|
|
| 83 |
|
|
$self->convert ($source, %$opt, |
| 84 |
|
|
Type => 'text/html', IsFragment => 1, |
| 85 |
|
|
IsPlaceholder => 1); |
| 86 |
|
|
|
| 87 |
|
|
## SuikaWiki/0.9 -> XHTML 1 |
| 88 |
|
|
$SW09->sw09_to_xhtml1 (source => $xml, parent => $opt->{-parent}, |
| 89 |
|
|
o => $opt->{o}, page => $opt->{page}); |
| 90 |
|
|
|
| 91 |
|
|
if ($opt->{-with_annotation_input}) { |
| 92 |
|
|
SuikaWiki::Plugin->module_package ('WikiFormCore') |
| 93 |
|
|
->make_content_form_in_html |
| 94 |
|
|
($opt->{-parent}, |
| 95 |
|
|
$WIKIRESOURCE->get |
| 96 |
|
|
(name => 'SuikaWiki/0.9:form:footannotate:input', |
| 97 |
|
|
o => $opt->{o}, wiki => $opt->{o}->{wiki}), |
| 98 |
|
|
option => $WIKIRESOURCE->get |
| 99 |
|
|
(name => 'SuikaWiki/0.9:form:footannotate:option', |
| 100 |
|
|
o => $opt->{o}, wiki => $opt->{o}->{wiki}), |
| 101 |
|
|
o => $opt->{o}, |
| 102 |
|
|
wiki => $opt->{o}->{wiki}, |
| 103 |
|
|
output => { |
| 104 |
|
|
page => $opt->{page}, |
| 105 |
|
|
}); |
| 106 |
|
|
} |
| 107 |
|
|
|
| 108 |
|
|
@Converter: |
| 109 |
|
|
@@Type: text/html |
| 110 |
|
|
@@IsFragment: 1 |
| 111 |
|
|
@@IsPlaceholder: 1 |
| 112 |
|
|
@@Description: |
| 113 |
|
|
@@@@: |
| 114 |
|
|
Placeholder for image embedding |
| 115 |
|
|
@@@lang: en |
| 116 |
|
|
@@Main: |
| 117 |
|
|
|
| 118 |
|
|
## Text format -> XML format |
| 119 |
|
|
my $xml = $SW09->get_xml_tree (text => $source, opt => $opt, |
| 120 |
|
|
wiki => $self->{wiki}); |
| 121 |
|
|
my $param = __FUNCPACK__->_get_parameter_and_image ($xml); |
| 122 |
|
|
|
| 123 |
|
|
my $fig = $opt->{-parent}->append_new_node |
| 124 |
|
|
(type => '#element', |
| 125 |
|
|
namespace_uri => $NS_XHTML1, |
| 126 |
|
|
local_name => 'div'); |
| 127 |
|
|
$fig->set_attribute (class => 'fig'); |
| 128 |
|
|
|
| 129 |
|
|
my $img = $fig->append_new_node |
| 130 |
|
|
(type => '#element', |
| 131 |
|
|
namespace_uri => $NS_XHTML1, |
| 132 |
|
|
local_name => 'img'); |
| 133 |
|
|
$img->option (use_EmptyElemTag => 1); |
| 134 |
|
|
$img->set_attribute (src => $self->{wiki}->uri_reference |
| 135 |
|
|
(page => $opt->{page}, |
| 136 |
|
|
mode => $MODE->{$param->{'image-type'}} |
| 137 |
|
|
->{mode}, |
| 138 |
|
|
with_lm => 1, base => 1)); |
| 139 |
|
|
$img->set_attribute (alt => $param->{'image-alt'}); |
| 140 |
|
|
$img->set_attribute (title => $opt->{page}->stringify |
| 141 |
|
|
(wiki => $self->{wiki})); |
| 142 |
|
|
$img->set_attribute (class => 'embed'); |
| 143 |
|
|
$img->set_attribute (longdesc => $self->{wiki}->uri_reference |
| 144 |
|
|
(page => $opt->{page}, |
| 145 |
|
|
base => 1)); |
| 146 |
|
|
$img->set_attribute (type => $MODE->{$param->{'image-type'}}->{type}); |
| 147 |
|
|
|
| 148 |
|
|
@Converter: |
| 149 |
|
|
@@Type: image/png |
| 150 |
|
|
@@ToOctetStream: |
| 151 |
|
|
## Text format -> XML format |
| 152 |
|
|
my $xml = $SW09->get_xml_tree (text => $source, opt => $opt, |
| 153 |
|
|
wiki => $self->{wiki}); |
| 154 |
|
|
my $param = __FUNCPACK__->_get_parameter_and_image ($xml); |
| 155 |
|
|
|
| 156 |
|
|
unless ($param->{'image-type'} eq 'image/png') { |
| 157 |
|
|
## TODO: |
| 158 |
|
|
CORE::die "Image type $param->{'image-type'} not supported"; |
| 159 |
|
|
} |
| 160 |
|
|
|
| 161 |
|
|
require MIME::Base64; |
| 162 |
|
|
return MIME::Base64::decode_base64 ($param->{-body}); |
| 163 |
|
|
|
| 164 |
|
|
@Converter: |
| 165 |
|
|
@@Type: image/vnd.microsoft.icon |
| 166 |
|
|
@@ToOctetStream: |
| 167 |
|
|
## Text format -> XML format |
| 168 |
|
|
my $xml = $SW09->get_xml_tree (text => $source, opt => $opt, |
| 169 |
|
|
wiki => $self->{wiki}); |
| 170 |
|
|
my $param = __FUNCPACK__->_get_parameter_and_image ($xml); |
| 171 |
|
|
|
| 172 |
|
|
unless ($param->{'image-type'} eq 'image/vnd.microsoft.icon' or |
| 173 |
|
|
$param->{'image-type'} eq 'image/x-icon') { |
| 174 |
|
|
## TODO: |
| 175 |
|
|
CORE::die "Image type $param->{'image-type'} not supported"; |
| 176 |
|
|
} |
| 177 |
|
|
|
| 178 |
|
|
require MIME::Base64; |
| 179 |
|
|
return MIME::Base64::decode_base64 ($param->{-body}); |
| 180 |
|
|
|
| 181 |
|
|
Function: |
| 182 |
|
|
@Name: _get_parameter_and_image |
| 183 |
|
|
@Main: |
| 184 |
|
|
my (undef, $xml) = @_; |
| 185 |
|
|
my %param; |
| 186 |
|
|
for (@{$xml->child_nodes}) { |
| 187 |
|
|
if ($_->node_type eq '#element' and |
| 188 |
|
|
$_->local_name eq 'document') { |
| 189 |
|
|
for (@{$_->child_nodes}) { |
| 190 |
|
|
if ($_->node_type eq '#element') { |
| 191 |
|
|
if ($_->local_name eq 'head') { |
| 192 |
|
|
for (@{$_->child_nodes}) { |
| 193 |
|
|
if ($_->node_type eq '#element' and |
| 194 |
|
|
$_->local_name eq 'parameter') { |
| 195 |
|
|
my $name = $_->get_attribute_value ('name'); |
| 196 |
|
|
for (@{$_->child_nodes}) { |
| 197 |
|
|
if ($_->node_type eq '#element' and |
| 198 |
|
|
$_->local_name eq 'value') { |
| 199 |
|
|
$param{$name} = $_->inner_text; |
| 200 |
|
|
} |
| 201 |
|
|
} |
| 202 |
|
|
} |
| 203 |
|
|
} |
| 204 |
|
|
} elsif ($_->local_name eq 'image') { |
| 205 |
|
|
$param{-body} = $_->inner_text; |
| 206 |
|
|
last; |
| 207 |
|
|
} |
| 208 |
|
|
} |
| 209 |
|
|
}}} |
| 210 |
|
|
\ \%param; |
| 211 |
wakaba |
1.2 |
|
| 212 |
|
|
Resource: |
| 213 |
|
|
@WikiFormat:MediaType:Description:IMT:text/x.suikawiki.image;version="0.9"##: |
| 214 |
|
|
@@@: |
| 215 |
|
|
SuikaWikiImage/0.9 (text format), i.e. SuikaWiki/0.9 + image embedding, |
| 216 |
|
|
as used in SuikaWiki 2 |
| 217 |
|
|
@@lang: en |
| 218 |
|
|
@WikiFormat:MediaType:Label:IMT:text/x.suikawiki.image;version="0.9"##: |
| 219 |
|
|
@@@: SuikaWikiImage/0.9 (text format) |
| 220 |
|
|
@@lang: en |
| 221 |
|
|
@WikiFormat:MediaType:Description:MAGIC:SuikaWikiImage/0.9##: |
| 222 |
|
|
@@@: |
| 223 |
|
|
SuikaWikiImage/0.9 (text format), i.e. SuikaWiki/0.9 + image embedding, |
| 224 |
|
|
as used in SuikaWiki 2 |
| 225 |
|
|
@@lang: en |
| 226 |
|
|
@WikiFormat:MediaType:Label:MAGIC:SuikaWikiImage/0.9##: |
| 227 |
|
|
@@@: SuikaWikiImage/0.9 (text format) |
| 228 |
|
|
@@lang: en |
| 229 |
|
|
|
| 230 |
|
|
|
| 231 |
|
|
|
| 232 |
wakaba |
1.1 |
|