#!/usr/bin/perl # make-musings-oai.pl - create a set of OAI files from the musings database # Eric Lease Morgan # 2004-11-07 - first cut use constant OAIROOT => '/usr/local/apache/htdocs/musings/oai/data/'; use constant WEBROOT => 'http://infomotions.com'; use Musings::Article; use Musings::Subject; use strict; my @articles = Musings::Article->get_articles; foreach (@articles) { my $date = $_->article_date; my $description = &escape($_->article_note); my $relation = WEBROOT . $_->article_path . $_->article_filename; my $source = &escape($_->article_source); my $title = &escape($_->article_title); my $url = WEBROOT . $_->article_path; my @subject_ids = $_->subject_ids; my $subjects; foreach (@subject_ids) { my $subject = Musings::Subject->new(id =>$_); $subjects .= '' . &escape($subject->subject_term) . ''; } open (OAI, '> ' . OAIROOT . 'musings-' . $_->article_id . '.xml'); print OAI < Eric Lease Morgan $date $title $description $subjects TEI/XML source for this document is available at $relation This text is distributed under the GNU Public License. $source $url Infomotions, Inc. text en-US text/html EOR close OAI; } sub escape { my $text = shift; $text =~ s/&/&/g; $text =~ s//>/g; return($text); }