5 |
@Description: |
@Description: |
6 |
@@@: Stylesheet support |
@@@: Stylesheet support |
7 |
@@lang:en |
@@lang:en |
8 |
@License: %%GPL%% |
@License: %%Perl%% |
9 |
@Author: |
@Author: |
10 |
@@Name: |
@@Name: |
11 |
@@@@: Wakaba |
@@@@: Wakaba |
12 |
@@@lang:ja |
@@@lang:ja |
13 |
@@@script:Latn |
@@@script:Latn |
14 |
@@Mail[list]: w@suika.fam.cx |
@@Mail[list]: w@suika.fam.cx |
15 |
@Date.RCS: $Date$ |
@Date.RCS: |
16 |
@RequiredModule[list]: |
$Date$ |
17 |
@RequiredPlugin[list]: |
@RequiredPlugin[list]: |
18 |
Error |
Error |
19 |
HTML |
HTML |
20 |
|
@RequiredModule[list]: |
21 |
|
URI |
22 |
@Use: |
@Use: |
23 |
|
use URI; |
24 |
use Message::Util::Error; |
use Message::Util::Error; |
25 |
my $WIKIRESOURCE; |
my $WIKIRESOURCE; |
26 |
|
@Namespace: |
27 |
|
@@ss: |
28 |
|
http://suika.fam.cx/~wakaba/archive/2004/05/sw-stylesheet# |
29 |
|
@@media-type: |
30 |
|
http://suika.fam.cx/~wakaba/-temp/2004/04/24/mt# |
31 |
|
@@edit: |
32 |
|
http://suika.fam.cx/~wakaba/-temp/2004/7/25/sw-edit# |
33 |
|
|
34 |
PluginConst: |
PluginConst: |
35 |
@NS_XHTML1: |
@NS_XHTML1: |
75 |
$node->append_text ($$source); |
$node->append_text ($$source); |
76 |
return $node; |
return $node; |
77 |
|
|
78 |
|
@content_written: |
79 |
|
@@Main: |
80 |
|
if ($opt{wiki}->{config}->{<Q:ss:use-static>}) { |
81 |
|
$opt{wiki}->{db}->set (static__css => $opt{page} => ${$opt{new_content}}); |
82 |
|
} |
83 |
|
|
84 |
|
@content_removed: |
85 |
|
@@Main: |
86 |
|
if ($opt{wiki}->{config}->{<Q:ss:use-static>}) { |
87 |
|
$opt{wiki}->{db}->delete (static__css => $opt{page}); |
88 |
|
} |
89 |
|
|
90 |
|
@content_type_changed_from: |
91 |
|
@@Main: |
92 |
|
if ($opt{wiki}->{config}->{<Q:ss:use-static>}) { |
93 |
|
$opt{wiki}->{db}->delete (static__css => $opt{page}); |
94 |
|
} |
95 |
|
|
96 |
|
@Prop: |
97 |
|
@@edit:new-mode--edit: edit |
98 |
|
@@edit:new-mode--adminedit: adminedit |
99 |
|
|
100 |
ViewDefinition: |
ViewDefinition: |
101 |
@Mode: css |
@Mode: css |
102 |
@Condition: |
@Condition: |
154 |
: $dg->{ua_winie30} ? 'WinIE3.0' |
: $dg->{ua_winie30} ? 'WinIE3.0' |
155 |
: 1; |
: 1; |
156 |
} |
} |
157 |
|
|
158 |
|
my $mkuri = $o->{wiki}->{config}->{<Q:ss:wikiname-to-uri>} || |
159 |
|
\ \&__FUNCPACK__::generate_uri; |
160 |
|
|
161 |
for my $set (@{$list->child_nodes}) { |
for my $set (@{$list->child_nodes}) { |
162 |
if ($set->local_name eq 'StyleSet') { |
if ($set->local_name eq 'StyleSet') { |
163 |
|
my $apply = $set->get_attribute_value ('Apply', |
164 |
|
default => ['alternate'], |
165 |
|
as_array => 1); |
166 |
my $type = { |
my $type = { |
167 |
map {$_ => 1} |
map {$_ => 1} |
168 |
map {ref $_ ? @$_ : [$_]} |
\ @$apply |
|
$set->get_attribute_value ('Apply', default => ['alternate']) |
|
169 |
}; |
}; |
170 |
next if $ua_apply and not $type->{$ua_apply}; |
next if $ua_apply and not $type->{$ua_apply}; |
171 |
my $rel = $type->{alternate} ? 'alternate stylesheet' : 'stylesheet'; |
my $rel = $type->{alternate} ? 'alternate stylesheet' : 'stylesheet'; |
174 |
type => $type); |
type => $type); |
175 |
for my $sheet (@{$set->child_nodes}) { |
for my $sheet (@{$set->child_nodes}) { |
176 |
if ($sheet->local_name eq 'StyleSheet') { |
if ($sheet->local_name eq 'StyleSheet') { |
177 |
|
my $stype = { |
178 |
|
map {$_ => 1} |
179 |
|
\ @{$sheet->get_attribute_value ('Apply', default => $apply, |
180 |
|
as_array => 1)} |
181 |
|
}; |
182 |
|
next if $ua_apply and not $stype->{$ua_apply}; |
183 |
|
next if not $ua_apply and (not $stype->{alternate} and |
184 |
|
not $stype->{preferred} and |
185 |
|
not $stype->{persistent}); |
186 |
my $link = $parent->append_new_node |
my $link = $parent->append_new_node |
187 |
(type => '#element', |
(type => '#element', |
188 |
namespace_uri => $NS_XHTML1, |
namespace_uri => $NS_XHTML1, |
198 |
my $media_descriptor = $sheet->get_attribute_value ('Media'); |
my $media_descriptor = $sheet->get_attribute_value ('Media'); |
199 |
$link->set_attribute (media => $media_descriptor || 'all'); |
$link->set_attribute (media => $media_descriptor || 'all'); |
200 |
} |
} |
201 |
my $mode = 'css'; ## ISSUE: Make this media-type independent! |
my $uri = $mkuri->(undef, o => $o, wiki => $o->{wiki}, |
202 |
$link->set_attribute |
wikiname => $o->{wiki}->name |
203 |
(href => $o->{wiki}->uri_reference |
($sheet->get_attribute_value |
|
(page => $o->{wiki}->name |
|
|
($sheet->get_attribute_value |
|
204 |
('WikiPage', default => '')), |
('WikiPage', default => '')), |
205 |
mode => $mode, |
mode => 'css'); ## ISSUE: Make this media-type independent! |
206 |
with_lm => 1, base => 1)); |
$link->set_attribute (href => $uri); |
207 |
$parent->append_text ("\n"); |
$parent->append_text ("\n"); |
208 |
} |
} |
209 |
} |
} |
251 |
return unless $list; |
return unless $list; |
252 |
my $parent = $p->{-parent}; |
my $parent = $p->{-parent}; |
253 |
|
|
254 |
|
my $mkuri = $o->{wiki}->{config}->{<Q:ss:wikiname-to-uri>} || |
255 |
|
\ \&__FUNCPACK__::generate_uri; |
256 |
|
|
257 |
for my $set (@{$list->child_nodes}) { |
for my $set (@{$list->child_nodes}) { |
258 |
if ($set->local_name eq 'StyleSet') { |
if ($set->local_name eq 'StyleSet') { |
259 |
my $type = {map {$_ => 1} |
my $apply = $set->get_attribute_value |
260 |
@{ |
('Apply', default => ['alternate'], |
261 |
$set->get_attribute_value ('Apply', default => ['alternate']) |
as_array => 1); |
262 |
}}; |
my $type = {map {$_ => 1} @$apply}; |
263 |
my $rel = $type->{alternate} ? 'alternate stylesheet' : 'stylesheet'; |
my $rel = $type->{alternate} ? 'alternate stylesheet' : 'stylesheet'; |
264 |
my $title = __FUNCPACK__->_get_styleset_title |
my $title = __FUNCPACK__->_get_styleset_title |
265 |
(StyleSet => $set, o => $o, |
(StyleSet => $set, o => $o, |
266 |
type => $type); |
type => $type); |
267 |
for my $sheet (@{$set->child_nodes}) { |
for my $sheet (@{$set->child_nodes}) { |
268 |
if ($sheet->local_name eq 'StyleSheet') { |
if ($sheet->local_name eq 'StyleSheet') { |
269 |
|
my $stype = { |
270 |
|
map {$_ => 1} |
271 |
|
\ @{$sheet->get_attribute_value ('Apply', default => $apply, |
272 |
|
as_array => 1)} |
273 |
|
}; |
274 |
|
next if (not $stype->{alternate} and |
275 |
|
not $stype->{preferred} and |
276 |
|
not $stype->{persistent}); |
277 |
my $link = $parent->append_new_node |
my $link = $parent->append_new_node |
278 |
(type => '#pi', |
(type => '#pi', |
279 |
local_name => 'xml-stylesheet'); |
local_name => 'xml-stylesheet'); |
290 |
my $media_descriptor = $sheet->get_attribute_value ('Media'); |
my $media_descriptor = $sheet->get_attribute_value ('Media'); |
291 |
$link->set_attribute (media => $media_descriptor || 'all'); |
$link->set_attribute (media => $media_descriptor || 'all'); |
292 |
} |
} |
293 |
my $mode = 'css'; ## ISSUE: Make this media-type independent! |
my $uri = $mkuri->(undef, o => $o, wiki => $o->{wiki}, |
294 |
$link->set_attribute |
wikiname => $o->{wiki}->name |
295 |
(href => $o->{wiki}->uri_reference |
($sheet->get_attribute_value |
|
(page => $o->{wiki}->name |
|
|
($sheet->get_attribute_value |
|
296 |
('WikiPage', default => '')), |
('WikiPage', default => '')), |
297 |
mode => $mode, |
lm => time, ## TODO: Should be last-modified |
298 |
with_lm => 1)); |
mode => 'css'); ## ISSUE: Make this media-type independent! |
299 |
|
$link->set_attribute (href => $uri); |
300 |
$parent->append_text ("\n"); |
$parent->append_text ("\n"); |
301 |
} |
} |
302 |
} |
} |
303 |
} |
} |
304 |
} |
} |
305 |
|
|
306 |
|
Function: |
307 |
|
@Name: generate_uri |
308 |
|
@Description: |
309 |
|
@@@: Default generator for stylesheet URI |
310 |
|
@@lang: en |
311 |
|
@Main: |
312 |
|
my (undef, %opt) = @_; |
313 |
|
return $opt{wiki}->uri_reference |
314 |
|
(page => $opt{wikiname}, |
315 |
|
mode => $opt{mode}, |
316 |
|
with_lm => 1, base => 1); |
317 |
|
|
318 |
|
ViewDefinition: |
319 |
|
@Mode: ss--no-static |
320 |
|
@Condition: |
321 |
|
@@http-method[list]: |
322 |
|
GET |
323 |
|
HEAD |
324 |
|
POST |
325 |
|
@Description: |
326 |
|
@@@: Generate static version |
327 |
|
@@lang: en |
328 |
|
@method: |
329 |
|
@@Name: main |
330 |
|
@@@: |
331 |
|
require SuikaWiki::Output::HTTP; |
332 |
|
my $wiki = $self->{view}->{wiki}; |
333 |
|
$wiki->init_db; |
334 |
|
|
335 |
|
GENSTATIC: { |
336 |
|
last GENSTATIC unless ref $wiki->{config}->{<Q:ss:uri-to-wikiname>} and |
337 |
|
$wiki->{config}->{<Q:ss:use-static>} and |
338 |
|
$wiki->{db} and $wiki->{input}; |
339 |
|
my $uri = $wiki->{input}->meta_variable ('REDIRECT_URL'); |
340 |
|
last GENSTATIC unless $uri; |
341 |
|
my $wn = $wiki->{config}->{<Q:ss:uri-to-wikiname>} |
342 |
|
->(undef, wiki => $wiki, |
343 |
|
uri => URI->new ($uri)); |
344 |
|
|
345 |
|
my $prop = $wiki->{db}->get (content_prop => $wn); |
346 |
|
my $mt = $prop->get_attribute_value (<Q:media-type:media-type>, |
347 |
|
default => '--'); |
348 |
|
last GENSTATIC unless $mt eq 'IMT:text/css##'; |
349 |
|
|
350 |
|
$wiki->{db}->set (static__css => $wn => |
351 |
|
$wiki->{db}->get (content => $wn)); |
352 |
|
|
353 |
|
$uri = $wiki->{config}->{<Q:ss:wikiname-to-uri>} |
354 |
|
->(undef, wiki => $wiki, |
355 |
|
wikiname => $wn); |
356 |
|
$uri = $uri->abs ($wiki->uri_reference); |
357 |
|
$uri->query (time); |
358 |
|
|
359 |
|
my $output = new SuikaWiki::Output::HTTP (wiki => $wiki); |
360 |
|
$output->set_redirect (uri => $uri, status_code => 303, |
361 |
|
status_phrase => 'Created'); |
362 |
|
$output->output (output => 'http-cgi'); |
363 |
|
|
364 |
|
return; |
365 |
|
} |
366 |
|
my $output = new SuikaWiki::Output::HTTP (wiki => $wiki); |
367 |
|
$output->{status_code} = 404; |
368 |
|
$output->{entity}->{media_type} = 'text/plain'; |
369 |
|
$output->{entity}->{body} = '404'; |
370 |
|
$output->output (output => 'http-cgi'); |
371 |
|
|
372 |
FormattingRule: |
FormattingRule: |
373 |
@Category[list]: |
@Category[list]: |
374 |
view |
view |
471 |
$_->option (use_EmptyElemTag => 1); |
$_->option (use_EmptyElemTag => 1); |
472 |
} |
} |
473 |
|
|
474 |
|
return if $o->{wiki}->{var}->{client}->{downgrade}->{js_no_regex}; |
475 |
__ATTRTEXT:%expires__; |
__ATTRTEXT:%expires__; |
476 |
my $cookie_path = '/'; ## ISSUE: Need some mechanism |
my $cookie_path = $o->{wiki}->uri_reference->path; |
477 |
for ($div->append_new_node (type => '#element', |
for ($div->append_new_node (type => '#element', |
478 |
namespace_uri => $NS_XHTML1, |
namespace_uri => $NS_XHTML1, |
479 |
local_name => 'script')) { |
local_name => 'script')) { |
541 |
Applying user preferred style |
Applying user preferred style |
542 |
@@lang: en |
@@lang: en |
543 |
@Formatting: |
@Formatting: |
544 |
|
return if $o->{wiki}->{var}->{client}->{downgrade}->{js_no_regex}; |
545 |
for ($p->{-parent}->append_new_node |
for ($p->{-parent}->append_new_node |
546 |
(type => '#element', |
(type => '#element', |
547 |
namespace_uri => $NS_XHTML1, |
namespace_uri => $NS_XHTML1, |
586 |
@Main: |
@Main: |
587 |
my (undef, %opt) = @_; |
my (undef, %opt) = @_; |
588 |
my $content; |
my $content; |
589 |
|
my $content_prop; |
590 |
if ($opt{wiki}->{db}) { |
if ($opt{wiki}->{db}) { |
591 |
try { |
try { |
592 |
$content = $opt{wiki}->{db}->get (content => $opt{page}); |
$content = $opt{wiki}->{db}->get (content => $opt{page}); |
593 |
|
$content_prop = $opt{wiki}->{db}->get (content_prop => $opt{page}); |
594 |
} catch SuikaWiki::DB::Util::Error with { |
} catch SuikaWiki::DB::Util::Error with { |
595 |
|
my $err = shift; |
596 |
|
$err->throw if $err->{-type} eq 'ERROR_REPORTED'; |
597 |
$content = undef; |
$content = undef; |
598 |
}; |
}; |
599 |
} |
} |
600 |
my $format = SuikaWiki::Plugin->module_package ('WikiFormat') |
my $format = SuikaWiki::Plugin->module_package ('WikiFormat') |
601 |
->handler (\$content, |
->handler (\$content, |
602 |
|
content_prop => $content_prop, |
603 |
o => $opt{o}, |
o => $opt{o}, |
604 |
wiki => $opt{o}->{wiki}); |
wiki => $opt{o}->{wiki}); |
605 |
my $cfg; |
my $cfg; |
733 |
$_->option (use_EmptyElemTag => 1); |
$_->option (use_EmptyElemTag => 1); |
734 |
} |
} |
735 |
|
|
736 |
|
return if $o->{wiki}->{var}->{client}->{downgrade}->{js_no_regex}; |
737 |
__ATTRTEXT:%expires__; |
__ATTRTEXT:%expires__; |
738 |
my $cookie_path = '/'; ## ISSUE: Need some mechanism |
my $cookie_path = $o->{wiki}->uri_reference->path; |
739 |
for ($div->append_new_node (type => '#element', |
for ($div->append_new_node (type => '#element', |
740 |
namespace_uri => $NS_XHTML1, |
namespace_uri => $NS_XHTML1, |
741 |
local_name => 'script')) { |
local_name => 'script')) { |
834 |
@@@: |
@@@: |
835 |
Save style selection |
Save style selection |
836 |
@@lang: en |
@@lang: en |
837 |
|
@WikiFormat:MediaType:Description:IMT:text/css##: |
838 |
|
@@@: CSS (Cascading Style Sheets) |
839 |
|
@@lang: en |
840 |
|
@WikiFormat:MediaType:Label:IMT:text/css##: |
841 |
|
@@@: CSS |
842 |
|
@@lang: en |
843 |
|
|
844 |
|
|