File: Simple.pm

package info (click to toggle)
libperlanet-perl 2.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 444 kB
  • sloc: xml: 1,177; perl: 757; sh: 6; makefile: 5
file content (88 lines) | stat: -rw-r--r-- 1,928 bytes parent folder | download
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
package Perlanet::Simple;

use 5.10.0;
use strict;
use warnings;

use Moose;
use namespace::autoclean;

use Carp;
use YAML 'LoadFile';

extends 'Perlanet';
with qw(
  Perlanet::Trait::Cache
  Perlanet::Trait::OPML
  Perlanet::Trait::Scrubber
  Perlanet::Trait::Tidy
  Perlanet::Trait::YAMLConfig
  Perlanet::Trait::TemplateToolkit
  Perlanet::Trait::FeedFile
);

=head1 NAME

Perlanet::Simple - a DWIM Perlanet

=head1 SYNOPSIS

  use Perlanet::Simple;

  my $perlanet = Perlanet::Simple->new_with_config(
    configfile => 'perlanet.yaml'
  );
  $perlanet->run;

=head1 DESCRIPTION

L<Perlanet> provides the driving force behind all Perlanet applications,
but it doesn't do a whole lot, which means you would normally have to write
the functionality you require. However, in the motive of simplicity,
Perlanet::Simple glues enough stuff together to allow you to get a very quick
planet working out of the box.

Perlanet::Simple takes the standard Perlanet module, and adds support for
caching, OPML feed generation, and L<Template> rendering support. It will
also attempt to clean each post using both L<HTML::Scrubber> and L<HTML::Tidy>.

=head2 Configuration

Perlanet::Simple uses L<Perlanet::Trait::YAMLConfig> to allow you to specify
configuration through a file.

=cut

around '_build_ua' => sub {
  my $orig = shift;
  my $self = shift;
  my $ua = $self->$orig;
  $ua->agent($self->agent) if $self->agent;
  return $ua;
};

=head2 clean_html

Some custom cleaning code to remove a nasty piece of BlogSpot HTML
(and still running all other cleaning traits)

=cut

around clean_html => sub {
  my $orig = shift;
  my $self = shift;
  my ($html) = @_;

  warn __PACKAGE__, '::clean_html' if $ENV{PERLANET_DEBUG};

  # hack to remove a particularly nasty piece of blogspot HTML
  $html = $self->$orig($html);
  $html =~ s|<div align="justify"></div>||g;

  return $html;
};

no Moose;
__PACKAGE__->meta->make_immutable;

1;