On Thu, 26 Sep 1996, Andy Powell wrote:
> Sigh... Paul, I'm not sure that it's sensible to push these tools too far
> outside the confines of this list for the time being - seems to me that
> you're not doing anyone any favours by encouraging them to create inline
> DC until you can be reasonably sure that the syntax for the META tags is
> stable. And we don't appear to have got to that point yet :-(.
Well I think both Paul and I thought we'd got to that point until earlier
this week. Time to do some more consensus building I guess. :-(
> I've written a similar tool here but we've decided to back off using it
> for a while.
Yeah, I've not advertised by little script outside of meta2 and I'm not
planning on doing it (especially seeing as Paul's CGI script is a lot
cooler than my script).
> Just done a quick comparison of the META tags generated by the scripts and
> the output is pretty similar.
>
> Jon, your script generates
>
> <META NAME="DC.subject" CONTENT="(scheme=keywords) ... ">
>
> Should be type= rather that scheme= perhaps?
Yep, dead right. Andy, you're getting dead good at this bug spotting
lark! 'Tis fixed (see attachment) :-)
Tatty bye,
Jim'll
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Jon "Jim'll" Knight, Researcher, Sysop and General Dogsbody, Dept. Computer
Studies, Loughborough University of Technology, Leics., ENGLAND. LE11 3TU.
* I've found I now dream in Perl. More worryingly, I enjoy those dreams. *
#!/usr/public/bin/perl
#
# dc_inject.pl - Script to inject Dublin Core metadata into an HTML document
#
# Author: [log in to unmask]
#
# $Id: dc_inject.pl,v 1.2 1996/09/26 23:59:08 jon Exp $
#
# needs libwww-perl - cf. <URL:http://www.oslonett.no/home/aas/perl/www/>
# and Perl 5.
use LWP::UserAgent;
use HTML::Parse;
use URI::URL;
use Getopt::Std;
require HTML::Element;
getopts("a:b:de:hk:l:p:P");
if($opt_h) {
print STDERR <<"EndOfHelp";
Usage: $0 [-a author_name] [-b url_base] [-d] [-e author_email] [-h]
[-k keywords] [-l language] [-p proxy] [-P] <url>
EndOfHelp
exit(1);
}
$AuthorName = $opt_a || $ENV{AUTHORNAME} || "Unknown";
$AuthorEmail = $opt_e || $ENV{AUTHOREMAIL} || $ENV{USER}."\@localhost";
$Keywords = $opt_k || $ENV{KEYWORDS} || "none";
$Language = $opt_l || $ENV{LANGUAGE} || "en";
$debug = $opt_d || 0;
$BASE = $opt_b || "http://localhost/";
$ua = new LWP::UserAgent;
$ua->env_proxy unless $opt_P;
$ua->proxy(['http', 'ftp', 'gopher', 'wais'], $opt_p) if $opt_p;
$ua->agent('dc_inject.pl libwww-perl/5.00');
# Get the URL we want to add the metadata to.
$url = $ARGV[0];
$url =~ chomp;
print STDERR "Examining <URL:$url>...\n" if $debug;
# We're only interested in URL's of HTML documents
if ($url =~ /\.htm[l]$/) {
# Make relative URLs into absolute URLs.
if(!/^http:/i) {
$url = url($url, $BASE)->abs->as_string;
}
# Build a request to go and get the document
$req = new HTTP::Request 'GET', $url;
$req->header('Accept' => 'text/html');
# send request
$res = $ua->request($req);
# check the outcome
if ($res->is_success) {
$html = parse_html($res->content);
$intitle = 0;
$html->traverse(\&callback, 0);
} else {
print STDERR "Error: " . $res->code . " " . $res->message;
}
}
exit;
sub callback {
local($node,$startflag,$depth) = @_;
if (!($node =~ "^HTML::")) {
print "$node\n";
if($intitle) {
$title = $node;
$intitle = 0;
}
return(1);
}
if(($startflag == 1) && ($node->tag() eq "title")) {
$intitle = 1;
}
if(($startflag == 0) && ($node->tag() eq "head")) {
print STDOUT <<"EndOfMETA";
<!-- Dublin Core Metadata Package -->
<META NAME="beginpackage" CONTENT="Dublin Core">
<META NAME="DC.title" CONTENT=" $title">
<LINK REL=SCHEMA.dc HREF="http://purl.org/metadata/dublin_core_elements#title">
<META NAME="DC.author" CONTENT="(type=Name) $AuthorName">
<META NAME="DC.author" CONTENT="(type=Email) $AuthorEmail">
<LINK REL=SCHEMA.dc HREF="http://purl.org/metadata/dublin_core_elements#author">
<META NAME="DC.subject" CONTENT="(type=Keyword) $Keywords">
<LINK REL=SCHEMA.dc HREF="http://purl.org/metadata/dublin_core_elements#subject">
<META NAME="DC.form" CONTENT="(scheme=IMT) text/html">
<LINK REL=SCHEMA.dc HREF="http://purl.org/metadata/dublin_core_elements#form">
<LINK REL=SCHEMA.imt HREF="http://sunsite.auc.dk/RFC/rfc/rfc1521.html">
<META NAME="DC.identifier" CONTENT="(scheme=URL) $url">
<LINK REL=SCHEMA.dc HREF="http://purl.org/metadata/dublin_core_elements#identifier">
<META NAME="DC.language" CONTENT="(scheme=ISO.639) $Language">
<LINK REL=SCHEMA.dc HREF="http://purl.org/metadata/dublin_core_elements#language">
<META NAME="endpackage" CONTENT="Dublin Core">
EndOfMETA
}
if($startflag==1) {
print $node->starttag();
} else {
print $node->endtag();
}
return(1);
}
|