#!/usr/bin/perl #------------------------------------------------------------------------ # _ _ _ o generate headlines for # )L __ __)) ___ __ _ __ __ )L __ __ _ __ __ today's stories # (( ((_)((_( ((_( \(/'_)) _))(( ((_)(| (( (('_)) # )) by eric richardson #------------------------------------------------------------------------ # $Id: todays_stories,v 1.6 2000/09/17 11:05:40 eric Exp $ # # todays_stories: generate today's RealGold headlines # Copyright (C) 2000 Eric Richardson # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # # Grab today's stories and print links to them. # #------------------------------------------------------------------------ use strict; use vars qw($db %cfg $core %stored); use eGold::core; use DBI; use String::CRC32; use Date::Format; #----------------# # Initialization # #----------------# $core = eGold::core->start("todays_stories"); die "Usage: ./todays_stories (output file) (locale)\n" unless (@ARGV >= 1); ($cfg{input}{file},$cfg{input}{locale}) = @ARGV; MAIN: { my $locale_sql = "and article.locale = '$cfg{input}{locale}'" if ($cfg{input}{locale}); my $get_story_details = $db->prepare(" select article.id,article.headline,article.subtitle,article.author, article.locale,article.written,art_topic_lnk.topic_id from article,art_topic_lnk where article.id = art_topic_lnk.article_id and released != 0 and state != 'WITHDRAWN' $locale_sql order by article.released desc limit 30 "); $get_story_details->execute(); warn "got: ".$get_story_details->rows."\n"; my %s; $get_story_details->bind_columns( \$s{id},\$s{headline},\$s{subtitle},\$s{author}, \$s{locale},\$s{written},\$s{topic} ); my (%d,$html); $html = qq(
).time2str("%B %d, %Y",(time+54000)).qq(

); my $count; while ($get_story_details->fetch) { next if ($d{$s{id}} || $cfg{exclude}{$s{topic}}); my $hhtml = $core->get_template("headline.".$cfg{input}{locale}); foreach ( 'id','headline','subtitle','author','locale','written','topic' ) { $hhtml =~ s!#{$_}!$s{$_}!gi; } $html .= $hhtml; $d{$s{id}}++; $count++; last if ($count == 15); } $core->write_file( name => $cfg{input}{file}, data => $html, ); $core->upload(@files); $core->save_memory(\%stored); } #-------------# # Subroutines # #-------------# #-------------# # Change Logs # #-------------# # $Log: todays_stories,v $ # Revision 1.6 2000/09/17 11:05:40 eric # * changed the way for determining published stories # * finished more functionality in make_archives # # Revision 1.5 2000/09/15 11:43:25 eric # * changed todays_stories to just display last ten stories regardless # of day (not exactly truth in naming, but i'm lazy) # * added make_archives script to generate archive pages # * little fixes # # Revision 1.4 2000/09/11 09:38:42 eric # * first working revision of todays_stories # * updates to eGold::core # # Revision 1.3 2000/09/08 11:32:00 eric # * moved get_template into eGold::core # # Revision 1.2 2000/09/08 11:20:56 eric # * it would be cool if there was a way to make ascii art out of valid # Perl. Unfortunately, my ascii art doesn't compile. # * fixed a little bug in where the package tag was placed in eGold::core # # Revision 1.1 2000/09/08 11:08:38 eric # * small fixes # * got rid of a couple warns # * added start of core module and todays_stories script # #----------