| 1 | package Mojolicious::Plugin::Ical; | ||||||||||||||||||||
| 2 | 2 | ▶ | use Mojo::Base 'Mojolicious::Plugin'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | 2 | ▶ | use POSIX (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 2 | ▶ | use Sys::Hostname (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 2 | ▶ | use Text::vFile::asData; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 2 | our $VERSION = '1.00'; | |||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 2 | ▶ | sub register { | ||||||||||||||||||
|
Subroutine
register: called CC=12 SCAR=28.3
Pod
documented
| |||||||||||||||||||||
| 11 | 2 | my ($self, $app, $config) = @_; | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 2 | ▶ | $config->{handler} //= 'ical'; | ||||||||||||||||||
|
Condition50%1/2
$config->{"handler"} //= "ical"
MC/DC0%0/1
$config->{"handler"} //= "ical"
$config->{"handler"}
Truth table50%1/2
A
A= $config->{"handler"}
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 2 | ▶ | $self->{properties} = $config->{properties} || {}; | ||||||||||||||||||
|
Condition50%1/2
$config->{'properties'} || {}
MC/DC0%0/1
$config->{'properties'} || {}
$config->{'properties'}
Truth table50%1/2
A
A= $config->{'properties'}
| |||||||||||||||||||||
| 16 | 2 | ▶ | $self->{properties}{calscale} ||= 'GREGORIAN'; | ||||||||||||||||||
|
Condition50%1/2
$self->{"properties"}{"calscale"} ||= "GREGORIAN"
MC/DC0%0/1
$self->{"properties"}{"calscale"} ||= "GREGORIAN"
$self->{"properties"}{"calscale"}
Truth table50%1/2
A
A= $self->{"properties"}{"calscale"}
| |||||||||||||||||||||
| 17 | 2 | ▶ | $self->{properties}{method} ||= 'PUBLISH'; | ||||||||||||||||||
|
Condition50%1/2
$self->{"properties"}{"method"} ||= "PUBLISH"
MC/DC0%0/1
$self->{"properties"}{"method"} ||= "PUBLISH"
$self->{"properties"}{"method"}
Truth table50%1/2
A
A= $self->{"properties"}{"method"}
| |||||||||||||||||||||
| 18 | 2 | ▶ | $self->{properties}{prodid} ||= sprintf '-//%s//NONSGML %s//EN', Sys::Hostname::hostname, $app->moniker; | ||||||||||||||||||
|
Condition33%1/3
$self->{"properties"}{"prodid"} ||= sprintf("-//%s//NONSGML %s//EN", Sys::Hostname::hostname(), $app->moniker)
MC/DC0%0/2
$self->{"properties"}{"prodid"} ||= sprintf("-//%s//NONSGML %s//EN", Sys::Hostname::hostname(), $app->moniker)
$self->{"properties"}{"prodid"}
sprintf("-//%s//NONSGML %s//EN", Sys::Hostname::hostname(), $app->moniker)
Truth table33%1/3
A ||= B
A= $self->{"properties"}{"prodid"}B= sprintf("-//%s//NONSGML %s//EN", Sys::Hostname::hostname(), $app->moniker)
| |||||||||||||||||||||
| 19 | 2 | ▶ | $self->{properties}{version} ||= '2.0'; | ||||||||||||||||||
|
Condition50%1/2
$self->{"properties"}{"version"} ||= "2.0"
MC/DC0%0/1
$self->{"properties"}{"version"} ||= "2.0"
$self->{"properties"}{"version"}
Truth table50%1/2
A
A= $self->{"properties"}{"version"}
| |||||||||||||||||||||
| 20 | 2 | ▶ | $self->{properties}{x_wr_caldesc} ||= ''; | ||||||||||||||||||
|
Condition50%1/2
$self->{"properties"}{"x_wr_caldesc"} ||= ""
MC/DC0%0/1
$self->{"properties"}{"x_wr_caldesc"} ||= ""
$self->{"properties"}{"x_wr_caldesc"}
Truth table50%1/2
A
A= $self->{"properties"}{"x_wr_caldesc"}
| |||||||||||||||||||||
| 21 | 2 | ▶ | $self->{properties}{x_wr_calname} ||= $app->moniker; | ||||||||||||||||||
|
Condition33%1/3
$self->{"properties"}{"x_wr_calname"} ||= $app->moniker
MC/DC0%0/2
$self->{"properties"}{"x_wr_calname"} ||= $app->moniker
$self->{"properties"}{"x_wr_calname"}
$app->moniker
Truth table33%1/3
A ||= B
A= $self->{"properties"}{"x_wr_calname"}B= $app->moniker
| |||||||||||||||||||||
| 22 | 2 | ▶ | $self->{properties}{x_wr_timezone} ||= POSIX::strftime('%Z', localtime); | ||||||||||||||||||
|
Condition33%1/3
$self->{"properties"}{"x_wr_timezone"} ||= POSIX::strftime("%Z", localtime)
MC/DC0%0/2
$self->{"properties"}{"x_wr_timezone"} ||= POSIX::strftime("%Z", localtime)
$self->{"properties"}{"x_wr_timezone"}
POSIX::strftime("%Z", localtime)
Truth table33%1/3
A ||= B
A= $self->{"properties"}{"x_wr_timezone"}B= POSIX::strftime("%Z", localtime)
| |||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 2 | ▶ | $self->{vfile} ||= Text::vFile::asData->new; | ||||||||||||||||||
|
Condition33%1/3
$self->{"vfile"} ||= "Text::vFile::asData"->new
MC/DC0%0/2
$self->{"vfile"} ||= "Text::vFile::asData"->new
$self->{"vfile"}
"Text::vFile::asData"->new
Truth table33%1/3
A ||= B
A= $self->{"vfile"}B= "Text::vFile::asData"->new
| |||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 2 | ▶ | $app->helper('reply.ical' => sub { $self->_reply_ical(@_) }); | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 27 | 2 | $app->types->type(ical => 'text/calendar'); | |||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 2 | ▶ | if ($config->{handler}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 30 | $app->renderer->add_handler( | ||||||||||||||||||||
| 31 | $config->{handler}, | ||||||||||||||||||||
| 32 | 1 | ▶ | sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||
| 33 | 1 | my ($renderer, $c, $output, $options) = @_; | |||||||||||||||||||
| 34 | 1 | ▶ | return undef unless my $ical = $c->stash('ical'); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 35 | 1 | $$output = join '', map {"$_\n"} $self->_render_ical($c, $ical); | |||||||||||||||||||
| 36 | 1 | return 1; | |||||||||||||||||||
| 37 | } | ||||||||||||||||||||
| 38 | 2 | ); | |||||||||||||||||||
| 39 | } | ||||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 2 | ▶ | sub _event_to_properties { | ||||||||||||||||||
|
Subroutine
_event_to_properties: called CC=9 SCAR=22.7
| |||||||||||||||||||||
| 43 | 2 | my ($event, $defaults) = @_; | |||||||||||||||||||
| 44 | 2 | my $properties = {}; | |||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 2 | for my $k (keys %$event) { | |||||||||||||||||||
| 47 | 14 | ▶ | my $v = $event->{$k} //= ''; | ||||||||||||||||||
|
Condition50%1/2
$event->{$k} //= ""
MC/DC0%0/1
$event->{$k} //= ""
$event->{$k}
Truth table50%1/2
A
A= $event->{$k}
| |||||||||||||||||||||
| 48 | 14 | my $p = _vkey($k); | |||||||||||||||||||
| 49 | 14 | ▶ | if (UNIVERSAL::isa($v, 'Mojo::Date')) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 50 | 6 | $v = $v->to_datetime; | |||||||||||||||||||
| 51 | 6 | $v =~ s![:-]!!g; # 1994-11-06T08:49:37Z => 19941106T084937Z | |||||||||||||||||||
| 52 | } | ||||||||||||||||||||
| 53 | 14 | $properties->{$p} = [{value => $v}]; | |||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 2 | ▶ | $properties->{DTSTAMP} ||= [{value => $defaults->{now}}]; | ||||||||||||||||||
|
Condition50%1/2
$properties->{"DTSTAMP"} ||= [{"value", $defaults->{"now"}}]
MC/DC0%0/1
$properties->{"DTSTAMP"} ||= [{"value", $defaults->{"now"}}]
$properties->{"DTSTAMP"}
Truth table50%1/2
A
A= $properties->{"DTSTAMP"}
| |||||||||||||||||||||
| 57 | 2 | ▶ | $properties->{SEQUENCE} ||= [{value => 0}]; | ||||||||||||||||||
|
Condition50%1/2
$properties->{"SEQUENCE"} ||= [{"value", 0}]
MC/DC0%0/1
$properties->{"SEQUENCE"} ||= [{"value", 0}]
$properties->{"SEQUENCE"}
Truth table50%1/2
A
A= $properties->{"SEQUENCE"}
| |||||||||||||||||||||
| 58 | 2 | ▶ | $properties->{STATUS} ||= [{value => 'CONFIRMED'}]; | ||||||||||||||||||
|
Condition50%1/2
$properties->{"STATUS"} ||= [{"value", "CONFIRMED"}]
MC/DC0%0/1
$properties->{"STATUS"} ||= [{"value", "CONFIRMED"}]
$properties->{"STATUS"}
Truth table50%1/2
A
A= $properties->{"STATUS"}
| |||||||||||||||||||||
| 59 | 2 | ▶ | $properties->{TRANSP} ||= [{value => 'OPAQUE'}]; | ||||||||||||||||||
|
Condition50%1/2
$properties->{"TRANSP"} ||= [{"value", "OPAQUE"}]
MC/DC0%0/1
$properties->{"TRANSP"} ||= [{"value", "OPAQUE"}]
$properties->{"TRANSP"}
Truth table50%1/2
A
A= $properties->{"TRANSP"}
| |||||||||||||||||||||
| 60 | 2 | ▶ | $properties->{UID} ||= [{value => sprintf '%s@%s', _md5($event), $defaults->{hostname}}]; | ||||||||||||||||||
|
Condition50%1/2
$properties->{"UID"} ||= [{"value", sprintf("%s\@%s", _md5($event), $defaults->{"hostname"})}]
MC/DC0%0/1
$properties->{"UID"} ||= [{"value", sprintf("%s\@%s", _md5($event), $defaults->{"hostname"})}]
$properties->{"UID"}
Truth table50%1/2
A
A= $properties->{"UID"}
| |||||||||||||||||||||
| 61 | 2 | $properties; | |||||||||||||||||||
| 62 | } | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | 2 | ▶ | sub _render_ical { | ||||||||||||||||||
|
Subroutine
_render_ical: called CC=12 SCAR=28.0
| |||||||||||||||||||||
| 65 | 2 | my ($self, $c, $data) = @_; | |||||||||||||||||||
| 66 | 2 | ▶ | my %properties = %{$data->{properties} || {}}; | ||||||||||||||||||
|
Condition50%1/2
$data->{'properties'} || {}
MC/DC0%0/1
$data->{'properties'} || {}
$data->{'properties'}
Truth table50%1/2
A
A= $data->{'properties'}
| |||||||||||||||||||||
| 67 | 2 | my $ical = {}; | |||||||||||||||||||
| 68 | 2 | my %defaults; | |||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | 2 | $ical->{objects} = []; | |||||||||||||||||||
| 71 | 2 | $ical->{properties} = {}; | |||||||||||||||||||
| 72 | 2 | $ical->{type} = 'VCALENDAR'; | |||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | 2 | ▶ | $properties{calscale} ||= $self->{properties}{calscale}; | ||||||||||||||||||
|
Condition33%1/3
$properties{"calscale"} ||= $self->{"properties"}{"calscale"}
MC/DC0%0/2
$properties{"calscale"} ||= $self->{"properties"}{"calscale"}
$properties{"calscale"}
$self->{"properties"}{"calscale"}
Truth table33%1/3
A ||= B
A= $properties{"calscale"}B= $self->{"properties"}{"calscale"}
| |||||||||||||||||||||
| 75 | 2 | ▶ | $properties{method} ||= $self->{properties}{method}; | ||||||||||||||||||
|
Condition33%1/3
$properties{"method"} ||= $self->{"properties"}{"method"}
MC/DC0%0/2
$properties{"method"} ||= $self->{"properties"}{"method"}
$properties{"method"}
$self->{"properties"}{"method"}
Truth table33%1/3
A ||= B
A= $properties{"method"}B= $self->{"properties"}{"method"}
| |||||||||||||||||||||
| 76 | 2 | ▶ | $properties{prodid} ||= $self->{properties}{prodid}; | ||||||||||||||||||
|
Condition33%1/3
$properties{"prodid"} ||= $self->{"properties"}{"prodid"}
MC/DC0%0/2
$properties{"prodid"} ||= $self->{"properties"}{"prodid"}
$properties{"prodid"}
$self->{"properties"}{"prodid"}
Truth table33%1/3
A ||= B
A= $properties{"prodid"}B= $self->{"properties"}{"prodid"}
| |||||||||||||||||||||
| 77 | 2 | ▶ | $properties{version} ||= $self->{properties}{version}; | ||||||||||||||||||
|
Condition33%1/3
$properties{"version"} ||= $self->{"properties"}{"version"}
MC/DC0%0/2
$properties{"version"} ||= $self->{"properties"}{"version"}
$properties{"version"}
$self->{"properties"}{"version"}
Truth table33%1/3
A ||= B
A= $properties{"version"}B= $self->{"properties"}{"version"}
| |||||||||||||||||||||
| 78 | 2 | ▶ | $properties{x_wr_caldesc} ||= $self->{properties}{x_wr_caldesc}; | ||||||||||||||||||
|
Condition33%1/3
$properties{"x_wr_caldesc"} ||= $self->{"properties"}{"x_wr_caldesc"}
MC/DC0%0/2
$properties{"x_wr_caldesc"} ||= $self->{"properties"}{"x_wr_caldesc"}
$properties{"x_wr_caldesc"}
$self->{"properties"}{"x_wr_caldesc"}
Truth table33%1/3
A ||= B
A= $properties{"x_wr_caldesc"}B= $self->{"properties"}{"x_wr_caldesc"}
| |||||||||||||||||||||
| 79 | 2 | ▶ | $properties{x_wr_calname} ||= $self->{properties}{x_wr_calname}; | ||||||||||||||||||
|
Condition33%1/3
$properties{"x_wr_calname"} ||= $self->{"properties"}{"x_wr_calname"}
MC/DC0%0/2
$properties{"x_wr_calname"} ||= $self->{"properties"}{"x_wr_calname"}
$properties{"x_wr_calname"}
$self->{"properties"}{"x_wr_calname"}
Truth table33%1/3
A ||= B
A= $properties{"x_wr_calname"}B= $self->{"properties"}{"x_wr_calname"}
| |||||||||||||||||||||
| 80 | 2 | ▶ | $properties{x_wr_timezone} ||= $self->{properties}{x_wr_timezone}; | ||||||||||||||||||
|
Condition33%1/3
$properties{"x_wr_timezone"} ||= $self->{"properties"}{"x_wr_timezone"}
MC/DC0%0/2
$properties{"x_wr_timezone"} ||= $self->{"properties"}{"x_wr_timezone"}
$properties{"x_wr_timezone"}
$self->{"properties"}{"x_wr_timezone"}
Truth table33%1/3
A ||= B
A= $properties{"x_wr_timezone"}B= $self->{"properties"}{"x_wr_timezone"}
| |||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 2 | for my $k (keys %properties) { | |||||||||||||||||||
| 83 | 14 | my $p = _vkey($k); | |||||||||||||||||||
| 84 | 14 | $ical->{properties}{$p} = [{value => $properties{$k}}]; | |||||||||||||||||||
| 85 | } | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | 2 | $defaults{hostname} = Sys::Hostname::hostname; | |||||||||||||||||||
| 88 | 2 | $defaults{now} = Mojo::Date->new->to_datetime; | |||||||||||||||||||
| 89 | 2 | $defaults{now} =~ s![:-]!!g; # 1994-11-06T08:49:37Z => 19941106T084937Z | |||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | 2 | ▶ | for my $event (@{$data->{events} || []}) { | ||||||||||||||||||
|
Condition50%1/2
$data->{'events'} || []
MC/DC0%0/1
$data->{'events'} || []
$data->{'events'}
Truth table50%1/2
A
A= $data->{'events'}
| |||||||||||||||||||||
| 92 | 2 | push @{$ical->{objects}}, {properties => _event_to_properties($event, \%defaults), type => 'VEVENT'}; | |||||||||||||||||||
| 93 | } | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | 2 | return $self->{vfile}->generate_lines($ical); | |||||||||||||||||||
| 96 | } | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | 1 | ▶ | sub _reply_ical { | ||||||||||||||||||
|
Subroutine
_reply_ical: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 99 | 1 | my ($self, $c, $data) = @_; | |||||||||||||||||||
| 100 | 1 | $c->res->headers->content_type('text/calendar'); | |||||||||||||||||||
| 101 | 1 | $c->render(text => join '', map {"$_\n"} $self->_render_ical($c, $data)); | |||||||||||||||||||
| 102 | } | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | 2 | ▶ | sub _md5 { | ||||||||||||||||||
|
Subroutine
_md5: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 105 | 2 | my $data = $_[0]; | |||||||||||||||||||
| 106 | 2 | Mojo::Util::md5_sum(join ':', map {"$_=$data->{$_}"} grep { $_ ne 'dtstamp' } sort keys %$data); | |||||||||||||||||||
| 107 | } | ||||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | 28 | ▶ | sub _vkey { | ||||||||||||||||||
|
Subroutine
_vkey: called CC=2 SCAR=7.0
| |||||||||||||||||||||
| 110 | 28 | ▶ | return $_[0] if $_[0] =~ /^[A-Z]/; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 111 | 28 | local $_ = uc $_[0]; | |||||||||||||||||||
| 112 | 28 | s!_!-!g; | |||||||||||||||||||
| 113 | 28 | $_; | |||||||||||||||||||
| 114 | } | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | 2 | 1; | |||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | =encoding utf8 | ||||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | =head1 NAME | ||||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | Mojolicious::Plugin::Ical - Generate .ical documents | ||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | =head1 VERSION | ||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | 0.05 | ||||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | =head1 SYNOPSIS | ||||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | =head2 Application | ||||||||||||||||||||
| 131 | |||||||||||||||||||||
| 132 | use Mojolicious::Lite; | ||||||||||||||||||||
| 133 | plugin ical => { | ||||||||||||||||||||
| 134 | properties => { | ||||||||||||||||||||
| 135 | calscale => "GREGORIAN" # default GREGORIAN | ||||||||||||||||||||
| 136 | method => "REQUEST", # default PUBLISH | ||||||||||||||||||||
| 137 | prodid => "-//ABC Corporation//NONSGML My Product//EN", | ||||||||||||||||||||
| 138 | version => "1.0", # default to 2.0 | ||||||||||||||||||||
| 139 | x_wr_caldesc => "Some description", | ||||||||||||||||||||
| 140 | x_wr_calname => "My calender", | ||||||||||||||||||||
| 141 | x_wr_timezone => "EDT", # default to timezone for localhost | ||||||||||||||||||||
| 142 | } | ||||||||||||||||||||
| 143 | }; | ||||||||||||||||||||
| 144 | |||||||||||||||||||||
| 145 | get '/calendar' => sub { | ||||||||||||||||||||
| 146 | my $c = shift; | ||||||||||||||||||||
| 147 | $c->reply->ical({ | ||||||||||||||||||||
| 148 | events => [ | ||||||||||||||||||||
| 149 | { | ||||||||||||||||||||
| 150 | created => $date, | ||||||||||||||||||||
| 151 | description => $str, # http://www.kanzaki.com/docs/ical/description.html | ||||||||||||||||||||
| 152 | dtend => $date, | ||||||||||||||||||||
| 153 | dtstamp => $date, # UTC time format, defaults to "now" | ||||||||||||||||||||
| 154 | dtstart => $date, | ||||||||||||||||||||
| 155 | last_modified => $date, # defaults to "now" | ||||||||||||||||||||
| 156 | location => $str, # http://www.kanzaki.com/docs/ical/location.html | ||||||||||||||||||||
| 157 | sequence => $int, # default 0 | ||||||||||||||||||||
| 158 | status => $str, # default CONFIRMED | ||||||||||||||||||||
| 159 | summary => $str, # http://www.kanzaki.com/docs/ical/summary.html | ||||||||||||||||||||
| 160 | transp => $str, # default OPAQUE | ||||||||||||||||||||
| 161 | uid => $str, # default to md5 of the values @hostname | ||||||||||||||||||||
| 162 | }, | ||||||||||||||||||||
| 163 | ... | ||||||||||||||||||||
| 164 | ], | ||||||||||||||||||||
| 165 | }); | ||||||||||||||||||||
| 166 | }; | ||||||||||||||||||||
| 167 | |||||||||||||||||||||
| 168 | # or using respond_to() | ||||||||||||||||||||
| 169 | get '/events' => sub { | ||||||||||||||||||||
| 170 | my $c = shift; | ||||||||||||||||||||
| 171 | my $ical = { events => [...] }; | ||||||||||||||||||||
| 172 | $c->respond_to( | ||||||||||||||||||||
| 173 | ical => {handler => 'ical', ical => $ical}, | ||||||||||||||||||||
| 174 | json => {json => $ical} | ||||||||||||||||||||
| 175 | ); | ||||||||||||||||||||
| 176 | }; | ||||||||||||||||||||
| 177 | |||||||||||||||||||||
| 178 | =head1 DESCRIPTION | ||||||||||||||||||||
| 179 | |||||||||||||||||||||
| 180 | L<Mojolicious::Plugin::Ical> is a L<Mojolicious> plugin for generating | ||||||||||||||||||||
| 181 | L<iCalendar|http://www.kanzaki.com/docs/ical/> documents. | ||||||||||||||||||||
| 182 | |||||||||||||||||||||
| 183 | This plugin will... | ||||||||||||||||||||
| 184 | |||||||||||||||||||||
| 185 | =over 4 | ||||||||||||||||||||
| 186 | |||||||||||||||||||||
| 187 | =item * | ||||||||||||||||||||
| 188 | |||||||||||||||||||||
| 189 | Add the helper L</reply.ical>. | ||||||||||||||||||||
| 190 | |||||||||||||||||||||
| 191 | =item * | ||||||||||||||||||||
| 192 | |||||||||||||||||||||
| 193 | Add ".ical" type to L<Mojolicious/types>. | ||||||||||||||||||||
| 194 | |||||||||||||||||||||
| 195 | =item * | ||||||||||||||||||||
| 196 | |||||||||||||||||||||
| 197 | Add a handler "ical" to L<Mojolicious/renderer>. | ||||||||||||||||||||
| 198 | |||||||||||||||||||||
| 199 | =back | ||||||||||||||||||||
| 200 | |||||||||||||||||||||
| 201 | =head1 HELPERS | ||||||||||||||||||||
| 202 | |||||||||||||||||||||
| 203 | =head2 reply.ical | ||||||||||||||||||||
| 204 | |||||||||||||||||||||
| 205 | $c = $c->reply->ical({ events => [...], properties => {...} }); | ||||||||||||||||||||
| 206 | |||||||||||||||||||||
| 207 | Will render a iCal document with the Content-Type "text/calender". | ||||||||||||||||||||
| 208 | |||||||||||||||||||||
| 209 | C<events> is an array ref of calendar events. | ||||||||||||||||||||
| 210 | C<properties> will override the defaults given to L</register>. | ||||||||||||||||||||
| 211 | |||||||||||||||||||||
| 212 | See L</SYNOPSIS> for more details. | ||||||||||||||||||||
| 213 | |||||||||||||||||||||
| 214 | =head1 METHODS | ||||||||||||||||||||
| 215 | |||||||||||||||||||||
| 216 | =head2 register | ||||||||||||||||||||
| 217 | |||||||||||||||||||||
| 218 | plugin ical => {properties => {...}}; | ||||||||||||||||||||
| 219 | |||||||||||||||||||||
| 220 | Register L</reply.ical> helper. | ||||||||||||||||||||
| 221 | |||||||||||||||||||||
| 222 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||
| 223 | |||||||||||||||||||||
| 224 | Copyright (C) 2014, Jan Henning Thorsen | ||||||||||||||||||||
| 225 | |||||||||||||||||||||
| 226 | This program is free software, you can redistribute it and/or modify it under | ||||||||||||||||||||
| 227 | the terms of the Artistic License version 2.0. | ||||||||||||||||||||
| 228 | |||||||||||||||||||||
| 229 | =head1 AUTHOR | ||||||||||||||||||||
| 230 | |||||||||||||||||||||
| 231 | Jan Henning Thorsen - C<jhthorsen@cpan.org> | ||||||||||||||||||||
| 232 | |||||||||||||||||||||
| 233 | =cut | ||||||||||||||||||||