TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

March 29, 2024, 05:14:57 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,105
  • Total Topics: 21,213
  • Online today: 310
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 1
  • Guests: 275
  • Total: 276
  • lurkalot

New feature: RSS Feed from Articles

Started by Doma, August 05, 2009, 01:44:38 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Doma

I am proposing to allow feeds to come directly from an article category.  Right now if you use a site like feedburner the feed you set up say from ...index.php?cat=1... only reads the current forum posts and ignores the articles all together. As a news site that uses TP as something like you would find at /. it would be fantastic if we could syndicate our news out to the community.


Proposed action: Generate RSS from article categories
Proposed features:
    ø Have an RSS icon in say the top right of every article that allows viewers to subscribe to that category
    ø Have a admin control panel under TP that has the xml file link so you can send the file to feedburner if your site doesnt support rss generation like: http://www.yoursite.com/tp/articlecat1.xml
    ø Control panel limits the outgoing RSS feed at a cap say 100K or some predefined value. (if your site does higher then use feedburner to host the feed.)


I guess that's it I can edit this as we discuss the features.

Zetan

I have moved this to Feedback. Proposed Features are for suggestions that are going to be considered, if a suggestion gets implemented, it then gets moved to Accepted.

Quote from: Proposed
Any proposed suggestion for TP that will be considered will be moved in here.

You could have posted this in one of the suggestion topics already running.. I'll leave it here for now. :)

Doma

Sorry I misread your post:

Quote from: Zetan on August 05, 2009, 12:00:49 PM
If this isn't a feature, there are Feature Request topics in Chit Chat and the Feedback board. This seems a reasonable request. :)

I thought you said go to feedback board and make one. My bad.

Zetan

#3
I'm a lazy poster ;)

"too few words can cause confusion.."

Doma

Oh its cool I totally get the wall o' text thing. If there are too many letters my brain shuts down.

Henk

Running a local news site (www.persbureaualmere.nl) I am very interested in the possibility to have the TP articles in a RSS feed as well.

IchBin

So what kind of features do you want to see in this? What about the different types of articles? PHP, imports I think will have problems if you try to include their content into an RSS feed. RSS feeds of categories? Number limit on results returned? Lets here it people! :)

Doma

Hey IchBin I appreciate you considering this for your beta. There is a SMF mod called zCommunity by Charles Hill. Its a blogging addon for SMF but doesn't have alot of configurability and displaying on the front page like TP. It does however export the articles in a cubic buttload of feed formats.

Here is an image of them in action:


You can click the feeds here:
http://falconrytoday.net/index.php?zc

I do not know xml well enough to say what would need to be done. I would think that standard html articles could be made into .xml without too much, maybe a script or something. Here is a rss generator php script that I cannot figure heads or tails from (sorry not a coder).

<?php

/*
  RSS Feed Generator for PHP 4 or higher version
  Version 1.0.3  
  Written by Vagharshak Tozalakyan <vagh@armdex.com>
  License: GNU Public License

  Classes in package:
    class rssGenerator_rss
    class rssGenerator_channel
    class rssGenerator_image
    class rssGenerator_textInput
    class rssGenerator_item

  For additional information please reffer the documentation
*/

class rssGenerator_rss
{
    var 
$rss_version '2.0';
    var 
$encoding '';
    var 
$stylesheet '';

    function 
cData($str)
    {
        return 
'<![CDATA[ ' $str ' ]]>';
    }

