#!/usr/bin/perl # make-rss.pl - create rss feed # Eric Lease Morgan # 2004-12-02 - first cut # 2004-12-04 - added random musing # 2004-12-06 - added item from the archives; added keywords and source to description # 2006-10-14 - moved to wilson # include/require use constant RSSOUT => '/disk01/www/html/main/musings/musings.rss'; use constant WEBROOT => 'http://infomotions.com'; use Musings::Article; use Musings::Subject; use DateTime; use strict; # startr output open (RSS, '> ' . RSSOUT); print RSS ''; print RSS ''; print RSS "Infomotions' Musings on Information and Librarianship"; print RSS 'http://infomotions.com/musings/'; print RSS 'This is a list of travel logs, software descriptions, formally published articles, or presentation handouts. Four are the most recently written. One is randomly chosen, and one is selected from the archives. All of these items, Musings on Information and Librarianship, were written by Eric Lease Morgan.'; print RSS 'en-us'; print RSS 'Copyright '. DateTime->now->year . ', Infomotions, Inc. This document is distributed under the GNU Public License.'; print RSS 'make-rss.pl'; print RSS 'libraries, librarians, & librarianship'; print RSS 'eric_morgan@infomotions.com'; print RSS 'eric_morgan@infomotions.com'; print RSS '' . &buildDate(DateTime->now->ymd) . ''; print RSS ''; print RSS 'Go'; print RSS 'Search Musings'; print RSS 'query'; print RSS 'http://infomotions.com/?cmd=search'; print RSS ''; print RSS ''; print RSS 'http://infomotions.com/logo.gif'; print RSS 'Infomotions, Inc.'; print RSS 'http://infomotions.com/'; print RSS ''; # get all the articles/musings; nice Perl module! my @articles = Musings::Article->get_articles (sort => 'date'); # get a random musing; cool random function gotten from http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=155&lngWId=6 my $lower = 4; my $upper = $#articles; my $random = int(rand($upper - $lower + 1)) + $lower; my $article = @articles[$random]; $article->article_title('Random Musing: ' . $article->article_title); #&printOne($article); # create archive musing if ($ARGV[0]) { my $article = Musings::Article->new(id => $ARGV[0]); $article->article_title('From the archives: ' . $article->article_title); &printOne($article); } # process the most recent 10 musings for (my $i = 0; $i < 100; $i++) { &printOne(@articles[$i]) } # cleanup and quit print RSS ''; close RSS; exit; sub printOne { my $article = shift; print RSS ''; print RSS '' . &escape($article->article_title) . ''; print RSS '' . WEBROOT . $article->article_path . ''; my @subject_ids = $article->subject_ids; my $keywords; foreach (@subject_ids) { my $subject = Musings::Subject->new(id =>$_); print RSS '' . &escape($subject->subject_term) . ''; $keywords .= $subject->subject_term . '; '; } print RSS '' . &escape($article->article_note . '
  • Keywords: ' . $keywords . '
  • Source: ' . $article->article_source . '
') . '
'; print RSS '' . &buildDate($article->article_date). ''; print RSS '
'; } sub buildDate { my $date = shift; my ($year, $month, $day) = split('-', $date); my $dt = DateTime->new(year => $year, month => $month, day => $day, time_zone => 'America/Indianapolis'); my $rv = $dt->strftime("%a, %d %b %Y %H:%M:%S %z"); return $rv; } sub escape { my $text = shift; $text =~ s/&/&/g; $text =~ s//>/g; return($text); }