59 |
|
|
60 |
my $sleep_on_error = 5; |
my $sleep_on_error = 5; |
61 |
|
|
62 |
|
# number of last tags to keep in circular buffer |
63 |
|
my $last_x_tags = 50; |
64 |
|
|
65 |
my $http_port = $NICK =~ m/-dev/ ? 8001 : 8000; |
my $http_port = $NICK =~ m/-dev/ ? 8001 : 8000; |
66 |
|
|
67 |
my $url = "http://$HOSTNAME:$http_port"; |
my $url = "http://$HOSTNAME:$http_port"; |
486 |
|
|
487 |
=cut |
=cut |
488 |
|
|
|
my $last_x_tags = 5; |
|
489 |
my @last_tags; |
my @last_tags; |
490 |
|
|
491 |
sub add_tag { |
sub add_tag { |
975 |
|
|
976 |
my $search = $q->param('search') || $q->param('grep') || ''; |
my $search = $q->param('search') || $q->param('grep') || ''; |
977 |
|
|
978 |
if ($request->url =~ m#/rss(?:/(tags)(?:=(\d+))?)?#i) { |
if ($request->url =~ m#/rss(?:/(tags|last-tag?)\w+(?:=(\d+))?)?#i) { |
979 |
my $show = lc($1); |
my $show = lc($1); |
980 |
my $arg = $2 || 50; |
my $nr = $2; |
981 |
|
|
982 |
my $type = 'RSS'; # Atom |
my $type = 'RSS'; # Atom |
983 |
|
|
989 |
my $feed = XML::Feed->new( $type ); |
my $feed = XML::Feed->new( $type ); |
990 |
|
|
991 |
if ( $show eq 'tags' ) { |
if ( $show eq 'tags' ) { |
992 |
|
$nr ||= 50; |
993 |
$feed->title( "tags from $CHANNEL" ); |
$feed->title( "tags from $CHANNEL" ); |
994 |
$feed->link( "$url/tags" ); |
$feed->link( "$url/tags" ); |
995 |
$feed->description( "tag cloud created from messages on channel $CHANNEL which have tags// in them" ); |
$feed->description( "tag cloud created from messages on channel $CHANNEL which have tags// in them" ); |
996 |
my $feed_entry = XML::Feed::Entry->new($type); |
my $feed_entry = XML::Feed::Entry->new($type); |
997 |
$feed_entry->title( "$arg tags from $CHANNEL" ); |
$feed_entry->title( "$nr tags from $CHANNEL" ); |
998 |
$feed_entry->author( $NICK ); |
$feed_entry->author( $NICK ); |
999 |
$feed_entry->link( '/#tags' ); |
$feed_entry->link( '/#tags' ); |
1000 |
|
|
1002 |
qq{<![CDATA[<style type="text/css">} |
qq{<![CDATA[<style type="text/css">} |
1003 |
. $cloud->css |
. $cloud->css |
1004 |
. qq{</style>} |
. qq{</style>} |
1005 |
. $cloud->html( $arg ) |
. $cloud->html( $nr ) |
1006 |
. qq{]]>} |
. qq{]]>} |
1007 |
); |
); |
1008 |
$feed->add_entry( $feed_entry ); |
$feed->add_entry( $feed_entry ); |
1009 |
|
|
1010 |
} else { |
} elsif ( $show eq 'last-tag' ) { |
1011 |
|
|
1012 |
$feed->title( "last $last_x_tags from $CHANNEL" ); |
$nr ||= $last_x_tags; |
1013 |
|
|
1014 |
|
$feed->title( "last $nr tagged messages from $CHANNEL" ); |
1015 |
$feed->link( $url ); |
$feed->link( $url ); |
1016 |
$feed->description( "collects messages which have tags// in them" ); |
$feed->description( "collects messages which have tags// in them" ); |
1017 |
|
|
1026 |
|
|
1027 |
my $message = $filter->{message}->( $m->{message} ); |
my $message = $filter->{message}->( $m->{message} ); |
1028 |
$message .= "<br/>\n" unless $message =~ m!<(/p|br/?)>!; |
$message .= "<br/>\n" unless $message =~ m!<(/p|br/?)>!; |
1029 |
warn "## message = $message\n"; |
# warn "## message = $message\n"; |
1030 |
from_to( $message, $ENCODING, 'UTF-8' ); |
from_to( $message, $ENCODING, 'UTF-8' ); |
1031 |
|
|
1032 |
#$feed_entry->summary( |
#$feed_entry->summary( |
1035 |
); |
); |
1036 |
$feed_entry->category( join(', ', @{$m->{tags}}) ); |
$feed_entry->category( join(', ', @{$m->{tags}}) ); |
1037 |
$feed->add_entry( $feed_entry ); |
$feed->add_entry( $feed_entry ); |
1038 |
|
|
1039 |
|
$nr--; |
1040 |
|
last if $nr <= 0; |
1041 |
|
|
1042 |
} |
} |
1043 |
|
|
1044 |
|
} else { |
1045 |
|
warn "!! unknown rss request for $show\n"; |
1046 |
|
return RC_DENY; |
1047 |
} |
} |
1048 |
|
|
1049 |
$response->content( $feed->as_xml ); |
$response->content( $feed->as_xml ); |
1103 |
$cal->weekdays('MON','TUE','WED','THU','FRI'); |
$cal->weekdays('MON','TUE','WED','THU','FRI'); |
1104 |
($l_yyyy,$l_mm) = ($yyyy,$mm); |
($l_yyyy,$l_mm) = ($yyyy,$mm); |
1105 |
} |
} |
1106 |
$cal->setcontent($dd, qq{ |
$cal->setcontent($dd, qq[ |
1107 |
<a href="$url?date=$row->{date}">$row->{nr}</a><br/>$row->{len} |
<a href="$url?date=$row->{date}">$row->{nr}</a><br/>$row->{len} |
1108 |
}); |
]); |
1109 |
|
|
1110 |
} |
} |
1111 |
$html .= qq{<td valign="top">} . $cal->as_HTML() . qq{</td></tr></table>}; |
$html .= qq{<td valign="top">} . $cal->as_HTML() . qq{</td></tr></table>}; |