| 1 | package Perlanet::Simple; | ||||||||||
| 2 | |||||||||||
| 3 | 11 | ▶ | use 5.10.0; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 11 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 11 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 11 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 11 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 11 | ▶ | use YAML 'LoadFile'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 11 | extends 'Perlanet'; | |||||||||
| 13 | 11 | with qw( | |||||||||
| 14 | Perlanet::Trait::Cache | ||||||||||
| 15 | Perlanet::Trait::OPML | ||||||||||
| 16 | Perlanet::Trait::Scrubber | ||||||||||
| 17 | Perlanet::Trait::Tidy | ||||||||||
| 18 | Perlanet::Trait::YAMLConfig | ||||||||||
| 19 | Perlanet::Trait::TemplateToolkit | ||||||||||
| 20 | Perlanet::Trait::FeedFile | ||||||||||
| 21 | ); | ||||||||||
| 22 | |||||||||||
| 23 | =head1 NAME | ||||||||||
| 24 | |||||||||||
| 25 | Perlanet::Simple - a DWIM Perlanet | ||||||||||
| 26 | |||||||||||
| 27 | =head1 SYNOPSIS | ||||||||||
| 28 | |||||||||||
| 29 | use Perlanet::Simple; | ||||||||||
| 30 | |||||||||||
| 31 | my $perlanet = Perlanet::Simple->new_with_config( | ||||||||||
| 32 | configfile => 'perlanet.yaml' | ||||||||||
| 33 | ); | ||||||||||
| 34 | $perlanet->run; | ||||||||||
| 35 | |||||||||||
| 36 | =head1 DESCRIPTION | ||||||||||
| 37 | |||||||||||
| 38 | L<Perlanet> provides the driving force behind all Perlanet applications, | ||||||||||
| 39 | but it doesn't do a whole lot, which means you would normally have to write | ||||||||||
| 40 | the functionality you require. However, in the motive of simplicity, | ||||||||||
| 41 | Perlanet::Simple glues enough stuff together to allow you to get a very quick | ||||||||||
| 42 | planet working out of the box. | ||||||||||
| 43 | |||||||||||
| 44 | Perlanet::Simple takes the standard Perlanet module, and adds support for | ||||||||||
| 45 | caching, OPML feed generation, and L<Template> rendering support. It will | ||||||||||
| 46 | also attempt to clean each post using both L<HTML::Scrubber> and L<HTML::T5>. | ||||||||||
| 47 | |||||||||||
| 48 | =head2 Configuration | ||||||||||
| 49 | |||||||||||
| 50 | Perlanet::Simple uses L<Perlanet::Trait::YAMLConfig> to allow you to specify | ||||||||||
| 51 | configuration through a file. | ||||||||||
| 52 | |||||||||||
| 53 | =cut | ||||||||||
| 54 | |||||||||||
| 55 | 10 | ▶ | around '_build_ua' => sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||
| 56 | 10 | my $orig = shift; | |||||||||
| 57 | 10 | my $self = shift; | |||||||||
| 58 | 10 | my $ua = $self->$orig; | |||||||||
| 59 | 10 | ▶ | $ua->agent($self->agent) if $self->agent; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | 10 | return $ua; | |||||||||
| 61 | 11 | }; | |||||||||
| 62 | |||||||||||
| 63 | =head2 clean_html | ||||||||||
| 64 | |||||||||||
| 65 | Some custom cleaning code to remove a nasty piece of BlogSpot HTML | ||||||||||
| 66 | (and still running all other cleaning traits) | ||||||||||
| 67 | |||||||||||
| 68 | =cut | ||||||||||
| 69 | |||||||||||
| 70 | 7 | ▶ | around clean_html => sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||
| 71 | 7 | my $orig = shift; | |||||||||
| 72 | 7 | my $self = shift; | |||||||||
| 73 | 7 | my ($html) = @_; | |||||||||
| 74 | |||||||||||
| 75 | 7 | ▶ | warn __PACKAGE__, '::clean_html' if $ENV{PERLANET_DEBUG}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 76 | |||||||||||
| 77 | # hack to remove a particularly nasty piece of blogspot HTML | ||||||||||
| 78 | 7 | $html = $self->$orig($html); | |||||||||
| 79 | 7 | $html =~ s|<div align="justify"></div>||g; | |||||||||
| 80 | |||||||||||
| 81 | 7 | return $html; | |||||||||
| 82 | 11 | }; | |||||||||
| 83 | |||||||||||
| 84 | 11 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 85 | 11 | __PACKAGE__->meta->make_immutable; | |||||||||
| 86 | |||||||||||
| 87 | 11 | 1; | |||||||||