[Bast-commits] r6364 - in ironman/plagger: .
assets/plugins/Publish-PagedPlanet/default/template
lib/Plagger/Plugin lib/Plagger/Plugin/Summary
castaway at dev.catalyst.perl.org
castaway at dev.catalyst.perl.org
Thu May 21 23:21:56 GMT 2009
Author: castaway
Date: 2009-05-21 23:21:55 +0000 (Thu, 21 May 2009)
New Revision: 6364
Added:
ironman/plagger/lib/Plagger/Plugin/Summary/
ironman/plagger/lib/Plagger/Plugin/Summary/HTMLTruncate.pm
Modified:
ironman/plagger/assets/plugins/Publish-PagedPlanet/default/template/index.tt
ironman/plagger/ironman.yaml
ironman/plagger/ironman_dev.yaml
Log:
Fix summarys!
Modified: ironman/plagger/assets/plugins/Publish-PagedPlanet/default/template/index.tt
===================================================================
--- ironman/plagger/assets/plugins/Publish-PagedPlanet/default/template/index.tt 2009-05-21 20:20:49 UTC (rev 6363)
+++ ironman/plagger/assets/plugins/Publish-PagedPlanet/default/template/index.tt 2009-05-21 23:21:55 UTC (rev 6364)
@@ -98,7 +98,7 @@
</div>
[% IF entry.body %]
<div class="entry-body">
- [% entry.summary || entry.body.truncate_html(300) %]
+ [% entry.summary %]
</div>
[% END %]
<div class="entry-footer">
Modified: ironman/plagger/ironman.yaml
===================================================================
--- ironman/plagger/ironman.yaml 2009-05-21 20:20:49 UTC (rev 6363)
+++ ironman/plagger/ironman.yaml 2009-05-21 23:21:55 UTC (rev 6364)
@@ -388,6 +388,8 @@
url: http://www.shadowcat.co.uk/feed/blog/matt-s-trout
title: Matt S. Trout (mst)
+ - module: Summary::HTMLTruncate
+
# Deduplicate entries using URL + datetime as a key
- module: Filter::Rule
rule:
Modified: ironman/plagger/ironman_dev.yaml
===================================================================
--- ironman/plagger/ironman_dev.yaml 2009-05-21 20:20:49 UTC (rev 6363)
+++ ironman/plagger/ironman_dev.yaml 2009-05-21 23:21:55 UTC (rev 6364)
@@ -273,6 +273,8 @@
module: Deduped
path: /var/www/ironboy.enlightenedperl.org/plagger/ironman.db
+ - module: Summary::HTMLTruncate
+
# - module: Filter::Rule
# rule:
# module: Fresh
@@ -286,17 +288,17 @@
# expression: grep $args->{entry}->body_text =~ /\b$_\b/i || $args->{entry}->has_tag($_), qw/perl cpan/
# title: Planet Iron Man
- - module: Publish::CSV
- config:
- dir: /var/www/ironboy.enlightenedperl.org/plagger/csv
- encoding: utf-8
- filename: my_%t.csv
- mode: append
- column:
- - author
- - title
- - permalink
- - date
+# - module: Publish::CSV
+# config:
+# dir: /var/www/ironboy.enlightenedperl.org/plagger/csv
+# encoding: utf-8
+# filename: my_%t.csv
+# mode: append
+# column:
+# - author
+# - title
+# - permalink
+# - date
## MyPlanet, is not the default Planet bundle
Added: ironman/plagger/lib/Plagger/Plugin/Summary/HTMLTruncate.pm
===================================================================
--- ironman/plagger/lib/Plagger/Plugin/Summary/HTMLTruncate.pm (rev 0)
+++ ironman/plagger/lib/Plagger/Plugin/Summary/HTMLTruncate.pm 2009-05-21 23:21:55 UTC (rev 6364)
@@ -0,0 +1,56 @@
+package Plagger::Plugin::Summary::HTMLTruncate;
+use strict;
+use base qw( Plagger::Plugin );
+
+use HTML::Truncate;
+
+sub register {
+ my($self, $context) = @_;
+ $context->register_hook(
+ $self,
+ 'summarizer.summarize' => \&summarize,
+ );
+}
+
+sub summarize {
+ my($self, $context, $args) = @_;
+ my $length = 300;
+
+ my $html_truncate = HTML::Truncate->new(repair=>1);
+ $html_truncate->chars($length);
+ $html_truncate->ellipsis(" [...]");
+# warn "Before truncate: " . $args->{text}->html . "\n";
+ my $truncated = eval { $html_truncate->truncate($args->{text}->html) };
+# warn "After truncate: $truncated\n";
+ if ($@) {
+ warn "Truncate failed: $@";
+ return $args->{text}->html;
+ }
+ return $truncated;
+}
+
+1;
+__END__
+
+=head1 NAME
+
+Plagger::Plugin::Summary::HTMLTruncate - uses HTML::Truncate to get first sentence
+
+=head1 SYNOPSIS
+
+ - module: Summary::TextOriginal
+
+=head1 DESCRIPTION
+
+This plugin uses Text::Original CPAN module to generate summary off of
+plaintext-ized body.
+
+=head1 AUTHOR
+
+Tatsuhiko Miyagawa
+
+=head1 SEE ALSO
+
+L<Plagger>, L<Text::Original>
+
+=cut
More information about the Bast-commits
mailing list