Gossamer Forum
Home : Products : Gossamer Forum : Development, Plugins and Globals :

RSS / XML Output for Ten Most Recent Postings

(Page 1 of 2)
> >
Quote Reply
RSS / XML Output for Ten Most Recent Postings
Is there any mod to do this - kind of surprised there is no method to do it. How do you folks here at gossamer-threads get the latest posts from a specific forum nicely outputed to your homepage?

I'd be happy to help, but am clueless on where to start? I'm thinking of a cgi script that grabs the latest headlines and outputs an rss file?

John Gotze has the below script for Links - it could be used as a base to produce RSS output for the forum?

http://www.gotzespace.dk/books/linksmod/xml.txt
Quote Reply
Re: [DoubleJJ] RSS / XML Output for Ten Most Recent Postings In reply to
--------------------------------------------------------------------
XML/RSS-feed from GT Forum - Release 1.0, 11-23-2002
--------------------------------------------------------------------
John Gotze, john@slashdemocracy.org

This is a simple hack to GT Forum which allows you to produce an XML/RSS-feed from your forum.

USAGE

The feed is called as a search query.
See it in action (if you have a RSS reader):
http://slashdemocracy.org/...&mh=15&t=xml

t=xml is the key to getting XML from search queries. Should be possible to add to all search strings.
Using mh=5 means the feed will have a maximum of 15 items, for example.

INSTALLATION

STEP 1:
Use Fileman or FTP/Telnet.
Go to admin/templates and create a new template directory called /xml (or whatever you want).
Set permissions to 777.

STEP 2:
Create a file with the name .tplinfo and put it in the /xml directory.
The file must contain these three lines:

{
inheritance => '../default'
}

STEP 3:
Create a file with the name search_results.html and put it in the /xml directory.
The file must contain the XML template, like this:

--------copy below section into your new template---

<?xml version="1.0" encoding="ISO-8859-1" ?>
<rss version="0.91">
<channel>
<title><%site_title%></title>
<link>http://yoursite.com</link>
<description>Forum Feed ...</description>
<language>en-us</language>
<copyright>You</copyright>
<managingEditor>you@yoursite.com</managingEditor>
<webMaster>you@yoursite.com</webMaster>

<%set num_page_items = $num_results%>
<%loop results%>
<item>
<title><%post_subject%></title>
<link>http://yoursite.com/gforum.cgi?post=<%post_id%></link>
<description><%nbsp post_username%> in <%forum_name%> on <%post_date%></description>
</item>
<%endloop%>
</channel>
</rss>

---- end copy ---

That's it.

Read more about RSS on
http://slashdemocracy.org/.../XML/Syndication/RSS

Smile
Quote Reply
Re: [gotze] RSS / XML Output for Ten Most Recent Postings In reply to
1/8/03 UPDATE:
This gizmo is still in-process, since invalid characters are allowed to creep into your xml. See later posting. Back to the orginal posting:

Nice John, I'm testing something similar. This was pieced from other postsings here - which I'm too lazy to credit. It should xml-ize the last ten posts (controlled by hot_threads variable).

This should allow for a short quote of the post to be displayed too.


http://nerock.com/cgi-bin/gforum/gforum.cgi?do=search_results&search_time=10h&t=rssmod

Step 1
Create two new global variables:

hot_threads


sub {
my $tags = shift;
my $post_db = $DB->table ('Post');
$post_db->select_options ('WHERE post_root_id=0',
'ORDER BY post_time DESC', 'LIMIT 10');
my $sth = $post_db->select;
my @output;
while (my $post = $sth->fetchrow_hashref)
{
push @output, $post;
}

return { post_loop => \@output };
}


hot_chop update: see later post below for improved hot_chop


sub {
my $post_message = shift;
return substr($post_message,0,125);
}


Step 2
Create a new directory / template set - called rssmod with two new templates:

.tplinfo


{
inheritance => '../default'
}


search_results.html


<?xml version="1.0" encoding="ISO-8859-1" ?>
<rss version="0.91">
<channel>
<title>Your Title</title>
<link>http://yousite.com</link>
<description>Your Description</description>
<language>en</language>

<%hot_threads%>
<%loop post_loop%>
<item>
<title><%post_subject%></title>
<link>http://www.yoursite.com/gforum/gforum.cgi?post=<%post_id%></link>
<description><%hot_chop($post_message)%></description>
</item>
<%endloop%>
</channel>
</rss>

