#!/usr/bin/perl -Tw # # rss-view.pl - Redland CGI RSS validator and viewer demo # # Copyright (C) 2000-2004, David Beckett http://www.dajobe.org/ # Copyright (C) 2000-2004, University of Bristol, UK http://www.bristol.ac.uk/ # # This package is Free Software and part of Redland http://librdf.org/ # # It is licensed under the following three licenses as alternatives: # 1. GNU Lesser General Public License (LGPL) V2.1 or any newer version # 2. GNU General Public License (GPL) V2 or any newer version # 3. Apache License, V2.0 or any newer version # # You may not use this file except in compliance with at least one of # the above three licenses. # # See LICENSE.html or LICENSE.txt at the top of this package for the # complete terms and further detail along with the license texts for # the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively. # # # # CHANGE THIS FOR YOUR CONFIGURATION $::ROOT_DIR='/somewhere'; use strict; # Helps with broken web requests (missing headers) $ENV{'Content-Length'}||=0; # Tainting, dontcha know $ENV{'PATH'}="/bin:/usr/bin:/usr/local/bin:$::ROOT_DIR/bin/"; delete $ENV{'BASH_ENV'}; # Standard perl modules use CGI; use LWP::Simple; use URI::URL; # Configuration my $tmp_dir="$::ROOT_DIR/tmp"; my $log_file="$::ROOT_DIR/logs/rss.log"; my $max_error_size=100; my $max_warning_size=100; my(@parameters)=qw(uri box soup); # Used for deleting databases my @suffixes=qw(po2s so2p sp2o); my(%namespaces)=( # Built in modules 'Dublin Core' => 'http://purl.org/dc/elements/1.1/', 'Syndication' => 'http://purl.org/rss/1.0/modules/syndication/', # Proposed modules from http://purl.org/rss/1.0/modules/proposed/ 'Changed Page' => 'http://my.theinfo.org/changed/1.0/rss/', 'RSS 0.91' => 'http://purl.org/rss/1.0/modules/rss091#', 'Threading' => 'http://purl.org/rss/1.0/modules/threading/', 'Taxonomy' => 'http://purl.org/rss/1.0/modules/taxonomy/', 'Events' => 'http://purl.org/rss/1.0/modules/event/', 'Content' => 'http://purl.org/rss/1.0/modules/content/', 'Creative Commons' => 'http://web.resource.org/cc/', 'Admin' => 'http://webns.net/mvcb/', 'Annotate' => 'http://purl.org/rss/1.0/modules/annotate/', # Other modules 'Dublin Core Terms' => 'http://purl.org/dc/terms/', 'Slash' => 'http://slashcode.com/rss/1.0/modules/Slash/', ); # Specify order for consistency. Note: must match keys %namespaces my(@namespace_order)=( 'Dublin Core', 'Dublin Core Terms', 'Syndication', 'Content', 'Creative Commons', 'Changed Page', 'Admin', 'RSS 0.91', 'Threading', 'Taxonomy', 'Events', 'Slash' ); my $rss_spec_url='http://purl.org/rss/1.0/spec'; my $content_encoded_uri=$namespaces{Content}."encoded"; my(%demo_rss_feeds)=( # Put your favourite RSS 1.0 feeds here 'W3C Semantic Web News' => 'http://www.w3.org/2001/sw/Overview.rss', ); my(@demo_rss_feeds_order)=sort {lc $a cmp lc $b} keys %demo_rss_feeds; # Redland perl modules use RDF::Redland; use RDF::Redland::RSS; ###################################################################### # Subroutines sub log_action ($$;$) { my($host, $message, $now)=@_; $now ||= time; return unless open (LOG, ">>$log_file"); my($sec,$min,$hour,$mday,$mon,$year)=gmtime $now; my $date=sprintf("%04d-%02d-%02dT%02d:%02d:%02dZ",1900+$year,$mon+1,$mday,$hour,$min,$sec); print LOG "$host $date $message\n"; close(LOG); } sub end_page($) { my $q=shift; print <<"EOT";
This was written using Redland and the RDF::Redland::RSS Perl interface, interpreting the RSS 1.0 content as RDF using the Raptor RDF parser.
The source code of this demonstration is available in the Redland distribution as demos/rss-show.pl or from the Redland website
EOT print qq{