| 1 |
wakaba |
1.1 |
use strict; |
| 2 |
|
|
package SuikaWiki::Plugin::Registry; |
| 3 |
|
|
|
| 4 |
|
|
|
| 5 |
|
|
our %Info; |
| 6 |
|
|
$Info{q#StyleSheet#}->{Name} = q#StyleSheet#; |
| 7 |
hero |
1.1.2.1 |
$Info{q#StyleSheet#}->{q#Version#} = q#2005.0121.1414#; |
| 8 |
wakaba |
1.1 |
$Info{q#StyleSheet#}->{q#InterfaceVersion#} = q#2.9.1#; |
| 9 |
|
|
$Info{q#StyleSheet#}->{q#mkpluginVersion#} = q#2.1.21#; |
| 10 |
hero |
1.1.2.1 |
$Info{q#StyleSheet#}->{q#module_name#} = q#SuikaWiki::Plugin::plugin::StyleSheet1050021141420JcOY#; |
| 11 |
wakaba |
1.1 |
$Info{q#StyleSheet#}->{q#Date.RCS#} = q#$Date: 2004/12/05 12:57:37 $#; |
| 12 |
|
|
$Info{q#StyleSheet#}->{RequiredPlugin} = [q#Error#, q#HTML#]; |
| 13 |
|
|
$Info{q#StyleSheet#}->{RequiredModule} = [q#URI#]; |
| 14 |
|
|
$Info{q#StyleSheet#}->{Description} = [[q#Stylesheet support#, q#en#, q##]]; |
| 15 |
|
|
$Info{q#StyleSheet#}->{License} = [[q#%%Perl%%#, q##, q##]]; |
| 16 |
|
|
$Info{q#StyleSheet#}->{Author} = [[[[q#Wakaba#, q#ja#, q#Latn#]], [[q#w@suika.fam.cx#]], [q##]]]; |
| 17 |
hero |
1.1.2.1 |
package SuikaWiki::Plugin::plugin::StyleSheet1050021141420JcOY; |
| 18 |
wakaba |
1.1 |
|
| 19 |
|
|
|
| 20 |
|
|
#line 1 "(WikiPlugin module source stylesheet.wp2, block Plugin/Use)" |
| 21 |
|
|
use URI; |
| 22 |
|
|
use Message::Util::Error; |
| 23 |
|
|
my $WIKIRESOURCE; |
| 24 |
|
|
#line 1 "(WikiPlugin module StyleSheet, chunk 1)" |
| 25 |
|
|
|
| 26 |
|
|
package SuikaWiki::Format::Definition::StyleSheet::CSS; |
| 27 |
|
|
|
| 28 |
|
|
our @ISA; |
| 29 |
|
|
push @ISA, 'SuikaWiki::Format::Definition::template'; |
| 30 |
|
|
$SuikaWiki::Format::Definition::Class{q#MAGIC:CSS/\#\##} = 'SuikaWiki::Format::Definition::StyleSheet::CSS'; |
| 31 |
|
|
$SuikaWiki::Format::Definition::Class{q#IMT:text/css\#\##} = 'SuikaWiki::Format::Definition::StyleSheet::CSS'; |
| 32 |
|
|
|
| 33 |
|
|
#line 1 "(WikiPlugin module source stylesheet.wp2, block Format[module-name()=SuikaWiki::Format::Definition::StyleSheet::CSS]/Use)" |
| 34 |
|
|
use Message::Markup::XML::QName qw(NS_xml_URI); |
| 35 |
|
|
#line 251 "(WikiPlugin module StyleSheet, chunk from ../../../bin/mkplugin2.pl)" |
| 36 |
|
|
our $Converter; |
| 37 |
|
|
sub convert ($$;%) { |
| 38 |
|
|
my ($self, $source, %opt) = @_; |
| 39 |
|
|
my $t = SuikaWiki::Format::Definition->serialize_media_type (%opt); |
| 40 |
|
|
my $converter = $Converter->{$t->{_}}; |
| 41 |
|
|
return ($converter->{$opt{return_type} or 'Main'} or |
| 42 |
|
|
CORE::die "Buggy implementation: $t->{_}/@{[$opt{return_type} or 'Main']} not defined") |
| 43 |
|
|
->($self, $source, \%opt) |
| 44 |
|
|
if $converter; |
| 45 |
|
|
local $Error::Depth = $Error::Depth + 1; |
| 46 |
|
|
$self->SUPER::convert ($source, %opt); |
| 47 |
|
|
} |
| 48 |
|
|
|
| 49 |
|
|
#line 1 "(WikiPlugin module StyleSheet, chunk 2)" |
| 50 |
|
|
$Converter->{q#IMT:text/css\#\##} = {q#Type#, q#text/css#, q#serialized_type#, q#IMT:text/css\#\##, q#ToString#, sub {my ($self, $source, $opt) = @_; |
| 51 |
|
|
#line 1 "(WikiPlugin module source stylesheet.wp2, block //Converter/ToString)" |
| 52 |
|
|
return $$source; |
| 53 |
|
|
#line 1 "(WikiPlugin module StyleSheet, chunk 3)" |
| 54 |
|
|
}, q#Type_param#, {}}; |
| 55 |
|
|
$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) = @_; |
| 56 |
|
|
#line 1 "(WikiPlugin module source stylesheet.wp2, block //Converter/Main)" |
| 57 |
|
|
my $node = $opt->{-parent}->append_new_node |
| 58 |
|
|
(type => '#element', |
| 59 |
|
|
namespace_uri => q#http://www.w3.org/1999/xhtml#, |
| 60 |
|
|
local_name => 'pre'); |
| 61 |
|
|
$node->set_attribute (class => 'text-css'); |
| 62 |
|
|
$node->set_attribute (space => 'preserve', namespace_uri => NS_xml_URI); |
| 63 |
|
|
$node->append_text ($$source); |
| 64 |
|
|
return $node; |
| 65 |
|
|
#line 1 "(WikiPlugin module StyleSheet, chunk 4)" |
| 66 |
|
|
}}; |
| 67 |
|
|
sub content_written { |
| 68 |
|
|
my ($self, %opt) = @_; |
| 69 |
|
|
#line 1 "(WikiPlugin module source stylesheet.wp2, block Format[module-name()=SuikaWiki::Format::Definition::StyleSheet::CSS]/content_written])" |
| 70 |
|
|
if ($opt{wiki}->{config}->{q#http://suika.fam.cx/~wakaba/archive/2004/05/sw-stylesheet\#use-static#}) { |
| 71 |
|
|
$opt{wiki}->{db}->set (static__css => $opt{page} => ${$opt{new_content}}); |
| 72 |
|
|
} |
| 73 |
|
|
#line 1 "(WikiPlugin module StyleSheet, chunk 5)" |
| 74 |
|
|
} |
| 75 |
|
|
sub content_removed { |
| 76 |
|
|
my ($self, %opt) = @_; |
| 77 |
|
|
#line 1 "(WikiPlugin module source stylesheet.wp2, block Format[module-name()=SuikaWiki::Format::Definition::StyleSheet::CSS]/content_removed])" |
| 78 |
|
|
if ($opt{wiki}->{config}->{q#http://suika.fam.cx/~wakaba/archive/2004/05/sw-stylesheet\#use-static#}) { |
| 79 |
|
|
$opt{wiki}->{db}->delete (static__css => $opt{page}); |
| 80 |
|
|
} |
| 81 |
|
|
#line 1 "(WikiPlugin module StyleSheet, chunk 6)" |
| 82 |
|
|
} |
| 83 |
|
|
sub content_type_changed_from { |
| 84 |
|
|
my ($self, %opt) = @_; |
| 85 |
|
|
#line 1 "(WikiPlugin module source stylesheet.wp2, block Format[module-name()=SuikaWiki::Format::Definition::StyleSheet::CSS]/content_type_changed_from])" |
| 86 |
|
|
if ($opt{wiki}->{config}->{q#http://suika.fam.cx/~wakaba/archive/2004/05/sw-stylesheet\#use-static#}) { |
| 87 |
|
|
$opt{wiki}->{db}->delete (static__css => $opt{page}); |
| 88 |
|
|
} |
| 89 |
|
|
#line 1 "(WikiPlugin module StyleSheet, chunk 7)" |
| 90 |
|
|
} |
| 91 |
|
|
sub prop ($$;%) { my ($self, $name, %opt) = @_;if ($name eq q#http://suika.fam.cx/~wakaba/-temp/2004/7/25/sw-edit\#new-mode--edit#) { return q#edit# } elsif ($name eq q#http://suika.fam.cx/~wakaba/-temp/2004/7/25/sw-edit\#new-mode--adminedit#) { return q#adminedit# } else {$self->SUPER::prop ($name, %opt);} |
| 92 |
|
|
} |
| 93 |
|
|
|
| 94 |
|
|
push @SuikaWiki::View::Implementation::CommonViewDefs, { |
| 95 |
|
|
condition => {q#mode#, q#css#, q#http_method#, [q#GET#, q#HEAD#, q#POST#]}, |
| 96 |
hero |
1.1.2.1 |
object_class => q#SuikaWiki::Plugin::plugin::StyleSheet1050021141420JcOY::css1050021141420Vkfx#, |
| 97 |
wakaba |
1.1 |
}; |
| 98 |
hero |
1.1.2.1 |
package SuikaWiki::Plugin::plugin::StyleSheet1050021141420JcOY::css1050021141420Vkfx; |
| 99 |
wakaba |
1.1 |
|
| 100 |
|
|
|
| 101 |
|
|
our @ISA = q#SuikaWiki::View::template#; |
| 102 |
|
|
|
| 103 |
|
|
sub main ($$$) { |
| 104 |
|
|
my ($self, $opt, $opt2) = @_; |
| 105 |
|
|
require SuikaWiki::Output::HTTP; |
| 106 |
|
|
$opt2->{output} = SuikaWiki::Output::HTTP->new |
| 107 |
|
|
(wiki => $self->{view}->{wiki}, |
| 108 |
|
|
view => $self->{view}, viewobj => $self); |
| 109 |
|
|
for (@{$self->{view}->{wiki}->{var}->{client}->{used_for_negotiate}}, |
| 110 |
|
|
'Accept-Language') { |
| 111 |
|
|
$opt2->{output}->add_negotiate_header_field ($_); |
| 112 |
|
|
} |
| 113 |
|
|
|
| 114 |
|
|
$opt2->{template} = q#%read (Type => {text/css}, return-type => {ToString}, |
| 115 |
|
|
when-no-converter => 406);#; |
| 116 |
|
|
$opt2->{o} = bless { |
| 117 |
|
|
## SuikaWiki 3 WikiPlugin interface |
| 118 |
|
|
wiki => $self->{view}->{wiki}, |
| 119 |
|
|
plugin => $self->{view}->{wiki}->{plugin}, |
| 120 |
|
|
var => {}, |
| 121 |
|
|
}, 'SuikaWiki::Plugin'; |
| 122 |
|
|
$opt2->{output}->{status_code} = 200; |
| 123 |
|
|
|
| 124 |
|
|
$opt2->{output}->{entity}->{media_type} = q#text/css#; |
| 125 |
|
|
|
| 126 |
|
|
$opt2->{output}->{entity}->{charset} = $self->{view}->{wiki}->{config}->{charset}->{output}; |
| 127 |
|
|
$opt2->{output}->set_expires (%{$self->{view}->{wiki}->{config}->{entity}->{expires}->{q#stylesheet#}}); |
| 128 |
|
|
$opt2->{output}->{entity}->{body_is_octet_stream} = 0; |
| 129 |
|
|
|
| 130 |
|
|
$self->{view}->{wiki}->init_db; |
| 131 |
|
|
$self->main_pre ($opt, $opt2); |
| 132 |
|
|
|
| 133 |
|
|
|
| 134 |
|
|
use Message::Util::Error; |
| 135 |
|
|
try { |
| 136 |
|
|
$opt2->{output}->{entity}->{body} |
| 137 |
|
|
= |
| 138 |
|
|
(SuikaWiki::Plugin->formatter ('view') |
| 139 |
|
|
->replace ($opt2->{template}, param => $opt2->{o})); |
| 140 |
|
|
} $self->{view}->{wiki}->{config}->{catch}->{ formatter_view }; |
| 141 |
|
|
$opt2->{output}->output (output => 'http-cgi'); |
| 142 |
|
|
|
| 143 |
|
|
$self->main_post ($opt, $opt2); |
| 144 |
|
|
} |
| 145 |
|
|
|
| 146 |
hero |
1.1.2.1 |
package SuikaWiki::Plugin::plugin::StyleSheet1050021141420JcOY; |
| 147 |
wakaba |
1.1 |
|
| 148 |
|
|
{my $def = {q#Parameter#, {}, q#Description#, [[q#Stylesheet list as HTML (link element)#, q#en#, q##]], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_; |
| 149 |
|
|
|
| 150 |
|
|
#line 1 "(WikiPlugin module source stylesheet.wp2, block FormattingRule[name()='[q#view#, q#view-resource#]/styles_wiki_html']/Formatting)" |
| 151 |
hero |
1.1.2.1 |
my $list = SuikaWiki::Plugin::plugin::StyleSheet1050021141420JcOY->_get_stylelist_definition_page |
| 152 |
wakaba |
1.1 |
(page => $o->{wiki}->name |
| 153 |
|
|
($p->{page} || |
| 154 |
|
|
$o->{wiki}->{config}->{page} |
| 155 |
|
|
->{'StyleSheetList(text/html)'} || |
| 156 |
|
|
[qw!Wiki Style List text/html!]), |
| 157 |
|
|
o => $o, wiki => $o->{wiki}); |
| 158 |
|
|
return unless $list; |
| 159 |
|
|
my $parent = $p->{-parent}; |
| 160 |
|
|
my $ua_apply; |
| 161 |
|
|
my $dg = $o->{wiki}->{var}->{client}->{downgrade}; |
| 162 |
|
|
if ($dg->{stylesheet_non_standard}) { |
| 163 |
|
|
$ua_apply = $dg->{ua_netscape4} ? 'Netscape4' |
| 164 |
|
|
: $dg->{ua_winie60} ? 'WinIE6.0' |
| 165 |
|
|
: $dg->{ua_winie55} ? 'WinIE5.5' |
| 166 |
|
|
: $dg->{ua_winie50} ? 'WinIE5.0' |
| 167 |
|
|
: $dg->{ua_winie40} ? 'WinIE4.0' |
| 168 |
|
|
: $dg->{ua_winie30} ? 'WinIE3.0' |
| 169 |
|
|
: 1; |
| 170 |
|
|
} |
| 171 |
|
|
my $mkuri = $o->{wiki}->{config}->{q#http://suika.fam.cx/~wakaba/archive/2004/05/sw-stylesheet\#wikiname-to-uri#} || |
| 172 |
hero |
1.1.2.1 |
\&SuikaWiki::Plugin::plugin::StyleSheet1050021141420JcOY::generate_uri; |
| 173 |
wakaba |
1.1 |
for my $set (@{$list->child_nodes}) { |
| 174 |
|
|
if ($set->local_name eq 'StyleSet') { |
| 175 |
|
|
my $apply = $set->get_attribute_value ('Apply', |
| 176 |
|
|
default => ['alternate'], |
| 177 |
|
|
as_array => 1); |
| 178 |
|
|
my $type = { |
| 179 |
|
|
map {$_ => 1} |
| 180 |
|
|
@$apply |
| 181 |
|
|
}; |
| 182 |
|
|
next if $ua_apply and not $type->{$ua_apply}; |
| 183 |
|
|
my $rel = $type->{alternate} ? 'alternate stylesheet' : 'stylesheet'; |
| 184 |
hero |
1.1.2.1 |
my $title = SuikaWiki::Plugin::plugin::StyleSheet1050021141420JcOY->_get_styleset_title |
| 185 |
wakaba |
1.1 |
(StyleSet => $set, o => $o, |
| 186 |
|
|
type => $type); |
| 187 |
|
|
for my $sheet (@{$set->child_nodes}) { |
| 188 |
|
|
if ($sheet->local_name eq 'StyleSheet') { |
| 189 |
|
|
my $stype = { |
| 190 |
|
|
map {$_ => 1} |
| 191 |
|
|
@{$sheet->get_attribute_value ('Apply', default => $apply, |
| 192 |
|
|
as_array => 1)} |
| 193 |
|
|
}; |
| 194 |
|
|
next if $ua_apply and not $stype->{$ua_apply}; |
| 195 |
|
|
next if not $ua_apply and (not $stype->{alternate} and |
| 196 |
|
|
not $stype->{preferred} and |
| 197 |
|
|
not $stype->{persistent}); |
| 198 |
|
|
my $link = $parent->append_new_node |
| 199 |
|
|
(type => '#element', |
| 200 |
|
|
namespace_uri => q#http://www.w3.org/1999/xhtml#, |
| 201 |
|
|
local_name => 'link'); |
| 202 |
|
|
$link->option (use_EmptyElemTag => 1); |
| 203 |
|
|
$link->set_attribute (rel => $rel); |
| 204 |
|
|
$link->set_attribute (title => $title) unless $type->{persistent}; |
| 205 |
|
|
my $media_type = $sheet->get_attribute_value |
| 206 |
|
|
('Type', default => 'text/css'); |
| 207 |
|
|
$link->set_attribute (type => $media_type); |
| 208 |
|
|
unless ($dg->{html_link_no_media}) { |
| 209 |
|
|
my $media_descriptor = $sheet->get_attribute_value ('Media'); |
| 210 |
|
|
$link->set_attribute (media => $media_descriptor || 'all'); |
| 211 |
|
|
} |
| 212 |
|
|
my $uri = $mkuri->(undef, o => $o, wiki => $o->{wiki}, |
| 213 |
|
|
wikiname => $o->{wiki}->name |
| 214 |
|
|
($sheet->get_attribute_value |
| 215 |
|
|
('WikiPage', default => '')), |
| 216 |
|
|
mode => 'css'); ## ISSUE: Make this media-type independent! |
| 217 |
|
|
$link->set_attribute (href => $uri); |
| 218 |
|
|
$parent->append_text ("\n"); |
| 219 |
|
|
} |
| 220 |
|
|
} |
| 221 |
|
|
} |
| 222 |
|
|
}}} |
| 223 |
|
|
#line 1 "(WikiPlugin module StyleSheet, chunk 8)" |
| 224 |
|
|
; |
| 225 |
|
|
$SuikaWiki::Plugin::Rule{view}->{styles_wiki_html} = $def; |
| 226 |
|
|
$SuikaWiki::Plugin::Rule{view_resource}->{styles_wiki_html} = $def; |
| 227 |
|
|
}; |
| 228 |
|
|
|
| 229 |
|
|
{my $def = {q#Parameter#, {q#downgrade_html#, {q#Type#, q#boolean#, q#Default#, q#"0"#, q#Description#, [[q#HTML downgrade mode. PIs are not outputed if User-Agent does not |
| 230 |
|
|
support PIs (eg. Classic Mozilla).#, q##, q##]]}}, q#Description#, [[q#Stylesheet list in xml-stylesheet processing instructions#, q#en#, q##]], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_; |
| 231 |
|
|
|
| 232 |
|
|
#line 1 "(WikiPlugin module source stylesheet.wp2, block FormattingRule[name()='[q#view#, q#view-resource#]/styles_wiki_xml']/Formatting)" |
| 233 |
|
|
$p->{q#downgrade_html#} = do { my $r = $f->parse_attr ($p=>q#downgrade_html#, $o, -non_parsed_to_node => 1, %opt); ref $r?$r->inner_text:$r}; |
| 234 |
|
|
if ($p->{downgrade_html}) { |
| 235 |
|
|
return if $o->{wiki}->{var}->{client}->{downgrade}->{html_no_pi}; |
| 236 |
|
|
} |
| 237 |
hero |
1.1.2.1 |
my $list = SuikaWiki::Plugin::plugin::StyleSheet1050021141420JcOY->_get_stylelist_definition_page |
| 238 |
wakaba |
1.1 |
(page => $o->{wiki}->name |
| 239 |
|
|
($p->{page} || |
| 240 |
|
|
$o->{wiki}->{config}->{page} |
| 241 |
|
|
->{'StyleSheetList(text/html)'} || |
| 242 |
|
|
[qw!Wiki Style List text/html!]), |
| 243 |
|
|
o => $o, wiki => $o->{wiki}); |
| 244 |
|
|
return unless $list; |
| 245 |
|
|
my $parent = $p->{-parent}; |
| 246 |
|
|
my $mkuri = $o->{wiki}->{config}->{q#http://suika.fam.cx/~wakaba/archive/2004/05/sw-stylesheet\#wikiname-to-uri#} || |
| 247 |
hero |
1.1.2.1 |
\&SuikaWiki::Plugin::plugin::StyleSheet1050021141420JcOY::generate_uri; |
| 248 |
wakaba |
1.1 |
for my $set (@{$list->child_nodes}) { |
| 249 |
|
|
if ($set->local_name eq 'StyleSet') { |
| 250 |
|
|
my $apply = $set->get_attribute_value |
| 251 |
|
|
('Apply', default => ['alternate'], |
| 252 |
|
|
as_array => 1); |
| 253 |
|
|
my $type = {map {$_ => 1} @$apply}; |
| 254 |
|
|
my $rel = $type->{alternate} ? 'alternate stylesheet' : 'stylesheet'; |
| 255 |
hero |
1.1.2.1 |
my $title = SuikaWiki::Plugin::plugin::StyleSheet1050021141420JcOY->_get_styleset_title |
| 256 |
wakaba |
1.1 |
(StyleSet => $set, o => $o, |
| 257 |
|
|
type => $type); |
| 258 |
|
|
for my $sheet (@{$set->child_nodes}) { |
| 259 |
|
|
if ($sheet->local_name eq 'StyleSheet') { |
| 260 |
|
|
my $stype = { |
| 261 |
|
|
map {$_ => 1} |
| 262 |
|
|
@{$sheet->get_attribute_value ('Apply', default => $apply, |
| 263 |
|
|
as_array => 1)} |
| 264 |
|
|
}; |
| 265 |
|
|
next if (not $stype->{alternate} and |
| 266 |
|
|
not $stype->{preferred} and |
| 267 |
|
|
not $stype->{persistent}); |
| 268 |
|
|
my $link = $parent->append_new_node |
| 269 |
|
|
(type => '#pi', |
| 270 |
|
|
local_name => 'xml-stylesheet'); |
| 271 |
|
|
$link->set_attribute (alternate => $type->{preferred} ? 'no' |
| 272 |
|
|
: 'yes') |
| 273 |
|
|
unless $type->{persistent}; |
| 274 |
|
|
$link->set_attribute (title => $title) unless $type->{persistent}; |
| 275 |
|
|
my $media_type = $sheet->get_attribute_value |
| 276 |
|
|
('Type', default => 'text/css'); |
| 277 |
|
|
$link->set_attribute (type => $media_type); |
| 278 |
|
|
unless ($o->{wiki}->{var}->{client}->{downgrade} |
| 279 |
|
|
->{html_link_no_media}) { |
| 280 |
|
|
my $media_descriptor = $sheet->get_attribute_value ('Media'); |
| 281 |
|
|
$link->set_attribute (media => $media_descriptor || 'all'); |
| 282 |
|
|
} |
| 283 |
|
|
my $uri = $mkuri->(undef, o => $o, wiki => $o->{wiki}, |
| 284 |
|
|
wikiname => $o->{wiki}->name |
| 285 |
|
|
($sheet->get_attribute_value |
| 286 |
|
|
('WikiPage', default => '')), |
| 287 |
|
|
lm => time, ## TODO: Should be last-modified |
| 288 |
|
|
mode => 'css'); ## ISSUE: Make this media-type independent! |
| 289 |
|
|
$link->set_attribute (href => $uri); |
| 290 |
|
|
$parent->append_text ("\n"); |
| 291 |
|
|
} |
| 292 |
|
|
} |
| 293 |
|
|
} |
| 294 |
|
|
}}} |
| 295 |
|
|
#line 1 "(WikiPlugin module StyleSheet, chunk 10)" |
| 296 |
|
|
; |
| 297 |
|
|
$SuikaWiki::Plugin::Rule{view}->{styles_wiki_xml} = $def; |
| 298 |
|
|
$SuikaWiki::Plugin::Rule{view_resource}->{styles_wiki_xml} = $def; |
| 299 |
|
|
}; |
| 300 |
|
|
|
| 301 |
|
|
|
| 302 |
|
|
sub generate_uri { |
| 303 |
|
|
|
| 304 |
|
|
#line 1 "(WikiPlugin module source stylesheet.wp2, block Function[Name='generate_uri']/Main)" |
| 305 |
|
|
my (undef, %opt) = @_; |
| 306 |
|
|
return $opt{wiki}->uri_reference |
| 307 |
|
|
(page => $opt{wikiname}, |
| 308 |
|
|
mode => $opt{mode}, |
| 309 |
|
|
with_lm => 1, base => 1); |
| 310 |
|
|
} |
| 311 |
|
|
|
| 312 |
|
|
#line 1 "(WikiPlugin module StyleSheet, chunk 12)" |
| 313 |
|
|
|
| 314 |
|
|
|
| 315 |
|
|
push @SuikaWiki::View::Implementation::CommonViewDefs, { |
| 316 |
|
|
condition => {q#mode#, q#ss__no_static#, q#http_method#, [q#GET#, q#HEAD#, q#POST#]}, |
| 317 |
hero |
1.1.2.1 |
object_class => q#SuikaWiki::Plugin::plugin::StyleSheet1050021141420JcOY::ss__no_static1050021141420hrFA#, |
| 318 |
wakaba |
1.1 |
}; |
| 319 |
hero |
1.1.2.1 |
package SuikaWiki::Plugin::plugin::StyleSheet1050021141420JcOY::ss__no_static1050021141420hrFA; |
| 320 |
wakaba |
1.1 |
|
| 321 |
|
|
|
| 322 |
|
|
our @ISA = q#SuikaWiki::View::template#; |
| 323 |
|
|
sub main ($$) { |
| 324 |
|
|
my ($self, $opt, $opt2) = @_; |
| 325 |
|
|
|
| 326 |
|
|
#line 1 "(WikiPlugin module source stylesheet.wp2, block ViewDefinition[Mode='ss__no_static']/method[Name='main'])" |
| 327 |
|
|
require SuikaWiki::Output::HTTP; |
| 328 |
|
|
my $wiki = $self->{view}->{wiki}; |
| 329 |
|
|
$wiki->init_db; |
| 330 |
|
|
GENSTATIC: { |
| 331 |
|
|
last GENSTATIC unless ref $wiki->{config}->{q#http://suika.fam.cx/~wakaba/archive/2004/05/sw-stylesheet\#uri-to-wikiname#} and |
| 332 |
|
|
$wiki->{config}->{q#http://suika.fam.cx/~wakaba/archive/2004/05/sw-stylesheet\#use-static#} and |
| 333 |
|
|
$wiki->{db} and $wiki->{input}; |
| 334 |
|
|
my $uri = $wiki->{input}->meta_variable ('REDIRECT_URL'); |
| 335 |
|
|
last GENSTATIC unless $uri; |
| 336 |
|
|
my $wn = $wiki->{config}->{q#http://suika.fam.cx/~wakaba/archive/2004/05/sw-stylesheet\#uri-to-wikiname#} |
| 337 |
|
|
->(undef, wiki => $wiki, |
| 338 |
|
|
uri => URI->new ($uri)); |
| 339 |
|
|
my $prop = $wiki->{db}->get (content_prop => $wn); |
| 340 |
|
|
my $mt = $prop->get_attribute_value (q#http://suika.fam.cx/~wakaba/-temp/2004/04/24/mt\#media-type#, |
| 341 |
|
|
default => '--'); |
| 342 |
|
|
last GENSTATIC unless $mt eq 'IMT:text/css##'; |
| 343 |
|
|
$wiki->{db}->set (static__css => $wn => |
| 344 |
|
|
$wiki->{db}->get (content => $wn)); |
| 345 |
|
|
$uri = $wiki->{config}->{q#http://suika.fam.cx/~wakaba/archive/2004/05/sw-stylesheet\#wikiname-to-uri#} |
| 346 |
|
|
->(undef, wiki => $wiki, |
| 347 |
|
|
wikiname => $wn); |
| 348 |
|
|
$uri = $uri->abs ($wiki->uri_reference); |
| 349 |
|
|
$uri->query (time); |
| 350 |
|
|
my $output = new SuikaWiki::Output::HTTP (wiki => $wiki); |
| 351 |
|
|
$output->set_redirect (uri => $uri, status_code => 303, |
| 352 |
|
|
status_phrase => 'Created'); |
| 353 |
|
|
$output->output (output => 'http-cgi'); |
| 354 |
|
|
return; |
| 355 |
|
|
} |
| 356 |
|
|
my $output = new SuikaWiki::Output::HTTP (wiki => $wiki); |
| 357 |
|
|
$output->{status_code} = 404; |
| 358 |
|
|
$output->{entity}->{media_type} = 'text/plain'; |
| 359 |
|
|
$output->{entity}->{body} = '404'; |
| 360 |
|
|
$output->output (output => 'http-cgi');} |
| 361 |
|
|
|
| 362 |
|
|
#line 1 "(WikiPlugin module StyleSheet, chunk 13)" |
| 363 |
|
|
|
| 364 |
hero |
1.1.2.1 |
package SuikaWiki::Plugin::plugin::StyleSheet1050021141420JcOY; |
| 365 |
wakaba |
1.1 |
|
| 366 |
|
|
{my $def = {q#Parameter#, {}, q#Description#, [[q#Select user preferred style#, q#en#, q##]], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_; |
| 367 |
|
|
|
| 368 |
|
|
#line 1 "(WikiPlugin module source stylesheet.wp2, block FormattingRule[name()='[q#view#, q#view-resource#, q#form-input#]/select_user_preferred_style']/Formatting)" |
| 369 |
|
|
$p->{q#page#} = do { my $r = $f->parse_attr ($p=>q#page#, $o, -non_parsed_to_node => 1, %opt); ref $r?$r->inner_text:$r}; |
| 370 |
hero |
1.1.2.1 |
my $list = SuikaWiki::Plugin::plugin::StyleSheet1050021141420JcOY->_get_stylelist_definition_page |
| 371 |
wakaba |
1.1 |
(page => $o->{wiki}->name |
| 372 |
|
|
($p->{page} || |
| 373 |
|
|
$o->{wiki}->{config}->{page} |
| 374 |
|
|
->{'StyleSheetList(text/html)'} || |
| 375 |
|
|
[qw!Wiki Style List text/html!]), |
| 376 |
|
|
o => $o, wiki => $o->{wiki}); |
| 377 |
|
|
return unless $list; |
| 378 |
|
|
my $form = $p->{-parent}->append_new_node |
| 379 |
|
|
(type => '#element', |
| 380 |
|
|
namespace_uri => q#http://www.w3.org/1999/xhtml#, |
| 381 |
|
|
local_name => 'form'); |
| 382 |
|
|
my $id = SuikaWiki::Plugin->module_package ('WikiFormCore') |
| 383 |
|
|
->control_id ($o, |
| 384 |
|
|
local_id => 'style-selector', |
| 385 |
|
|
require_local_id => 1); |
| 386 |
|
|
$form->set_attribute (id => $id->{global_id}); |
| 387 |
|
|
my $div = $form->append_new_node |
| 388 |
|
|
(type => '#element', |
| 389 |
|
|
namespace_uri => q#http://www.w3.org/1999/xhtml#, |
| 390 |
|
|
local_name => 'div'); |
| 391 |
|
|
my $parent = $div->append_new_node |
| 392 |
|
|
(type => '#element', |
| 393 |
|
|
namespace_uri => q#http://www.w3.org/1999/xhtml#, |
| 394 |
|
|
local_name => 'select'); |
| 395 |
|
|
$parent->set_attribute (id => $id->{global_id}.'-list'); |
| 396 |
|
|
my $default = $parent->append_new_node |
| 397 |
|
|
(type => '#element', |
| 398 |
|
|
namespace_uri => q#http://www.w3.org/1999/xhtml#, |
| 399 |
|
|
local_name => 'option'); |
| 400 |
|
|
$default->set_attribute (value => 'no-style'); |
| 401 |
|
|
$default->append_text (($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))->get (name => 'Style:Default', |
| 402 |
|
|
o => $o, wiki => $o->{wiki})); |
| 403 |
|
|
my $selected = 0; |
| 404 |
|
|
for my $set (@{$list->child_nodes}) { |
| 405 |
|
|
if ($set->local_name eq 'StyleSet') { |
| 406 |
|
|
my $type = {map {$_ => 1} |
| 407 |
|
|
@{ |
| 408 |
|
|
$set->get_attribute_value ('Apply', default => ['alternate']) |
| 409 |
|
|
}}; |
| 410 |
|
|
next unless $type->{preferred} or $type->{alternate}; |
| 411 |
hero |
1.1.2.1 |
my $title = SuikaWiki::Plugin::plugin::StyleSheet1050021141420JcOY->_get_styleset_title |
| 412 |
wakaba |
1.1 |
(StyleSet => $set, o => $o, |
| 413 |
|
|
type => $type); |
| 414 |
|
|
my $link = $parent->append_new_node |
| 415 |
|
|
(type => '#element', |
| 416 |
|
|
namespace_uri => q#http://www.w3.org/1999/xhtml#, |
| 417 |
|
|
local_name => 'option'); |
| 418 |
|
|
$link->set_attribute (selected => 'selected'), $selected = 1 |
| 419 |
|
|
if $type->{preferred}; |
| 420 |
|
|
$link->set_attribute (value => $title); |
| 421 |
|
|
$link->append_text ($title); |
| 422 |
|
|
$parent->append_text ("\n"); |
| 423 |
|
|
} |
| 424 |
|
|
} |
| 425 |
|
|
$default->set_attribute (selected => 'selected') unless $selected; |
| 426 |
|
|
for ($div->append_new_node (type => '#element', |
| 427 |
|
|
namespace_uri => q#http://www.w3.org/1999/xhtml#, |
| 428 |
|
|
local_name => 'input')) { |
| 429 |
|
|
$_->set_attribute (type => 'button'); |
| 430 |
|
|
$_->set_attribute (id => $id->{global_id}.'-save'); |
| 431 |
|
|
$_->set_attribute (value => ($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))->get |
| 432 |
|
|
(name => 'Style:Save', |
| 433 |
|
|
o => $o, wiki => $o->{wiki})); |
| 434 |
|
|
$_->set_attribute (class => 'save'); |
| 435 |
|
|
$_->option (use_EmptyElemTag => 1); |
| 436 |
|
|
} |
| 437 |
|
|
for ($div->append_new_node (type => '#element', |
| 438 |
|
|
namespace_uri => q#http://www.w3.org/1999/xhtml#, |
| 439 |
|
|
local_name => 'input')) { |
| 440 |
|
|
$_->set_attribute (type => 'reset'); |
| 441 |
|
|
$_->set_attribute (id => $id->{global_id}.'-reset'); |
| 442 |
|
|
$_->set_attribute (value => ($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))->get |
| 443 |
|
|
(name => 'Style:Reset', |
| 444 |
|
|
o => $o, wiki => $o->{wiki})); |
| 445 |
|
|
$_->set_attribute (class => 'reset'); |
| 446 |
|
|
$_->option (use_EmptyElemTag => 1); |
| 447 |
|
|
} |
| 448 |
|
|
$p->{q#expires#} = do { my $r = $f->parse_attr ($p=>q#expires#, $o, -non_parsed_to_node => 1, %opt); ref $r?$r->inner_text:$r}; |
| 449 |
|
|
my $cookie_path = $o->{wiki}->uri_reference->path; |
| 450 |
|
|
for ($div->append_new_node (type => '#element', |
| 451 |
|
|
namespace_uri => q#http://www.w3.org/1999/xhtml#, |
| 452 |
|
|
local_name => 'script')) { |
| 453 |
|
|
$_->set_attribute (type => $o->{wiki}->{var}->{client}->{downgrade} |
| 454 |
|
|
->{media_type_no_app_js} |
| 455 |
|
|
? 'text/javascript' |
| 456 |
|
|
: 'application/x-javascript'); |
| 457 |
|
|
$_->set_attribute (defer => 'defer'); |
| 458 |
|
|
$_->append_new_node (type => '#xml', value => <<EOH); |
| 459 |
|
|
function getCookieValue (name) { |
| 460 |
|
|
var c = document.cookie.split(';'); |
| 461 |
|
|
for (var i = 0; c.length > i; i++) { |
| 462 |
|
|
var v = c[i].split('='); |
| 463 |
|
|
if (v[0].replace(/^\\s+/,'').replace(/\\s+\$/,'') == name) { |
| 464 |
|
|
return decodeURIComponent (v[1].replace(/^\\s+/,'') |
| 465 |
|
|
.replace(/\\s+\$/,'')); |
| 466 |
|
|
} |
| 467 |
|
|
} |
| 468 |
|
|
return ''; |
| 469 |
|
|
} |
| 470 |
|
|
var selectList = document.getElementById('$id->{global_id}-list'); |
| 471 |
|
|
selectList.value = getCookieValue('Selected'); |
| 472 |
|
|
selectList.onchange = function () { |
| 473 |
|
|
var selectList = document.getElementById('$id->{global_id}-list'); |
| 474 |
|
|
for (var i = 0; document.styleSheets.length > i; i++) { |
| 475 |
|
|
var s = document.styleSheets.item(i); |
| 476 |
|
|
if (s.href != document.URL) { |
| 477 |
|
|
if (s.title) |
| 478 |
|
|
s.disabled = (s.title != selectList.value); |
| 479 |
|
|
} |
| 480 |
|
|
} |
| 481 |
|
|
} |
| 482 |
|
|
document.getElementById('$id->{global_id}-save').onclick = function () { |
| 483 |
|
|
var selectList = document.getElementById('$id->{global_id}-list'); |
| 484 |
|
|
var expires = new Date(); |
| 485 |
|
|
expires.setTime (expires.getTime() |
| 486 |
|
|
+ 1000*3600*24*@{[$p->{expires}||365]}); |
| 487 |
|
|
document.cookie = 'Selected=' + encodeURIComponent(selectList.value) |
| 488 |
|
|
+ ';path=$cookie_path;expires='+expires.toGMTString(); |
| 489 |
|
|
} |
| 490 |
|
|
document.getElementById('$id->{global_id}-reset').onclick = function () { |
| 491 |
|
|
var expires = new Date(); |
| 492 |
|
|
expires.setTime (expires.getTime() - 3600); |
| 493 |
|
|
document.cookie = 'Selected=;path=$cookie_path;expires=' |
| 494 |
|
|
+ expires.toGMTString(); |
| 495 |
|
|
} |
| 496 |
|
|
EOH |
| 497 |
|
|
}}} |
| 498 |
|
|
#line 1 "(WikiPlugin module StyleSheet, chunk 14)" |
| 499 |
|
|
; |
| 500 |
|
|
$SuikaWiki::Plugin::Rule{view}->{select_user_preferred_style} = $def; |
| 501 |
|
|
$SuikaWiki::Plugin::Rule{view_resource}->{select_user_preferred_style} = $def; |
| 502 |
|
|
$SuikaWiki::Plugin::Rule{form_input}->{select_user_preferred_style} = $def; |
| 503 |
|
|
}; |
| 504 |
|
|
|
| 505 |
|
|
{my $def = {q#Parameter#, {}, q#Description#, [[q#Applying user preferred style#, q#en#, q##]], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_; |
| 506 |
|
|
|
| 507 |
|
|
#line 1 "(WikiPlugin module source stylesheet.wp2, block FormattingRule[name()='[q#view#, q#view-resource#, q#form-input#]/apply_user_preferred_style']/Formatting)" |
| 508 |
|
|
for ($p->{-parent}->append_new_node |
| 509 |
|
|
(type => '#element', |
| 510 |
|
|
namespace_uri => q#http://www.w3.org/1999/xhtml#, |
| 511 |
|
|
local_name => 'script')) { |
| 512 |
|
|
$_->set_attribute (type => $o->{wiki}->{var}->{client}->{downgrade} |
| 513 |
|
|
->{media_type_no_app_js} |
| 514 |
|
|
? 'text/javascript' |
| 515 |
|
|
: 'application/x-javascript'); |
| 516 |
|
|
$_->set_attribute (defer => 'defer'); |
| 517 |
|
|
$_->append_new_node (type => '#xml', value => <<EOH); |
| 518 |
|
|
function getCookieValue (name) { |
| 519 |
|
|
var c = document.cookie.split(';'); |
| 520 |
|
|
for (var i = 0; c.length > i; i++) { |
| 521 |
|
|
var v = c[i].split('='); |
| 522 |
|
|
if (v[0].replace(/^\\s+/,'').replace(/\\s+\$/,'') == name) { |
| 523 |
|
|
return decodeURIComponent (v[1].replace(/^\\s+/,'') |
| 524 |
|
|
.replace(/\\s+\$/,'')); |
| 525 |
|
|
} |
| 526 |
|
|
} |
| 527 |
|
|
return ''; |
| 528 |
|
|
} |
| 529 |
|
|
var styleName = getCookieValue('Selected'); |
| 530 |
|
|
if (styleName) { |
| 531 |
|
|
for (var i = 0; document.styleSheets.length > i; i++) { |
| 532 |
|
|
var s = document.styleSheets.item(i); |
| 533 |
|
|
if (s.href != document.URL) { |
| 534 |
|
|
if (s.title) |
| 535 |
|
|
s.disabled = (s.title != styleName) ? true : false; |
| 536 |
|
|
} |
| 537 |
|
|
} |
| 538 |
|
|
} |
| 539 |
|
|
EOH |
| 540 |
|
|
}}} |
| 541 |
|
|
#line 1 "(WikiPlugin module StyleSheet, chunk 16)" |
| 542 |
|
|
; |
| 543 |
|
|
$SuikaWiki::Plugin::Rule{view}->{apply_user_preferred_style} = $def; |
| 544 |
|
|
$SuikaWiki::Plugin::Rule{view_resource}->{apply_user_preferred_style} = $def; |
| 545 |
|
|
$SuikaWiki::Plugin::Rule{form_input}->{apply_user_preferred_style} = $def; |
| 546 |
|
|
}; |
| 547 |
|
|
|
| 548 |
|
|
|
| 549 |
|
|
sub _get_stylelist_definition_page { |
| 550 |
|
|
|
| 551 |
|
|
#line 1 "(WikiPlugin module source stylesheet.wp2, block Function[Name='_get_stylelist_definition_page']/Main)" |
| 552 |
|
|
my (undef, %opt) = @_; |
| 553 |
|
|
my $content; |
| 554 |
|
|
my $content_prop; |
| 555 |
|
|
if ($opt{wiki}->{db}) { |
| 556 |
|
|
try { |
| 557 |
|
|
$content = $opt{wiki}->{db}->get (content => $opt{page}); |
| 558 |
|
|
$content_prop = $opt{wiki}->{db}->get (content_prop => $opt{page}); |
| 559 |
|
|
} catch SuikaWiki::DB::Util::Error with { |
| 560 |
|
|
my $err = shift; |
| 561 |
|
|
$err->throw if $err->{-type} eq 'ERROR_REPORTED'; |
| 562 |
|
|
$content = undef; |
| 563 |
|
|
}; |
| 564 |
|
|
} |
| 565 |
|
|
my $format = SuikaWiki::Plugin->module_package ('WikiFormat') |
| 566 |
|
|
->handler (\$content, |
| 567 |
|
|
content_prop => $content_prop, |
| 568 |
|
|
o => $opt{o}, |
| 569 |
|
|
wiki => $opt{o}->{wiki}); |
| 570 |
|
|
my $cfg; |
| 571 |
|
|
try { |
| 572 |
|
|
$cfg = $format->convert (\$content, |
| 573 |
|
|
Type => 'application/x.suikawiki.config', |
| 574 |
|
|
Type_param => {version => '2.0'}, |
| 575 |
|
|
o => $opt{o}, page => $opt{page}); |
| 576 |
|
|
} catch SuikaWiki::Format::Definition::error with { |
| 577 |
|
|
my $err = shift; |
| 578 |
|
|
if ($err->{-type} eq 'CONVERTER_NOT_FOUND') { |
| 579 |
|
|
SuikaWiki::Plugin->module_package ('Error') |
| 580 |
|
|
->report_error_simple |
| 581 |
|
|
($opt{o}->{wiki}, |
| 582 |
|
|
'Condition' => $err->stringify); |
| 583 |
|
|
} else { |
| 584 |
|
|
$err->throw; |
| 585 |
|
|
} |
| 586 |
|
|
}; |
| 587 |
|
|
$cfg; |
| 588 |
|
|
} |
| 589 |
|
|
|
| 590 |
|
|
#line 1 "(WikiPlugin module StyleSheet, chunk 18)" |
| 591 |
|
|
|
| 592 |
|
|
|
| 593 |
|
|
|
| 594 |
|
|
sub _get_styleset_title { |
| 595 |
|
|
|
| 596 |
|
|
#line 1 "(WikiPlugin module source stylesheet.wp2, block Function[Name='_get_styleset_title']/Main)" |
| 597 |
|
|
my (undef, %opt) = @_; |
| 598 |
|
|
my $title; |
| 599 |
|
|
if (not $opt{type}->{persistent}) { |
| 600 |
|
|
$title = $opt{StyleSet}->get_attribute_value |
| 601 |
|
|
('DisplayName', default => ''); |
| 602 |
|
|
if (length $title) { |
| 603 |
|
|
try { |
| 604 |
|
|
$title = SuikaWiki::Plugin->formatter ('view_resource') |
| 605 |
|
|
->replace ($title, |
| 606 |
|
|
param => $opt{o}) |
| 607 |
|
|
->inner_text; |
| 608 |
|
|
} catch Message::Util::Formatter::error with { |
| 609 |
|
|
my $err = shift; |
| 610 |
|
|
if ($err->{-object}->{-category_name} eq 'view_resource') { |
| 611 |
|
|
my $wiki = $err->{option}->{param}->{wiki}; |
| 612 |
|
|
SuikaWiki::Plugin->module_package ('Error') |
| 613 |
|
|
->reporting_formatting_template_error |
| 614 |
|
|
($err, $wiki, |
| 615 |
|
|
template => $title); |
| 616 |
|
|
} else { |
| 617 |
|
|
$err->throw; |
| 618 |
|
|
} |
| 619 |
|
|
$title ||= $opt{StyleSet}->get_attribute_value |
| 620 |
|
|
('Name', default => ''); |
| 621 |
|
|
}; |
| 622 |
|
|
} else { |
| 623 |
|
|
$title = $opt{StyleSet}->get_attribute_value ('Name', default => ''); |
| 624 |
|
|
} |
| 625 |
|
|
} |
| 626 |
|
|
return $title; |
| 627 |
|
|
} |
| 628 |
|
|
|
| 629 |
|
|
#line 1 "(WikiPlugin module StyleSheet, chunk 19)" |
| 630 |
|
|
|
| 631 |
|
|
|
| 632 |
|
|
{my $def = {q#Parameter#, {}, q#Description#, [[q#Select user preferred mode#, q#en#, q##]], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_; |
| 633 |
|
|
|
| 634 |
|
|
#line 1 "(WikiPlugin module source stylesheet.wp2, block FormattingRule[name()='[q#view#, q#view-resource#, q#form-input#]/select_user_preferred_mode']/Formatting)" |
| 635 |
|
|
my $list = [grep /^[0-9A-Za-z_]/, keys %{$o->{wiki}->{view}->{definition}}]; |
| 636 |
|
|
my $form = $p->{-parent}->append_new_node |
| 637 |
|
|
(type => '#element', |
| 638 |
|
|
namespace_uri => q#http://www.w3.org/1999/xhtml#, |
| 639 |
|
|
local_name => 'form'); |
| 640 |
|
|
my $id = SuikaWiki::Plugin->module_package ('WikiFormCore') |
| 641 |
|
|
->control_id ($o, |
| 642 |
|
|
local_id => 'spss--mode-selector', |
| 643 |
|
|
require_local_id => 1); |
| 644 |
|
|
$form->set_attribute (id => $id->{global_id}); |
| 645 |
|
|
my $div = $form->append_new_node |
| 646 |
|
|
(type => '#element', |
| 647 |
|
|
namespace_uri => q#http://www.w3.org/1999/xhtml#, |
| 648 |
|
|
local_name => 'div'); |
| 649 |
|
|
my $parent = $div->append_new_node |
| 650 |
|
|
(type => '#element', |
| 651 |
|
|
namespace_uri => q#http://www.w3.org/1999/xhtml#, |
| 652 |
|
|
local_name => 'select'); |
| 653 |
|
|
$parent->set_attribute (id => $id->{global_id}.'-list'); |
| 654 |
|
|
my $default = $parent->append_new_node |
| 655 |
|
|
(type => '#element', |
| 656 |
|
|
namespace_uri => q#http://www.w3.org/1999/xhtml#, |
| 657 |
|
|
local_name => 'option'); |
| 658 |
|
|
$default->set_attribute (value => 'default'); |
| 659 |
|
|
$default->append_text (($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))->get (name => 'Mode:Default', |
| 660 |
|
|
o => $o, wiki => $o->{wiki})); |
| 661 |
|
|
$default->set_attribute (selected => 'selected'); |
| 662 |
|
|
for my $set (@$list) { |
| 663 |
|
|
my $title = ($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))->get (name => 'Mode:'.$set, |
| 664 |
|
|
o => $o, wiki => $o->{wiki}); |
| 665 |
|
|
my $link = $parent->append_new_node |
| 666 |
|
|
(type => '#element', |
| 667 |
|
|
namespace_uri => q#http://www.w3.org/1999/xhtml#, |
| 668 |
|
|
local_name => 'option'); |
| 669 |
|
|
$link->set_attribute (value => $set); |
| 670 |
|
|
$link->append_text ($title); |
| 671 |
|
|
$parent->append_text ("\n"); |
| 672 |
|
|
} |
| 673 |
|
|
for ($div->append_new_node (type => '#element', |
| 674 |
|
|
namespace_uri => q#http://www.w3.org/1999/xhtml#, |
| 675 |
|
|
local_name => 'input')) { |
| 676 |
|
|
$_->set_attribute (type => 'button'); |
| 677 |
|
|
$_->set_attribute (id => $id->{global_id}.'-save'); |
| 678 |
|
|
$_->set_attribute (value => ($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))->get |
| 679 |
|
|
(name => 'Mode:Save', |
| 680 |
|
|
o => $o, wiki => $o->{wiki})); |
| 681 |
|
|
$_->set_attribute (class => 'save'); |
| 682 |
|
|
$_->option (use_EmptyElemTag => 1); |
| 683 |
|
|
} |
| 684 |
|
|
for ($div->append_new_node (type => '#element', |
| 685 |
|
|
namespace_uri => q#http://www.w3.org/1999/xhtml#, |
| 686 |
|
|
local_name => 'input')) { |
| 687 |
|
|
$_->set_attribute (type => 'reset'); |
| 688 |
|
|
$_->set_attribute (id => $id->{global_id}.'-reset'); |
| 689 |
|
|
$_->set_attribute (value => ($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))->get |
| 690 |
|
|
(name => 'Mode:Reset', |
| 691 |
|
|
o => $o, wiki => $o->{wiki})); |
| 692 |
|
|
$_->set_attribute (class => 'reset'); |
| 693 |
|
|
$_->option (use_EmptyElemTag => 1); |
| 694 |
|
|
} |
| 695 |
|
|
$p->{q#expires#} = do { my $r = $f->parse_attr ($p=>q#expires#, $o, -non_parsed_to_node => 1, %opt); ref $r?$r->inner_text:$r}; |
| 696 |
|
|
my $cookie_path = $o->{wiki}->uri_reference->path; |
| 697 |
|
|
for ($div->append_new_node (type => '#element', |
| 698 |
|
|
namespace_uri => q#http://www.w3.org/1999/xhtml#, |
| 699 |
|
|
local_name => 'script')) { |
| 700 |
|
|
$_->set_attribute (type => $o->{wiki}->{var}->{client}->{downgrade} |
| 701 |
|
|
->{media_type_no_app_js} |
| 702 |
|
|
? 'text/javascript' |
| 703 |
|
|
: 'application/x-javascript'); |
| 704 |
|
|
$_->set_attribute (defer => 'defer'); |
| 705 |
|
|
$_->append_new_node (type => '#xml', value => <<EOH); |
| 706 |
|
|
function getCookieValue (name) { |
| 707 |
|
|
var c = document.cookie.split(';'); |
| 708 |
|
|
for (var i = 0; c.length > i; i++) { |
| 709 |
|
|
var v = c[i].split('='); |
| 710 |
|
|
if (v[0].replace(/^\\s+/,'').replace(/\\s+\$/,'') == name) { |
| 711 |
|
|
return decodeURIComponent (v[1].replace(/^\\s+/,'') |
| 712 |
|
|
.replace(/\\s+\$/,'')); |
| 713 |
|
|
} |
| 714 |
|
|
} |
| 715 |
|
|
return ''; |
| 716 |
|
|
} |
| 717 |
|
|
document.getElementById ('$id->{global_id}-list').value |
| 718 |
|
|
= getCookieValue('SelectedMode'); |
| 719 |
|
|
document.getElementById ('$id->{global_id}-save').onclick = function () { |
| 720 |
|
|
var expires = new Date (); |
| 721 |
|
|
expires.setTime (expires.getTime () |
| 722 |
|
|
+ 1000*3600*24*@{[$p->{expires}||365]}); |
| 723 |
|
|
document.cookie = 'SelectedMode=' |
| 724 |
|
|
+ encodeURIComponent |
| 725 |
|
|
(document.getElementById('$id->{global_id}-list') |
| 726 |
|
|
.value) |
| 727 |
|
|
+ ';path=$cookie_path;expires=' |
| 728 |
|
|
+ expires.toGMTString (); |
| 729 |
|
|
} |
| 730 |
|
|
document.getElementById('$id->{global_id}-reset').onclick = function () { |
| 731 |
|
|
var expires = new Date(); |
| 732 |
|
|
expires.setTime (expires.getTime() - 3600); |
| 733 |
|
|
document.cookie = 'SelectedMode=;path=$cookie_path;expires=' |
| 734 |
|
|
+ expires.toGMTString(); |
| 735 |
|
|
} |
| 736 |
|
|
EOH |
| 737 |
|
|
}}} |
| 738 |
|
|
#line 1 "(WikiPlugin module StyleSheet, chunk 20)" |
| 739 |
|
|
; |
| 740 |
|
|
$SuikaWiki::Plugin::Rule{view}->{select_user_preferred_mode} = $def; |
| 741 |
|
|
$SuikaWiki::Plugin::Rule{view_resource}->{select_user_preferred_mode} = $def; |
| 742 |
|
|
$SuikaWiki::Plugin::Rule{form_input}->{select_user_preferred_mode} = $def; |
| 743 |
|
|
}; |
| 744 |
|
|
|
| 745 |
|
|
push @{$SuikaWiki::View::Implementation::TemplateFragment{q#ht__stylesheets_html#}}, { |
| 746 |
|
|
Main => q#%styles-wiki-html;#, |
| 747 |
|
|
Order => 0, |
| 748 |
|
|
Description => [[q#Default stylesheets links#, q#en#, q##]], |
| 749 |
|
|
}; |
| 750 |
|
|
|
| 751 |
|
|
push @{$SuikaWiki::View::Implementation::TemplateFragment{q#ht__pre_element_content#}}, { |
| 752 |
|
|
Main => q#%styles-wiki-xml (downgrade-html);#, |
| 753 |
|
|
Order => 0, |
| 754 |
|
|
Description => [[q#Default stylesheets links (as xml-stylesheet PIs)#, q#en#, q##]], |
| 755 |
|
|
}; |
| 756 |
|
|
|
| 757 |
|
|
push @{$SuikaWiki::View::Implementation::TemplateFragment{q#ws__footer#}}, { |
| 758 |
|
|
Main => q#%apply-user-preferred-style;#, |
| 759 |
|
|
Order => 100000, |
| 760 |
|
|
Description => [[q#Apply user selected stylesheets#, q#en#, q##]], |
| 761 |
|
|
}; |
| 762 |
|
|
|
| 763 |
|
|
package SuikaWiki::Plugin::Resource; |
| 764 |
|
|
|
| 765 |
|
|
our $BaseResource; |
| 766 |
|
|
$BaseResource->{q#en#}->{q##}->{q#Mode:css#} = q#Cascading Style Sheet output#; |
| 767 |
|
|
$BaseResource->{q#en#}->{q##}->{q#Mode:Default#} = q#Default#; |
| 768 |
|
|
$BaseResource->{q#en#}->{q##}->{q#Mode:Reset#} = q#Reset default mode selection#; |
| 769 |
|
|
$BaseResource->{q#en#}->{q##}->{q#Mode:Save#} = q#Save default mode selection#; |
| 770 |
|
|
$BaseResource->{q#und#}->{q##}->{q#Style:Default#} = q#Basic Page Style#; |
| 771 |
|
|
$BaseResource->{q#en#}->{q##}->{q#Style:Reset#} = q#Reset style selection#; |
| 772 |
|
|
$BaseResource->{q#en#}->{q##}->{q#Style:Save#} = q#Save style selection#; |
| 773 |
|
|
$BaseResource->{q#en#}->{q##}->{q#WikiFormat:MediaType:Description:IMT:text/css\#\##} = q#CSS (Cascading Style Sheets)#; |
| 774 |
|
|
$BaseResource->{q#en#}->{q##}->{q#WikiFormat:MediaType:Label:IMT:text/css\#\##} = q#CSS#; |
| 775 |
|
|
package SuikaWiki::Plugin::Registry; |
| 776 |
|
|
|
| 777 |
|
|
$Info{q#StyleSheet#}->{provide} = {q#rule#, {q#form_input#, [q#select_user_preferred_style#, q#apply_user_preferred_style#, q#select_user_preferred_mode#], q#view#, [q#styles_wiki_html#, q#styles_wiki_xml#, q#select_user_preferred_style#, q#apply_user_preferred_style#, q#select_user_preferred_mode#], q#view_resource#, [q#styles_wiki_html#, q#styles_wiki_xml#, q#select_user_preferred_style#, q#apply_user_preferred_style#, q#select_user_preferred_mode#]}, q#viewfragment#, [{q#Name#, q#ht__stylesheets_html#}, {q#Name#, q#ht__pre_element_content#}, {q#Name#, q#ws__footer#}], q#viewdef#, [{q#Description#, [q#CSS Style Sheet#, q#en#, q##], q#Name#, q#css#}, {q#Description#, [q#Generate static version#, q#en#, q##], q#Name#, q#ss__no_static#}]}; |
| 778 |
|
|
|
| 779 |
|
|
1; |