Last edited by:

DoubleJJ: Jan 13, 2003, 5:56 PM
Quote Reply
Re: [DoubleJJ] RSS / XML Output for Ten Most Recent Postings In reply to
Nice one. Smile

I don't how to do so, but I think you will need to strip out all HTML from the hot_chop. I tried your subs, and the result is not pretty, for example, it chopped a link.

Not that it matters, really, but there seems to be a problem displaying the XML in MSIE. Why? I guess it's something about the document declaration, but from where is that sent?
Quote Reply
Re: [gotze] RSS / XML Output - strip bad chars? In reply to
Well - I fixed it. No more strange errors, it was the comment at the begining of the template that caused it.

I believe that slashcode (what I'm using for my website) strips and checks rss feeds - so that is not an issue. Slashcode strips out the hot_chop comments anyway, so it's somewhat pointless.

Back to more hacking, I appreciate the forum code more now. I was not aware of how flexible it is. Good stuff. I'll be very interested in seeing the "community" software GT has been hinting at.

-j
Quote Reply
Re: [DoubleJJ] RSS / XML Output for Ten Most Recent Postings In reply to
DoubleJJ :

Thanks for the post. I understand all that= add the globals, make the new directory and all... but I know NOTHING about XML!

After I add the globals and the template, how do I call it? What code do I put on the page?

Thanks for helping a dumbie! Sly
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] RSS / XML Output for Ten Most Recent Postings In reply to
I'm not sure what you're after? Are you just looking for the last ten postings - or are you in search of xml? My website "engine" makes use of rss / xml feeds.

See this page:

http://nerock.com/cheesyportal.pl

The issue that gotze mentioned - invalid characters is a problem. I have not had time to fix it - bad characters will have to be stripped out. Unimpressed

I love a challenge. You always learn something along the way. Here is a start @ a hot_chop that will filter out "bad html":

sub {
my $post_message = shift;

$post_message=~ s/^\s*//; # leading spaces
$post_message=~ s/\s*$//; # trailing spaces
$post_message=~ s/\s+/ /g; # multiple spaces
#
# Strip HTML tags
#
$post_message=~ s(<[^>]*>)()g;
#
# Decode HTML encoded characters
#
$post_message=~ s(\&lt;) (<)g;
$post_message=~ s(\&gt;) (>)g;
$post_message=~ s(\&amp;) (&)g;

return substr($post_message,0,125);
}


I've gotten it started - do we need to add all these?

Shocked

http://developer.netscape.com/docs/manuals/htmlguid/tags22.htm

Last edited by:

DoubleJJ: Jan 8, 2003, 8:34 PM
Quote Reply
Re: [DoubleJJ] RSS / XML Output for Ten Most Recent Postings In reply to
DoubleJJ:

Thanks for the response. I am not too worried about the stripping characters, I have a similar code I use in Links to shorted a couple fields, and can easily copy that...

I am sorry my question was not clearer. I just wanted to know once you have set up the dummy template and the globals, you have to put some sort of code to CALL the results on the page. What code do you use to to call the XML feed?

I have not yet had a chance to see the page you recommended, I will go there later today...

Thanks!
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] RSS / XML Output for Ten Most Recent Postings In reply to
http://yourdomain.com/gforum/gforum.cgi?do=search_results&search_time=10h&t=rssmod
Quote Reply
Re: [DoubleJJ] RSS / XML Output for Ten Most Recent Postings In reply to
DoubleJJ:

Thanks- cool. I will ALSO read up on this! Wink
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [DoubleJJ] RSS / XML Output for Ten Most Recent Postings In reply to
I am getting following error

Parse error in http://<url>/cgi-bin/gforum.cgi?do=search_results&search_time=10h&t=rssmod: not well-formed (invalid token) at line 20

Not sure what line 20

Wayne
Quote Reply
Re: [DoubleJJ] RSS / XML Output for Ten Most Recent Postings In reply to
DoubleJJ:

I just noticed this is posting links to threads in "hidden" forums. Of course, if you are not an admin, you cannot "get" to the thread.... but is there an easy add to make this ignore pposts to specific forums?
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] RSS / XML Output for Ten Most Recent Postings In reply to
Just change the SQL call in hot_threads to whatever forums you want to flag as "hot". It's easy to get threads from one specific forum, I'd have to do some digging in SQL commands to figure out how to flag more than one forum. Post whatever you find out.