    function 
createFeed($channel)
    {
        
$selfUrl = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on' 'http://' 'https://');
        
$selfUrl .= $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
        
$rss '<?xml version="1.0"';
        if (!empty(
$this->encoding)) {
            
$rss .= ' encoding="' $this->encoding '"';
        }
        
$rss .= '?>
' . "\n";
        if (!empty($this->stylesheet)) {
            $rss .= $this->stylesheet . "\n";
        }
        $rss .= '<!-- Generated on ' . date('r') . ' -->' . "\n";
        $rss .= '<rss version="' . $this->rss_version . '" xmlns:atom="http://www.w3.org/2005/Atom">' . "\n";
        $rss .= '  <channel>' . "\n";
    $rss .= '    <atom:link href="' . ($channel->atomLinkHref ? $channel->atomLinkHref : $selfUrl) . '" rel="self" type="application/rss+xml" />' . "\n";
        $rss .= '    <title>' . $channel->title . '</title>' . "\n";
        $rss .= '    <link>' . $channel->link . '</link>' . "\n";
        $rss .= '    <description>' . $channel->description . '</description>' . "\n";
        if (!empty($channel->language)) {
            $rss .= '    <language>' . $channel->language . '</language>' . "\n";
        }
        if (!empty($channel->copyright)) {
            $rss .= '    <copyright>' . $channel->copyright . '</copyright>' . "\n";
        }
        if (!empty($channel->managingEditor)) {
            $rss .= '    <managingEditor>' . $channel->managingEditor . '</managingEditor>' . "\n";
        }
        if (!empty($channel->webMaster)) {
            $rss .= '    <webMaster>' . $channel->webMaster . '</webMaster>' . "\n";
        }
        if (!empty($channel->pubDate)) {
            $rss .= '    <pubDate>' . $channel->pubDate . '</pubDate>' . "\n";
        }
        if (!empty($channel->lastBuildDate)) {
            $rss .= '    <lastBuildDate>' . $channel->lastBuildDate . '</lastBuildDate>' . "\n";
        }
        foreach ($channel->categories as $category) {
            $rss .= '    <category';
            if (!empty($category['domain'])) {
                $rss .= ' domain="' . $category['domain'] . '"';
            }
            $rss .= '>' . $category['name'] . '</category>' . "\n";
        }
        if (!empty($channel->generator)) {
            $rss .= '    <generator>' . $channel->generator . '</generator>' . "\n";
        }
        if (!empty($channel->docs)) {
            $rss .= '    <docs>' . $channel->docs . '</docs>' . "\n";
        }
        if (!empty($channel->ttl)) {
            $rss .= '    <ttl>' . $channel->ttl . '</ttl>' . "\n";
        }
        if (sizeof($channel->skipHours)) {
            $rss .= '    <skipHours>' . "\n";
            foreach ($channel->skipHours as $hour) {
                $rss .= '      <hour>' . $hour . '</hour>' . "\n";
            }
            $rss .= '    </skipHours>' . "\n";
        }
        if (sizeof($channel->skipDays)) {
            $rss .= '    <skipDays>' . "\n";
            foreach ($channel->skipDays as $day) {
                $rss .= '      <day>' . $day . '</day>' . "\n";
            }
            $rss .= '    </skipDays>' . "\n";
        }
        if (!empty($channel->image)) {
            $image = $channel->image;
            $rss .= '    <image>' . "\n";
            $rss .= '      <url>' . $image->url . '</url>' . "\n";
            $rss .= '      <title>' . $image->title . '</title>' . "\n";
            $rss .= '      <link>' . $image->link . '</link>' . "\n";
            if ($image->width) {
                $rss .= '      <width>' . $image->width . '</width>' . "\n";
            }
            if ($image->height) {
                $rss .= '      <height>' . $image->height . '</height>' . "\n";
            }
            if (!empty($image->description)) {
                $rss .= '      <description>' . $image->description . '</description>' . "\n";
            }
            $rss .= '    </image>' . "\n";
        }
        if (!empty($channel->textInput)) {
            $textInput = $channel->textInput;
            $rss .= '    <textInput>' . "\n";
            $rss .= '      <title>' . $textInput->title . '</title>' . "\n";
            $rss .= '      <description>' . $textInput->description . '</description>' . "\n";
            $rss .= '      <name>' . $textInput->name . '</name>' . "\n";
            $rss .= '      <link>' . $textInput->link . '</link>' . "\n";
            $rss .= '    </textInput>' . "\n";
        }
        if (!empty($channel->cloud_domain) || !empty($channel->cloud_path) || !empty($channel->cloud_registerProcedure) || !empty($channel->cloud_protocol)) {
            $rss .= '    <cloud domain="' . $channel->cloud_domain . '" ';
            $rss .= 'port="' . $channel->cloud_port . '" path="' . $channel->cloud_path . '" ';
            $rss .= 'registerProcedure="' . $channel->cloud_registerProcedure . '" ';
            $rss .= 'protocol="' . $channel->cloud_protocol . '" />' . "\n";
        }
        if (!empty($channel->extraXML)) {
            $rss .= $channel->extraXML . "\n";
        }
        foreach ($channel->items as $item) {
            $rss .= '    <item>' . "\n";
            if (!empty($item->title)) {
                $rss .= '      <title>' . $item->title . '</title>' . "\n";
            }
            if (!empty($item->description)) {
                $rss .= '      <description>' . $item->description . '</description>' . "\n";
            }
            if (!empty($item->link)) {
                $rss .= '      <link>' . $item->link . '</link>' . "\n";
            }
            if (!empty($item->pubDate)) {
                $rss .= '      <pubDate>' . $item->pubDate . '</pubDate>' . "\n";
            }
            if (!empty($item->author)) {
                $rss .= '      <author>' . $item->author . '</author>' . "\n";
            }
            if (!empty($item->comments)) {
                $rss .= '      <comments>' . $item->comments . '</comments>' . "\n";
            }
            if (!empty($item->guid)) {
                $rss .= '      <guid isPermaLink="';
                $rss .= ($item->guid_isPermaLink ? 'true' : 'false') . '">';
                $rss .= $item->guid . '</guid>' . "\n";
            }
            if (!empty($item->source)) {
                $rss .= '      <source url="' . $item->source_url . '">';
                $rss .= $item->source . '</source>' . "\n";
            }
            if (!empty($item->enclosure_url) || !empty($item->enclosure_type)) {
                $rss .= '      <enclosure url="' . $item->enclosure_url . '" ';
                $rss .= 'length="' . $item->enclosure_length . '" ';
                $rss .= 'type="' . $item->enclosure_type . '" />' . "\n";
            }
            foreach ($item->categories as $category) {
                $rss .= '      <category';
                if (!empty($category['domain'])) {
                    $rss .= ' domain="' . $category['domain'] . '"';
                }
                $rss .= '>' . $category['name'] . '</category>' . "\n";
            }
            $rss .= '    </item>' . "\n";
        }
        $rss .= '  </channel>' . "\r";
        return $rss .= '</rss>';
    }

}

