1 |
#?SuikaWikiConfig/2.0 |
2 |
|
3 |
Plugin: |
4 |
@Name: StyleSheet |
5 |
@Description: |
6 |
@@@: Stylesheet support |
7 |
@@lang:en |
8 |
@License: %%Perl%% |
9 |
@Author: |
10 |
@@Name: |
11 |
@@@@: Wakaba |
12 |
@@@lang:ja |
13 |
@@@script:Latn |
14 |
@@Mail[list]: w@suika.fam.cx |
15 |
@Date.RCS: |
16 |
$Date: 2004/02/18 07:22:11 $ |
17 |
@RequiredPlugin[list]: |
18 |
Error |
19 |
HTML |
20 |
@Use: |
21 |
use Message::Util::Error; |
22 |
my $WIKIRESOURCE; |
23 |
|
24 |
PluginConst: |
25 |
@NS_XHTML1: |
26 |
http://www.w3.org/1999/xhtml |
27 |
@WIKIRESOURCE: |
28 |
{($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))} |
29 |
|
30 |
Format: |
31 |
@ModuleName: |
32 |
StyleSheet::CSS |
33 |
|
34 |
@Name: CSS |
35 |
@Type: text/css |
36 |
@Description: |
37 |
@@@: Cascading Style Sheets (CSS) |
38 |
@@lang: en |
39 |
|
40 |
@Use: |
41 |
use Message::Markup::XML::QName qw(NS_xml_URI); |
42 |
|
43 |
@Converter: |
44 |
@@Type: text/css |
45 |
@@Description: |
46 |
@@@: CSS -> CSS (no convertion) |
47 |
@@lang: en |
48 |
@@ToString: |
49 |
return $$source; |
50 |
## BUG: Insecure specification MUST be removed |
51 |
|
52 |
@Converter: |
53 |
@@Type: text/html |
54 |
@@IsFragment: 1 |
55 |
@@Description: |
56 |
@@@: CSS with some decoration, marked-up in HTML |
57 |
@@lang: en |
58 |
@@Main: |
59 |
my $node = $opt->{-parent}->append_new_node |
60 |
(type => '#element', |
61 |
namespace_uri => $NS_XHTML1, |
62 |
local_name => 'pre'); |
63 |
$node->set_attribute (class => 'text-css'); |
64 |
$node->set_attribute (space => 'preserve', namespace_uri => NS_xml_URI); |
65 |
$node->append_text ($$source); |
66 |
return $node; |
67 |
|
68 |
ViewDefinition: |
69 |
@Mode: css |
70 |
@Condition: |
71 |
@@http-method[list]: |
72 |
GET |
73 |
HEAD |
74 |
POST |
75 |
@Description: |
76 |
@@@: CSS Style Sheet |
77 |
@@lang: en |
78 |
@template: |
79 |
@@http-status-code: 200 |
80 |
@@media-type: text/css |
81 |
@@use-media-type-charset: 1 |
82 |
@@expires: %%stylesheet%% |
83 |
@@body: |
84 |
%read (Type => {text/css}, return-type => {ToString}, |
85 |
when-no-converter => 406); |
86 |
|
87 |
FormattingRule: |
88 |
@Category[list]: |
89 |
view |
90 |
view-resource |
91 |
@Name: styles-wiki-html |
92 |
@Description: |
93 |
@@@: |
94 |
Stylesheet list as HTML (link element) |
95 |
@@lang: en |
96 |
@Paramater: |
97 |
@@Name: page |
98 |
@@Type: WikiName |
99 |
@@Default: (auto) |
100 |
@@Description: |
101 |
@@@@: WikiPage in which stylesheet list is defined |
102 |
@@@lang: en |
103 |
@Formatting: |
104 |
my $list = __FUNCPACK__->_get_stylelist_definition_page |
105 |
(page => $o->{wiki}->name |
106 |
($p->{page} || |
107 |
$o->{wiki}->{config}->{page} |
108 |
->{'StyleSheetList(text/html)'} || |
109 |
[qw!Wiki Style List text/html!]), |
110 |
o => $o, wiki => $o->{wiki}); |
111 |
return unless $list; |
112 |
my $parent = $p->{-parent}; |
113 |
|
114 |
my $ua_apply; |
115 |
my $dg = $o->{wiki}->{var}->{client}->{downgrade}; |
116 |
if ($dg->{stylesheet_non_standard}) { |
117 |
$ua_apply = $dg->{ua_netscape4} ? 'Netscape4' |
118 |
: $dg->{ua_winie60} ? 'WinIE6.0' |
119 |
: $dg->{ua_winie55} ? 'WinIE5.5' |
120 |
: $dg->{ua_winie50} ? 'WinIE5.0' |
121 |
: $dg->{ua_winie40} ? 'WinIE4.0' |
122 |
: $dg->{ua_winie30} ? 'WinIE3.0' |
123 |
: 1; |
124 |
} |
125 |
|
126 |
for my $set (@{$list->child_nodes}) { |
127 |
if ($set->local_name eq 'StyleSet') { |
128 |
my $type = { |
129 |
map {$_ => 1} |
130 |
map {ref $_ ? @$_ : [$_]} |
131 |
$set->get_attribute_value ('Apply', default => ['alternate']) |
132 |
}; |
133 |
next if $ua_apply and not $type->{$ua_apply}; |
134 |
my $rel = $type->{alternate} ? 'alternate stylesheet' : 'stylesheet'; |
135 |
my $title = __FUNCPACK__->_get_styleset_title |
136 |
(StyleSet => $set, o => $o, |
137 |
type => $type); |
138 |
for my $sheet (@{$set->child_nodes}) { |
139 |
if ($sheet->local_name eq 'StyleSheet') { |
140 |
my $link = $parent->append_new_node |
141 |
(type => '#element', |
142 |
namespace_uri => $NS_XHTML1, |
143 |
local_name => 'link'); |
144 |
$link->option (use_EmptyElemTag => 1); |
145 |
$link->set_attribute (rel => $rel); |
146 |
$link->set_attribute (title => $title) unless $type->{persistent}; |
147 |
my $media_type = $sheet->get_attribute_value |
148 |
('Type', default => 'text/css'); |
149 |
## TODO: parameter |
150 |
$link->set_attribute (type => $media_type); |
151 |
unless ($dg->{html_link_no_media}) { |
152 |
my $media_descriptor = $sheet->get_attribute_value ('Media'); |
153 |
$link->set_attribute (media => $media_descriptor || 'all'); |
154 |
} |
155 |
my $mode = 'css'; ## ISSUE: Make this media-type independent! |
156 |
$link->set_attribute |
157 |
(href => $o->{wiki}->uri_reference |
158 |
(page => $o->{wiki}->name |
159 |
($sheet->get_attribute_value |
160 |
('WikiPage', default => '')), |
161 |
mode => $mode, |
162 |
with_lm => 1, base => 1)); |
163 |
$parent->append_text ("\n"); |
164 |
} |
165 |
} |
166 |
|
167 |
} |
168 |
} |
169 |
|
170 |
FormattingRule: |
171 |
@Category[list]: |
172 |
view |
173 |
view-resource |
174 |
@Name: styles-wiki-xml |
175 |
@Description: |
176 |
@@@: |
177 |
Stylesheet list in xml-stylesheet processing instructions |
178 |
@@lang: en |
179 |
@Parameter: |
180 |
@@Name: downgrade-html |
181 |
@@Type: boolean |
182 |
@@Default: "0" |
183 |
@@Description: |
184 |
@@@@: |
185 |
HTML downgrade mode. PIs are not outputed if User-Agent does not |
186 |
support PIs (eg. Classic Mozilla). |
187 |
@@lang: en |
188 |
@Paramater: |
189 |
@@Name: page |
190 |
@@Type: WikiName |
191 |
@@Default: (auto) |
192 |
@@Description: |
193 |
@@@@: WikiPage in which stylesheet list is defined |
194 |
@@@lang: en |
195 |
@Formatting: |
196 |
__ATTRTEXT:%downgrade_html__; |
197 |
if ($p->{downgrade_html}) { |
198 |
return if $o->{wiki}->{var}->{client}->{downgrade}->{html_no_pi}; |
199 |
} |
200 |
my $list = __FUNCPACK__->_get_stylelist_definition_page |
201 |
(page => $o->{wiki}->name |
202 |
($p->{page} || |
203 |
$o->{wiki}->{config}->{page} |
204 |
->{'StyleSheetList(text/html)'} || |
205 |
[qw!Wiki Style List text/html!]), |
206 |
o => $o, wiki => $o->{wiki}); |
207 |
return unless $list; |
208 |
my $parent = $p->{-parent}; |
209 |
|
210 |
for my $set (@{$list->child_nodes}) { |
211 |
if ($set->local_name eq 'StyleSet') { |
212 |
my $type = {map {$_ => 1} |
213 |
@{ |
214 |
$set->get_attribute_value ('Apply', default => ['alternate']) |
215 |
}}; |
216 |
my $rel = $type->{alternate} ? 'alternate stylesheet' : 'stylesheet'; |
217 |
my $title = __FUNCPACK__->_get_styleset_title |
218 |
(StyleSet => $set, o => $o, |
219 |
type => $type); |
220 |
for my $sheet (@{$set->child_nodes}) { |
221 |
if ($sheet->local_name eq 'StyleSheet') { |
222 |
my $link = $parent->append_new_node |
223 |
(type => '#pi', |
224 |
local_name => 'xml-stylesheet'); |
225 |
$link->set_attribute (alternate => $type->{preferred} ? 'no' |
226 |
: 'yes') |
227 |
unless $type->{persistent}; |
228 |
$link->set_attribute (title => $title) unless $type->{persistent}; |
229 |
my $media_type = $sheet->get_attribute_value |
230 |
('Type', default => 'text/css'); |
231 |
## TODO: parameter |
232 |
$link->set_attribute (type => $media_type); |
233 |
unless ($o->{wiki}->{var}->{client}->{downgrade} |
234 |
->{html_link_no_media}) { |
235 |
my $media_descriptor = $sheet->get_attribute_value ('Media'); |
236 |
$link->set_attribute (media => $media_descriptor || 'all'); |
237 |
} |
238 |
my $mode = 'css'; ## ISSUE: Make this media-type independent! |
239 |
$link->set_attribute |
240 |
(href => $o->{wiki}->uri_reference |
241 |
(page => $o->{wiki}->name |
242 |
($sheet->get_attribute_value |
243 |
('WikiPage', default => '')), |
244 |
mode => $mode, |
245 |
with_lm => 1)); |
246 |
$parent->append_text ("\n"); |
247 |
} |
248 |
} |
249 |
} |
250 |
} |
251 |
|
252 |
FormattingRule: |
253 |
@Category[list]: |
254 |
view |
255 |
view-resource |
256 |
form-input |
257 |
@Name: select-user-preferred-style |
258 |
@Description: |
259 |
@@@: |
260 |
Select user preferred style |
261 |
@@lang: en |
262 |
@Paramater: |
263 |
@@Name: page |
264 |
@@Type: WikiName |
265 |
@@Default: (auto) |
266 |
@@Description: |
267 |
@@@@: WikiPage in which stylesheet list is defined |
268 |
@@@lang: en |
269 |
@Formatting: |
270 |
__ATTRTEXT:%page__; |
271 |
my $list = __FUNCPACK__->_get_stylelist_definition_page |
272 |
(page => $o->{wiki}->name |
273 |
($p->{page} || |
274 |
$o->{wiki}->{config}->{page} |
275 |
->{'StyleSheetList(text/html)'} || |
276 |
[qw!Wiki Style List text/html!]), |
277 |
o => $o, wiki => $o->{wiki}); |
278 |
return unless $list; |
279 |
my $form = $p->{-parent}->append_new_node |
280 |
(type => '#element', |
281 |
namespace_uri => $NS_XHTML1, |
282 |
local_name => 'form'); |
283 |
my $id = SuikaWiki::Plugin->module_package ('WikiFormCore') |
284 |
->control_id ($o, |
285 |
local_id => 'style-selector', |
286 |
require_local_id => 1); |
287 |
$form->set_attribute (id => $id->{global_id}); |
288 |
my $div = $form->append_new_node |
289 |
(type => '#element', |
290 |
namespace_uri => $NS_XHTML1, |
291 |
local_name => 'div'); |
292 |
my $parent = $div->append_new_node |
293 |
(type => '#element', |
294 |
namespace_uri => $NS_XHTML1, |
295 |
local_name => 'select'); |
296 |
$parent->set_attribute (id => $id->{global_id}.'-list'); |
297 |
|
298 |
my $default = $parent->append_new_node |
299 |
(type => '#element', |
300 |
namespace_uri => $NS_XHTML1, |
301 |
local_name => 'option'); |
302 |
$default->set_attribute (value => 'no-style'); |
303 |
$default->append_text ($WIKIRESOURCE->get (name => 'Style:Default', |
304 |
o => $o, wiki => $o->{wiki})); |
305 |
my $selected = 0; |
306 |
|
307 |
for my $set (@{$list->child_nodes}) { |
308 |
if ($set->local_name eq 'StyleSet') { |
309 |
my $type = {map {$_ => 1} |
310 |
@{ |
311 |
$set->get_attribute_value ('Apply', default => ['alternate']) |
312 |
}}; |
313 |
next unless $type->{preferred} or $type->{alternate}; |
314 |
my $title = __FUNCPACK__->_get_styleset_title |
315 |
(StyleSet => $set, o => $o, |
316 |
type => $type); |
317 |
my $link = $parent->append_new_node |
318 |
(type => '#element', |
319 |
namespace_uri => $NS_XHTML1, |
320 |
local_name => 'option'); |
321 |
$link->set_attribute (selected => 'selected'), $selected = 1 |
322 |
if $type->{preferred}; |
323 |
$link->set_attribute (value => $title); |
324 |
$link->append_text ($title); |
325 |
$parent->append_text ("\n"); |
326 |
} |
327 |
} |
328 |
|
329 |
$default->set_attribute (selected => 'selected') unless $selected; |
330 |
|
331 |
for ($div->append_new_node (type => '#element', |
332 |
namespace_uri => $NS_XHTML1, |
333 |
local_name => 'input')) { |
334 |
$_->set_attribute (type => 'button'); |
335 |
$_->set_attribute (id => $id->{global_id}.'-save'); |
336 |
$_->set_attribute (value => $WIKIRESOURCE->get |
337 |
(name => 'Style:Save', |
338 |
o => $o, wiki => $o->{wiki})); |
339 |
$_->set_attribute (class => 'save'); |
340 |
$_->option (use_EmptyElemTag => 1); |
341 |
} |
342 |
for ($div->append_new_node (type => '#element', |
343 |
namespace_uri => $NS_XHTML1, |
344 |
local_name => 'input')) { |
345 |
$_->set_attribute (type => 'reset'); |
346 |
$_->set_attribute (id => $id->{global_id}.'-reset'); |
347 |
$_->set_attribute (value => $WIKIRESOURCE->get |
348 |
(name => 'Style:Reset', |
349 |
o => $o, wiki => $o->{wiki})); |
350 |
$_->set_attribute (class => 'reset'); |
351 |
$_->option (use_EmptyElemTag => 1); |
352 |
} |
353 |
|
354 |
__ATTRTEXT:%expires__; |
355 |
my $cookie_path = $o->{wiki}->uri_reference->path; |
356 |
for ($div->append_new_node (type => '#element', |
357 |
namespace_uri => $NS_XHTML1, |
358 |
local_name => 'script')) { |
359 |
$_->set_attribute (type => $o->{wiki}->{var}->{client}->{downgrade} |
360 |
->{media_type_no_app_js} |
361 |
? 'text/javascript' |
362 |
: 'application/x-javascript'); |
363 |
$_->set_attribute (defer => 'defer'); |
364 |
## Gecko assumes <script> content as CDATA even if it is XHTML, |
365 |
## when it is labeled as text/html. (Pseudo) comment declaration |
366 |
## nor CDATA marked section can be used to keep compatibility and |
367 |
## well-formedness. Use #xml type, instead of #text, not to escape |
368 |
## GREATER-THAN SIGN. |
369 |
$_->append_new_node (type => '#xml', value => <<EOH); |
370 |
|
371 |
function getCookieValue (name) { |
372 |
var c = document.cookie.split(';'); |
373 |
for (var i = 0; c.length > i; i++) { |
374 |
var v = c[i].split('='); |
375 |
if (v[0].replace(/^\\s+/,'').replace(/\\s+\$/,'') == name) { |
376 |
return decodeURIComponent (v[1].replace(/^\\s+/,'') |
377 |
.replace(/\\s+\$/,'')); |
378 |
} |
379 |
} |
380 |
return ''; |
381 |
} |
382 |
var selectList = document.getElementById('$id->{global_id}-list'); |
383 |
selectList.value = getCookieValue('Selected'); |
384 |
selectList.onchange = function () { |
385 |
var selectList = document.getElementById('$id->{global_id}-list'); |
386 |
for (var i = 0; document.styleSheets.length > i; i++) { |
387 |
var s = document.styleSheets.item(i); |
388 |
if (s.href != document.URL) { |
389 |
if (s.title) |
390 |
s.disabled = (s.title != selectList.value); |
391 |
} |
392 |
} |
393 |
} |
394 |
document.getElementById('$id->{global_id}-save').onclick = function () { |
395 |
var selectList = document.getElementById('$id->{global_id}-list'); |
396 |
var expires = new Date(); |
397 |
expires.setTime (expires.getTime() |
398 |
+ 1000*3600*24*@{[$p->{expires}||365]}); |
399 |
document.cookie = 'Selected=' + encodeURIComponent(selectList.value) |
400 |
+ ';path=$cookie_path;expires='+expires.toGMTString(); |
401 |
} |
402 |
document.getElementById('$id->{global_id}-reset').onclick = function () { |
403 |
var expires = new Date(); |
404 |
expires.setTime (expires.getTime() - 3600); |
405 |
document.cookie = 'Selected=;path=$cookie_path;expires=' |
406 |
+ expires.toGMTString(); |
407 |
} |
408 |
|
409 |
EOH |
410 |
} |
411 |
|
412 |
FormattingRule: |
413 |
@Category[list]: |
414 |
view |
415 |
view-resource |
416 |
form-input |
417 |
@Name: apply-user-preferred-style |
418 |
@Description: |
419 |
@@@: |
420 |
Applying user preferred style |
421 |
@@lang: en |
422 |
@Formatting: |
423 |
for ($p->{-parent}->append_new_node |
424 |
(type => '#element', |
425 |
namespace_uri => $NS_XHTML1, |
426 |
local_name => 'script')) { |
427 |
$_->set_attribute (type => $o->{wiki}->{var}->{client}->{downgrade} |
428 |
->{media_type_no_app_js} |
429 |
? 'text/javascript' |
430 |
: 'application/x-javascript'); |
431 |
$_->set_attribute (defer => 'defer'); |
432 |
## TODO: Some mechanism to prevent multiple outputing of same functions |
433 |
## required. |
434 |
$_->append_new_node (type => '#xml', value => <<EOH); |
435 |
|
436 |
function getCookieValue (name) { |
437 |
var c = document.cookie.split(';'); |
438 |
for (var i = 0; c.length > i; i++) { |
439 |
var v = c[i].split('='); |
440 |
if (v[0].replace(/^\\s+/,'').replace(/\\s+\$/,'') == name) { |
441 |
return decodeURIComponent (v[1].replace(/^\\s+/,'') |
442 |
.replace(/\\s+\$/,'')); |
443 |
} |
444 |
} |
445 |
return ''; |
446 |
} |
447 |
|
448 |
var styleName = getCookieValue('Selected'); |
449 |
if (styleName) { |
450 |
for (var i = 0; document.styleSheets.length > i; i++) { |
451 |
var s = document.styleSheets.item(i); |
452 |
if (s.href != document.URL) { |
453 |
if (s.title) |
454 |
s.disabled = (s.title != styleName) ? true : false; |
455 |
} |
456 |
} |
457 |
} |
458 |
|
459 |
EOH |
460 |
} |
461 |
|
462 |
Function: |
463 |
@Name: _get_stylelist_definition_page |
464 |
@Main: |
465 |
my (undef, %opt) = @_; |
466 |
my $content; |
467 |
my $content_prop; |
468 |
if ($opt{wiki}->{db}) { |
469 |
try { |
470 |
$content = $opt{wiki}->{db}->get (content => $opt{page}); |
471 |
$content_prop = $opt{wiki}->{db}->get (content_prop => $opt{page}); |
472 |
} catch SuikaWiki::DB::Util::Error with { |
473 |
my $err = shift; |
474 |
$err->throw if $err->{-type} eq 'ERROR_REPORTED'; |
475 |
$content = undef; |
476 |
}; |
477 |
} |
478 |
my $format = SuikaWiki::Plugin->module_package ('WikiFormat') |
479 |
->handler (\$content, |
480 |
content_prop => $content_prop, |
481 |
o => $opt{o}, |
482 |
wiki => $opt{o}->{wiki}); |
483 |
my $cfg; |
484 |
try { |
485 |
$cfg = $format->convert (\$content, |
486 |
Type => 'application/x.suikawiki.config', |
487 |
Type_param => {version => '2.0'}, |
488 |
o => $opt{o}, page => $opt{page}); |
489 |
} catch SuikaWiki::Format::Definition::error with { |
490 |
my $err = shift; |
491 |
if ($err->{-type} eq 'CONVERTER_NOT_FOUND') { |
492 |
SuikaWiki::Plugin->module_package ('Error') |
493 |
->report_error_simple |
494 |
($opt{o}->{wiki}, |
495 |
'Condition' => $err->stringify); |
496 |
} else { |
497 |
$err->throw; |
498 |
} |
499 |
}; |
500 |
$cfg; |
501 |
|
502 |
Function: |
503 |
@Name: _get_styleset_title |
504 |
@Description: |
505 |
@@@: Get "title" of the styleset |
506 |
@@lang: en |
507 |
@Main: |
508 |
my (undef, %opt) = @_; |
509 |
my $title; |
510 |
if (not $opt{type}->{persistent}) { |
511 |
$title = $opt{StyleSet}->get_attribute_value |
512 |
('DisplayName', default => ''); |
513 |
if (length $title) { |
514 |
try { |
515 |
$title = SuikaWiki::Plugin->formatter ('view_resource') |
516 |
->replace ($title, |
517 |
param => $opt{o}) |
518 |
->inner_text; |
519 |
} catch Message::Util::Formatter::error with { |
520 |
my $err = shift; |
521 |
if ($err->{-object}->{-category_name} eq 'view_resource') { |
522 |
my $wiki = $err->{option}->{param}->{wiki}; |
523 |
SuikaWiki::Plugin->module_package ('Error') |
524 |
->reporting_formatting_template_error |
525 |
($err, $wiki, |
526 |
template => $title); |
527 |
} else { |
528 |
$err->throw; |
529 |
} |
530 |
$title ||= $opt{StyleSet}->get_attribute_value |
531 |
('Name', default => ''); |
532 |
}; |
533 |
} else { |
534 |
$title = $opt{StyleSet}->get_attribute_value ('Name', default => ''); |
535 |
} |
536 |
} |
537 |
return $title; |
538 |
|
539 |
FormattingRule: |
540 |
@Category[list]: |
541 |
view |
542 |
view-resource |
543 |
form-input |
544 |
@Name: select-user-preferred-mode |
545 |
@Description: |
546 |
@@@: |
547 |
Select user preferred mode |
548 |
@@lang: en |
549 |
@Formatting: |
550 |
my $list = [grep /^[0-9A-Za-z_]/, keys %{$o->{wiki}->{view}->{definition}}]; |
551 |
my $form = $p->{-parent}->append_new_node |
552 |
(type => '#element', |
553 |
namespace_uri => $NS_XHTML1, |
554 |
local_name => 'form'); |
555 |
my $id = SuikaWiki::Plugin->module_package ('WikiFormCore') |
556 |
->control_id ($o, |
557 |
local_id => 'spss--mode-selector', |
558 |
require_local_id => 1); |
559 |
$form->set_attribute (id => $id->{global_id}); |
560 |
my $div = $form->append_new_node |
561 |
(type => '#element', |
562 |
namespace_uri => $NS_XHTML1, |
563 |
local_name => 'div'); |
564 |
my $parent = $div->append_new_node |
565 |
(type => '#element', |
566 |
namespace_uri => $NS_XHTML1, |
567 |
local_name => 'select'); |
568 |
$parent->set_attribute (id => $id->{global_id}.'-list'); |
569 |
|
570 |
my $default = $parent->append_new_node |
571 |
(type => '#element', |
572 |
namespace_uri => $NS_XHTML1, |
573 |
local_name => 'option'); |
574 |
$default->set_attribute (value => 'default'); |
575 |
$default->append_text ($WIKIRESOURCE->get (name => 'Mode:Default', |
576 |
o => $o, wiki => $o->{wiki})); |
577 |
$default->set_attribute (selected => 'selected'); |
578 |
|
579 |
for my $set (@$list) { |
580 |
my $title = $WIKIRESOURCE->get (name => 'Mode:'.$set, |
581 |
o => $o, wiki => $o->{wiki}); |
582 |
my $link = $parent->append_new_node |
583 |
(type => '#element', |
584 |
namespace_uri => $NS_XHTML1, |
585 |
local_name => 'option'); |
586 |
$link->set_attribute (value => $set); |
587 |
$link->append_text ($title); |
588 |
$parent->append_text ("\n"); |
589 |
} |
590 |
|
591 |
for ($div->append_new_node (type => '#element', |
592 |
namespace_uri => $NS_XHTML1, |
593 |
local_name => 'input')) { |
594 |
$_->set_attribute (type => 'button'); |
595 |
$_->set_attribute (id => $id->{global_id}.'-save'); |
596 |
$_->set_attribute (value => $WIKIRESOURCE->get |
597 |
(name => 'Mode:Save', |
598 |
o => $o, wiki => $o->{wiki})); |
599 |
$_->set_attribute (class => 'save'); |
600 |
$_->option (use_EmptyElemTag => 1); |
601 |
} |
602 |
for ($div->append_new_node (type => '#element', |
603 |
namespace_uri => $NS_XHTML1, |
604 |
local_name => 'input')) { |
605 |
$_->set_attribute (type => 'reset'); |
606 |
$_->set_attribute (id => $id->{global_id}.'-reset'); |
607 |
$_->set_attribute (value => $WIKIRESOURCE->get |
608 |
(name => 'Mode:Reset', |
609 |
o => $o, wiki => $o->{wiki})); |
610 |
$_->set_attribute (class => 'reset'); |
611 |
$_->option (use_EmptyElemTag => 1); |
612 |
} |
613 |
|
614 |
__ATTRTEXT:%expires__; |
615 |
my $cookie_path = $o->{wiki}->uri_reference->path; |
616 |
for ($div->append_new_node (type => '#element', |
617 |
namespace_uri => $NS_XHTML1, |
618 |
local_name => 'script')) { |
619 |
$_->set_attribute (type => $o->{wiki}->{var}->{client}->{downgrade} |
620 |
->{media_type_no_app_js} |
621 |
? 'text/javascript' |
622 |
: 'application/x-javascript'); |
623 |
$_->set_attribute (defer => 'defer'); |
624 |
$_->append_new_node (type => '#xml', value => <<EOH); |
625 |
|
626 |
function getCookieValue (name) { |
627 |
var c = document.cookie.split(';'); |
628 |
for (var i = 0; c.length > i; i++) { |
629 |
var v = c[i].split('='); |
630 |
if (v[0].replace(/^\\s+/,'').replace(/\\s+\$/,'') == name) { |
631 |
return decodeURIComponent (v[1].replace(/^\\s+/,'') |
632 |
.replace(/\\s+\$/,'')); |
633 |
} |
634 |
} |
635 |
return ''; |
636 |
} |
637 |
|
638 |
document.getElementById ('$id->{global_id}-list').value |
639 |
= getCookieValue('SelectedMode'); |
640 |
document.getElementById ('$id->{global_id}-save').onclick = function () { |
641 |
var expires = new Date (); |
642 |
expires.setTime (expires.getTime () |
643 |
+ 1000*3600*24*@{[$p->{expires}||365]}); |
644 |
document.cookie = 'SelectedMode=' |
645 |
+ encodeURIComponent |
646 |
(document.getElementById('$id->{global_id}-list') |
647 |
.value) |
648 |
+ ';path=$cookie_path;expires=' |
649 |
+ expires.toGMTString (); |
650 |
} |
651 |
document.getElementById('$id->{global_id}-reset').onclick = function () { |
652 |
var expires = new Date(); |
653 |
expires.setTime (expires.getTime() - 3600); |
654 |
document.cookie = 'SelectedMode=;path=$cookie_path;expires=' |
655 |
+ expires.toGMTString(); |
656 |
} |
657 |
|
658 |
EOH |
659 |
} |
660 |
|
661 |
ViewFragment: |
662 |
@Name: ht--stylesheets-html |
663 |
@Order: 0 |
664 |
@Description: |
665 |
@@@: Default stylesheets links |
666 |
@@lang: en |
667 |
@Formatting: |
668 |
%styles-wiki-html; |
669 |
|
670 |
ViewFragment: |
671 |
@Name: ht--pre-element-content |
672 |
@Order: 0 |
673 |
@Description: |
674 |
@@@: Default stylesheets links (as xml-stylesheet PIs) |
675 |
@@lang: en |
676 |
@Formatting: |
677 |
%styles-wiki-xml (downgrade-html); |
678 |
|
679 |
ViewFragment: |
680 |
@Name: ws--footer |
681 |
@Order: 100000 |
682 |
@Description: |
683 |
@@@: Apply user selected stylesheets |
684 |
@@lang: en |
685 |
@Formatting: |
686 |
%apply-user-preferred-style; |
687 |
|
688 |
Resource: |
689 |
@Mode:css: |
690 |
@@@: Cascading Style Sheet output |
691 |
@@lang: en |
692 |
@Mode:Default: |
693 |
@@@: |
694 |
Default |
695 |
@@lang: en |
696 |
@Mode:Reset: |
697 |
@@@: Reset default mode selection |
698 |
@@lang: en |
699 |
@Mode:Save: |
700 |
@@@: Save default mode selection |
701 |
@@lang: en |
702 |
@Style:Default: |
703 |
@@@: |
704 |
Basic Page Style |
705 |
@@: lang: en |
706 |
@Style:Reset: |
707 |
@@@: |
708 |
Reset style selection |
709 |
@@lang: en |
710 |
@Style:Save: |
711 |
@@@: |
712 |
Save style selection |
713 |
@@lang: en |
714 |
@WikiFormat:MediaType:Description:IMT:text/css##: |
715 |
@@@: CSS (Cascading Style Sheets) |
716 |
@@lang: en |
717 |
@WikiFormat:MediaType:Label:IMT:text/css##: |
718 |
@@@: CSS |
719 |
@@lang: en |
720 |
|
721 |
|