$post_db->select_options ('WHERE post_root_id=0',

There are also tricks you can use to get a dynamic listing from the search page. See some of the posts re: blogs. If I'm not mistaken, using a modified search page will only list posts that the user is authorized to see.



-jj

Last edited by:

DoubleJJ: Feb 4, 2003, 10:17 AM
Quote Reply
Re: [DoubleJJ] RSS / XML Output for Ten Most Recent Postings In reply to
Cool! Made it work!Wink
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] RSS / XML Output for Ten Most Recent Postings In reply to
..and the solution was.....???
Quote Reply
Re: [DoubleJJ] RSS / XML Output for Ten Most Recent Postings In reply to
... pretty easy...

I took the line you mentioned, and edited it a bit:

$post_db->select_options ('WHERE post_root_id=0 and thread_show =1', 'ORDER BY post_time DESC', 'LIMIT 5');

Then I added a field "thread_show" into posts, made it = 1... and there ya go. You DO have to manually edit the field to a "0" for each post you do not want to show, but for now, it works.

I will look into how posts are posted. If I can find the right place, I will add a "thread_show=0" line to posts if category = XXX so it will all be automatic...
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] RSS / XML Output for Ten Most Recent Postings In reply to
There is a final version I can implement?
(the rss feed for the last 10 posts...)
Thanks
Max
The one with Mac OS X Server 10.4 :)
Quote Reply
Re: [gotze] RSS / XML Output for Ten Most Recent Postings In reply to
No replies yet? Frown
Max
The one with Mac OS X Server 10.4 :)
Quote Reply
Re: [DoubleJJ] RSS / XML Output for Ten Most Recent Postings In reply to
I use this to strip html for my XML feeds - might work for you too :-)

Code:
sub {
my $tags = shift;
my $review = $tags;
$review = GT::CGI::html_escape($review);
$review =~ s/\n/&lt\;BR&gt\;/g;
$review =~ s/^\s+|\s+$//g;
return $review;
}

Klaus

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] RSS / XML Output for Ten Most Recent Postings In reply to
Or, as the new RSS overlords preach, use <xhtml:body> to enclose HTML in the feed ... that is, if you move on to RSS 2.0.

Still, the <description> should be well-formed XML, so Klaus' filter is useful.

I've just updated my LSQL RSS-feeds to RSS 2.0 (using Pagebuilder, so I can't document it), and guess I should do the same to the GF feeds. Oh, so much to do, so little time ...

Maxpico, my original guide (up top here) does the basic job. Start with that, and go find a forgiving/lightweight XML-parser - you'll do fine with that.
Quote Reply
Re: [gotze] RSS / XML Output for Ten Most Recent Postings In reply to
Seems that most parser don't like <BR /> for some strange reason? Should it not work?

Klaus

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] RSS / XML Output for Ten Most Recent Postings In reply to
You're probably right. Most parsers out there suck ... It's a mess Mad

Safe solution today is probably to stick with RSS0.91 and strip all HTML.

John
PS: You should use <br /> and not <BR />, but that probably doesn't matter.
Quote Reply
Re: [gotze] RSS / XML Output for Ten Most Recent Postings In reply to
Has anybody played with RSS on their Gforum recently? I've tried these instructions, managed to get last 5 posts in the search function, but can't get anything to display in my XMl readers.

SEO Consultation
Economics & Personal Finances
Quote Reply
Re: [discusswireless] RSS / XML Output for Ten Most Recent Postings In reply to
I just checked my old feed, and it works in Bloglines. Now I'm going to break it Tongue and change it to Atom I think...

Can you post (or PM) a link to your feed?
Quote Reply
Re: [gotze] RSS / XML Output for Ten Most Recent Postings In reply to
Hey Gotze, thanks fo rthe reply, i did PM you a while back, but nice to see you back :P

I do'nt think i have the right stuff posted everywhere (for the hack)

What i really want is a workable XMl or RSS feed that I can throw into a parser and feature that way. Right now it's just a search function operating.

**removed**

what i have now.

SEO Consultation
Economics & Personal Finances

Last edited by:

discusswireless: May 5, 2007, 11:00 AM
> >