Browse Source

extracing titles in feed

pull/1/head
Brennen Bearnes 14 years ago
parent
commit
8305a6ef14
1 changed files with 16 additions and 3 deletions
  1. +16
    -3
      lib/Display.pm

+ 16
- 3
lib/Display.pm View File

@ -226,6 +226,7 @@ Takes a hashref which contains a map of entry titles to entry descriptions.
=cut
# TODO: this has gotten more than a little silly.
$default{entry_descriptions} = {
new => 'newest entries',
all => 'all entries',
@ -234,13 +235,15 @@ $default{entry_descriptions} = {
1999 => 'entries for 1999',
2000 => 'entries for 2000',
2001 => 'entries for 2001',
2002 => 'entries for 2001',
2002 => 'entries for 2002',
2003 => 'entries for 2003',
2004 => 'entries for 2004',
2005 => 'entries for 2005',
2006 => 'entries for 2006',
2007 => 'entries for 2007',
2008 => 'entries for 2008',
2009 => 'entries for 2009',
2010 => 'entries for 2010',
};
# Set up some accessor methods:
@ -420,6 +423,7 @@ sub link_bar {
my (%description) = %{ $self->entry_descriptions() };
# TODO: this obviously should not be hardcoded
my @years = qw(2010 2009 2008 2007 2006 2005 2004 2003 2002 2001 2000 1999 1998 1997);
# This makes the short list of years context sensitive:
@ -1072,11 +1076,20 @@ sub feed_print {
my $entry = "$month/$entry_file";
my $entry_url = $month_url . "/$entry_file";
my $title = $entry;
my $content = $self->entry($entry);
# try to pull out a header:
my ($extracted_title) = $content =~ m{<h3>(.*?)</h3>}s;
if ($extracted_title) {
$title = $extracted_title;
}
$feed->add_entry(
title => $entry,
title => $title,
link => $entry_url,
id => $entry_url,
content => $self->entry($entry),
content => $content,
updated => Wala::iso_date(Wala::get_mtime("$month_file/$entry_file")),
);
}


|||||||
x
 
000:0
Loading…
Cancel
Save