I've been working on this for the past couple of days, and have some changes that others might consider:
1) in site_html_templates get rid of the invalid characters (including the displayed '-' in the record dates):
sub site_html_rsslink {
# --------------------------------------------------------
# This routine is used to display what a link should look
# like in the lastlink.html webpage.
my %rec = @_;
# Set new and pop to either 1 or 0 for templates.
($rec{'isNew'} eq 'Yes') ? ($rec{'isNew'} = 1) : (delete $rec{'isNew'});
($rec{'isPopular'} eq 'Yes') ? ($rec{'isPopular'} = 1) : (delete $rec{'isPopular'});
if ($rec{'Title'}) { ($rec{'Title'}) =~ s/&/&/g; }
if ($rec{'Title'}) { ($rec{'Title'}) =~ s/</</g; }
if ($rec{'Title'}) { ($rec{'Title'}) =~ s/>/>/g; }
if ($rec{'Title'}) { ($rec{'Title'}) =~ s/’/'/g; }
if ($rec{'Date'}) { ($rec{'Date'}) =~ s/-/ /g; }
return &load_template ('rsslink.html', {
#detailed_url => "$db_detailed_url/$rec{'ID'}$build_extension",
%rec,
%globals
});
}
2) in site_html_templates comment out the standard headers and deliver an xml header instead:
sub site_html_search_rssresults {
# --------------------------------------------------------
# This routine displays the search results.
#
my $term = &urlencode ($in{'query'});
# &html_print_headers;
print "Content-type: application/xml\n\n";
print &load_template ('search_rssresults.html', {
term => $term,
link_results => $link_results,
category_results => $category_results,
next => $next,
cat_hits => $cat_hits,
link_hits => $link_hits,
%in,
%globals
});
}
3) Create a new global to display the date without hyphens (another validation issue):
3a) in site_html_templates change:
%globals = (
date => &get_date,
rssdate => &get_rssdate,
time => &get_time,
db_cgi_url => $db_cgi_url,
build_root_url => $build_root_url,
site_title => $build_site_title,
css => $build_css_url,
banner => ''
);
3b) then in db_utils create a new sub (I put mine under "get_date"):
sub get_rssdate {
# --------------------------------------------------------
# Returns the current date.
#
my ($time1) = $_[0];
($time1) or ($time1 = time());
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time1);
my (@months) = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
($day < 10) and ($day = "0$day");
$year = $year + 1900;
return "$day $months[$mon] $year";
}
4) Change the templates to RSS 2.0:
4a) search_rssresults.html changes (including new global date):
<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
<channel>
<title>Company Name</title>
<link>http://www.mysite.com</link>
<description>Feed Description</description>
<language>en</language>
<lastBuildDate><%rssdate%> <%time%> PST</lastBuildDate>
<copyright>copyright holder</copyright>
<managingEditor>my@email.com</managingEditor>
<webMaster>webmaster@email.com</webMaster>
<%if link_results%>
<%link_results%>
<%endif%>
</channel>
</rss>
4b) rsslink.html changes:
<item>
<title><%Title%></title>
<pubDate><%Date%> <%time%> PST</pubDate>
<description><%Description%></description>
<link><%URL%></link>
</item>
Hope this helps, and I'm sure all the bugs aren't worked out yet. But it's getting to be 'useable' anyway.
tx, Steve
1) in site_html_templates get rid of the invalid characters (including the displayed '-' in the record dates):
sub site_html_rsslink {
# --------------------------------------------------------
# This routine is used to display what a link should look
# like in the lastlink.html webpage.
my %rec = @_;
# Set new and pop to either 1 or 0 for templates.
($rec{'isNew'} eq 'Yes') ? ($rec{'isNew'} = 1) : (delete $rec{'isNew'});
($rec{'isPopular'} eq 'Yes') ? ($rec{'isPopular'} = 1) : (delete $rec{'isPopular'});
if ($rec{'Title'}) { ($rec{'Title'}) =~ s/&/&/g; }
if ($rec{'Title'}) { ($rec{'Title'}) =~ s/</</g; }
if ($rec{'Title'}) { ($rec{'Title'}) =~ s/>/>/g; }
if ($rec{'Title'}) { ($rec{'Title'}) =~ s/’/'/g; }
if ($rec{'Date'}) { ($rec{'Date'}) =~ s/-/ /g; }
return &load_template ('rsslink.html', {
#detailed_url => "$db_detailed_url/$rec{'ID'}$build_extension",
%rec,
%globals
});
}
2) in site_html_templates comment out the standard headers and deliver an xml header instead:
sub site_html_search_rssresults {
# --------------------------------------------------------
# This routine displays the search results.
#
my $term = &urlencode ($in{'query'});
# &html_print_headers;
print "Content-type: application/xml\n\n";
print &load_template ('search_rssresults.html', {
term => $term,
link_results => $link_results,
category_results => $category_results,
next => $next,
cat_hits => $cat_hits,
link_hits => $link_hits,
%in,
%globals
});
}
3) Create a new global to display the date without hyphens (another validation issue):
3a) in site_html_templates change:
%globals = (
date => &get_date,
rssdate => &get_rssdate,
time => &get_time,
db_cgi_url => $db_cgi_url,
build_root_url => $build_root_url,
site_title => $build_site_title,
css => $build_css_url,
banner => ''
);
3b) then in db_utils create a new sub (I put mine under "get_date"):
sub get_rssdate {
# --------------------------------------------------------
# Returns the current date.
#
my ($time1) = $_[0];
($time1) or ($time1 = time());
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time1);
my (@months) = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
($day < 10) and ($day = "0$day");
$year = $year + 1900;
return "$day $months[$mon] $year";
}
4) Change the templates to RSS 2.0:
4a) search_rssresults.html changes (including new global date):
<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
<channel>
<title>Company Name</title>
<link>http://www.mysite.com</link>
<description>Feed Description</description>
<language>en</language>
<lastBuildDate><%rssdate%> <%time%> PST</lastBuildDate>
<copyright>copyright holder</copyright>
<managingEditor>my@email.com</managingEditor>
<webMaster>webmaster@email.com</webMaster>
<%if link_results%>
<%link_results%>
<%endif%>
</channel>
</rss>
4b) rsslink.html changes:
<item>
<title><%Title%></title>
<pubDate><%Date%> <%time%> PST</pubDate>
<description><%Description%></description>
<link><%URL%></link>
</item>
Hope this helps, and I'm sure all the bugs aren't worked out yet. But it's getting to be 'useable' anyway.
tx, Steve