class rssGenerator_channel
{
    var $atomLinkHref = '';
    var $title = '';
    var $link = '';
    var $description = '';
    var $language = '';
    var $copyright = '';
    var $managingEditor = '';
    var $webMaster = '';
    var $pubDate = '';
    var $lastBuildDate = '';
    var $categories = array();
    var $generator = '';
    var $docs = '';
    var $ttl = '';
    var $image = '';
    var $textInput = '';
    var $skipHours = array();
    var $skipDays = array();
    var $cloud_domain = '';
    var $cloud_port = '80';
    var $cloud_path = '';
    var $cloud_registerProcedure = '';
    var $cloud_protocol = '';
    var $items = array();
    var $extraXML = '';

}

class rssGenerator_image
{
    var $url = '';
    var $title = '';
    var $link = '';
    var $width = '88';
    var $height = '31';
    var $description = '';

}

class rssGenerator_textInput
{
    var $title = '';
    var $description = '';
    var $name = '';
    var $link = '';

}

class rssGenerator_item
{
    var $title = '';
    var $description = '';
    var $link = '';
    var $author = '';
    var $pubDate = '';
    var $comments = '';
    var $guid = '';
    var $guid_isPermaLink = true;
    var $source = '';
    var $source_url = '';
    var $enclosure_url = '';
    var $enclosure_length = '0';
    var $enclosure_type = '';
    var $categories = array();

}

?>


So once you have that configured you lay it out like this:
<?php

require_once 'rss_generator.inc.php';

$rss_channel = new rssGenerator_channel();
$rss_channel->atomLinkHref '';
$rss_channel->title 'My News';
$rss_channel->link 'http://mysite.com/news.php';
$rss_channel->description 'The latest news about web-development.';
$rss_channel->language 'en-us';
$rss_channel->generator 'PHP RSS Feed Generator';
$rss_channel->managingEditor 'editor@mysite.com (Alex Jefferson)';
$rss_channel->webMaster 'webmaster@mysite.com (Vagharshak Tozalakyan)';

$item = new rssGenerator_item();
$item->title 'New website launched';
$item->description 'Today I finaly launch a new website.';
$item->link 'http://newsite.com';
$item->guid 'http://newsite.com';
$item->pubDate 'Tue, 07 Mar 2006 00:00:01 GMT';
$rss_channel->items[] = $item;

$item = new rssGenerator_item();
$item->title 'Another website launched';
$item->description 'Just another website launched.';
$item->link 'http://anothersite.com';
$item->guid 'http://anothersite.com';
$item->pubDate 'Wed, 08 Mar 2006 00:00:01 GMT';
$rss_channel->items[] = $item;

$rss_feed = new rssGenerator_rss();
$rss_feed->encoding 'UTF-8';
$rss_feed->version '2.0';
header('Content-Type: text/xml');
echo 
$rss_feed->createFeed($rss_channel);

?>



I hope that can help you somehow.  ???

Henk

#8
Indeed I use categories for the different type of articles. All of them becomes the actual front page. For me, a feed with all the new articles shown on the front page will be sufficient.
Update rate is approx. 5-10 articles a day.

Doma

Same quantity for me Henk - About 5-10 per day would be fine.

So can that be done? Can we have a front end that we do our articles in that generates the rss and then we make a scaleable block that has the feed sent to it? The functionality is already there right now we just need to rework it to make it flow into an RSS feed and then make that feed the front block. I would however like to keep the icons or even set the icons for the different catagories and then the block parses out the icons and displays them next to the front block.

Im just throwing around ideas.