AnnoCPAN

 view release on metacpan or  search on metacpan

lib/AnnoCPAN/Control.pm  view on Meta::CPAN

package AnnoCPAN::Control;

$VERSION = '0.22';

use strict;
use warnings;
no warnings 'uninitialized';
use AnnoCPAN::Config;
use AnnoCPAN::DBI;
use CGI::Cookie;
use Digest::MD5 qw(md5_hex);
use IO::String;
use POSIX qw(ceil);
use Lingua::EN::Inflect qw(NO);
use AnnoCPAN::Feed;

# it should be possible to subclass this module to use a different
# interface and templating system by overriding new and the simple
# 'delegational' methods param, process, header...

lib/AnnoCPAN/Control.pm  view on Meta::CPAN

    my $user = $self->user;
    my $value;
    if ($user) {
        $value = AnnoCPAN::DBI::Prefs->retrieve(user => $user, name => $name);
    }
    defined $value ? $value->value : AnnoCPAN::Config->option($name);
}

=item $obj->cookies

Return an arrayref with the current cookies (which are L<CGI::Cookie> objects).

=cut

sub cookies { 
    my ($self) = @_;
    $self->{cookies} || [];
}

=item $obj->add_cookie($name, $value)

Create a cookie. It will be later pushed to the client with the HTTP headers,
and it is immediately available via $obj->cookies.

=cut

sub add_cookie {
    my ($self, $name, $val) = @_;

    my $max_time = AnnoCPAN::Config->option('cookie_duration');
    push @{$self->{cookies}}, CGI::Cookie->new(
        -name => $name, -value => $val,
        $max_time ? (-expires => "+${max_time}d") : (),
    );
}

=item $obj->delete_cookie($name)

Issue an expired cookie with a given name, forcing the client to forget it (one
use is for logging out).

=cut

sub delete_cookie {
    my ($self, $name) = @_;
    push @{$self->{cookies}}, CGI::Cookie->new(
        -name => $name, -value => '', -expires => '-1Y',
    );
}

=item $obj->check_login

Check if the user is logged in (by checking the login, time, and key cookies);
Returns an AnnoCPAN::DBI::User object if logged in, or false if not.

=cut

sub check_login {
    my ($self) = @_;
    if ($ENV{TEST_USER}) {
        return AnnoCPAN::DBI::User->retrieve(username => 'test');
    }
    my %cookies = CGI::Cookie->fetch;
    my $login = $cookies{login}  && $cookies{login}->value;
    my $time  = $cookies{'time'} && $cookies{'time'}->value;
    my $key   = $cookies{key}    && $cookies{key}->value;
    my $max_time = (AnnoCPAN::Config->option('cookie_duration') || 1E9) * 86400;
    if ($self->key($login, $time) eq $key and time-$time < $max_time) {
        return AnnoCPAN::DBI::User->retrieve(username => $login);
    }
    0;
}

tt/faq.html  view on Meta::CPAN

discussed above. As with all heuristics, there will be mistakes, especially
when a paragraph is completely deleted or modified very heavily. In these cases
it is necessary to move the note manually or hide it if it no longer
applies.</p>

<a name="browser"></a><h3>What are the browser requirements?</h3>

<p>IE 6, Mozilla/Firefox, Netscape 7, Opera 7, etc., although it should degrade
gracefully in text browsers such as Lynx. It will likely not look reasonable
in browsers with severely broken CSS implementations. JavaScript is recommended
but not strictly required. Cookies are required for authentication. A monitor
resolution of 1024x768 or greater is recommended, especially if you want the
notes to show on the margin.</p>

<a name="uses"></a><h3>What does AnnoCPAN run on?</h3>

<p>Linux/Apache/MySQL/Perl. Some of the most notable modules used include
the 
[% link_dist_name("Template-Toolkit") %], 
[% link_dist_name("Class-DBI") %], 
[% link_dist_name("Archive-Tar") %], and

tt/policy.html  view on Meta::CPAN

[% PROCESS form.html %]

<h2>Site Policies</h2>

<h3>Privacy policy</h3>

<p>The information that you provide to this site, such as email addresses,
won't be published or shared with anyone without your consent (except by
judicial order). Other than that, the only information collected is the IP
address used to post each note, but IP addresses won't be published either.
Cookies are used for authentication purposes only.

<h3>License</h3>

<p>By posting a note in this site, you agree that it may be used, modified, and
redistributed under the same terms as Perl itself. This is to make sure that
other sites can use the notes and so that they may be included as part of the
documentation for a module if the maintainer of the module wishes.

<h3>Moderation</h3>



( run in 0.774 second using v1.01-cache-2.11-cpan-e9199f4ba4c )