| 1 | ############################################################################## | ||
| 2 | # The Faq-O-Matic is Copyright 1997 by Jon Howell, all rights reserved. # | ||
| 3 | # # | ||
| 4 | # This program is free software; you can redistribute it and/or # | ||
| 5 | # modify it under the terms of the GNU General Public License # | ||
| 6 | # as published by the Free Software Foundation; either version 2 # | ||
| 7 | # of the License, or (at your option) any later version. # | ||
| 8 | # # | ||
| 9 | # This program is distributed in the hope that it will be useful, # | ||
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | ||
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | ||
| 12 | # GNU General Public License for more details. # | ||
| 13 | # # | ||
| 14 | # You should have received a copy of the GNU General Public License # | ||
| 15 | # along with this program; if not, write to the Free Software # | ||
| 16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.# | ||
| 17 | # # | ||
| 18 | # Jon Howell can be contacted at: # | ||
| 19 | # 6211 Sudikoff Lab, Dartmouth College # | ||
| 20 | # Hanover, NH 03755-3510 # | ||
| 21 | # jonh@cs.dartmouth.edu # | ||
| 22 | # # | ||
| 23 | # An electronic copy of the GPL is available at: # | ||
| 24 | # http://www.gnu.org/copyleft/gpl.html # | ||
| 25 | # # | ||
| 26 | ############################################################################## | ||
| 27 | |||
| 28 | # This entire file is THANKS Doug Schremp <doug_schremp@yahoo.com>. | ||
| 29 | # Purpose: "...I have added an XML/RDF | ||
| 30 | # recent search function. I use this to publish recent | ||
| 31 | # changes to the internal Slash based site as a | ||
| 32 | # slashbox. I would like to submit this code for | ||
| 33 | # possible inclusion in the base FAQ-O-Matic | ||
| 34 | # distribution. | ||
| 35 | # | ||
| 36 | # The code is based on recent.pm with changes to | ||
| 37 | # produce XML/RDF instead of HTML." | ||
| 38 | # | ||
| 39 | # jonh: So presumably Doug just synthesizes URLs directly to extract this | ||
| 40 | # XML data; there's no interface to grab it. | ||
| 41 | |||
| 42 | use strict; | ||
| 43 | |||
| 44 | package FAQ::OMatic::recentrdf; | ||
| 45 | |||
| 46 | use CGI; | ||
| 47 | use FAQ::OMatic::Item; | ||
| 48 | use FAQ::OMatic; | ||
| 49 | use FAQ::OMatic::SearchMod; | ||
| 50 | |||
| 51 | sub main { | ||
| 52 | my $cgi = FAQ::OMatic::dispatch::cgi(); | ||
| 53 | |||
| 54 | my $params = FAQ::OMatic::getParams($cgi); | ||
| 55 | |||
| 56 | # Get the names of the recent files | ||
| 57 | my $matchset = FAQ::OMatic::SearchMod::getRecentSet($params); | ||
| 58 | |||
| 59 | # Filter out those in the trash | ||
| 60 | # THANKS: dschulte@facstaff.wisc.edu for the suggestion | ||
| 61 | my @finalset = (); | ||
| 62 | my $file; | ||
| 63 | foreach $file (@{$matchset}) { | ||
| 64 | my $item = new FAQ::OMatic::Item($file); | ||
| 65 | if (not $item->hasParent('trash')) { | ||
| 66 | push @finalset, $item; | ||
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | |||
| 71 | print $cgi->header('-type'=>"text/xml"); | ||
| 72 | print <<EOL; | ||
| 73 | <?xml version="1.0"?> | ||
| 74 | <rdf:RDF | ||
| 75 | xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | ||
| 76 | xmlns="http://my.netscape.com/rdf/simple/0.9/"> | ||
| 77 | <channel> | ||
| 78 | EOL | ||
| 79 | |||
| 80 | my $topitem=new FAQ::OMatic::Item('1'); | ||
| 81 | my $title=$topitem->getTitle('undefokay'); | ||
| 82 | my $topUrl=FAQ::OMatic::getCacheUrl({'file' => $topitem->{'filename'}} ,{'file' => $topitem->{'filename'}} ); | ||
| 83 | print ("<title>",$title,"</title>\n"); | ||
| 84 | print ("<link>",$topUrl ,"</link>\n"); | ||
| 85 | print ("<description>",$title,"Recent Updates </description>\n"); | ||
| 86 | print ("</channel>\n"); | ||
| 87 | |||
| 88 | my $item; | ||
| 89 | my $test; | ||
| 90 | |||
| 91 | foreach $item (sort byModDate @finalset) | ||
| 92 | { | ||
| 93 | print "<item>\n"; | ||
| 94 | $test=$item->getTitle(); | ||
| 95 | print ("<title>$test</title>\n"); | ||
| 96 | $test=FAQ::OMatic::getCacheUrl({'file' => $item->{'filename'}} ,{'file' => $item->{'filename'}} ); | ||
| 97 | print ("<link>$test</link>\n"); | ||
| 98 | print ("</item>\n"); | ||
| 99 | } | ||
| 100 | print ("</rdf:RDF>\n"); | ||
| 101 | |||
| 102 | |||
| 103 | FAQ::OMatic::SearchMod::closeWordDB(); | ||
| 104 | } | ||
| 105 | |||
| 106 | sub byModDate { | ||
| 107 | my $lmsa = $a->{'LastModifiedSecs'} || -1; | ||
| 108 | my $lmsb = $b->{'LastModifiedSecs'} || -1; | ||
| 109 | return $lmsb <=> $lmsa; | ||
| 110 | } | ||
| 111 | |||
| 112 | 1; |