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 |
my $type = { |
my $type = { |
166 |
map {$_ => 1} |
map {$_ => 1} |
167 |
map {ref $_ ? @$_ : [$_]} |
map {ref $_ ? @$_ : [$_]} |
168 |
$set->get_attribute_value ('Apply', default => ['alternate']) |
$apply |
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 |
|
map {ref $_ ? @$_ : [$_]} |
180 |
|
$sheet->get_attribute_value ('Apply', default => $apply) |
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 $type = {map {$_ => 1} |
282 |
my $media_descriptor = $sheet->get_attribute_value ('Media'); |
my $media_descriptor = $sheet->get_attribute_value ('Media'); |
283 |
$link->set_attribute (media => $media_descriptor || 'all'); |
$link->set_attribute (media => $media_descriptor || 'all'); |
284 |
} |
} |
285 |
my $mode = 'css'; ## ISSUE: Make this media-type independent! |
my $uri = $mkuri->(undef, o => $o, wiki => $o->{wiki}, |
286 |
$link->set_attribute |
wikiname => $o->{wiki}->name |
287 |
(href => $o->{wiki}->uri_reference |
($sheet->get_attribute_value |
|
(page => $o->{wiki}->name |
|
|
($sheet->get_attribute_value |
|
288 |
('WikiPage', default => '')), |
('WikiPage', default => '')), |
289 |
mode => $mode, |
lm => time, ## TODO: Should be last-modified |
290 |
with_lm => 1)); |
mode => 'css'); ## ISSUE: Make this media-type independent! |
291 |
|
$link->set_attribute (href => $uri); |
292 |
$parent->append_text ("\n"); |
$parent->append_text ("\n"); |
293 |
} |
} |
294 |
} |
} |
295 |
} |
} |
296 |
} |
} |
297 |
|
|
298 |
|
Function: |
299 |
|
@Name: generate_uri |
300 |
|
@Description: |
301 |
|
@@@: Default generator for stylesheet URI |
302 |
|
@@lang: en |
303 |
|
@Main: |
304 |
|
my (undef, %opt) = @_; |
305 |
|
return $opt{wiki}->uri_reference |
306 |
|
(page => $opt{wikiname}, |
307 |
|
mode => $opt{mode}, |
308 |
|
with_lm => 1, base => 1); |
309 |
|
|
310 |
|
ViewDefinition: |
311 |
|
@Mode: ss--no-static |
312 |
|
@Condition: |
313 |
|
@@http-method[list]: |
314 |
|
GET |
315 |
|
HEAD |
316 |
|
POST |
317 |
|
@Description: |
318 |
|
@@@: Generate static version |
319 |
|
@@lang: en |
320 |
|
@method: |
321 |
|
@@Name: main |
322 |
|
@@@: |
323 |
|
require SuikaWiki::Output::HTTP; |
324 |
|
my $wiki = $self->{view}->{wiki}; |
325 |
|
$wiki->init_db; |
326 |
|
|
327 |
|
GENSTATIC: { |
328 |
|
last GENSTATIC unless ref $wiki->{config}->{<Q:ss:uri-to-wikiname>} and |
329 |
|
$wiki->{config}->{<Q:ss:use-static>} and |
330 |
|
$wiki->{db} and $wiki->{input}; |
331 |
|
my $uri = $wiki->{input}->meta_variable ('REDIRECT_URL'); |
332 |
|
last GENSTATIC unless $uri; |
333 |
|
my $wn = $wiki->{config}->{<Q:ss:uri-to-wikiname>} |
334 |
|
->(undef, wiki => $wiki, |
335 |
|
uri => URI->new ($uri)); |
336 |
|
|
337 |
|
my $prop = $wiki->{db}->get (content_prop => $wn); |
338 |
|
my $mt = $prop->get_attribute_value (<Q:media-type:media-type>, |
339 |
|
default => '--'); |
340 |
|
last GENSTATIC unless $mt eq 'IMT:text/css##'; |
341 |
|
|
342 |
|
$wiki->{db}->set (static__css => $wn => |
343 |
|
$wiki->{db}->get (content => $wn)); |
344 |
|
|
345 |
|
$uri = $wiki->{config}->{<Q:ss:wikiname-to-uri>} |
346 |
|
->(undef, wiki => $wiki, |
347 |
|
wikiname => $wn); |
348 |
|
$uri = $uri->abs ($wiki->uri_reference); |
349 |
|
$uri->query (time); |
350 |
|
|
351 |
|
my $output = new SuikaWiki::Output::HTTP (wiki => $wiki); |
352 |
|
$output->set_redirect (uri => $uri, status_code => 303, |
353 |
|
status_phrase => 'Created'); |
354 |
|
$output->output (output => 'http-cgi'); |
355 |
|
|
356 |
|
return; |
357 |
|
} |
358 |
|
my $output = new SuikaWiki::Output::HTTP (wiki => $wiki); |
359 |
|
$output->{status_code} = 404; |
360 |
|
$output->{entity}->{media_type} = 'text/plain'; |
361 |
|
$output->{entity}->{body} = '404'; |
362 |
|
$output->output (output => 'http-cgi'); |
363 |
|
|
364 |
FormattingRule: |
FormattingRule: |
365 |
@Category[list]: |
@Category[list]: |
366 |
view |
view |
464 |
} |
} |
465 |
|
|
466 |
__ATTRTEXT:%expires__; |
__ATTRTEXT:%expires__; |
467 |
my $cookie_path = '/'; ## ISSUE: Need some mechanism |
my $cookie_path = $o->{wiki}->uri_reference->path; |
468 |
for ($div->append_new_node (type => '#element', |
for ($div->append_new_node (type => '#element', |
469 |
namespace_uri => $NS_XHTML1, |
namespace_uri => $NS_XHTML1, |
470 |
local_name => 'script')) { |
local_name => 'script')) { |
576 |
@Main: |
@Main: |
577 |
my (undef, %opt) = @_; |
my (undef, %opt) = @_; |
578 |
my $content; |
my $content; |
579 |
|
my $content_prop; |
580 |
if ($opt{wiki}->{db}) { |
if ($opt{wiki}->{db}) { |
581 |
try { |
try { |
582 |
$content = $opt{wiki}->{db}->get (content => $opt{page}); |
$content = $opt{wiki}->{db}->get (content => $opt{page}); |
583 |
|
$content_prop = $opt{wiki}->{db}->get (content_prop => $opt{page}); |
584 |
} catch SuikaWiki::DB::Util::Error with { |
} catch SuikaWiki::DB::Util::Error with { |
585 |
|
my $err = shift; |
586 |
|
$err->throw if $err->{-type} eq 'ERROR_REPORTED'; |
587 |
$content = undef; |
$content = undef; |
588 |
}; |
}; |
589 |
} |
} |
590 |
my $format = SuikaWiki::Plugin->module_package ('WikiFormat') |
my $format = SuikaWiki::Plugin->module_package ('WikiFormat') |
591 |
->handler (\$content, |
->handler (\$content, |
592 |
|
content_prop => $content_prop, |
593 |
o => $opt{o}, |
o => $opt{o}, |
594 |
wiki => $opt{o}->{wiki}); |
wiki => $opt{o}->{wiki}); |
595 |
my $cfg; |
my $cfg; |
724 |
} |
} |
725 |
|
|
726 |
__ATTRTEXT:%expires__; |
__ATTRTEXT:%expires__; |
727 |
my $cookie_path = '/'; ## ISSUE: Need some mechanism |
my $cookie_path = $o->{wiki}->uri_reference->path; |
728 |
for ($div->append_new_node (type => '#element', |
for ($div->append_new_node (type => '#element', |
729 |
namespace_uri => $NS_XHTML1, |
namespace_uri => $NS_XHTML1, |
730 |
local_name => 'script')) { |
local_name => 'script')) { |
823 |
@@@: |
@@@: |
824 |
Save style selection |
Save style selection |
825 |
@@lang: en |
@@lang: en |
826 |
|
@WikiFormat:MediaType:Description:IMT:text/css##: |
827 |
|
@@@: CSS (Cascading Style Sheets) |
828 |
|
@@lang: en |
829 |
|
@WikiFormat:MediaType:Label:IMT:text/css##: |
830 |
|
@@@: CSS |
831 |
|
@@lang: en |
832 |
|
|
833 |
|
|