File: RSS.pm

package info (click to toggle)
libsvn-web-perl 0.63-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 736 kB
  • sloc: perl: 1,987; sh: 73; makefile: 11
file content (112 lines) | stat: -rw-r--r-- 2,210 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package SVN::Web::RSS;
use strict;
use warnings;

use base 'SVN::Web::Log';

our $VERSION = 0.54;

=head1 NAME

SVN::Web::RSS - SVN::Web action to generate an RSS feed

=head1 SYNOPSIS

In F<config.yaml>

  actions:
    ...
    rss:
      class: SVN::Web::RSS
      action_menu:
        show:
          - file
          - directory
        link_text: (rss)
        head_only: 1
        icon: /css/trac/feed-icon-16x16.png
      opts:
        publisher: address@domain
    ...

=head1 DESCRIPTION

Generates an RSS feed of commits to a file or path in the Subversion
repository.

=head1 CONFIGURATION

The following options may be specified in F<config.yaml>.

=over

=item publisher

The e-mail address of the feed's publisher.  This is placed in to the
C<< <dc:publisher> >> element in the RSS output.

There is no default.  If not specified then no C<< <dc:publisher> >>
element is included.

=back

B<Note:> RSS dates have a specific format.  Accordingly, the C<timezone>
and C<timedate_format> configuration options are ignored by this action.

=head1 OPTIONS

See L<SVN::Web::Log>.

=head1 TEMPLATE VARIABLES

See L<SVN::Web::Log>.

=head1 EXCEPTIONS

See L<SVN::Web::Log>.

=cut

my %default_opts = ( publisher => '' );

# <dc:date> elements have a specific format that we must use, overriding
# the user's choice
sub format_svn_timestamp {
    my $self    = shift;
    my $cstring = shift;

    my $time = SVN::Core::time_from_cstring($cstring) / 1_000_000;

    return POSIX::strftime( '%Y-%m-%dT%H:%M:%S', gmtime($time) );
}

sub run {
    my $self = shift;

    my $data = $self->SUPER::run(@_)->{data};

    $self->{opts} = { %default_opts, %{ $self->{opts} } };

    return {
        template => 'rss',
        mimetype => 'text/xml',
        data     => { %{$data}, publisher => $self->{opts}{publisher}, }
    };
}

1;

=head1 COPYRIGHT

Copyright 2003-2004 by Chia-liang Kao C<< <clkao@clkao.org> >>.

Copyright 2005-2007 by Nik Clayton C<< <nik@FreeBSD.org> >>.

Copyright 2012 by Dean Hamstead C<< <dean@fragfest.com.au> >>.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

See L<http://www.perl.com/perl/misc/Artistic.html>

=cut