1 |
use strict; |
use strict; |
2 |
use warnings; |
use warnings; |
3 |
use feature 'state'; |
use feature 'state'; |
|
use UNIVERSAL::require; |
|
4 |
|
|
5 |
## --- Configurations |
## --- Configurations |
6 |
|
|
10 |
my $db_id_dir_name = $db_dir_name . q[ids/]; |
my $db_id_dir_name = $db_dir_name . q[ids/]; |
11 |
my $db_name_dir_name = $db_dir_name . q[names/]; |
my $db_name_dir_name = $db_dir_name . q[names/]; |
12 |
|
|
|
my @content_type = |
|
|
( |
|
|
{type => 'text/x-suikawiki', module => 'SWE::Lang::SWML', |
|
|
label => 'SWML'}, |
|
|
{type => 'text/x.suikawiki.image', module => 'SWE::Lang::SWML'}, |
|
|
{type => 'application/x.suikawiki.config'}, |
|
|
{type => 'text/plain', label => 'Plain text'}, |
|
|
{type => 'image/x-canvas-instructions+text', |
|
|
module => 'SWE::Lang::CanvasInstructions', |
|
|
label => 'Drawing'}, |
|
|
{type => 'text/css', label => 'CSS'}, |
|
|
); |
|
|
my %content_type = map { $_->{type} => $_ } @content_type; |
|
|
|
|
13 |
## --- Common modules |
## --- Common modules |
14 |
|
|
15 |
require Encode; |
require Encode; |
23 |
|
|
24 |
require Char::Normalize::FullwidthHalfwidth; |
require Char::Normalize::FullwidthHalfwidth; |
25 |
|
|
26 |
|
use SWE::Lang qw/@ContentMediaType/; |
27 |
|
|
28 |
## --- Prepares database access variables (commonly used ones) |
## --- Prepares database access variables (commonly used ones) |
29 |
|
|
30 |
require SWE::DB; |
require SWE::DB; |
1168 |
my $ct = $cgi->get_parameter ('content-type') // 'text/x-suikawiki'; |
my $ct = $cgi->get_parameter ('content-type') // 'text/x-suikawiki'; |
1169 |
|
|
1170 |
my $valid_ct; |
my $valid_ct; |
1171 |
for (@content_type) { |
for (@ContentMediaType) { |
1172 |
if ($_->{type} eq $ct) { |
if ($_->{type} eq $ct) { |
1173 |
$valid_ct = 1; |
$valid_ct = 1; |
1174 |
last; |
last; |
1187 |
$ct //= 'text/x-suikawiki'; |
$ct //= 'text/x-suikawiki'; |
1188 |
|
|
1189 |
my $has_ct; |
my $has_ct; |
1190 |
for (@content_type) { |
for (@ContentMediaType) { |
1191 |
next unless defined $_->{label}; |
next unless defined $_->{label}; |
1192 |
my $option_el = $doc->create_element_ns (HTML_NS, 'option'); |
my $option_el = $doc->create_element_ns (HTML_NS, 'option'); |
1193 |
$option_el->set_attribute (value => $_->{type}); |
$option_el->set_attribute (value => $_->{type}); |