File: olive

package info (click to toggle)
olive 1.3-3
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 288 kB
  • ctags: 79
  • sloc: perl: 2,219; makefile: 35
file content (149 lines) | stat: -rwxr-xr-x 3,986 bytes parent folder | download | duplicates (3)
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/usr/bin/perl

=head1 NAME

Olive -- The Totally Sweet Newsfeeder

=head1 DESCRIPTION

Olive is a totally sweet console mode RSS aggregator / newsreader
written in Perl with Curses::UI as its toolkit.

=head1 SYNOPSIS

    olive             # run olive
    olive <file.opml> # import a feedlist from an OPML file

=cut

use warnings;
use strict;
use lib ".";

use Config::YAML;
use Curses::UI;
use DBI;
use LWP::UserAgent;

use OliveFeed;
use OliveMisc;
use OliveStory;
use OliveWindow;

# force XML::Simple to use XML::Parser instead of XML::SAX
$XML::Simple::PREFERRED_PARSER = "XML::Parser";

# set uber-config vars
my $rel = 'r1';
my $rev = '$Rev: 439 $';
$rev =~ s/\D//g;
$rev = uc(sprintf("%4.4x",$rev));
my $tz  = `date +%z`;
$tz =~ s/00$//;

# system init;
sysinit();

# OPML import (and help/version messages)
if (@ARGV) {
    showhelp() if ($ARGV[0] eq '-h' or $ARGV[0] eq '--help');
    showver($rel, $rev)  if ($ARGV[0] eq '-v' or $ARGV[0] eq '--version');
    my $opml = shift;
    require OliveOPML;
    import OliveOPML;
    opmlimport($opml);
    exit;
}

# create Curses::UI object
my $cui = new Curses::UI( -color_support => 1,
                          -clear_on_exit => 1,
                          -keydelay      => 30,
                          -mouse_support => 0,
                        );
#create objects, windows and userdata storage
my $root = $cui->add('root', 'Window');
my $ud = { dbh   => DBI->connect("dbi:SQLite:dbname=$ENV{HOME}/.olive/stories.db","",""),
           feeds => "$ENV{HOME}/.olive/feeds",
           focus => 'news',
           rel   => $rel,
           rev   => $rev,
           opts  => [ qw(sls snu knf gsp dst coe) ],
           tz    => $tz,
         };
$cui->userdata($ud);
$cui->userdata->{c}    = Config::YAML->new( config => "$ENV{HOME}/.olive/olive.yaml" );
$cui->userdata->{sid}  = 0;
$cui->userdata->{ua}   = LWP::UserAgent->new( agent   => 'Olive/' . $cui->userdata->{rel}, 
                                              timeout => ($cui->userdata->{c}->{to} || 30) );
$cui->userdata->{wins} = wininit($cui,$root);
$cui->userdata->{keys} = { prev      => '[',
                           next      => ']',
                           mark      => 'm',
                           unmark    => 'u',
                           markall   => 'M',
                           unmarkall => 'U',
                           star      => 's',
                           focus     => 'w',
                           link      => 'l',
                           linklist  => 'L',
                           poll      => 'p',
                           force     => 'P',
                           filterf   => 'F',
                           filters   => 'S',
                           gpup      => '-',
                           gpdn      => ' ',
                          };
@{ $cui->userdata->{keys} }{ keys %{$cui->userdata->{c}->{keys}} } = 
    values %{ $cui->userdata->{c}->{keys} };

# set up database, keybindings, and timer loop
sysinit2($cui);
setkeys($cui,$root,"./docs");
setpollwait($cui);

# run a poll and populate the story list
feedpoll($cui);
refreshlist($cui);

# go!
$cui->mainloop();

#-------------------------------------------------------------

sub showhelp {
    print <<HELP;

Usage is: olive [<options> | <filename.opml>]

If a filename is specified, an OPML feed import will be performed and
the program will exit. Otherwise the program will start normally.
Options are:

 -h  --help     Show this message and exit
 -v  --version  Display version string and exit

HELP
1;
    exit;
}

sub showver {
    print "This is Olive $_[0] ($_[1])\n";
    exit;
}

=head1 FILES

    ~/.olive/olive.yaml # config file
    ~/.olive/stories.db # SQLite feed data db
    ~/.olive/errors.log # logger messages go here

=head1 COPYRIGHT & LICENSE

Copyright 2005,2006 Shawn Boyette, All Rights Reserved.

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

=cut