Gossamer Forum
Home : Products : Links 2.0 : Customization :

XML, RSS and Links! XMLinks mod ...

Quote Reply
XML, RSS and Links! XMLinks mod ...
I would like to announce what I think is the first XML application using Links - XMLinks Smile

I have changed the What's New page to a RSS (Rich Site Summary) file, i.e. a RDF/XML file, see: http://www.statskontoret.se/...erna/senaste/rss.xml (will show in MSIE5, but due to my use of Swedish characters, it might not show; look at the source to see the XML)

You can also see it via XMLTree, a XML repository:
http://www.xmltree.com/.../L/3/ResourceID/3946
where you can subscribe to it on several portals or as a HTML-newsletter. Also there, you can (on Tester) get a HTMLified output of the XML source).

How did I do this? Well, I have played with the sub build_new_page in nph_build.cgi, added a new sub to site_html_templates.pl, and XMLified the new.html template. Oh, and created a new template for the RSS/XML links, to which I refer in the modded sub. Laziness also made me turn off spanning pages (will fix that, solution for that is in Eliot and/or Bobsie thread somewhere here...)

I have described these changes in detail at:
http://www.gotzespace.dk/...linksmod/xmlinks.txt

It works. Well, sort of. It creates the RSS-file, but I am having problems with the sorting. In general in this installation of Links, I sort by ID only, and the RSS items should also do this. This is where I need help! - since this is independent of all the XML-stuff, I beg you perl-wizards for assistance -- formulated as a general mod question: How do I get the What's New pages to sort independetly of categories, and only by ID??

(For more information about (that is, links to resources) RSS and XML, see http://www.links.gotzespace.dk
-> XML -> Syndication)

Cheers
John
Quote Reply
Re: XML, RSS and Links! XMLinks mod ... In reply to
Hi:

Do you know of any sites using your modifications to create a backend feed. I know that within the next three to four months, we hope to be adding an array of "backends" to various segments of our site "Nonprofit-TechWorld" so that we can feed data to other sources, especially since so many sources are generously feeding data to us.

So I'm very interested in a XML implemtation that will allow us to convert data from the .cgi files to .rdf or .xml format.

Alnisa

Quote Reply
Re: [allgood2] XML, RSS and Links! XMLinks mod ... In reply to
Is this MOD still available by any chance ?
>> Nakul Goyal (SEO, Link Building Expert)
Web Site Promotion
Tips 'n' Tricks
SEO News


Quote Reply
Re: [nakulgoyal] XML, RSS and Links! XMLinks mod ... In reply to
Here is a copy of the file, hope Mr. Gotze dosen't mind...


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] XML, RSS and Links! XMLinks mod ... In reply to
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/</&#60;/g; }
if ($rec{'Title'}) { ($rec{'Title'}) =~ s/>/&#62;/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

Last edited by:

smatthew: May 18, 2005, 2:38 PM
Quote Reply
XML, RSS and Links! XMLinks mod ... In reply to
I also installed the 'sort by date' change listed here:
http://gossamer-threads.com/..._flat&post=25659

and here's a link to John's original mod:
http://www.gotzespace.dk/books/xml.txt

Steve