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') { |
187 |
my $media_descriptor = $sheet->get_attribute_value ('Media'); |
my $media_descriptor = $sheet->get_attribute_value ('Media'); |
188 |
$link->set_attribute (media => $media_descriptor || 'all'); |
$link->set_attribute (media => $media_descriptor || 'all'); |
189 |
} |
} |
190 |
my $mode = 'css'; ## ISSUE: Make this media-type independent! |
my $uri = $mkuri->(undef, o => $o, wiki => $o->{wiki}, |
191 |
$link->set_attribute |
wikiname => $o->{wiki}->name |
192 |
(href => $o->{wiki}->uri_reference |
($sheet->get_attribute_value |
|
(page => $o->{wiki}->name |
|
|
($sheet->get_attribute_value |
|
193 |
('WikiPage', default => '')), |
('WikiPage', default => '')), |
194 |
mode => $mode, |
mode => 'css'); ## ISSUE: Make this media-type independent! |
195 |
with_lm => 1, base => 1)); |
$link->set_attribute (href => $uri); |
196 |
$parent->append_text ("\n"); |
$parent->append_text ("\n"); |
197 |
} |
} |
198 |
} |
} |
240 |
return unless $list; |
return unless $list; |
241 |
my $parent = $p->{-parent}; |
my $parent = $p->{-parent}; |
242 |
|
|
243 |
|
my $mkuri = $o->{wiki}->{config}->{<Q:ss:wikiname-to-uri>} || |
244 |
|
\ \&__FUNCPACK__::generate_uri; |
245 |
|
|
246 |
for my $set (@{$list->child_nodes}) { |
for my $set (@{$list->child_nodes}) { |
247 |
if ($set->local_name eq 'StyleSet') { |
if ($set->local_name eq 'StyleSet') { |
248 |
my $type = {map {$_ => 1} |
my $type = {map {$_ => 1} |
271 |
my $media_descriptor = $sheet->get_attribute_value ('Media'); |
my $media_descriptor = $sheet->get_attribute_value ('Media'); |
272 |
$link->set_attribute (media => $media_descriptor || 'all'); |
$link->set_attribute (media => $media_descriptor || 'all'); |
273 |
} |
} |
274 |
my $mode = 'css'; ## ISSUE: Make this media-type independent! |
my $uri = $mkuri->(undef, o => $o, wiki => $o->{wiki}, |
275 |
$link->set_attribute |
wikiname => $o->{wiki}->name |
276 |
(href => $o->{wiki}->uri_reference |
($sheet->get_attribute_value |
|
(page => $o->{wiki}->name |
|
|
($sheet->get_attribute_value |
|
277 |
('WikiPage', default => '')), |
('WikiPage', default => '')), |
278 |
mode => $mode, |
lm => time, ## TODO: Should be last-modified |
279 |
with_lm => 1)); |
mode => 'css'); ## ISSUE: Make this media-type independent! |
280 |
|
$link->set_attribute (href => $uri); |
281 |
$parent->append_text ("\n"); |
$parent->append_text ("\n"); |
282 |
} |
} |
283 |
} |
} |
284 |
} |
} |
285 |
} |
} |
286 |
|
|
287 |
|
Function: |
288 |
|
@Name: generate_uri |
289 |
|
@Description: |
290 |
|
@@@: Default generator for stylesheet URI |
291 |
|
@@lang: en |
292 |
|
@Main: |
293 |
|
my (undef, %opt) = @_; |
294 |
|
return $opt{wiki}->uri_reference |
295 |
|
(page => $opt{wikiname}, |
296 |
|
mode => $opt{mode}, |
297 |
|
with_lm => 1, base => 1); |
298 |
|
|
299 |
|
ViewDefinition: |
300 |
|
@Mode: ss--no-static |
301 |
|
@Condition: |
302 |
|
@@http-method[list]: |
303 |
|
GET |
304 |
|
HEAD |
305 |
|
POST |
306 |
|
@Description: |
307 |
|
@@@: Generate static version |
308 |
|
@@lang: en |
309 |
|
@method: |
310 |
|
@@Name: main |
311 |
|
@@@: |
312 |
|
require SuikaWiki::Output::HTTP; |
313 |
|
my $wiki = $self->{view}->{wiki}; |
314 |
|
$wiki->init_db; |
315 |
|
|
316 |
|
GENSTATIC: { |
317 |
|
last GENSTATIC unless ref $wiki->{config}->{<Q:ss:uri-to-wikiname>} and |
318 |
|
$wiki->{config}->{<Q:ss:use-static>} and |
319 |
|
$wiki->{db} and $wiki->{input}; |
320 |
|
my $uri = $wiki->{input}->meta_variable ('REDIRECT_URL'); |
321 |
|
last GENSTATIC unless $uri; |
322 |
|
my $wn = $wiki->{config}->{<Q:ss:uri-to-wikiname>} |
323 |
|
->(undef, wiki => $wiki, |
324 |
|
uri => URI->new ($uri)); |
325 |
|
|
326 |
|
my $prop = $wiki->{db}->get (content_prop => $wn); |
327 |
|
my $mt = $prop->get_attribute_value (<Q:media-type:media-type>, |
328 |
|
default => '--'); |
329 |
|
last GENSTATIC unless $mt eq 'IMT:text/css##'; |
330 |
|
|
331 |
|
$wiki->{db}->set (static__css => $wn => |
332 |
|
$wiki->{db}->get (content => $wn)); |
333 |
|
|
334 |
|
$uri = $wiki->{config}->{<Q:ss:wikiname-to-uri>} |
335 |
|
->(undef, wiki => $wiki, |
336 |
|
wikiname => $wn); |
337 |
|
$uri = $uri->abs ($wiki->uri_reference); |
338 |
|
$uri->query (time); |
339 |
|
|
340 |
|
my $output = new SuikaWiki::Output::HTTP (wiki => $wiki); |
341 |
|
$output->set_redirect (uri => $uri, status_code => 303, |
342 |
|
status_phrase => 'Created'); |
343 |
|
$output->output (output => 'http-cgi'); |
344 |
|
|
345 |
|
return; |
346 |
|
} |
347 |
|
my $output = new SuikaWiki::Output::HTTP (wiki => $wiki); |
348 |
|
$output->{status_code} = 404; |
349 |
|
$output->{entity}->{media_type} = 'text/plain'; |
350 |
|
$output->{entity}->{body} = '404'; |
351 |
|
$output->output (output => 'http-cgi'); |
352 |
|
|
353 |
FormattingRule: |
FormattingRule: |
354 |
@Category[list]: |
@Category[list]: |
355 |
view |
view |
453 |
} |
} |
454 |
|
|
455 |
__ATTRTEXT:%expires__; |
__ATTRTEXT:%expires__; |
456 |
my $cookie_path = '/'; ## ISSUE: Need some mechanism |
my $cookie_path = $o->{wiki}->uri_reference->path; |
457 |
for ($div->append_new_node (type => '#element', |
for ($div->append_new_node (type => '#element', |
458 |
namespace_uri => $NS_XHTML1, |
namespace_uri => $NS_XHTML1, |
459 |
local_name => 'script')) { |
local_name => 'script')) { |
565 |
@Main: |
@Main: |
566 |
my (undef, %opt) = @_; |
my (undef, %opt) = @_; |
567 |
my $content; |
my $content; |
568 |
|
my $content_prop; |
569 |
if ($opt{wiki}->{db}) { |
if ($opt{wiki}->{db}) { |
570 |
try { |
try { |
571 |
$content = $opt{wiki}->{db}->get (content => $opt{page}); |
$content = $opt{wiki}->{db}->get (content => $opt{page}); |
572 |
|
$content_prop = $opt{wiki}->{db}->get (content_prop => $opt{page}); |
573 |
} catch SuikaWiki::DB::Util::Error with { |
} catch SuikaWiki::DB::Util::Error with { |
574 |
|
my $err = shift; |
575 |
|
$err->throw if $err->{-type} eq 'ERROR_REPORTED'; |
576 |
$content = undef; |
$content = undef; |
577 |
}; |
}; |
578 |
} |
} |
579 |
my $format = SuikaWiki::Plugin->module_package ('WikiFormat') |
my $format = SuikaWiki::Plugin->module_package ('WikiFormat') |
580 |
->handler (\$content, |
->handler (\$content, |
581 |
|
content_prop => $content_prop, |
582 |
o => $opt{o}, |
o => $opt{o}, |
583 |
wiki => $opt{o}->{wiki}); |
wiki => $opt{o}->{wiki}); |
584 |
my $cfg; |
my $cfg; |
713 |
} |
} |
714 |
|
|
715 |
__ATTRTEXT:%expires__; |
__ATTRTEXT:%expires__; |
716 |
my $cookie_path = '/'; ## ISSUE: Need some mechanism |
my $cookie_path = $o->{wiki}->uri_reference->path; |
717 |
for ($div->append_new_node (type => '#element', |
for ($div->append_new_node (type => '#element', |
718 |
namespace_uri => $NS_XHTML1, |
namespace_uri => $NS_XHTML1, |
719 |
local_name => 'script')) { |
local_name => 'script')) { |
812 |
@@@: |
@@@: |
813 |
Save style selection |
Save style selection |
814 |
@@lang: en |
@@lang: en |
815 |
|
@WikiFormat:MediaType:Description:IMT:text/css##: |
816 |
|
@@@: CSS (Cascading Style Sheets) |
817 |
|
@@lang: en |
818 |
|
@WikiFormat:MediaType:Label:IMT:text/css##: |
819 |
|
@@@: CSS |
820 |
|
@@lang: en |
821 |
|
|
822 |
|
|