line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OurCal; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
789
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
4
|
1
|
|
|
1
|
|
483
|
use OurCal::Day; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
5
|
1
|
|
|
1
|
|
629
|
use OurCal::Month; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
6
|
1
|
|
|
1
|
|
518
|
use OurCal::Provider; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
11
|
|
7
|
1
|
|
|
1
|
|
3827
|
use Data::Dumper; |
|
1
|
|
|
|
|
7204
|
|
|
1
|
|
|
|
|
767
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '1.2'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
OurCal - a simple yet featureful personal calendaring system |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
This is a example index.cgi |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $config = OurCal::Config->new( file => 'ourcal.conf' ); |
20
|
|
|
|
|
|
|
my $handler = OurCal::Handler->new( config => $config); |
21
|
|
|
|
|
|
|
my $cal = OurCal->new( date => $handler->date, user => $handler->user, config => $config ); |
22
|
|
|
|
|
|
|
my $view = OurCal::View->load_view($handler->view, config => $config->config, calendar => $cal); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
print $handler->header($view->mime_type); |
25
|
|
|
|
|
|
|
print $view->handle($handler->mode); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 DESCRIPTION |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
OurCal was written one hungover Sunday afternoon 5 years ago and hasn't |
30
|
|
|
|
|
|
|
changed that much since. It's not a complicated calendaring system, I've |
31
|
|
|
|
|
|
|
got other code to do that, but it's simple and extendable and it works. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Feature wise: |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=over 4 |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=item simple events |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
OurCal has no concept of start or end times - an event is on a day or it |
40
|
|
|
|
|
|
|
isn't. Surprisingly this suffices 99% of my time and makes things much |
41
|
|
|
|
|
|
|
quicker and easier internally. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Events can be marked up using the Chump syntax which is kind of like |
44
|
|
|
|
|
|
|
Markdown but had the virtue of existing at the time. There's no real |
45
|
|
|
|
|
|
|
reason why Chump couldn't be ripped out and replaced with Markdown. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Events have a date and a description and that's pretty much it. If you |
48
|
|
|
|
|
|
|
want more feed me beer and choclate covered coffee beans until I get |
49
|
|
|
|
|
|
|
round to finishing EventQueue. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item todos |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
OurCal has simple TODO items as well - these are also marked up in |
54
|
|
|
|
|
|
|
Chump. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item icalendar |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
OurCal can import iCalendar feeds from both local and remote sources and |
59
|
|
|
|
|
|
|
can also export an ICS feed. Since it's all done with plugins (I loves |
60
|
|
|
|
|
|
|
me my plugins) you could write plugins to import and export whatever you |
61
|
|
|
|
|
|
|
want. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item multi user |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Nominally OurCal is multi user but there's no user management to speak |
66
|
|
|
|
|
|
|
of and I only ever use it for one person so I wouldn't know. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item hCalendar |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
All events use hCalendar semantic markup because I'm nothing if not |
71
|
|
|
|
|
|
|
Buzzword Compatible. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item mod_perl |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
There's no mod_perl or mod_perl handler at the moment but it'd be but a |
76
|
|
|
|
|
|
|
moments work to do. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=back |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 METHODS |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 new |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Requires a C param of type C and a C param |
88
|
|
|
|
|
|
|
in the form C or C. Can optionally take a user |
89
|
|
|
|
|
|
|
param. No user validation is done. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub new { |
94
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
95
|
0
|
|
|
|
|
|
my %opts = @_; |
96
|
0
|
|
0
|
|
|
|
$opts{provider} ||= OurCal::Provider->new(config => $opts{config}); |
97
|
0
|
|
|
|
|
|
return bless \%opts, $class; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 date |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Return the current date |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub date { |
107
|
0
|
|
|
0
|
1
|
|
return $_[0]->{date}; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 user |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Return the current user |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub user { |
117
|
0
|
|
|
0
|
1
|
|
return $_[0]->{user}; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 span_name |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Return the current date as a span name (month or day) |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub span_name { |
127
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
128
|
0
|
|
|
|
|
|
my $date = $self->date; |
129
|
0
|
0
|
|
|
|
|
if (10 == length($date)) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
return 'day'; |
131
|
|
|
|
|
|
|
} elsif (7 == length($date)) { |
132
|
0
|
|
|
|
|
|
return 'month'; |
133
|
|
|
|
|
|
|
} elsif (4 == length($date)) { |
134
|
0
|
|
|
|
|
|
return 'year'; |
135
|
|
|
|
|
|
|
} else { |
136
|
0
|
|
|
|
|
|
die "Unknown date type for $date\n"; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 span |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Return the current date as an object - either an C or |
143
|
|
|
|
|
|
|
an C). |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=cut |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub span { |
148
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
149
|
0
|
|
|
|
|
|
my $name = $self->span_name; |
150
|
0
|
|
|
|
|
|
my $date = $self->date; |
151
|
0
|
|
|
|
|
|
my %what = ( date => $date, calendar => $self ); |
152
|
0
|
0
|
|
|
|
|
$what{user} = $self->{user} if defined $self->user; |
153
|
0
|
0
|
|
|
|
|
if ('month' eq $name) { |
|
|
0
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
return OurCal::Month->new(%what); |
155
|
|
|
|
|
|
|
} elsif ('day' eq $name) { |
156
|
0
|
|
|
|
|
|
return OurCal::Day->new(%what); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
0
|
|
|
|
|
|
die "Don't have a handler for $name\n"; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 events |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Return the events for a current span as C objects |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub events { |
170
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
171
|
0
|
|
|
|
|
|
my %opts = @_; |
172
|
0
|
0
|
|
|
|
|
$opts{user} = $self->user if defined $self->user; |
173
|
0
|
|
|
|
|
|
return $self->{provider}->events(%opts); |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 has_events |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Return whether the current span has events |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
sub has_events { |
183
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
184
|
0
|
|
|
|
|
|
my %opts = @_; |
185
|
0
|
0
|
|
|
|
|
$opts{user} = $self->user if defined $self->user; |
186
|
0
|
|
|
|
|
|
return $self->{provider}->has_events(%opts); |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head2 todos |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Return all the current todos as C objects. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=cut |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
sub todos { |
197
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
198
|
0
|
|
|
|
|
|
my %opts = @_; |
199
|
0
|
0
|
|
|
|
|
$opts{user} = $self->user if defined $self->user; |
200
|
0
|
|
|
|
|
|
return $self->{provider}->todos(%opts); |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head2 users |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Returns the names of all the current users |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=cut |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub users { |
210
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
211
|
0
|
|
|
|
|
|
return $self->{provider}->users; |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head2 save_todo C |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
Save a TODO item |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=cut |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
sub save_todo { |
221
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
222
|
0
|
|
|
|
|
|
my $todo = shift; |
223
|
0
|
|
|
|
|
|
$self->{provider}->save_todo($todo) |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head2 del_todo C |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
Delete a TODO item |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=cut |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
sub del_todo { |
234
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
235
|
0
|
|
|
|
|
|
my $todo = shift; |
236
|
0
|
|
|
|
|
|
$self->{provider}->del_todo($todo); |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head2 save_event C |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
Save an Event |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=cut |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
sub save_event { |
247
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
248
|
0
|
|
|
|
|
|
my $event = shift; |
249
|
0
|
|
|
|
|
|
$self->{provider}->save_event($event); |
250
|
|
|
|
|
|
|
} |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head2 del_event C |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
Delete an event |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=cut |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
sub del_event { |
259
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
260
|
0
|
|
|
|
|
|
my $event = shift; |
261
|
0
|
|
|
|
|
|
$self->{provider}->del_event($event); |
262
|
|
|
|
|
|
|
} |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=head1 AUTHOR |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
Simon Wistow |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head1 COPYRIGHT |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
Copyright, 2007 - Simon Wistow |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
Distributed under the same terms as Perl itself |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=head1 SEE ALSO |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
L, L, L, L |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=cut |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
1; |