/[pub]/suikawiki/script/misc/plugins/calender.pm
Suika

Contents of /suikawiki/script/misc/plugins/calender.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.2.1 - (hide annotations) (download)
Sun May 16 23:53:45 2010 UTC (14 years, 5 months ago) by hero
Branch: helowiki-2005
Changes since 1.1: +17 -17 lines
current .pm

1 wakaba 1.1 use strict;
2     package SuikaWiki::Plugin::Registry;
3    
4    
5     our %Info;
6     $Info{q#Calender#}->{Name} = q#Calender#;
7 hero 1.1.2.1 $Info{q#Calender#}->{q#Version#} = q#2005.0121.1410#;
8 wakaba 1.1 $Info{q#Calender#}->{q#InterfaceVersion#} = q#2.9.1#;
9 hero 1.1.2.1 $Info{q#Calender#}->{q#mkpluginVersion#} = q#2.1.21#;
10     $Info{q#Calender#}->{q#module_name#} = q#SuikaWiki::Plugin::plugin::Calender1050021141024KjBQ#;
11 wakaba 1.1 $Info{q#Calender#}->{q#Date.RCS#} = q#$Date: 2010/05/16 23:53:45 $#;
12     $Info{q#Calender#}->{RequiredPlugin} = [q#Phrase#, q#WikiResource#, q#WikiStructure#, q#WikiLinking#];
13     $Info{q#Calender#}->{Description} = [[q#Calender#, q#en#, q##]];
14     $Info{q#Calender#}->{License} = [[q#%%Perl%%#, q##, q##]];
15     $Info{q#Calender#}->{Author} = [[[[q#Wakaba#, q#ja#, q#Latn#]], [[q#w@suika.fam.cx#]], [q##]]];
16 hero 1.1.2.1 package SuikaWiki::Plugin::plugin::Calender1050021141024KjBQ;
17 wakaba 1.1
18    
19     #line 1 "(WikiPlugin module source calender.wp2, block Plugin/Use)"
20     my $WIKILINKING;
21     my $WIKIRESOURCE;
22     #line 1 "(WikiPlugin module Calender, chunk 1)"
23    
24     {my $def = {q#Parameter#, {q#page#, {q#Type#, q#WikiName#, q#Default#, q#(auto)#, q#Description#, [[q#WikiPage to be tested#, q##, q##]]}, q#false#, {q#Type#, q#CDATA#, q#Default#, q#(none)#, q#Description#, [[q#Template to be evaluated when it is part of calender#, q#en#, q##]]}, q#month#, {q#Type#, q#CDATA#, q#Default#, q#(none)#, q#Description#, [[q#Template to be evaluated when it is part of calender and has
25     "month" part. This template will not be used if "day" template
26     is used.#, q#en#, q##]]}, q#day#, {q#Type#, q#CDATA#, q#Default#, q#(none)#, q#Description#, [[q#Template to be evaluated when it is part of calender and has
27     "day" information.#, q#en#, q##]]}, q#true#, {q#Type#, q#CDATA#, q#Default#, q#(none)#, q#Description#, [[q#Template to be evaluated when it is part of calender.
28     This template will not be used if "year", "month" or "day"
29     template is used.#, q#en#, q##]]}, q#year#, {q#Type#, q#CDATA#, q#Default#, q#(none)#, q#Description#, [[q#Template to be evaluated when it is part of calender.
30     This template will not be used if "month" or "day" template
31     is used.#, q##, q##]]}}, q#Description#, [[q#Test whether the WikiPage is part of calender or not#, q#en#, q##]], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_;
32    
33     #line 1 "(WikiPlugin module source calender.wp2, block FormattingRule[name()='[q#view#, q#view-resource#, q#form-input#]/if_calender']/Formatting)"
34     my $page = $o->{wiki}->name ($p->{page} or $o->{wiki}->{var}->{page});
35 hero 1.1.2.1 my $date = SuikaWiki::Plugin::plugin::Calender1050021141024KjBQ->wikiname_to_date (name => $page, o => $o);
36 wakaba 1.1 if ($date->{year}) {
37     if ($date->{day} and $p->{day}) {
38     $f->parse_attr ($p=>q#day#, $o, -parent => $p->{-parent}, -non_parsed_to_node => 1, %opt);
39     } elsif ($date->{month} and $p->{month}) {
40     $f->parse_attr ($p=>q#month#, $o, -parent => $p->{-parent}, -non_parsed_to_node => 1, %opt);
41     } elsif ($p->{year}) {
42     $f->parse_attr ($p=>q#year#, $o, -parent => $p->{-parent}, -non_parsed_to_node => 1, %opt);
43     } else {
44     $f->parse_attr ($p=>q#true#, $o, -parent => $p->{-parent}, -non_parsed_to_node => 1, %opt);
45     }
46     } else {
47     $f->parse_attr ($p=>q#false#, $o, -parent => $p->{-parent}, -non_parsed_to_node => 1, %opt);
48     }}}
49     #line 1 "(WikiPlugin module Calender, chunk 2)"
50     ;
51     $SuikaWiki::Plugin::Rule{view}->{if_calender} = $def;
52     $SuikaWiki::Plugin::Rule{view_resource}->{if_calender} = $def;
53     $SuikaWiki::Plugin::Rule{form_input}->{if_calender} = $def;
54     };
55    
56     {my $def = {q#Parameter#, {q#month#, {q#Type#, q#<<1*2DIGIT>>#, q#Default#, q#(auto)#, q#Description#, [[q#Month#, q#en#, q##]]}, q#label#, {q#Type#, q#template#, q#Default#, q#(auto)#, q#Description#, [[q#Template to be used to construct day item#, q#en#, q##]]}, q#year#, {q#Type#, q#<<4*DIGIT>>#, q#Default#, q#(auto)#, q#Description#, [[q#Year#, q#en#, q##]]}}, q#Description#, [[q#List of months in the year#, q#en#, q##]], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_;
57    
58     #line 1 "(WikiPlugin module source calender.wp2, block FormattingRule[name()='[q#form-input#, q#view#, q#view-resource#]/calender']/Formatting)"
59     require Time::Local;
60 hero 1.1.2.1 my $date = SuikaWiki::Plugin::plugin::Calender1050021141024KjBQ->wikiname_to_date
61 wakaba 1.1 (name => $o->{wiki}->name ($p->{page} ||
62     $o->{wiki}->{var}->{page}),
63     o => $o);
64     my $year = $p->{year} || $date->{year} || (gmtime)[5] + 1900;
65     my $month = $p->{month} || $date->{month} || (gmtime)[4] + 1;
66     my $dow = 0;
67     eval q{$dow = (gmtime (Time::Local::timegm_nocheck
68     (0,0,0,1, $month-1, $year)))[6]};
69     my $lom = 0;
70     eval {$lom = (gmtime (Time::Local::timegm_nocheck
71     (0,0,0,0, $month==12?0:$month, $year)))[3]};
72     my $tbl = $p->{-parent}->append_new_node
73     (type => '#element',
74     namespace_uri => q#http://www.w3.org/1999/xhtml#,
75     local_name => 'table');
76     $tbl->set_attribute (class => 'calender');
77     $tbl->set_attribute (summary => ($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))->get_op
78     ('Calender:Table:Summary', $o)
79     ->inner_text);
80     $p->{q#nocaption#} = do { my $r = $f->parse_attr ($p=>q#nocaption#, $o, -non_parsed_to_node => 1, %opt); ref $r?$r->inner_text:$r};
81     unless ($p->{nocaption}) {
82     my $caption = $tbl->append_new_node (type => '#element',
83     namespace_uri => q#http://www.w3.org/1999/xhtml#,
84     local_name => 'caption');
85     local $o->{link}->{option} = {-cal__year => $year, -cal__month => $month};
86     if ($p->{caption}) {
87     $f->parse_attr ($p=>q#caption#, $o, -parent => $caption, -non_parsed_to_node => 1, %opt);
88     } else {
89     ($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))->get_op ('Calender:Table:Caption', $o, $caption);
90     }
91     }
92     my @dayname = qw(sun mon tue wed thu fri sat);
93     for (@dayname) {
94     $tbl->append_new_node (type => '#element',
95     namespace_uri => q#http://www.w3.org/1999/xhtml#,
96     local_name => 'col')
97     ->set_attribute (class => $_);
98     }
99     $p->{q#noheader#} = do { my $r = $f->parse_attr ($p=>q#noheader#, $o, -non_parsed_to_node => 1, %opt); ref $r?$r->inner_text:$r};
100     unless ($p->{noheader}) {
101     my @wname = map {($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))->get_op
102     ('Calender:Weekday:Label:'.$_, $o)} @dayname;
103     my $row = $tbl->append_new_node
104     (type => '#element',
105     namespace_uri => q#http://www.w3.org/1999/xhtml#,
106     local_name => 'thead')
107     ->append_new_node
108     (type => '#element',
109     namespace_uri => q#http://www.w3.org/1999/xhtml#,
110     local_name => 'tr');
111     for my $i (0..6) {
112     my $cell = $row->append_new_node
113     (type => '#element',
114     namespace_uri => q#http://www.w3.org/1999/xhtml#,
115     local_name => 'th');
116     $cell->set_attribute (class => $dayname[$i]);
117     $cell->set_attribute (scope => 'col');
118     $cell->append_node ($wname[$i]);
119     }
120     }
121     my $tb = $tbl->append_new_node
122     (type => '#element',
123     namespace_uri => q#http://www.w3.org/1999/xhtml#,
124     local_name => 'tbody');
125     my $e_week;
126     unless ($dow == 0) { ## 1st day is not sunday
127     $e_week = $tb->append_new_node
128     (type => '#element',
129     namespace_uri => q#http://www.w3.org/1999/xhtml#,
130     local_name => 'tr');
131     for (1..$dow) {
132     $e_week->append_new_node
133     (type => '#element',
134     namespace_uri => q#http://www.w3.org/1999/xhtml#,
135     local_name => 'td');
136     }
137     }
138     $p->{q#day_label#} = do { my $r = $f->parse_attr ($p=>q#day_label#, $o, -non_parsed_to_node => 1, %opt); ref $r?$r->inner_text:$r};
139     my $label = $p->{day_label} || ($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))->get
140     (name => 'Calender:Day:Label',
141     o => $o, wiki => $o->{wiki});
142     $p->{q#mode#} = do { my $r = $f->parse_attr ($p=>q#mode#, $o, -non_parsed_to_node => 1, %opt); ref $r?$r->inner_text:$r};
143     for my $day (1..$lom) {
144     $e_week = $tb->append_new_node
145     (type => '#element',
146     namespace_uri => q#http://www.w3.org/1999/xhtml#,
147     local_name => 'tr')
148     if $dow == 0; ## New week
149     my $e_day = $e_week->append_new_node
150     (type => '#element',
151     namespace_uri => q#http://www.w3.org/1999/xhtml#,
152     local_name => 'td');
153     $e_day->set_attribute (class => $dayname[$dow]);
154     ($WIKILINKING ||= SuikaWiki::Plugin->module_package ('WikiLinking'))->to_wikipage_in_html ({
155     label => $label,
156     } => {
157     base => $o->{wiki}->{var}->{page},
158 hero 1.1.2.1 page_name_relative => SuikaWiki::Plugin::plugin::Calender1050021141024KjBQ->date_to_wikiname
159 wakaba 1.1 (year => $year,
160     month => $month,
161     day => $day,
162     base => $date->{base},
163     o => $o),
164     wiki_mode => $p->{mode},
165     }, {
166     o => $o,
167     parent => $e_day,
168     -cal__year => $year,
169     -cal__month => $month,
170     -cal__day => $day,
171     });
172     $dow++; $dow = 0 if $dow == 7;
173     }}}
174     #line 1 "(WikiPlugin module Calender, chunk 4)"
175     ;
176     $SuikaWiki::Plugin::Rule{form_input}->{calender} = $def;
177     $SuikaWiki::Plugin::Rule{view}->{calender} = $def;
178     $SuikaWiki::Plugin::Rule{view_resource}->{calender} = $def;
179     };
180    
181     {my $def = {q#Parameter#, {q#label#, {q#Type#, q#template#, q#Default#, q#(auto)#, q#Description#, [[q#Template to be used to construct month item#, q#en#, q##]]}, q#year#, {q#Type#, q#<<4*DIGIT>>#, q#Default#, q#(auto)#, q#Description#, [[q#Year#, q#en#, q##]]}}, q#Description#, [[q#List of months in the year#, q#en#, q##]], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_;
182    
183     #line 1 "(WikiPlugin module source calender.wp2, block FormattingRule[name()='[q#form-input#, q#view#, q#view-resource#]/calender_months']/Formatting)"
184     $p->{q#year#} = do { my $r = $f->parse_attr ($p=>q#year#, $o, -non_parsed_to_node => 1, %opt); ref $r?$r->inner_text:$r};
185 hero 1.1.2.1 my $date = SuikaWiki::Plugin::plugin::Calender1050021141024KjBQ->wikiname_to_date
186 wakaba 1.1 (name => $o->{wiki}->name ($p->{page} ||
187     $o->{wiki}->{var}->{page}),
188     o => $o);
189     my $year = $p->{year} || $date->{year} || (gmtime)[5] + 1900;
190     my $list = $p->{-parent}->append_new_node
191     (type => '#element',
192     namespace_uri => q#http://www.w3.org/1999/xhtml#,
193     local_name => 'ol');
194     $list->set_attribute (class => 'calender year');
195     $p->{q#label#} = do { my $r = $f->parse_attr ($p=>q#label#, $o, -non_parsed_to_node => 1, %opt); ref $r?$r->inner_text:$r};
196     my $label = $p->{label} || ($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))->get
197     (name => 'Calender:MonthList:Item',
198     wiki => $o->{wiki}, o => $o);
199     for (1..12) {
200     ($WIKILINKING ||= SuikaWiki::Plugin->module_package ('WikiLinking'))->to_wikipage_in_html ({
201     label => $label,
202     } => {
203     base => $o->{wiki}->{var}->{page},
204 hero 1.1.2.1 page_name_relative => SuikaWiki::Plugin::plugin::Calender1050021141024KjBQ->date_to_wikiname
205 wakaba 1.1 (year => $year,
206     month => $_,
207     base => $date->{base},
208     o => $o),
209     }, {
210     o => $o,
211     parent => $list->append_new_node
212     (type => '#element',
213     namespace_uri => q#http://www.w3.org/1999/xhtml#,
214     local_name => 'li'),
215     -cal__year => $year,
216     -cal__month => $_,
217     });
218     $list->append_text ("\n");
219     }}}
220     #line 1 "(WikiPlugin module Calender, chunk 6)"
221     ;
222     $SuikaWiki::Plugin::Rule{form_input}->{calender_months} = $def;
223     $SuikaWiki::Plugin::Rule{view}->{calender_months} = $def;
224     $SuikaWiki::Plugin::Rule{view_resource}->{calender_months} = $def;
225     };
226    
227     {my $def = {q#Parameter#, {}, q#Description#, [[q#Year number#, q#en#, q##]], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_;
228    
229     #line 1 "(WikiPlugin module source calender.wp2, block FormattingRule[name()='[q#page-link#, q#view-resource#]/calender__year']/Formatting)"
230     $p->{-parent}->append_text ($o->{link}->{option}->{-cal__year} + 0);}}
231     #line 1 "(WikiPlugin module Calender, chunk 8)"
232     ;
233     $SuikaWiki::Plugin::Rule{page_link}->{calender__year} = $def;
234     $SuikaWiki::Plugin::Rule{view_resource}->{calender__year} = $def;
235     };
236    
237     {my $def = {q#Parameter#, {}, q#Description#, [[q#Month number#, q#en#, q##]], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_;
238    
239     #line 1 "(WikiPlugin module source calender.wp2, block FormattingRule[name()='[q#page-link#, q#view-resource#]/calender__month']/Formatting)"
240     $p->{-parent}->append_text ($o->{link}->{option}->{-cal__month} + 0);}}
241     #line 1 "(WikiPlugin module Calender, chunk 10)"
242     ;
243     $SuikaWiki::Plugin::Rule{page_link}->{calender__month} = $def;
244     $SuikaWiki::Plugin::Rule{view_resource}->{calender__month} = $def;
245     };
246    
247     {my $def = {q#Parameter#, {}, q#Description#, [[q#Day number#, q#en#, q##]], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_;
248    
249     #line 1 "(WikiPlugin module source calender.wp2, block FormattingRule[name()='[q#page-link#, q#view-resource#]/calender__day']/Formatting)"
250     $p->{-parent}->append_text ($o->{link}->{option}->{-cal__day} + 0);}}
251     #line 1 "(WikiPlugin module Calender, chunk 12)"
252     ;
253     $SuikaWiki::Plugin::Rule{page_link}->{calender__day} = $def;
254     $SuikaWiki::Plugin::Rule{view_resource}->{calender__day} = $def;
255     };
256    
257     {my $def = {q#Parameter#, {q#page#, {q#Type#, q#WikiName#, q#Default#, q#(auto)#, q#Description#, [[q#Some WikiPage in calender#, q#en#, q##]]}, q#year#, {q#Type#, q#<<4*DIGIT>>#, q#Default#, q#(auto)#, q#Description#, [[q#Year number#, q#en#, q##]]}}, q#Description#, [[q#Year WikiPage name#, q#en#, q##]], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_;
258    
259     #line 1 "(WikiPlugin module source calender.wp2, block FormattingRule[name()='[q#view#, q#view-resource#, q#form-input#]/cal__year_page']/Formatting)"
260     my $page = $o->{wiki}->name ($p->{page} or $o->{wiki}->{var}->{page});
261 hero 1.1.2.1 my $date = SuikaWiki::Plugin::plugin::Calender1050021141024KjBQ->wikiname_to_date (name => $page, o => $o);
262     $p->{-parent}->append_text (SuikaWiki::Plugin::plugin::Calender1050021141024KjBQ->date_to_wikiname
263 wakaba 1.1 (base => $date->{base},
264     year => $date->{year} || (gmtime)[5] + 1900,
265     o => $o)->stringify (wiki => $o->{wiki}));}}
266     #line 1 "(WikiPlugin module Calender, chunk 14)"
267     ;
268     $SuikaWiki::Plugin::Rule{view}->{cal__year_page} = $def;
269     $SuikaWiki::Plugin::Rule{view_resource}->{cal__year_page} = $def;
270     $SuikaWiki::Plugin::Rule{form_input}->{cal__year_page} = $def;
271     };
272    
273     {my $def = {q#Parameter#, {q#page#, {q#Type#, q#WikiName#, q#Default#, q#(auto)#, q#Description#, [[q#Some WikiPage in calender#, q#en#, q##]]}, q#month#, {q#Type#, q#<<1*2DIGIT>>#, q#Default#, q#(auto)#, q#Description#, [[q#Month number#, q#en#, q##]]}, q#year#, {q#Type#, q#<<4*DIGIT>>#, q#Default#, q#(auto)#, q#Description#, [[q#Year number#, q#en#, q##]]}}, q#Description#, [[q#Year-month WikiPage name#, q#en#, q##]], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_;
274    
275     #line 1 "(WikiPlugin module source calender.wp2, block FormattingRule[name()='[q#view#, q#view-resource#, q#form-input#]/cal__month_page']/Formatting)"
276     my $page = $o->{wiki}->name ($p->{page} or $o->{wiki}->{var}->{page});
277 hero 1.1.2.1 my $date = SuikaWiki::Plugin::plugin::Calender1050021141024KjBQ->wikiname_to_date (name => $page, o => $o);
278     $p->{-parent}->append_text (SuikaWiki::Plugin::plugin::Calender1050021141024KjBQ->date_to_wikiname
279 wakaba 1.1 (base => $date->{base},
280     year => $p->{year} || $date->{year}
281     || (gmtime)[5] + 1900,
282     month => $p->{month} || $date->{month}
283     || (gmtime)[4] + 1,
284     o => $o)->stringify (wiki => $o->{wiki}));}}
285     #line 1 "(WikiPlugin module Calender, chunk 16)"
286     ;
287     $SuikaWiki::Plugin::Rule{view}->{cal__month_page} = $def;
288     $SuikaWiki::Plugin::Rule{view_resource}->{cal__month_page} = $def;
289     $SuikaWiki::Plugin::Rule{form_input}->{cal__month_page} = $def;
290     };
291    
292     {my $def = {q#Parameter#, {q#page#, {q#Type#, q#WikiName#, q#Default#, q#(auto)#, q#Description#, [[q#Some WikiPage in calender#, q#en#, q##]]}, q#month#, {q#Type#, q#<<1*2DIGIT>>#, q#Default#, q#(auto)#, q#Description#, [[q#Month number#, q#en#, q##]]}, q#day#, {q#Type#, q#<<1*2DIGIT>>#, q#Default#, q#(auto)#, q#Description#, [[q#Day number#, q#en#, q##]]}, q#year#, {q#Type#, q#<<4*DIGIT>>#, q#Default#, q#(auto)#, q#Description#, [[q#Year number#, q#en#, q##]]}}, q#Description#, [[q#Year-month-day WikiPage name#, q#en#, q##]], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_;
293    
294     #line 1 "(WikiPlugin module source calender.wp2, block FormattingRule[name()='[q#view#, q#view-resource#, q#form-input#]/cal__day_page']/Formatting)"
295     my $page = $o->{wiki}->name ($p->{page} or $o->{wiki}->{var}->{page});
296 hero 1.1.2.1 my $date = SuikaWiki::Plugin::plugin::Calender1050021141024KjBQ->wikiname_to_date (name => $page, o => $o);
297     $p->{-parent}->append_text (SuikaWiki::Plugin::plugin::Calender1050021141024KjBQ->date_to_wikiname
298 wakaba 1.1 (base => $date->{base},
299     year => $p->{year} || $date->{year}
300     || (gmtime)[5] + 1900,
301     month => $p->{month} || $date->{month}
302     || (gmtime)[4] + 1,
303     day => $p->{day} || $date->{day}
304     || (gmtime)[3],
305     o => $o)->stringify (wiki => $o->{wiki}));}}
306     #line 1 "(WikiPlugin module Calender, chunk 18)"
307     ;
308     $SuikaWiki::Plugin::Rule{view}->{cal__day_page} = $def;
309     $SuikaWiki::Plugin::Rule{view_resource}->{cal__day_page} = $def;
310     $SuikaWiki::Plugin::Rule{form_input}->{cal__day_page} = $def;
311     };
312    
313     $SuikaWiki::Plugin::Rule{view}->{link_calender_date} = {q#Parameter#, {}, q#Description#, [[q#Link to previous/next calender WikiPage#, q#en#, q##]], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_;
314    
315     #line 1 "(WikiPlugin module source calender.wp2, block FormattingRule[name()='[q#view#]/link_calender_date']/Formatting)"
316     my $page = $o->{wiki}->name ($p->{page} or $o->{wiki}->{var}->{page});
317 hero 1.1.2.1 my $date = SuikaWiki::Plugin::plugin::Calender1050021141024KjBQ->wikiname_to_date (name => $page, o => $o);
318 wakaba 1.1 my $year = $p->{year} || $date->{year} || return;
319     my $month = $p->{month} || $date->{month};
320     my $day = $p->{day} || $date->{day};
321     my ($Year, $Month, $Day) = (0, 0, 0);
322     my ($yeaR, $montH, $daY) = (0, 0, 0);
323     my %page;
324     if ($day) { ## 2003-04-01
325     require Time::Local;
326     (undef, undef, undef, $Day, $Month, $Year)
327     = gmtime (Time::Local::timegm_nocheck (0,0,0,$day, $month - 1, $year)
328     - 24 * 3600);
329     $Month++; $Year += 1900;
330     $page{prev} = {year => $Year, month => $Month, day => $Day};
331     (undef, undef, undef, $daY, $montH, $yeaR)
332     = gmtime (Time::Local::timegm_nocheck (0,0,0,$day, $month - 1, $year)
333     + 25 * 3600);
334     $montH++; $yeaR += 1900;
335     $page{next} = {year => $yeaR, month => $montH, day => $daY};
336     $page{up} = {year => $year, month => $month};
337     (undef, undef, undef, $Day, $Month, $Year)
338     = gmtime (Time::Local::timegm_nocheck (0,0,0,$day, $month - 1, $year)
339     - 7 * 24 * 3600);
340     $Month++; $Year += 1900;
341     $page{'prev-week'} = {year => $Year, month => $Month, day => $Day};
342     (undef, undef, undef, $daY, $montH, $yeaR)
343     = gmtime (Time::Local::timegm_nocheck (0,0,0,$day, $month - 1, $year)
344     + 7 * 25 * 3600);
345     $montH++; $yeaR += 1900;
346     $page{'next-week'} = {year => $yeaR, month => $montH, day => $daY};
347     } elsif ($month) { ## 2003-04
348     ($Year, $Month) = ($year, $month - 1);
349     ($Month = 12, $Year--) if $Month == 0;
350     $page{prev} = {year => $Year, month => $Month};
351     ($yeaR, $montH) = ($year, $month + 1);
352     ($montH = 1, $yeaR++) if $montH == 13;
353     $page{next} = {year => $yeaR, month => $montH};
354     $page{up} = {year => $year};
355     } else { ## 2003
356     $Year = $year - 1;
357     $page{prev} = {year => $Year};
358     $yeaR = $year + 1;
359     $page{next} = {year => $yeaR};
360     }
361     my @gmtime = gmtime;
362     $page{today} = {year => $gmtime[5] + 1900, month => $gmtime[4] + 1,
363     day => $gmtime[3]};
364     $p->{q#mode#} = do { my $r = $f->parse_attr ($p=>q#mode#, $o, -non_parsed_to_node => 1, %opt); ref $r?$r->inner_text:$r};$p->{q#with_lm#} = do { my $r = $f->parse_attr ($p=>q#with_lm#, $o, -non_parsed_to_node => 1, %opt); ref $r?$r->inner_text:$r};$p->{q#up_to_date#} = do { my $r = $f->parse_attr ($p=>q#up_to_date#, $o, -non_parsed_to_node => 1, %opt); ref $r?$r->inner_text:$r};
365     for my $rel (qw/prev next up prev-week next-week today/) {
366     next unless $page{$rel};
367     ($WIKILINKING ||= SuikaWiki::Plugin->module_package ('WikiLinking'))->to_wikipage_in_html ({
368     label => qq(%html-link;\n),
369     -ht__alt_description
370     => ($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))->get
371     (name => 'Calender:Link:'.$rel
372     .($page{$rel}->{day}?':ymd':
373     $page{$rel}->{month}?':ym':':y')
374     .':Description',
375     o => $o, wiki => $o->{wiki}),
376     } => {
377     base => $page,
378 hero 1.1.2.1 page_name_relative => SuikaWiki::Plugin::plugin::Calender1050021141024KjBQ->date_to_wikiname
379 wakaba 1.1 (base => $date->{base}, o => $o,
380     %{$page{$rel}}),
381     wiki_mode => $p->{mode},
382     _with_lm => $p->{with_lm},
383     _up_to_date => $p->{up_to_date},
384     }, {
385     o => $o,
386     parent => $p->{-parent},
387     -rel => $rel,
388     -cal__year => $page{$rel}->{year},
389     -cal__month => $page{$rel}->{month},
390     -cal__day => $page{$rel}->{day},
391     });
392     }}}
393     #line 1 "(WikiPlugin module Calender, chunk 20)"
394     ;
395    
396    
397     sub wikiname_to_date {
398    
399     #line 1 "(WikiPlugin module source calender.wp2, block Function[Name='wikiname_to_date']/Main)"
400     my (undef, %opt) = @_;
401     if ($opt{name}->[$#{$opt{name}}]
402     =~ /^([0-9]{4,})(?:-([0-9][0-9])(?:-([0-9][0-9]))?)?$/) {
403     {year => $1, month => $2, day => $3,
404     base => $opt{o}->{wiki}->name
405     ([@{$opt{name}}[0..$#{$opt{name}}-1]])};
406     } else {
407     {base => $opt{name}};
408     }
409     }
410    
411     #line 1 "(WikiPlugin module Calender, chunk 22)"
412    
413    
414    
415     sub date_to_wikiname {
416    
417     #line 1 "(WikiPlugin module source calender.wp2, block Function[Name='date_to_wikiname']/Main)"
418     my (undef, %opt) = @_;
419     my $date = sprintf '%04d', $opt{year};
420     if ($opt{month}) {
421     $date .= sprintf '-%02d', $opt{month};
422     $date .= sprintf '-%02d', $opt{day} if $opt{day};
423     }
424     my $clone = $opt{base}->clone;
425     $clone->append_component ($date);
426     $clone;
427     }
428    
429     #line 1 "(WikiPlugin module Calender, chunk 23)"
430    
431    
432     push @{$SuikaWiki::View::Implementation::TemplateFragment{q#wr__read_body#}}, {
433     Main => q#%if-calender (
434     month => {%calender;}p,
435     year => {%calender-months;}p,
436     );#,
437     Order => -10,
438     Description => [[q#"Read" mode body -- Calender#, q#en#, q##]],
439     };
440    
441     push @{$SuikaWiki::View::Implementation::TemplateFragment{q#links#}}, {
442     Main => q#%link-calender-date;#,
443     Order => -100,
444     Description => [[q#Link to previous/next WikiPage in calender#, q#en#, q##]],
445     };
446    
447     package SuikaWiki::Plugin::Resource;
448    
449     our $BaseResource;
450     $BaseResource->{q#und#}->{q##}->{q#Calender:Day:Label#} = q#%link-to-it ( label => {%calender--day;}p, description=>{%page-name(absolute);; %if-linked-wikipage-exist( true=>{%page-headline;}, false=>{(%res(name=>{Link:toWikiPage:NotExist:Description});)}, );}p, class=>{%if-linked-wikipage-exist(false=>{not-exist});}p, );#;
451     $BaseResource->{q#und#}->{q##}->{q#Calender:Link:prev:y:Description#} = q#%calender--year; (%page-name;)#;
452     $BaseResource->{q#und#}->{q##}->{q#Calender:Link:next:y:Description#} = q#%calender--year; (%page-name;)#;
453     $BaseResource->{q#und#}->{q##}->{q#Calender:Link:up:y:Description#} = q#%calender--year; (%page-name;)#;
454     $BaseResource->{q#und#}->{q##}->{q#Calender:Link:prev:ym:Description#} = q#%calender--year;-%calender--month; (%page-name;)#;
455     $BaseResource->{q#und#}->{q##}->{q#Calender:Link:next:ym:Description#} = q#%calender--year;-%calender--month; (%page-name;)#;
456     $BaseResource->{q#und#}->{q##}->{q#Calender:Link:up:ym:Description#} = q#%calender--year;-%calender--month; (%page-name;)#;
457     $BaseResource->{q#und#}->{q##}->{q#Calender:Link:prev:ymd:Description#} = q#%calender--year;-%calender--month;-%calender--day; (%page-name;)#;
458     $BaseResource->{q#und#}->{q##}->{q#Calender:Link:next:ymd:Description#} = q#%calender--year;-%calender--month;-%calender--day; (%page-name;)#;
459     $BaseResource->{q#und#}->{q##}->{q#Calender:Link:prev-week:ymd:Description#} = q#%calender--year;-%calender--month;-%calender--day; (%page-name;)#;
460     $BaseResource->{q#und#}->{q##}->{q#Calender:Link:next-week:ymd:Description#} = q#%calender--year;-%calender--month;-%calender--day; (%page-name;)#;
461     $BaseResource->{q#en#}->{q##}->{q#Calender:Link:today:ymd:Description#} = q#Today's WikiPage (%page-name;)#;
462     $BaseResource->{q#und#}->{q##}->{q#Calender:MonthList:Item#} = q#%link-to-it ( label => {%calender--month;}p, description=>{%page-name(absolute);; %if-linked-wikipage-exist( true=>{%page-headline;}, false=>{(%res(name=>{Link:toWikiPage:NotExist:Description});)}, );}p, class=>{%if-linked-wikipage-exist(false=>{not-exist});}p, );#;
463     $BaseResource->{q#und#}->{q##}->{q#Calender:Table:Caption#} = q#%link-to-wikipage ( label => {%percent;link-to-it (label => {%calender--year;});}p, page => {%cal--year-page;}p, rel => {up up}, );-%link-to-wikipage ( label => {%percent;link-to-it (label => {%calender--month;});}p, page => {%cal--month-page;}p, rel => {up}, );#;
464     $BaseResource->{q#en#}->{q##}->{q#Calender:Table:Summary#} = q#A calender. Days are listed with columns assigned to days in week (i.e. Sunday, Monday, ..., and Saturday)#;
465     $BaseResource->{q#en#}->{q##}->{q#Calender:Weekday:Long:sun#} = q#Sunday#;
466     $BaseResource->{q#en#}->{q##}->{q#Calender:Weekday:Long:mon#} = q#Monday#;
467     $BaseResource->{q#en#}->{q##}->{q#Calender:Weekday:Long:tue#} = q#Tuesday#;
468     $BaseResource->{q#en#}->{q##}->{q#Calender:Weekday:Long:wed#} = q#Wednesday#;
469     $BaseResource->{q#en#}->{q##}->{q#Calender:Weekday:Long:thu#} = q#Thursday#;
470     $BaseResource->{q#en#}->{q##}->{q#Calender:Weekday:Long:fri#} = q#Friday#;
471     $BaseResource->{q#en#}->{q##}->{q#Calender:Weekday:Long:sat#} = q#Saturday#;
472     $BaseResource->{q#en#}->{q##}->{q#Calender:Weekday:Short:sun#} = q#Sun#;
473     $BaseResource->{q#en#}->{q##}->{q#Calender:Weekday:Short:mon#} = q#Mon#;
474     $BaseResource->{q#en#}->{q##}->{q#Calender:Weekday:Short:tue#} = q#Tue#;
475     $BaseResource->{q#en#}->{q##}->{q#Calender:Weekday:Short:wed#} = q#Wed#;
476     $BaseResource->{q#en#}->{q##}->{q#Calender:Weekday:Short:thu#} = q#Thu#;
477     $BaseResource->{q#en#}->{q##}->{q#Calender:Weekday:Short:fri#} = q#Fri#;
478     $BaseResource->{q#en#}->{q##}->{q#Calender:Weekday:Short:sat#} = q#Sat#;
479     $BaseResource->{q#und#}->{q##}->{q#Calender:Weekday:Label:sun#} = q#%abbr ( short => {%res (name => {Calender:Weekday:Short:sun});}p, long => {%res (name => {Calender:Weekday:Long:sun});}p, );#;
480     $BaseResource->{q#und#}->{q##}->{q#Calender:Weekday:Label:mon#} = q#%abbr ( short => {%res (name => {Calender:Weekday:Short:mon});}p, long => {%res (name => {Calender:Weekday:Long:mon});}p, );#;
481     $BaseResource->{q#und#}->{q##}->{q#Calender:Weekday:Label:tue#} = q#%abbr ( short => {%res (name => {Calender:Weekday:Short:tue});}p, long => {%res (name => {Calender:Weekday:Long:tue});}p, );#;
482     $BaseResource->{q#und#}->{q##}->{q#Calender:Weekday:Label:wed#} = q#%abbr ( short => {%res (name => {Calender:Weekday:Short:wed});}p, long => {%res (name => {Calender:Weekday:Long:wed});}p, );#;
483     $BaseResource->{q#und#}->{q##}->{q#Calender:Weekday:Label:thu#} = q#%abbr ( short => {%res (name => {Calender:Weekday:Short:thu});}p, long => {%res (name => {Calender:Weekday:Long:thu});}p, );#;
484     $BaseResource->{q#und#}->{q##}->{q#Calender:Weekday:Label:fri#} = q#%abbr ( short => {%res (name => {Calender:Weekday:Short:fri});}p, long => {%res (name => {Calender:Weekday:Long:fri});}p, );#;
485     $BaseResource->{q#und#}->{q##}->{q#Calender:Weekday:Label:sat#} = q#%abbr ( short => {%res (name => {Calender:Weekday:Short:sat});}p, long => {%res (name => {Calender:Weekday:Long:sat});}p, );#;
486     package SuikaWiki::Plugin::Registry;
487    
488     $Info{q#Calender#}->{provide} = {q#rule#, {q#form_input#, [q#if_calender#, q#calender#, q#calender_months#, q#cal__year_page#, q#cal__month_page#, q#cal__day_page#], q#view#, [q#if_calender#, q#calender#, q#calender_months#, q#cal__year_page#, q#cal__month_page#, q#cal__day_page#, q#link_calender_date#], q#view_resource#, [q#if_calender#, q#calender#, q#calender_months#, q#calender__year#, q#calender__month#, q#calender__day#, q#cal__year_page#, q#cal__month_page#, q#cal__day_page#], q#page_link#, [q#calender__year#, q#calender__month#, q#calender__day#]}, q#viewfragment#, [{q#Name#, q#wr__read_body#}, {q#Name#, q#links#}]};
489    
490     1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24