use strict; package SuikaWiki::Plugin::Registry; our %Info; $Info{q#StyleSheet#}->{Name} = q#StyleSheet#; $Info{q#StyleSheet#}->{q#Version#} = q#2005.0315.0849#; $Info{q#StyleSheet#}->{q#InterfaceVersion#} = q#2.9.1#; $Info{q#StyleSheet#}->{q#mkpluginVersion#} = q#2.1.21#; $Info{q#StyleSheet#}->{q#module_name#} = q#SuikaWiki::Plugin::plugin::StyleSheet1050215084916LDrj#; $Info{q#StyleSheet#}->{q#Date.RCS#} = q#$Date: 2010/05/16 23:05:50 $#; $Info{q#StyleSheet#}->{RequiredPlugin} = [q#Error#, q#HTML#]; $Info{q#StyleSheet#}->{RequiredModule} = [q#URI#]; $Info{q#StyleSheet#}->{Description} = [[q#Stylesheet support#, q#en#, q##]]; $Info{q#StyleSheet#}->{License} = [[q#%%Perl%%#, q##, q##]]; $Info{q#StyleSheet#}->{Author} = [[[[q#Wakaba#, q#ja#, q#Latn#]], [[q#w@suika.fam.cx#]], [q##]]]; package SuikaWiki::Plugin::plugin::StyleSheet1050215084916LDrj; #line 1 "(WikiPlugin module source stylesheet.wp2, block Plugin/Use)" use URI; use Message::Util::Error; my $WIKIRESOURCE; #line 1 "(WikiPlugin module StyleSheet, chunk 1)" package SuikaWiki::Format::Definition::StyleSheet::CSS; our @ISA; push @ISA, 'SuikaWiki::Format::Definition::template'; $SuikaWiki::Format::Definition::Class{q#MAGIC:CSS/\#\##} = 'SuikaWiki::Format::Definition::StyleSheet::CSS'; $SuikaWiki::Format::Definition::Class{q#IMT:text/css\#\##} = 'SuikaWiki::Format::Definition::StyleSheet::CSS'; #line 1 "(WikiPlugin module source stylesheet.wp2, block Format[module-name()=SuikaWiki::Format::Definition::StyleSheet::CSS]/Use)" use Message::Markup::XML::QName qw(NS_xml_URI); #line 251 "(WikiPlugin module StyleSheet, chunk from ../../../bin/mkplugin2.pl)" our $Converter; sub convert ($$;%) { my ($self, $source, %opt) = @_; my $t = SuikaWiki::Format::Definition->serialize_media_type (%opt); my $converter = $Converter->{$t->{_}}; return ($converter->{$opt{return_type} or 'Main'} or CORE::die "Buggy implementation: $t->{_}/@{[$opt{return_type} or 'Main']} not defined") ->($self, $source, \%opt) if $converter; local $Error::Depth = $Error::Depth + 1; $self->SUPER::convert ($source, %opt); } #line 1 "(WikiPlugin module StyleSheet, chunk 2)" $Converter->{q#IMT:text/css\#\##} = {q#Type#, q#text/css#, q#serialized_type#, q#IMT:text/css\#\##, q#ToString#, sub {my ($self, $source, $opt) = @_; #line 1 "(WikiPlugin module source stylesheet.wp2, block //Converter/ToString)" return $$source; #line 1 "(WikiPlugin module StyleSheet, chunk 3)" }, q#Type_param#, {}}; $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) = @_; #line 1 "(WikiPlugin module source stylesheet.wp2, block //Converter/Main)" my $node = $opt->{-parent}->append_new_node (type => '#element', namespace_uri => q#http://www.w3.org/1999/xhtml#, local_name => 'pre'); $node->set_attribute (class => 'text-css'); $node->set_attribute (space => 'preserve', namespace_uri => NS_xml_URI); $node->append_text ($$source); return $node; #line 1 "(WikiPlugin module StyleSheet, chunk 4)" }}; sub content_written { my ($self, %opt) = @_; #line 1 "(WikiPlugin module source stylesheet.wp2, block Format[module-name()=SuikaWiki::Format::Definition::StyleSheet::CSS]/content_written])" if ($opt{wiki}->{config}->{q#http://suika.fam.cx/~wakaba/archive/2004/05/sw-stylesheet\#use-static#}) { $opt{wiki}->{db}->set (static__css => $opt{page} => ${$opt{new_content}}); } #line 1 "(WikiPlugin module StyleSheet, chunk 5)" } sub content_removed { my ($self, %opt) = @_; #line 1 "(WikiPlugin module source stylesheet.wp2, block Format[module-name()=SuikaWiki::Format::Definition::StyleSheet::CSS]/content_removed])" if ($opt{wiki}->{config}->{q#http://suika.fam.cx/~wakaba/archive/2004/05/sw-stylesheet\#use-static#}) { $opt{wiki}->{db}->delete (static__css => $opt{page}); } #line 1 "(WikiPlugin module StyleSheet, chunk 6)" } sub content_type_changed_from { my ($self, %opt) = @_; #line 1 "(WikiPlugin module source stylesheet.wp2, block Format[module-name()=SuikaWiki::Format::Definition::StyleSheet::CSS]/content_type_changed_from])" if ($opt{wiki}->{config}->{q#http://suika.fam.cx/~wakaba/archive/2004/05/sw-stylesheet\#use-static#}) { $opt{wiki}->{db}->delete (static__css => $opt{page}); } #line 1 "(WikiPlugin module StyleSheet, chunk 7)" } 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);} } push @SuikaWiki::View::Implementation::CommonViewDefs, { condition => {q#mode#, q#css#, q#http_method#, [q#GET#, q#HEAD#, q#POST#]}, object_class => q#SuikaWiki::Plugin::plugin::StyleSheet1050215084916LDrj::css105021508491663oY#, }; package SuikaWiki::Plugin::plugin::StyleSheet1050215084916LDrj::css105021508491663oY; our @ISA = q#SuikaWiki::View::template#; sub main ($$$) { my ($self, $opt, $opt2) = @_; require SuikaWiki::Output::HTTP; $opt2->{output} = SuikaWiki::Output::HTTP->new (wiki => $self->{view}->{wiki}, view => $self->{view}, viewobj => $self); for (@{$self->{view}->{wiki}->{var}->{client}->{used_for_negotiate}}, 'Accept-Language') { $opt2->{output}->add_negotiate_header_field ($_); } $opt2->{template} = q#%read (Type => {text/css}, return-type => {ToString}, when-no-converter => 406);#; $opt2->{o} = bless { ## SuikaWiki 3 WikiPlugin interface wiki => $self->{view}->{wiki}, plugin => $self->{view}->{wiki}->{plugin}, var => {}, }, 'SuikaWiki::Plugin'; $opt2->{output}->{status_code} = 200; $opt2->{output}->{entity}->{media_type} = q#text/css#; $opt2->{output}->{entity}->{charset} = $self->{view}->{wiki}->{config}->{charset}->{output}; $opt2->{output}->set_expires (%{$self->{view}->{wiki}->{config}->{entity}->{expires}->{q#stylesheet#}}); $opt2->{output}->{entity}->{body_is_octet_stream} = 0; $self->{view}->{wiki}->init_db; $self->main_pre ($opt, $opt2); use Message::Util::Error; try { $opt2->{output}->{entity}->{body} = (SuikaWiki::Plugin->formatter ('view') ->replace ($opt2->{template}, param => $opt2->{o})); } $self->{view}->{wiki}->{config}->{catch}->{ formatter_view }; $opt2->{output}->output (output => 'http-cgi'); $self->main_post ($opt, $opt2); } package SuikaWiki::Plugin::plugin::StyleSheet1050215084916LDrj; {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) = @_; #line 1 "(WikiPlugin module source stylesheet.wp2, block FormattingRule[name()='[q#view#, q#view-resource#]/styles_wiki_html']/Formatting)" my $list = SuikaWiki::Plugin::plugin::StyleSheet1050215084916LDrj->_get_stylelist_definition_page (page => $o->{wiki}->name ($p->{page} || $o->{wiki}->{config}->{page} ->{'StyleSheetList(text/html)'} || [qw!Wiki Style List text/html!]), o => $o, wiki => $o->{wiki}); return unless $list; my $parent = $p->{-parent}; my $ua_apply; my $dg = $o->{wiki}->{var}->{client}->{downgrade}; if ($dg->{stylesheet_non_standard}) { $ua_apply = $dg->{ua_netscape4} ? 'Netscape4' : $dg->{ua_winie60} ? 'WinIE6.0' : $dg->{ua_winie55} ? 'WinIE5.5' : $dg->{ua_winie50} ? 'WinIE5.0' : $dg->{ua_winie40} ? 'WinIE4.0' : $dg->{ua_winie30} ? 'WinIE3.0' : 1; } my $mkuri = $o->{wiki}->{config}->{q#http://suika.fam.cx/~wakaba/archive/2004/05/sw-stylesheet\#wikiname-to-uri#} || \&SuikaWiki::Plugin::plugin::StyleSheet1050215084916LDrj::generate_uri; for my $set (@{$list->child_nodes}) { if ($set->local_name eq 'StyleSet') { my $apply = $set->get_attribute_value ('Apply', default => ['alternate'], as_array => 1); my $type = { map {$_ => 1} @$apply }; next if $ua_apply and not $type->{$ua_apply}; my $rel = $type->{alternate} ? 'alternate stylesheet' : 'stylesheet'; my $title = SuikaWiki::Plugin::plugin::StyleSheet1050215084916LDrj->_get_styleset_title (StyleSet => $set, o => $o, type => $type); for my $sheet (@{$set->child_nodes}) { if ($sheet->local_name eq 'StyleSheet') { my $stype = { map {$_ => 1} @{$sheet->get_attribute_value ('Apply', default => $apply, as_array => 1)} }; next if $ua_apply and not $stype->{$ua_apply}; next if not $ua_apply and (not $stype->{alternate} and not $stype->{preferred} and not $stype->{persistent}); my $link = $parent->append_new_node (type => '#element', namespace_uri => q#http://www.w3.org/1999/xhtml#, local_name => 'link'); $link->option (use_EmptyElemTag => 1); $link->set_attribute (rel => $rel); $link->set_attribute (title => $title) unless $type->{persistent}; my $media_type = $sheet->get_attribute_value ('Type', default => 'text/css'); $link->set_attribute (type => $media_type); unless ($dg->{html_link_no_media}) { my $media_descriptor = $sheet->get_attribute_value ('Media'); $link->set_attribute (media => $media_descriptor || 'all'); } my $uri = $mkuri->(undef, o => $o, wiki => $o->{wiki}, wikiname => $o->{wiki}->name ($sheet->get_attribute_value ('WikiPage', default => '')), mode => 'css'); ## ISSUE: Make this media-type independent! $link->set_attribute (href => $uri); $parent->append_text ("\n"); } } } }}} #line 1 "(WikiPlugin module StyleSheet, chunk 8)" ; $SuikaWiki::Plugin::Rule{view}->{styles_wiki_html} = $def; $SuikaWiki::Plugin::Rule{view_resource}->{styles_wiki_html} = $def; }; {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 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) = @_; #line 1 "(WikiPlugin module source stylesheet.wp2, block FormattingRule[name()='[q#view#, q#view-resource#]/styles_wiki_xml']/Formatting)" $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}; if ($p->{downgrade_html}) { return if $o->{wiki}->{var}->{client}->{downgrade}->{html_no_pi}; } my $list = SuikaWiki::Plugin::plugin::StyleSheet1050215084916LDrj->_get_stylelist_definition_page (page => $o->{wiki}->name ($p->{page} || $o->{wiki}->{config}->{page} ->{'StyleSheetList(text/html)'} || [qw!Wiki Style List text/html!]), o => $o, wiki => $o->{wiki}); return unless $list; my $parent = $p->{-parent}; my $mkuri = $o->{wiki}->{config}->{q#http://suika.fam.cx/~wakaba/archive/2004/05/sw-stylesheet\#wikiname-to-uri#} || \&SuikaWiki::Plugin::plugin::StyleSheet1050215084916LDrj::generate_uri; for my $set (@{$list->child_nodes}) { if ($set->local_name eq 'StyleSet') { my $apply = $set->get_attribute_value ('Apply', default => ['alternate'], as_array => 1); my $type = {map {$_ => 1} @$apply}; my $rel = $type->{alternate} ? 'alternate stylesheet' : 'stylesheet'; my $title = SuikaWiki::Plugin::plugin::StyleSheet1050215084916LDrj->_get_styleset_title (StyleSet => $set, o => $o, type => $type); for my $sheet (@{$set->child_nodes}) { if ($sheet->local_name eq 'StyleSheet') { my $stype = { map {$_ => 1} @{$sheet->get_attribute_value ('Apply', default => $apply, as_array => 1)} }; next if (not $stype->{alternate} and not $stype->{preferred} and not $stype->{persistent}); my $link = $parent->append_new_node (type => '#pi', local_name => 'xml-stylesheet'); $link->set_attribute (alternate => $type->{preferred} ? 'no' : 'yes') unless $type->{persistent}; $link->set_attribute (title => $title) unless $type->{persistent}; my $media_type = $sheet->get_attribute_value ('Type', default => 'text/css'); $link->set_attribute (type => $media_type); unless ($o->{wiki}->{var}->{client}->{downgrade} ->{html_link_no_media}) { my $media_descriptor = $sheet->get_attribute_value ('Media'); $link->set_attribute (media => $media_descriptor || 'all'); } my $uri = $mkuri->(undef, o => $o, wiki => $o->{wiki}, wikiname => $o->{wiki}->name ($sheet->get_attribute_value ('WikiPage', default => '')), lm => time, ## TODO: Should be last-modified mode => 'css'); ## ISSUE: Make this media-type independent! $link->set_attribute (href => $uri); $parent->append_text ("\n"); } } } }}} #line 1 "(WikiPlugin module StyleSheet, chunk 10)" ; $SuikaWiki::Plugin::Rule{view}->{styles_wiki_xml} = $def; $SuikaWiki::Plugin::Rule{view_resource}->{styles_wiki_xml} = $def; }; sub generate_uri { #line 1 "(WikiPlugin module source stylesheet.wp2, block Function[Name='generate_uri']/Main)" my (undef, %opt) = @_; return $opt{wiki}->uri_reference (page => $opt{wikiname}, mode => $opt{mode}, with_lm => 1, base => 1); } #line 1 "(WikiPlugin module StyleSheet, chunk 12)" push @SuikaWiki::View::Implementation::CommonViewDefs, { condition => {q#mode#, q#ss__no_static#, q#http_method#, [q#GET#, q#HEAD#, q#POST#]}, object_class => q#SuikaWiki::Plugin::plugin::StyleSheet1050215084916LDrj::ss__no_static1050215084916GAk9#, }; package SuikaWiki::Plugin::plugin::StyleSheet1050215084916LDrj::ss__no_static1050215084916GAk9; our @ISA = q#SuikaWiki::View::template#; sub main ($$) { my ($self, $opt, $opt2) = @_; #line 1 "(WikiPlugin module source stylesheet.wp2, block ViewDefinition[Mode='ss__no_static']/method[Name='main'])" require SuikaWiki::Output::HTTP; my $wiki = $self->{view}->{wiki}; $wiki->init_db; GENSTATIC: { last GENSTATIC unless ref $wiki->{config}->{q#http://suika.fam.cx/~wakaba/archive/2004/05/sw-stylesheet\#uri-to-wikiname#} and $wiki->{config}->{q#http://suika.fam.cx/~wakaba/archive/2004/05/sw-stylesheet\#use-static#} and $wiki->{db} and $wiki->{input}; my $uri = $wiki->{input}->meta_variable ('REDIRECT_URL'); last GENSTATIC unless $uri; my $wn = $wiki->{config}->{q#http://suika.fam.cx/~wakaba/archive/2004/05/sw-stylesheet\#uri-to-wikiname#} ->(undef, wiki => $wiki, uri => URI->new ($uri)); my $prop = $wiki->{db}->get (content_prop => $wn); my $mt = $prop->get_attribute_value (q#http://suika.fam.cx/~wakaba/-temp/2004/04/24/mt\#media-type#, default => '--'); last GENSTATIC unless $mt eq 'IMT:text/css##'; $wiki->{db}->set (static__css => $wn => $wiki->{db}->get (content => $wn)); $uri = $wiki->{config}->{q#http://suika.fam.cx/~wakaba/archive/2004/05/sw-stylesheet\#wikiname-to-uri#} ->(undef, wiki => $wiki, wikiname => $wn); $uri = $uri->abs ($wiki->uri_reference); $uri->query (time); my $output = new SuikaWiki::Output::HTTP (wiki => $wiki); $output->set_redirect (uri => $uri, status_code => 303, status_phrase => 'Created'); $output->output (output => 'http-cgi'); return; } my $output = new SuikaWiki::Output::HTTP (wiki => $wiki); $output->{status_code} = 404; $output->{entity}->{media_type} = 'text/plain'; $output->{entity}->{body} = '404'; $output->output (output => 'http-cgi');} #line 1 "(WikiPlugin module StyleSheet, chunk 13)" package SuikaWiki::Plugin::plugin::StyleSheet1050215084916LDrj; {my $def = {q#Parameter#, {}, q#Description#, [[q#Select user preferred style#, q#en#, q##]], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_; #line 1 "(WikiPlugin module source stylesheet.wp2, block FormattingRule[name()='[q#view#, q#view-resource#, q#form-input#]/select_user_preferred_style']/Formatting)" $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}; my $list = SuikaWiki::Plugin::plugin::StyleSheet1050215084916LDrj->_get_stylelist_definition_page (page => $o->{wiki}->name ($p->{page} || $o->{wiki}->{config}->{page} ->{'StyleSheetList(text/html)'} || [qw!Wiki Style List text/html!]), o => $o, wiki => $o->{wiki}); return unless $list; my $form = $p->{-parent}->append_new_node (type => '#element', namespace_uri => q#http://www.w3.org/1999/xhtml#, local_name => 'form'); my $id = SuikaWiki::Plugin->module_package ('WikiFormCore') ->control_id ($o, local_id => 'style-selector', require_local_id => 1); $form->set_attribute (id => $id->{global_id}); my $div = $form->append_new_node (type => '#element', namespace_uri => q#http://www.w3.org/1999/xhtml#, local_name => 'div'); my $parent = $div->append_new_node (type => '#element', namespace_uri => q#http://www.w3.org/1999/xhtml#, local_name => 'select'); $parent->set_attribute (id => $id->{global_id}.'-list'); my $default = $parent->append_new_node (type => '#element', namespace_uri => q#http://www.w3.org/1999/xhtml#, local_name => 'option'); $default->set_attribute (value => 'no-style'); $default->append_text (($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))->get (name => 'Style:Default', o => $o, wiki => $o->{wiki})); my $selected = 0; for my $set (@{$list->child_nodes}) { if ($set->local_name eq 'StyleSet') { my $type = {map {$_ => 1} @{ $set->get_attribute_value ('Apply', default => ['alternate']) }}; next unless $type->{preferred} or $type->{alternate}; my $title = SuikaWiki::Plugin::plugin::StyleSheet1050215084916LDrj->_get_styleset_title (StyleSet => $set, o => $o, type => $type); my $link = $parent->append_new_node (type => '#element', namespace_uri => q#http://www.w3.org/1999/xhtml#, local_name => 'option'); $link->set_attribute (selected => 'selected'), $selected = 1 if $type->{preferred}; $link->set_attribute (value => $title); $link->append_text ($title); $parent->append_text ("\n"); } } $default->set_attribute (selected => 'selected') unless $selected; for ($div->append_new_node (type => '#element', namespace_uri => q#http://www.w3.org/1999/xhtml#, local_name => 'input')) { $_->set_attribute (type => 'button'); $_->set_attribute (id => $id->{global_id}.'-save'); $_->set_attribute (value => ($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))->get (name => 'Style:Save', o => $o, wiki => $o->{wiki})); $_->set_attribute (class => 'save'); $_->option (use_EmptyElemTag => 1); } for ($div->append_new_node (type => '#element', namespace_uri => q#http://www.w3.org/1999/xhtml#, local_name => 'input')) { $_->set_attribute (type => 'reset'); $_->set_attribute (id => $id->{global_id}.'-reset'); $_->set_attribute (value => ($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))->get (name => 'Style:Reset', o => $o, wiki => $o->{wiki})); $_->set_attribute (class => 'reset'); $_->option (use_EmptyElemTag => 1); } return if $o->{wiki}->{var}->{client}->{downgrade}->{js_no_regex}; $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}; my $cookie_path = $o->{wiki}->uri_reference->path; for ($div->append_new_node (type => '#element', namespace_uri => q#http://www.w3.org/1999/xhtml#, local_name => 'script')) { $_->set_attribute (type => $o->{wiki}->{var}->{client}->{downgrade} ->{media_type_no_app_js} ? 'text/javascript' : 'application/x-javascript'); $_->set_attribute (defer => 'defer'); $_->append_new_node (type => '#xml', value => < i; i++) { var v = c[i].split('='); if (v[0].replace(/^\\s+/,'').replace(/\\s+\$/,'') == name) { return decodeURIComponent (v[1].replace(/^\\s+/,'') .replace(/\\s+\$/,'')); } } return ''; } var selectList = document.getElementById('$id->{global_id}-list'); selectList.value = getCookieValue('Selected'); selectList.onchange = function () { var selectList = document.getElementById('$id->{global_id}-list'); for (var i = 0; document.styleSheets.length > i; i++) { var s = document.styleSheets.item(i); if (s.href != document.URL) { if (s.title) s.disabled = (s.title != selectList.value); } } } document.getElementById('$id->{global_id}-save').onclick = function () { var selectList = document.getElementById('$id->{global_id}-list'); var expires = new Date(); expires.setTime (expires.getTime() + 1000*3600*24*@{[$p->{expires}||365]}); document.cookie = 'Selected=' + encodeURIComponent(selectList.value) + ';path=$cookie_path;expires='+expires.toGMTString(); } document.getElementById('$id->{global_id}-reset').onclick = function () { var expires = new Date(); expires.setTime (expires.getTime() - 3600); document.cookie = 'Selected=;path=$cookie_path;expires=' + expires.toGMTString(); } EOH }}} #line 1 "(WikiPlugin module StyleSheet, chunk 14)" ; $SuikaWiki::Plugin::Rule{view}->{select_user_preferred_style} = $def; $SuikaWiki::Plugin::Rule{view_resource}->{select_user_preferred_style} = $def; $SuikaWiki::Plugin::Rule{form_input}->{select_user_preferred_style} = $def; }; {my $def = {q#Parameter#, {}, q#Description#, [[q#Applying user preferred style#, q#en#, q##]], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_; #line 1 "(WikiPlugin module source stylesheet.wp2, block FormattingRule[name()='[q#view#, q#view-resource#, q#form-input#]/apply_user_preferred_style']/Formatting)" return if $o->{wiki}->{var}->{client}->{downgrade}->{js_no_regex}; for ($p->{-parent}->append_new_node (type => '#element', namespace_uri => q#http://www.w3.org/1999/xhtml#, local_name => 'script')) { $_->set_attribute (type => $o->{wiki}->{var}->{client}->{downgrade} ->{media_type_no_app_js} ? 'text/javascript' : 'application/x-javascript'); $_->set_attribute (defer => 'defer'); $_->append_new_node (type => '#xml', value => < i; i++) { var v = c[i].split('='); if (v[0].replace(/^\\s+/,'').replace(/\\s+\$/,'') == name) { return decodeURIComponent (v[1].replace(/^\\s+/,'') .replace(/\\s+\$/,'')); } } return ''; } var styleName = getCookieValue('Selected'); if (styleName) { for (var i = 0; document.styleSheets.length > i; i++) { var s = document.styleSheets.item(i); if (s.href != document.URL) { if (s.title) s.disabled = (s.title != styleName) ? true : false; } } } EOH }}} #line 1 "(WikiPlugin module StyleSheet, chunk 16)" ; $SuikaWiki::Plugin::Rule{view}->{apply_user_preferred_style} = $def; $SuikaWiki::Plugin::Rule{view_resource}->{apply_user_preferred_style} = $def; $SuikaWiki::Plugin::Rule{form_input}->{apply_user_preferred_style} = $def; }; sub _get_stylelist_definition_page { #line 1 "(WikiPlugin module source stylesheet.wp2, block Function[Name='_get_stylelist_definition_page']/Main)" my (undef, %opt) = @_; my $content; my $content_prop; if ($opt{wiki}->{db}) { try { $content = $opt{wiki}->{db}->get (content => $opt{page}); $content_prop = $opt{wiki}->{db}->get (content_prop => $opt{page}); } catch SuikaWiki::DB::Util::Error with { my $err = shift; $err->throw if $err->{-type} eq 'ERROR_REPORTED'; $content = undef; }; } my $format = SuikaWiki::Plugin->module_package ('WikiFormat') ->handler (\$content, content_prop => $content_prop, o => $opt{o}, wiki => $opt{o}->{wiki}); my $cfg; try { $cfg = $format->convert (\$content, Type => 'application/x.suikawiki.config', Type_param => {version => '2.0'}, o => $opt{o}, page => $opt{page}); } catch SuikaWiki::Format::Definition::error with { my $err = shift; if ($err->{-type} eq 'CONVERTER_NOT_FOUND') { SuikaWiki::Plugin->module_package ('Error') ->report_error_simple ($opt{o}->{wiki}, 'Condition' => $err->stringify); } else { $err->throw; } }; $cfg; } #line 1 "(WikiPlugin module StyleSheet, chunk 18)" sub _get_styleset_title { #line 1 "(WikiPlugin module source stylesheet.wp2, block Function[Name='_get_styleset_title']/Main)" my (undef, %opt) = @_; my $title; if (not $opt{type}->{persistent}) { $title = $opt{StyleSet}->get_attribute_value ('DisplayName', default => ''); if (length $title) { try { $title = SuikaWiki::Plugin->formatter ('view_resource') ->replace ($title, param => $opt{o}) ->inner_text; } catch Message::Util::Formatter::error with { my $err = shift; if ($err->{-object}->{-category_name} eq 'view_resource') { my $wiki = $err->{option}->{param}->{wiki}; SuikaWiki::Plugin->module_package ('Error') ->reporting_formatting_template_error ($err, $wiki, template => $title); } else { $err->throw; } $title ||= $opt{StyleSet}->get_attribute_value ('Name', default => ''); }; } else { $title = $opt{StyleSet}->get_attribute_value ('Name', default => ''); } } return $title; } #line 1 "(WikiPlugin module StyleSheet, chunk 19)" {my $def = {q#Parameter#, {}, q#Description#, [[q#Select user preferred mode#, q#en#, q##]], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_; #line 1 "(WikiPlugin module source stylesheet.wp2, block FormattingRule[name()='[q#view#, q#view-resource#, q#form-input#]/select_user_preferred_mode']/Formatting)" my $list = [grep /^[0-9A-Za-z_]/, keys %{$o->{wiki}->{view}->{definition}}]; my $form = $p->{-parent}->append_new_node (type => '#element', namespace_uri => q#http://www.w3.org/1999/xhtml#, local_name => 'form'); my $id = SuikaWiki::Plugin->module_package ('WikiFormCore') ->control_id ($o, local_id => 'spss--mode-selector', require_local_id => 1); $form->set_attribute (id => $id->{global_id}); my $div = $form->append_new_node (type => '#element', namespace_uri => q#http://www.w3.org/1999/xhtml#, local_name => 'div'); my $parent = $div->append_new_node (type => '#element', namespace_uri => q#http://www.w3.org/1999/xhtml#, local_name => 'select'); $parent->set_attribute (id => $id->{global_id}.'-list'); my $default = $parent->append_new_node (type => '#element', namespace_uri => q#http://www.w3.org/1999/xhtml#, local_name => 'option'); $default->set_attribute (value => 'default'); $default->append_text (($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))->get (name => 'Mode:Default', o => $o, wiki => $o->{wiki})); $default->set_attribute (selected => 'selected'); for my $set (@$list) { my $title = ($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))->get (name => 'Mode:'.$set, o => $o, wiki => $o->{wiki}); my $link = $parent->append_new_node (type => '#element', namespace_uri => q#http://www.w3.org/1999/xhtml#, local_name => 'option'); $link->set_attribute (value => $set); $link->append_text ($title); $parent->append_text ("\n"); } for ($div->append_new_node (type => '#element', namespace_uri => q#http://www.w3.org/1999/xhtml#, local_name => 'input')) { $_->set_attribute (type => 'button'); $_->set_attribute (id => $id->{global_id}.'-save'); $_->set_attribute (value => ($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))->get (name => 'Mode:Save', o => $o, wiki => $o->{wiki})); $_->set_attribute (class => 'save'); $_->option (use_EmptyElemTag => 1); } for ($div->append_new_node (type => '#element', namespace_uri => q#http://www.w3.org/1999/xhtml#, local_name => 'input')) { $_->set_attribute (type => 'reset'); $_->set_attribute (id => $id->{global_id}.'-reset'); $_->set_attribute (value => ($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))->get (name => 'Mode:Reset', o => $o, wiki => $o->{wiki})); $_->set_attribute (class => 'reset'); $_->option (use_EmptyElemTag => 1); } return if $o->{wiki}->{var}->{client}->{downgrade}->{js_no_regex}; $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}; my $cookie_path = $o->{wiki}->uri_reference->path; for ($div->append_new_node (type => '#element', namespace_uri => q#http://www.w3.org/1999/xhtml#, local_name => 'script')) { $_->set_attribute (type => $o->{wiki}->{var}->{client}->{downgrade} ->{media_type_no_app_js} ? 'text/javascript' : 'application/x-javascript'); $_->set_attribute (defer => 'defer'); $_->append_new_node (type => '#xml', value => < i; i++) { var v = c[i].split('='); if (v[0].replace(/^\\s+/,'').replace(/\\s+\$/,'') == name) { return decodeURIComponent (v[1].replace(/^\\s+/,'') .replace(/\\s+\$/,'')); } } return ''; } document.getElementById ('$id->{global_id}-list').value = getCookieValue('SelectedMode'); document.getElementById ('$id->{global_id}-save').onclick = function () { var expires = new Date (); expires.setTime (expires.getTime () + 1000*3600*24*@{[$p->{expires}||365]}); document.cookie = 'SelectedMode=' + encodeURIComponent (document.getElementById('$id->{global_id}-list') .value) + ';path=$cookie_path;expires=' + expires.toGMTString (); } document.getElementById('$id->{global_id}-reset').onclick = function () { var expires = new Date(); expires.setTime (expires.getTime() - 3600); document.cookie = 'SelectedMode=;path=$cookie_path;expires=' + expires.toGMTString(); } EOH }}} #line 1 "(WikiPlugin module StyleSheet, chunk 20)" ; $SuikaWiki::Plugin::Rule{view}->{select_user_preferred_mode} = $def; $SuikaWiki::Plugin::Rule{view_resource}->{select_user_preferred_mode} = $def; $SuikaWiki::Plugin::Rule{form_input}->{select_user_preferred_mode} = $def; }; push @{$SuikaWiki::View::Implementation::TemplateFragment{q#ht__stylesheets_html#}}, { Main => q#%styles-wiki-html;#, Order => 0, Description => [[q#Default stylesheets links#, q#en#, q##]], }; push @{$SuikaWiki::View::Implementation::TemplateFragment{q#ht__pre_element_content#}}, { Main => q#%styles-wiki-xml (downgrade-html);#, Order => 0, Description => [[q#Default stylesheets links (as xml-stylesheet PIs)#, q#en#, q##]], }; push @{$SuikaWiki::View::Implementation::TemplateFragment{q#ws__footer#}}, { Main => q#%apply-user-preferred-style;#, Order => 100000, Description => [[q#Apply user selected stylesheets#, q#en#, q##]], }; package SuikaWiki::Plugin::Resource; our $BaseResource; $BaseResource->{q#en#}->{q##}->{q#Mode:css#} = q#Cascading Style Sheet output#; $BaseResource->{q#en#}->{q##}->{q#Mode:Default#} = q#Default#; $BaseResource->{q#en#}->{q##}->{q#Mode:Reset#} = q#Reset default mode selection#; $BaseResource->{q#en#}->{q##}->{q#Mode:Save#} = q#Save default mode selection#; $BaseResource->{q#und#}->{q##}->{q#Style:Default#} = q#Basic Page Style#; $BaseResource->{q#en#}->{q##}->{q#Style:Reset#} = q#Reset style selection#; $BaseResource->{q#en#}->{q##}->{q#Style:Save#} = q#Save style selection#; $BaseResource->{q#en#}->{q##}->{q#WikiFormat:MediaType:Description:IMT:text/css\#\##} = q#CSS (Cascading Style Sheets)#; $BaseResource->{q#en#}->{q##}->{q#WikiFormat:MediaType:Label:IMT:text/css\#\##} = q#CSS#; package SuikaWiki::Plugin::Registry; $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#}]}; 1;