1 |
wakaba |
1.1 |
#?SuikaWikiConfig/2.0 |
2 |
|
|
|
3 |
|
|
Plugin: |
4 |
|
|
@Name: Calender |
5 |
|
|
@Description: |
6 |
|
|
@@@: Calender |
7 |
|
|
@@lang:en |
8 |
wakaba |
1.2 |
@License: %%Perl%% |
9 |
wakaba |
1.1 |
@Author: |
10 |
|
|
@@Name: |
11 |
|
|
@@@@: Wakaba |
12 |
|
|
@@@lang:ja |
13 |
|
|
@@@script:Latn |
14 |
|
|
@@Mail[list]: w@suika.fam.cx |
15 |
|
|
@Date.RCS: |
16 |
wakaba |
1.5 |
$Date: 2004/03/29 03:21:24 $ |
17 |
wakaba |
1.1 |
@RequiredPlugin[list]: |
18 |
|
|
Phrase |
19 |
|
|
WikiResource |
20 |
|
|
WikiStructure |
21 |
|
|
WikiLinking |
22 |
|
|
@Use: |
23 |
|
|
my $WIKILINKING; |
24 |
|
|
my $WIKIRESOURCE; |
25 |
|
|
|
26 |
|
|
PluginConst: |
27 |
|
|
@NS_XHTML1: |
28 |
|
|
http://www.w3.org/1999/xhtml |
29 |
|
|
@WIKILINKING: |
30 |
|
|
{($WIKILINKING ||= SuikaWiki::Plugin->module_package ('WikiLinking'))} |
31 |
|
|
@WIKIRESOURCE: |
32 |
|
|
{($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))} |
33 |
|
|
|
34 |
|
|
FormattingRule: |
35 |
|
|
@Category[list]: |
36 |
|
|
view |
37 |
|
|
view-resource |
38 |
|
|
form-input |
39 |
|
|
@Name: if-calender |
40 |
|
|
@Description: |
41 |
|
|
@@@: Test whether the WikiPage is part of calender or not |
42 |
|
|
@@lang: en |
43 |
|
|
@Parameter: |
44 |
|
|
@@Name: day |
45 |
|
|
@@Type: CDATA |
46 |
|
|
@@Default: (none) |
47 |
|
|
@@Description: |
48 |
|
|
@@@@: |
49 |
|
|
Template to be evaluated when it is part of calender and has |
50 |
|
|
"day" information. |
51 |
|
|
@@@lang: en |
52 |
|
|
@Parameter: |
53 |
|
|
@@Name: false |
54 |
|
|
@@Type: CDATA |
55 |
|
|
@@Default: (none) |
56 |
|
|
@@Description: |
57 |
|
|
@@@@: |
58 |
|
|
Template to be evaluated when it is part of calender |
59 |
|
|
@@@lang: en |
60 |
|
|
@Parameter: |
61 |
|
|
@@Name: month |
62 |
|
|
@@Type: CDATA |
63 |
|
|
@@Default: (none) |
64 |
|
|
@@Description: |
65 |
|
|
@@@@: |
66 |
|
|
Template to be evaluated when it is part of calender and has |
67 |
|
|
"month" part. This template will not be used if "day" template |
68 |
|
|
is used. |
69 |
|
|
@@@lang: en |
70 |
|
|
@Parameter: |
71 |
|
|
@@Name: page |
72 |
|
|
@@Type: WikiName |
73 |
|
|
@@Default: (auto) |
74 |
|
|
@@Description: |
75 |
|
|
@@@@: |
76 |
|
|
WikiPage to be tested |
77 |
|
|
@@lang: en |
78 |
|
|
@Parameter: |
79 |
|
|
@@Name: true |
80 |
|
|
@@Type: CDATA |
81 |
|
|
@@Default: (none) |
82 |
|
|
@@Description: |
83 |
|
|
@@@@: |
84 |
|
|
Template to be evaluated when it is part of calender. |
85 |
|
|
This template will not be used if "year", "month" or "day" |
86 |
|
|
template is used. |
87 |
|
|
@@@lang: en |
88 |
|
|
@Parameter: |
89 |
|
|
@@Name: year |
90 |
|
|
@@Type: CDATA |
91 |
|
|
@@Default: (none) |
92 |
|
|
@@Description: |
93 |
|
|
@@@@: |
94 |
|
|
Template to be evaluated when it is part of calender. |
95 |
|
|
This template will not be used if "month" or "day" template |
96 |
|
|
is used. |
97 |
|
|
@@lang: en |
98 |
|
|
@Formatting: |
99 |
|
|
my $page = $o->{wiki}->name ($p->{page} or $o->{wiki}->{var}->{page}); |
100 |
|
|
my $date = __FUNCPACK__->wikiname_to_date (name => $page, o => $o); |
101 |
|
|
if ($date->{year}) { |
102 |
|
|
if ($date->{day} and $p->{day}) { |
103 |
|
|
__ATTRNODE:%day->{$p->{-parent}}__; |
104 |
|
|
} elsif ($date->{month} and $p->{month}) { |
105 |
|
|
__ATTRNODE:%month->{$p->{-parent}}__; |
106 |
|
|
} elsif ($p->{year}) { |
107 |
|
|
__ATTRNODE:%year->{$p->{-parent}}__; |
108 |
|
|
} else { |
109 |
|
|
__ATTRNODE:%true->{$p->{-parent}}__; |
110 |
|
|
} |
111 |
|
|
} else { |
112 |
|
|
__ATTRNODE:%false->{$p->{-parent}}__; |
113 |
|
|
} |
114 |
|
|
|
115 |
|
|
FormattingRule: |
116 |
|
|
@Category[list]: |
117 |
|
|
form-input |
118 |
|
|
view |
119 |
|
|
view-resource |
120 |
|
|
@Name: calender |
121 |
|
|
@Description: |
122 |
|
|
@@@: List of months in the year |
123 |
|
|
@@lang: en |
124 |
|
|
@Parameter: |
125 |
|
|
@@Name: label |
126 |
|
|
@@Type: template |
127 |
|
|
@@Default: (auto) |
128 |
|
|
@@Description: |
129 |
|
|
@@@@: Template to be used to construct day item |
130 |
|
|
@@@lang: en |
131 |
|
|
@Parameter: |
132 |
|
|
@@Name: month |
133 |
|
|
@@Type: <<1*2DIGIT>> |
134 |
|
|
@@Default: (auto) |
135 |
|
|
@@Description: |
136 |
|
|
@@@@: Month |
137 |
|
|
@@@lang: en |
138 |
|
|
@Parameter: |
139 |
|
|
@@Name: year |
140 |
|
|
@@Type: <<4*DIGIT>> |
141 |
|
|
@@Default: (auto) |
142 |
|
|
@@Description: |
143 |
|
|
@@@@: Year |
144 |
|
|
@@@lang: en |
145 |
|
|
@Formatting: |
146 |
|
|
require Time::Local; |
147 |
|
|
my $date = __FUNCPACK__->wikiname_to_date |
148 |
|
|
(name => $o->{wiki}->name ($p->{page} || |
149 |
|
|
$o->{wiki}->{var}->{page}), |
150 |
|
|
o => $o); |
151 |
|
|
my $year = $p->{year} || $date->{year} || (gmtime)[5] + 1900; |
152 |
|
|
my $month = $p->{month} || $date->{month} || (gmtime)[4] + 1; |
153 |
|
|
|
154 |
|
|
my $dow = 0; |
155 |
|
|
eval q{$dow = (gmtime (Time::Local::timegm_nocheck |
156 |
|
|
(0,0,0,1, $month-1, $year)))[6]}; |
157 |
|
|
my $lom = 0; |
158 |
|
|
eval {$lom = (gmtime (Time::Local::timegm_nocheck |
159 |
|
|
(0,0,0,0, $month==12?0:$month, $year)))[3]}; |
160 |
|
|
|
161 |
|
|
my $tbl = $p->{-parent}->append_new_node |
162 |
|
|
(type => '#element', |
163 |
|
|
namespace_uri => $NS_XHTML1, |
164 |
|
|
local_name => 'table'); |
165 |
|
|
$tbl->set_attribute (class => 'calender'); |
166 |
|
|
$tbl->set_attribute (summary => $WIKIRESOURCE->get_op |
167 |
|
|
('Calender:Table:Summary', $o) |
168 |
|
|
->inner_text); |
169 |
|
|
|
170 |
|
|
__ATTRTEXT:%nocaption__; |
171 |
|
|
unless ($p->{nocaption}) { |
172 |
|
|
my $caption = $tbl->append_new_node (type => '#element', |
173 |
|
|
namespace_uri => $NS_XHTML1, |
174 |
|
|
local_name => 'caption'); |
175 |
|
|
local $o->{link}->{option} = {-cal__year => $year, -cal__month => $month}; |
176 |
|
|
if ($p->{caption}) { |
177 |
|
|
__ATTRNODE:%caption->{$caption}__; |
178 |
|
|
} else { |
179 |
|
|
$WIKIRESOURCE->get_op ('Calender:Table:Caption', $o, $caption); |
180 |
|
|
} |
181 |
|
|
} |
182 |
|
|
|
183 |
|
|
my @dayname = qw(sun mon tue wed thu fri sat); |
184 |
|
|
for (@dayname) { |
185 |
|
|
$tbl->append_new_node (type => '#element', |
186 |
|
|
namespace_uri => $NS_XHTML1, |
187 |
|
|
local_name => 'col') |
188 |
|
|
->set_attribute (class => $_); |
189 |
|
|
} |
190 |
|
|
|
191 |
|
|
__ATTRTEXT:%noheader__; |
192 |
|
|
unless ($p->{noheader}) { |
193 |
|
|
my @wname = map {$WIKIRESOURCE->get_op |
194 |
|
|
('Calender:Weekday:Label:'.$_, $o)} @dayname; |
195 |
|
|
my $row = $tbl->append_new_node |
196 |
|
|
(type => '#element', |
197 |
|
|
namespace_uri => $NS_XHTML1, |
198 |
|
|
local_name => 'thead') |
199 |
|
|
->append_new_node |
200 |
|
|
(type => '#element', |
201 |
|
|
namespace_uri => $NS_XHTML1, |
202 |
|
|
local_name => 'tr'); |
203 |
|
|
for my $i (0..6) { |
204 |
|
|
my $cell = $row->append_new_node |
205 |
|
|
(type => '#element', |
206 |
|
|
namespace_uri => $NS_XHTML1, |
207 |
|
|
local_name => 'th'); |
208 |
|
|
$cell->set_attribute (class => $dayname[$i]); |
209 |
|
|
$cell->set_attribute (scope => 'col'); |
210 |
|
|
$cell->append_node ($wname[$i]); |
211 |
|
|
} |
212 |
|
|
} |
213 |
|
|
|
214 |
|
|
my $tb = $tbl->append_new_node |
215 |
|
|
(type => '#element', |
216 |
|
|
namespace_uri => $NS_XHTML1, |
217 |
|
|
local_name => 'tbody'); |
218 |
|
|
my $e_week; |
219 |
|
|
unless ($dow == 0) { ## 1st day is not sunday |
220 |
|
|
$e_week = $tb->append_new_node |
221 |
|
|
(type => '#element', |
222 |
|
|
namespace_uri => $NS_XHTML1, |
223 |
|
|
local_name => 'tr'); |
224 |
|
|
for (1..$dow) { |
225 |
|
|
$e_week->append_new_node |
226 |
|
|
(type => '#element', |
227 |
|
|
namespace_uri => $NS_XHTML1, |
228 |
|
|
local_name => 'td'); |
229 |
|
|
} |
230 |
|
|
} |
231 |
|
|
|
232 |
|
|
__ATTRTEXT:%day_label__; |
233 |
|
|
my $label = $p->{day_label} || $WIKIRESOURCE->get |
234 |
|
|
(name => 'Calender:Day:Label', |
235 |
|
|
o => $o, wiki => $o->{wiki}); |
236 |
|
|
__ATTRTEXT:%mode__; |
237 |
|
|
for my $day (1..$lom) { |
238 |
|
|
$e_week = $tb->append_new_node |
239 |
|
|
(type => '#element', |
240 |
|
|
namespace_uri => $NS_XHTML1, |
241 |
|
|
local_name => 'tr') |
242 |
|
|
if $dow == 0; ## New week |
243 |
|
|
my $e_day = $e_week->append_new_node |
244 |
|
|
(type => '#element', |
245 |
|
|
namespace_uri => $NS_XHTML1, |
246 |
|
|
local_name => 'td'); |
247 |
|
|
$e_day->set_attribute (class => $dayname[$dow]); |
248 |
|
|
$WIKILINKING->to_wikipage_in_html ({ |
249 |
|
|
label => $label, |
250 |
|
|
} => { |
251 |
|
|
base => $o->{wiki}->{var}->{page}, |
252 |
|
|
page_name_relative => __FUNCPACK__->date_to_wikiname |
253 |
|
|
(year => $year, |
254 |
|
|
month => $month, |
255 |
|
|
day => $day, |
256 |
|
|
base => $date->{base}, |
257 |
|
|
o => $o), |
258 |
|
|
wiki_mode => $p->{mode}, |
259 |
|
|
}, { |
260 |
|
|
o => $o, |
261 |
|
|
parent => $e_day, |
262 |
|
|
-cal__year => $year, |
263 |
|
|
-cal__month => $month, |
264 |
|
|
-cal__day => $day, |
265 |
|
|
}); |
266 |
|
|
$dow++; $dow = 0 if $dow == 7; |
267 |
|
|
} |
268 |
|
|
|
269 |
|
|
FormattingRule: |
270 |
|
|
@Category[list]: |
271 |
|
|
form-input |
272 |
|
|
view |
273 |
|
|
view-resource |
274 |
|
|
@Name: calender-months |
275 |
|
|
@Description: |
276 |
|
|
@@@: List of months in the year |
277 |
|
|
@@lang: en |
278 |
|
|
@Parameter: |
279 |
|
|
@@Name: label |
280 |
|
|
@@Type: template |
281 |
|
|
@@Default: (auto) |
282 |
|
|
@@Description: |
283 |
|
|
@@@@: Template to be used to construct month item |
284 |
|
|
@@@lang: en |
285 |
|
|
@Parameter: |
286 |
|
|
@@Name: year |
287 |
|
|
@@Type: <<4*DIGIT>> |
288 |
|
|
@@Default: (auto) |
289 |
|
|
@@Description: |
290 |
|
|
@@@@: Year |
291 |
|
|
@@@lang: en |
292 |
|
|
@Formatting: |
293 |
|
|
__ATTRTEXT:%year__; |
294 |
|
|
my $date = __FUNCPACK__->wikiname_to_date |
295 |
|
|
(name => $o->{wiki}->name ($p->{page} || |
296 |
|
|
$o->{wiki}->{var}->{page}), |
297 |
|
|
o => $o); |
298 |
|
|
my $year = $p->{year} || $date->{year} || (gmtime)[5] + 1900; |
299 |
|
|
my $list = $p->{-parent}->append_new_node |
300 |
|
|
(type => '#element', |
301 |
|
|
namespace_uri => $NS_XHTML1, |
302 |
|
|
local_name => 'ol'); |
303 |
|
|
$list->set_attribute (class => 'calender year'); |
304 |
|
|
|
305 |
|
|
__ATTRTEXT:%label__; |
306 |
|
|
my $label = $p->{label} || $WIKIRESOURCE->get |
307 |
|
|
(name => 'Calender:MonthList:Item', |
308 |
|
|
wiki => $o->{wiki}, o => $o); |
309 |
|
|
for (1..12) { |
310 |
|
|
$WIKILINKING->to_wikipage_in_html ({ |
311 |
|
|
label => $label, |
312 |
|
|
} => { |
313 |
|
|
base => $o->{wiki}->{var}->{page}, |
314 |
|
|
page_name_relative => __FUNCPACK__->date_to_wikiname |
315 |
|
|
(year => $year, |
316 |
|
|
month => $_, |
317 |
|
|
base => $date->{base}, |
318 |
|
|
o => $o), |
319 |
|
|
}, { |
320 |
|
|
o => $o, |
321 |
|
|
parent => $list->append_new_node |
322 |
|
|
(type => '#element', |
323 |
|
|
namespace_uri => $NS_XHTML1, |
324 |
|
|
local_name => 'li'), |
325 |
|
|
-cal__year => $year, |
326 |
|
|
-cal__month => $_, |
327 |
|
|
}); |
328 |
|
|
$list->append_text ("\n"); |
329 |
|
|
} |
330 |
|
|
|
331 |
|
|
FormattingRule: |
332 |
|
|
@Category[list]: |
333 |
|
|
page-link |
334 |
|
|
view-resource |
335 |
|
|
@Name: calender--year |
336 |
|
|
@Description: |
337 |
|
|
@@@: Year number |
338 |
|
|
@@lang: en |
339 |
|
|
@Formatting: |
340 |
|
|
$p->{-parent}->append_text ($o->{link}->{option}->{-cal__year} + 0); |
341 |
|
|
|
342 |
|
|
FormattingRule: |
343 |
|
|
@Category[list]: |
344 |
|
|
page-link |
345 |
|
|
view-resource |
346 |
|
|
@Name: calender--month |
347 |
|
|
@Description: |
348 |
|
|
@@@: Month number |
349 |
|
|
@@lang: en |
350 |
|
|
@Formatting: |
351 |
|
|
$p->{-parent}->append_text ($o->{link}->{option}->{-cal__month} + 0); |
352 |
|
|
|
353 |
|
|
FormattingRule: |
354 |
|
|
@Category[list]: |
355 |
|
|
page-link |
356 |
|
|
view-resource |
357 |
|
|
@Name: |
358 |
|
|
calender--day |
359 |
|
|
@Description: |
360 |
|
|
@@@: Day number |
361 |
|
|
@@lang: en |
362 |
|
|
@Formatting: |
363 |
|
|
$p->{-parent}->append_text ($o->{link}->{option}->{-cal__day} + 0); |
364 |
|
|
|
365 |
|
|
FormattingRule: |
366 |
|
|
@Category[list]: |
367 |
|
|
view |
368 |
|
|
view-resource |
369 |
|
|
form-input |
370 |
|
|
@Name: cal--year-page |
371 |
|
|
@Description: |
372 |
|
|
@@@: Year WikiPage name |
373 |
|
|
@@lang: en |
374 |
|
|
@Parameter: |
375 |
|
|
@@Name: page |
376 |
|
|
@@Type: WikiName |
377 |
|
|
@@Default: (auto) |
378 |
|
|
@@Description: |
379 |
|
|
@@@@: Some WikiPage in calender |
380 |
|
|
@@@lang: en |
381 |
|
|
@Parameter: |
382 |
|
|
@@Name: year |
383 |
|
|
@@Type: <<4*DIGIT>> |
384 |
|
|
@@Default: (auto) |
385 |
|
|
@@Description: |
386 |
|
|
@@@@: Year number |
387 |
|
|
@@@lang: en |
388 |
|
|
@Formatting: |
389 |
|
|
my $page = $o->{wiki}->name ($p->{page} or $o->{wiki}->{var}->{page}); |
390 |
|
|
my $date = __FUNCPACK__->wikiname_to_date (name => $page, o => $o); |
391 |
|
|
$p->{-parent}->append_text (__FUNCPACK__->date_to_wikiname |
392 |
|
|
(base => $date->{base}, |
393 |
wakaba |
1.4 |
year => $date->{year} || (gmtime)[5] + 1900, |
394 |
wakaba |
1.1 |
o => $o)->stringify (wiki => $o->{wiki})); |
395 |
|
|
|
396 |
|
|
FormattingRule: |
397 |
|
|
@Category[list]: |
398 |
|
|
view |
399 |
|
|
view-resource |
400 |
|
|
form-input |
401 |
|
|
@Name: cal--month-page |
402 |
|
|
@Description: |
403 |
|
|
@@@: Year-month WikiPage name |
404 |
|
|
@@lang: en |
405 |
|
|
@Parameter: |
406 |
|
|
@@Name: month |
407 |
|
|
@@Type: <<1*2DIGIT>> |
408 |
|
|
@@Default: (auto) |
409 |
|
|
@@Description: |
410 |
|
|
@@@@: Month number |
411 |
|
|
@@@lang: en |
412 |
|
|
@Parameter: |
413 |
|
|
@@Name: page |
414 |
|
|
@@Type: WikiName |
415 |
|
|
@@Default: (auto) |
416 |
|
|
@@Description: |
417 |
|
|
@@@@: Some WikiPage in calender |
418 |
|
|
@@@lang: en |
419 |
|
|
@Parameter: |
420 |
|
|
@@Name: year |
421 |
|
|
@@Type: <<4*DIGIT>> |
422 |
|
|
@@Default: (auto) |
423 |
|
|
@@Description: |
424 |
|
|
@@@@: Year number |
425 |
|
|
@@@lang: en |
426 |
|
|
@Formatting: |
427 |
|
|
my $page = $o->{wiki}->name ($p->{page} or $o->{wiki}->{var}->{page}); |
428 |
|
|
my $date = __FUNCPACK__->wikiname_to_date (name => $page, o => $o); |
429 |
|
|
$p->{-parent}->append_text (__FUNCPACK__->date_to_wikiname |
430 |
|
|
(base => $date->{base}, |
431 |
wakaba |
1.4 |
year => $p->{year} || $date->{year} |
432 |
|
|
|| (gmtime)[5] + 1900, |
433 |
|
|
month => $p->{month} || $date->{month} |
434 |
|
|
|| (gmtime)[4] + 1, |
435 |
wakaba |
1.1 |
o => $o)->stringify (wiki => $o->{wiki})); |
436 |
|
|
|
437 |
|
|
FormattingRule: |
438 |
|
|
@Category[list]: |
439 |
|
|
view |
440 |
|
|
view-resource |
441 |
|
|
form-input |
442 |
|
|
@Name: cal--day-page |
443 |
|
|
@Description: |
444 |
|
|
@@@: Year-month-day WikiPage name |
445 |
|
|
@@lang: en |
446 |
|
|
@Parameter: |
447 |
|
|
@@Name: day |
448 |
|
|
@@Type: <<1*2DIGIT>> |
449 |
|
|
@@Default: (auto) |
450 |
|
|
@@Description: |
451 |
|
|
@@@@: Day number |
452 |
|
|
@@@lang: en |
453 |
|
|
@Parameter: |
454 |
|
|
@@Name: month |
455 |
|
|
@@Type: <<1*2DIGIT>> |
456 |
|
|
@@Default: (auto) |
457 |
|
|
@@Description: |
458 |
|
|
@@@@: Month number |
459 |
|
|
@@@lang: en |
460 |
|
|
@Parameter: |
461 |
|
|
@@Name: page |
462 |
|
|
@@Type: WikiName |
463 |
|
|
@@Default: (auto) |
464 |
|
|
@@Description: |
465 |
|
|
@@@@: Some WikiPage in calender |
466 |
|
|
@@@lang: en |
467 |
|
|
@Parameter: |
468 |
|
|
@@Name: year |
469 |
|
|
@@Type: <<4*DIGIT>> |
470 |
|
|
@@Default: (auto) |
471 |
|
|
@@Description: |
472 |
|
|
@@@@: Year number |
473 |
|
|
@@@lang: en |
474 |
|
|
@Formatting: |
475 |
|
|
my $page = $o->{wiki}->name ($p->{page} or $o->{wiki}->{var}->{page}); |
476 |
|
|
my $date = __FUNCPACK__->wikiname_to_date (name => $page, o => $o); |
477 |
|
|
$p->{-parent}->append_text (__FUNCPACK__->date_to_wikiname |
478 |
|
|
(base => $date->{base}, |
479 |
wakaba |
1.4 |
year => $p->{year} || $date->{year} |
480 |
|
|
|| (gmtime)[5] + 1900, |
481 |
|
|
month => $p->{month} || $date->{month} |
482 |
|
|
|| (gmtime)[4] + 1, |
483 |
|
|
day => $p->{day} || $date->{day} |
484 |
|
|
|| (gmtime)[3], |
485 |
wakaba |
1.1 |
o => $o)->stringify (wiki => $o->{wiki})); |
486 |
|
|
|
487 |
|
|
FormattingRule: |
488 |
|
|
@Category[list]: |
489 |
|
|
view |
490 |
|
|
@Name: |
491 |
|
|
link-calender-date |
492 |
|
|
@Description: |
493 |
|
|
@@@: Link to previous/next calender WikiPage |
494 |
|
|
@@lang: en |
495 |
|
|
@Formatting: |
496 |
|
|
my $page = $o->{wiki}->name ($p->{page} or $o->{wiki}->{var}->{page}); |
497 |
|
|
my $date = __FUNCPACK__->wikiname_to_date (name => $page, o => $o); |
498 |
|
|
my $year = $p->{year} || $date->{year} || return; |
499 |
|
|
my $month = $p->{month} || $date->{month}; |
500 |
|
|
my $day = $p->{day} || $date->{day}; |
501 |
|
|
|
502 |
|
|
my ($Year, $Month, $Day) = (0, 0, 0); |
503 |
|
|
my ($yeaR, $montH, $daY) = (0, 0, 0); |
504 |
|
|
my %page; |
505 |
|
|
if ($day) { ## 2003-04-01 |
506 |
|
|
require Time::Local; |
507 |
|
|
(undef, undef, undef, $Day, $Month, $Year) |
508 |
|
|
= gmtime (Time::Local::timegm_nocheck (0,0,0,$day, $month - 1, $year) |
509 |
|
|
- 24 * 3600); |
510 |
|
|
$Month++; $Year += 1900; |
511 |
|
|
$page{prev} = {year => $Year, month => $Month, day => $Day}; |
512 |
|
|
(undef, undef, undef, $daY, $montH, $yeaR) |
513 |
|
|
= gmtime (Time::Local::timegm_nocheck (0,0,0,$day, $month - 1, $year) |
514 |
|
|
+ 25 * 3600); |
515 |
|
|
$montH++; $yeaR += 1900; |
516 |
|
|
$page{next} = {year => $yeaR, month => $montH, day => $daY}; |
517 |
|
|
$page{up} = {year => $year, month => $month}; |
518 |
|
|
(undef, undef, undef, $Day, $Month, $Year) |
519 |
|
|
= gmtime (Time::Local::timegm_nocheck (0,0,0,$day, $month - 1, $year) |
520 |
|
|
- 7 * 24 * 3600); |
521 |
|
|
$Month++; $Year += 1900; |
522 |
|
|
$page{'prev-week'} = {year => $Year, month => $Month, day => $Day}; |
523 |
|
|
(undef, undef, undef, $daY, $montH, $yeaR) |
524 |
|
|
= gmtime (Time::Local::timegm_nocheck (0,0,0,$day, $month - 1, $year) |
525 |
|
|
+ 7 * 25 * 3600); |
526 |
|
|
$montH++; $yeaR += 1900; |
527 |
|
|
$page{'next-week'} = {year => $yeaR, month => $montH, day => $daY}; |
528 |
|
|
} elsif ($month) { ## 2003-04 |
529 |
|
|
($Year, $Month) = ($year, $month - 1); |
530 |
|
|
($Month = 12, $Year--) if $Month == 0; |
531 |
|
|
$page{prev} = {year => $Year, month => $Month}; |
532 |
|
|
($yeaR, $montH) = ($year, $month + 1); |
533 |
|
|
($montH = 1, $yeaR++) if $montH == 13; |
534 |
|
|
$page{next} = {year => $yeaR, month => $montH}; |
535 |
|
|
$page{up} = {year => $year}; |
536 |
|
|
} else { ## 2003 |
537 |
|
|
$Year = $year - 1; |
538 |
|
|
$page{prev} = {year => $Year}; |
539 |
|
|
$yeaR = $year + 1; |
540 |
|
|
$page{next} = {year => $yeaR}; |
541 |
|
|
} |
542 |
wakaba |
1.5 |
|
543 |
|
|
my @gmtime = gmtime; |
544 |
|
|
$page{today} = {year => $gmtime[5] + 1900, month => $gmtime[4] + 1, |
545 |
|
|
day => $gmtime[3]}; |
546 |
wakaba |
1.1 |
|
547 |
|
|
__ATTRTEXT:%mode__;__ATTRTEXT:%with_lm__;__ATTRTEXT:%up_to_date__; |
548 |
wakaba |
1.5 |
for my $rel (qw/prev next up prev-week next-week today/) { |
549 |
wakaba |
1.1 |
next unless $page{$rel}; |
550 |
|
|
$WIKILINKING->to_wikipage_in_html ({ |
551 |
|
|
label => qq(%html-link;\n), |
552 |
|
|
-ht__alt_description |
553 |
|
|
=> $WIKIRESOURCE->get |
554 |
|
|
(name => 'Calender:Link:'.$rel |
555 |
|
|
.($page{$rel}->{day}?':ymd': |
556 |
|
|
$page{$rel}->{month}?':ym':':y') |
557 |
|
|
.':Description', |
558 |
|
|
o => $o, wiki => $o->{wiki}), |
559 |
|
|
} => { |
560 |
|
|
base => $page, |
561 |
|
|
page_name_relative => __FUNCPACK__->date_to_wikiname |
562 |
|
|
(base => $date->{base}, o => $o, |
563 |
|
|
%{$page{$rel}}), |
564 |
|
|
wiki_mode => $p->{mode}, |
565 |
|
|
_with_lm => $p->{with_lm}, |
566 |
|
|
_up_to_date => $p->{up_to_date}, |
567 |
|
|
}, { |
568 |
|
|
o => $o, |
569 |
|
|
parent => $p->{-parent}, |
570 |
|
|
-rel => $rel, |
571 |
|
|
-cal__year => $page{$rel}->{year}, |
572 |
|
|
-cal__month => $page{$rel}->{month}, |
573 |
|
|
-cal__day => $page{$rel}->{day}, |
574 |
|
|
}); |
575 |
|
|
} |
576 |
|
|
|
577 |
|
|
|
578 |
|
|
Function: |
579 |
|
|
@Name: wikiname_to_date |
580 |
|
|
@Description: |
581 |
|
|
@@@: |
582 |
|
|
Return what time is the WikiPage means, if it is part of calender. |
583 |
|
|
@@lang: en |
584 |
|
|
@Main: |
585 |
|
|
my (undef, %opt) = @_; |
586 |
|
|
if ($opt{name}->[$#{$opt{name}}] |
587 |
|
|
=~ /^([0-9]{4,})(?:-([0-9][0-9])(?:-([0-9][0-9]))?)?$/) { |
588 |
|
|
{year => $1, month => $2, day => $3, |
589 |
|
|
base => $opt{o}->{wiki}->name |
590 |
|
|
([@{$opt{name}}[0..$#{$opt{name}}-1]])}; |
591 |
|
|
} else { |
592 |
|
|
{base => $opt{name}}; |
593 |
|
|
} |
594 |
|
|
|
595 |
|
|
Function: |
596 |
|
|
@Name: date_to_wikiname |
597 |
wakaba |
1.3 |
@Description: |
598 |
|
|
@@@: Generates WikiName from date |
599 |
|
|
@@lang: en |
600 |
wakaba |
1.1 |
@Main: |
601 |
|
|
my (undef, %opt) = @_; |
602 |
|
|
my $date = sprintf '%04d', $opt{year}; |
603 |
wakaba |
1.3 |
if ($opt{month}) { |
604 |
|
|
$date .= sprintf '-%02d', $opt{month}; |
605 |
|
|
$date .= sprintf '-%02d', $opt{day} if $opt{day}; |
606 |
|
|
} |
607 |
wakaba |
1.1 |
my $clone = $opt{base}->clone; |
608 |
|
|
$clone->append_component ($date); |
609 |
|
|
$clone; |
610 |
|
|
|
611 |
|
|
ViewFragment: |
612 |
|
|
@Template[list]:wr--read-body |
613 |
|
|
@Order: -10 |
614 |
|
|
@Description: |
615 |
|
|
@@@: "Read" mode body -- Calender |
616 |
|
|
@@lang:en |
617 |
|
|
@Formatting: |
618 |
|
|
%if-calender ( |
619 |
|
|
month => {%calender;}p, |
620 |
|
|
year => {%calender-months;}p, |
621 |
|
|
); |
622 |
|
|
|
623 |
|
|
ViewFragment: |
624 |
|
|
@Template[list]: links |
625 |
|
|
@Order: -100 |
626 |
|
|
@Description: |
627 |
|
|
@@@: Link to previous/next WikiPage in calender |
628 |
|
|
@@lang:en |
629 |
|
|
@Formatting: |
630 |
|
|
%link-calender-date; |
631 |
|
|
|
632 |
|
|
Resource: |
633 |
|
|
@Calender:Day:Label: |
634 |
|
|
%link-to-it ( |
635 |
|
|
label => {%calender--day;}p, |
636 |
|
|
description=>{%page-name(absolute);; %if-linked-wikipage-exist( |
637 |
|
|
true=>{%page-headline;}, |
638 |
|
|
false=>{(%res(name=>{Link:toWikiPage:NotExist:Description});)}, |
639 |
|
|
);}p, |
640 |
|
|
class=>{%if-linked-wikipage-exist(false=>{not-exist});}p, |
641 |
|
|
); |
642 |
|
|
@Calender:Link:prev:y:Description: |
643 |
|
|
%calender--year; (%page-name;) |
644 |
|
|
@Calender:Link:next:y:Description: |
645 |
|
|
%calender--year; (%page-name;) |
646 |
|
|
@Calender:Link:up:y:Description: |
647 |
|
|
%calender--year; (%page-name;) |
648 |
|
|
@Calender:Link:prev:ym:Description: |
649 |
|
|
%calender--year;-%calender--month; (%page-name;) |
650 |
|
|
@Calender:Link:next:ym:Description: |
651 |
|
|
%calender--year;-%calender--month; (%page-name;) |
652 |
|
|
@Calender:Link:up:ym:Description: |
653 |
|
|
%calender--year;-%calender--month; (%page-name;) |
654 |
|
|
@Calender:Link:prev:ymd:Description: |
655 |
|
|
%calender--year;-%calender--month;-%calender--day; (%page-name;) |
656 |
|
|
@Calender:Link:next:ymd:Description: |
657 |
|
|
%calender--year;-%calender--month;-%calender--day; (%page-name;) |
658 |
|
|
@Calender:Link:prev-week:ymd:Description: |
659 |
|
|
%calender--year;-%calender--month;-%calender--day; (%page-name;) |
660 |
|
|
@Calender:Link:next-week:ymd:Description: |
661 |
|
|
%calender--year;-%calender--month;-%calender--day; (%page-name;) |
662 |
wakaba |
1.5 |
@Calender:Link:today:ymd:Description: |
663 |
|
|
@@@: Today's WikiPage (%page-name;) |
664 |
|
|
@@lang: en |
665 |
wakaba |
1.1 |
@Calender:MonthList:Item: |
666 |
|
|
%link-to-it ( |
667 |
|
|
label => {%calender--month;}p, |
668 |
|
|
description=>{%page-name(absolute);; %if-linked-wikipage-exist( |
669 |
|
|
true=>{%page-headline;}, |
670 |
|
|
false=>{(%res(name=>{Link:toWikiPage:NotExist:Description});)}, |
671 |
|
|
);}p, |
672 |
|
|
class=>{%if-linked-wikipage-exist(false=>{not-exist});}p, |
673 |
|
|
); |
674 |
|
|
@Calender:Table:Caption: |
675 |
|
|
%link-to-wikipage ( |
676 |
|
|
label => {%percent;link-to-it (label => {%calender--year;});}p, |
677 |
|
|
page => {%cal--year-page;}p, |
678 |
|
|
rel => {up up}, |
679 |
|
|
);-%link-to-wikipage ( |
680 |
|
|
label => {%percent;link-to-it (label => {%calender--month;});}p, |
681 |
|
|
page => {%cal--month-page;}p, |
682 |
|
|
rel => {up}, |
683 |
|
|
); |
684 |
|
|
@Calender:Table:Summary: |
685 |
|
|
@@@: |
686 |
|
|
A calender. Days are listed with columns assigned to days in week |
687 |
|
|
(i.e. Sunday, Monday, ..., and Saturday) |
688 |
|
|
@@lang: en |
689 |
|
|
@Calender:Weekday:Long:sun: |
690 |
|
|
@@@: Sunday |
691 |
|
|
@@lang: en |
692 |
|
|
@Calender:Weekday:Long:mon: |
693 |
|
|
@@@: Monday |
694 |
|
|
@@lang: en |
695 |
|
|
@Calender:Weekday:Long:tue: |
696 |
|
|
@@@: Tuesday |
697 |
|
|
@@lang: en |
698 |
|
|
@Calender:Weekday:Long:wed: |
699 |
|
|
@@@: Wednesday |
700 |
|
|
@@lang: en |
701 |
|
|
@Calender:Weekday:Long:thu: |
702 |
|
|
@@@: Thursday |
703 |
|
|
@@lang: en |
704 |
|
|
@Calender:Weekday:Long:fri: |
705 |
|
|
@@@: Friday |
706 |
|
|
@@lang: en |
707 |
|
|
@Calender:Weekday:Long:sat: |
708 |
|
|
@@@: Saturday |
709 |
|
|
@@lang: en |
710 |
|
|
@Calender:Weekday:Short:sun: |
711 |
|
|
@@@: Sun |
712 |
|
|
@@lang: en |
713 |
|
|
@Calender:Weekday:Short:mon: |
714 |
|
|
@@@: Mon |
715 |
|
|
@@lang: en |
716 |
|
|
@Calender:Weekday:Short:tue: |
717 |
|
|
@@@: Tue |
718 |
|
|
@@lang: en |
719 |
|
|
@Calender:Weekday:Short:wed: |
720 |
|
|
@@@: Wed |
721 |
|
|
@@lang: en |
722 |
|
|
@Calender:Weekday:Short:thu: |
723 |
|
|
@@@: Thu |
724 |
|
|
@@lang: en |
725 |
|
|
@Calender:Weekday:Short:fri: |
726 |
|
|
@@@: Fri |
727 |
|
|
@@lang: en |
728 |
|
|
@Calender:Weekday:Short:sat: |
729 |
|
|
@@@: Sat |
730 |
|
|
@@lang: en |
731 |
|
|
@Calender:Weekday:Label:sun: |
732 |
|
|
%abbr ( |
733 |
|
|
short => {%res (name => {Calender:Weekday:Short:sun});}p, |
734 |
|
|
long => {%res (name => {Calender:Weekday:Long:sun});}p, |
735 |
|
|
); |
736 |
|
|
@Calender:Weekday:Label:mon: |
737 |
|
|
%abbr ( |
738 |
|
|
short => {%res (name => {Calender:Weekday:Short:mon});}p, |
739 |
|
|
long => {%res (name => {Calender:Weekday:Long:mon});}p, |
740 |
|
|
); |
741 |
|
|
@Calender:Weekday:Label:tue: |
742 |
|
|
%abbr ( |
743 |
|
|
short => {%res (name => {Calender:Weekday:Short:tue});}p, |
744 |
|
|
long => {%res (name => {Calender:Weekday:Long:tue});}p, |
745 |
|
|
); |
746 |
|
|
@Calender:Weekday:Label:wed: |
747 |
|
|
%abbr ( |
748 |
|
|
short => {%res (name => {Calender:Weekday:Short:wed});}p, |
749 |
|
|
long => {%res (name => {Calender:Weekday:Long:wed});}p, |
750 |
|
|
); |
751 |
|
|
@Calender:Weekday:Label:thu: |
752 |
|
|
%abbr ( |
753 |
|
|
short => {%res (name => {Calender:Weekday:Short:thu});}p, |
754 |
|
|
long => {%res (name => {Calender:Weekday:Long:thu});}p, |
755 |
|
|
); |
756 |
|
|
@Calender:Weekday:Label:fri: |
757 |
|
|
%abbr ( |
758 |
|
|
short => {%res (name => {Calender:Weekday:Short:fri});}p, |
759 |
|
|
long => {%res (name => {Calender:Weekday:Long:fri});}p, |
760 |
|
|
); |
761 |
|
|
@Calender:Weekday:Label:sat: |
762 |
|
|
%abbr ( |
763 |
|
|
short => {%res (name => {Calender:Weekday:Short:sat});}p, |
764 |
|
|
long => {%res (name => {Calender:Weekday:Long:sat});}p, |
765 |
|
|
); |
766 |
|
|
|
767 |
|
|
|
768 |
|
|
|